Skip to content

Commit

Permalink
Remove redirection query parameter for CI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
monsieurswag committed Nov 29, 2024
1 parent c097a0e commit 7e6a240
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
1 change: 1 addition & 0 deletions .github/workflows/functional-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
run: |
touch .env
echo PUBLIC_BACKEND_API_URL=http://localhost:8000/api >> .env
echo CI_TEST=1 >> .env
- name: Create backend environment variables file
working-directory: ${{ env.backend-directory }}
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lib/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export const BASE_API_URL = `${
: 'http://localhost:8000/api'
}`;

export const CI_TEST: boolean = Object.hasOwn(env, 'CI_TEST');

export const ALLAUTH_API_URL = `${BASE_API_URL}/_allauth/app/v1`;

export const BACKEND_API_EXPOSED_URL = `${
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/routes/(app)/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { redirect } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
import { CI_TEST } from '$lib/utils/constants';

const redirectURL = CI_TEST ? '/analytics' : '/analytics?refresh=1';

export const load: PageServerLoad = async () => {
redirect(301, '/analytics');
redirect(301, redirectURL);
};
4 changes: 2 additions & 2 deletions frontend/src/routes/(authentication)/login/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getSecureRedirect } from '$lib/utils/helpers';

import { ALLAUTH_API_URL, BASE_API_URL } from '$lib/utils/constants';
import { ALLAUTH_API_URL, BASE_API_URL, CI_TEST } from '$lib/utils/constants';
import { loginSchema } from '$lib/utils/schemas';
import type { LoginRequestBody } from '$lib/utils/types';
import { fail, redirect, type Actions } from '@sveltejs/kit';
Expand Down Expand Up @@ -131,7 +131,7 @@ export const actions: Actions = {
}

const next = url.searchParams.get('next') || '/';
const redirectURL = getSecureRedirect(next) + '';
const redirectURL = getSecureRedirect(next) + (CI_TEST ? '' : '?refresh=1');
redirect(302, redirectURL);
},
mfaAuthenticate: async (event) => {
Expand Down
14 changes: 1 addition & 13 deletions frontend/tests/utils/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,19 +273,8 @@ export const test = base.extend<Fixtures>({

data: { ...testData },

populateDatabase: async ({ pages, loginPage, sideBar, data, browser }, use) => {
populateDatabase: async ({ pages, loginPage, sideBar, data }, use) => {
test.slow();

const context = await browser.newContext();
context.on('requestfailed', request => {
console.log('[REQUEST_FAILED] ' + request.url() + ' ' + request.failure().errorText);
});

const start = new Date();
await new Promise((resolve) => setTimeout(resolve, 3000));
const end = new Date();
const diff = end - start
console.log(`Sleep time = ${diff}`);
await loginPage.goto();
await loginPage.login();
for (const [page, pageData] of Object.entries(data)) {
Expand All @@ -296,7 +285,6 @@ export const test = base.extend<Fixtures>({
'dependency' in pageData ? pageData.dependency : null
);
}
await context.close();
await sideBar.logout();
await use();
}
Expand Down

0 comments on commit 7e6a240

Please sign in to comment.