From 1075936ade1bba8e5ca2be4e9faa4629f97714ca Mon Sep 17 00:00:00 2001 From: Nassim Tabchiche Date: Wed, 2 Oct 2024 16:33:15 +0200 Subject: [PATCH] Build frontend before running playwright tests --- .github/workflows/functional-tests.yml | 6 ++++++ .github/workflows/startup-tests.yml | 6 ++++++ frontend/playwright.config.ts | 3 +-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/functional-tests.yml b/.github/workflows/functional-tests.yml index afaec2a693..3fd15fccbe 100644 --- a/.github/workflows/functional-tests.yml +++ b/.github/workflows/functional-tests.yml @@ -98,6 +98,9 @@ jobs: export $(grep -v '^#' .env | xargs) python manage.py createsuperuser --noinput nohup python manage.py runserver & + - name: Build frontend + working-directory: ${{ env.frontend-directory }} + run: pnpm run build - name: Run tests with browser ${{ matrix.playwright-browser }} working-directory: ${{ env.frontend-directory }} run: pnpx playwright test --project=${{ matrix.playwright-browser }} @@ -196,6 +199,9 @@ jobs: export $(grep -v '^#' .env | xargs) poetry run python manage.py createsuperuser --noinput nohup poetry run python manage.py runserver --settings=${{ env.enterprise-backend-settings-module }} & + - name: Build frontend + working-directory: ${{ env.frontend-directory }} + run: pnpm run build - name: Run tests with browser ${{ matrix.playwright-browser }} working-directory: ${{ env.enterprise-frontend-build-directory }} run: pnpx playwright test --project=${{ matrix.playwright-browser }} diff --git a/.github/workflows/startup-tests.yml b/.github/workflows/startup-tests.yml index 8ff93e3c76..159120ba4a 100644 --- a/.github/workflows/startup-tests.yml +++ b/.github/workflows/startup-tests.yml @@ -87,6 +87,9 @@ jobs: export $(grep -v '^#' .env | xargs) poetry run python manage.py createsuperuser --noinput nohup poetry run python manage.py runserver & + - name: Build frontend + working-directory: ${{ env.frontend-directory }} + run: pnpm run build - name: Run tests working-directory: ${{ env.frontend-directory }} run: pnpx playwright test tests/functional/startup.test.ts @@ -214,6 +217,9 @@ jobs: export $(grep -v '^#' .env | xargs) poetry run python manage.py createsuperuser --noinput nohup poetry run python manage.py runserver --settings=${{ env.enterprise-backend-settings-module }} & + - name: Build frontend + working-directory: ${{ env.frontend-directory }} + run: pnpm run build - name: Run tests working-directory: ${{ env.enterprise-frontend-build-directory }} run: pnpx playwright test tests/functional/startup.test.ts diff --git a/frontend/playwright.config.ts b/frontend/playwright.config.ts index 1587b165f3..20a0b846a2 100644 --- a/frontend/playwright.config.ts +++ b/frontend/playwright.config.ts @@ -3,10 +3,9 @@ import { devices } from '@playwright/test'; const config: PlaywrightTestConfig = { webServer: { - timeout: 2 * 60 * 1000, command: process.env.COMPOSE_TEST ? 'echo "The docker compose frontend server didn\'t start correctly"' - : 'npm install -g pnpm && pnpm install && pnpm run build && pnpm run preview', + : 'pnpm run preview', url: `http://localhost:${process.env.COMPOSE_TEST ? 3000 : 4173}`, reuseExistingServer: !process.env.CI },