From e1433a6e24d7295adbe0c69bc49bbb751439bcf2 Mon Sep 17 00:00:00 2001 From: monsieurswag Date: Tue, 3 Dec 2024 13:45:52 +0100 Subject: [PATCH] Fix tests Quickfix --- .github/workflows/functional-tests.yml | 17 +++++++---------- .../(authentication)/login/+page.server.ts | 8 ++++++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/functional-tests.yml b/.github/workflows/functional-tests.yml index 80bfe60b28..9a81d02577 100644 --- a/.github/workflows/functional-tests.yml +++ b/.github/workflows/functional-tests.yml @@ -164,21 +164,18 @@ jobs: - name: Install enterprise backend working-directory: ${{ env.enterprise-backend-directory }} run: poetry install - - name: Create the frontend build directory before build - working-directory: ${{ env.enterprise-backend-directory }} - run: mkdir -p ./build/frontend - - name: Create frontend environment variables file - working-directory: ${{ env.enterprise-frontend-build-directory }} - run: | - touch .env - echo PUBLIC_BACKEND_API_URL=http://localhost:8000/api >> .env - echo CI_TEST=1 >> .env - name: Build enterprise frontend working-directory: ${{ env.enterprise-frontend-directory }} run: make - name: Install Playwright browser ${{ matrix.playwright-browser }} working-directory: ${{ env.enterprise-frontend-build-directory }} run: pnpm exec playwright install --with-deps ${{ matrix.playwright-browser }} + - name: Create frontend environment variables file + working-directory: ${{ env.enterprise-frontend-build-directory }} + 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 }} run: | @@ -214,7 +211,7 @@ jobs: nohup poetry run python manage.py runserver --settings=${{ env.enterprise-backend-settings-module }} & - name: Run tests with browser ${{ matrix.playwright-browser }} working-directory: ${{ env.enterprise-frontend-build-directory }} - run: pnpm exec playwright test --project=${{ matrix.playwright-browser }} -g "fuzz" + run: pnpm exec playwright test --project=${{ matrix.playwright-browser }} env: CI: true - uses: actions/upload-artifact@v4 diff --git a/frontend/src/routes/(authentication)/login/+page.server.ts b/frontend/src/routes/(authentication)/login/+page.server.ts index 31f5013dcf..999393ce0a 100644 --- a/frontend/src/routes/(authentication)/login/+page.server.ts +++ b/frontend/src/routes/(authentication)/login/+page.server.ts @@ -120,9 +120,9 @@ export const actions: Actions = { const preferences = await preferencesRes.json(); const currentLang = cookies.get('ciso_lang') || 'en'; - const preferedLang = preferences.lang; + const preferedLang = preferences.lang || 'en'; - if (preferedLang && currentLang !== preferedLang) { + if (currentLang !== preferedLang) { cookies.set('ciso_lang', preferedLang, { httpOnly: false, sameSite: 'lax', @@ -134,6 +134,10 @@ export const actions: Actions = { const next = url.searchParams.get('next') || '/'; const secureNext = getSecureRedirect(next); const refreshQueryParam = CI_TEST ? '' : '?refresh=1'; + if (currentLang != preferedLang) { + redirect(302, secureNext); + } + const redirectURL = secureNext ? `${secureNext}${refreshQueryParam}` : `/${refreshQueryParam}`; redirect(302, redirectURL); },