import { defineConfig, devices } from '@playwright/test'; const WEB = process.env.E2E_BASE_URL ?? 'http://localhost:4200'; const API = process.env.E2E_API_URL ?? 'http://localhost:8080'; export default defineConfig({ testDir: './tests', outputDir: './test-results', // These tests share one database, and several of them assert on seat counts // and booking totals. Running a single worker keeps those assertions // meaningful; the suite is small enough that the wall-clock cost is minor. workers: 1, fullyParallel: false, // A stray test.only should fail the build rather than silently skip the suite. forbidOnly: !!process.env.CI, retries: process.env.CI ? 2 : 0, timeout: 60_000, expect: { timeout: 10_000 }, // The evidence reporter turns the screenshots and data captured by passing // tests into a readable run report; the html one stays for debugging failures. // junit.xml is the machine-readable result any CI (Azure DevOps, Gitea) can // ingest; the evidence reporter is the human record; html is for debugging. reporter: process.env.CI ? [ ['github'], ['junit', { outputFile: 'results/junit.xml' }], ['html', { open: 'never' }], ['./reporters/evidence.ts'], ['list'], ] : [ ['junit', { outputFile: 'results/junit.xml' }], ['html', { open: 'never' }], ['./reporters/evidence.ts'], ['list'], ], use: { baseURL: WEB, trace: 'retain-on-failure', // 'on' rather than 'only-on-failure': the evidence report is a record of // what passed, so every test contributes at least a final screenshot. screenshot: 'on', video: 'retain-on-failure', actionTimeout: 15_000, }, projects: [ { name: 'chromium', use: { ...devices['Desktop Chrome'], viewport: { width: 1440, height: 900 } }, }, // A narrow viewport, because the console is built to work on a phone too. // Only the read-mostly specs run here: the booking flows write to a shared // database, and running them twice would churn the demo data for no gain. { name: 'mobile-chrome', use: { ...devices['Pixel 7'] }, testMatch: /(auth|responsive)\.spec\.ts/, }, ], // Starts the Go API and the Angular dev server if they are not already up, so // `npm test` is the only command a developer or CI job needs. webServer: [ { command: 'go run ./cmd/api', cwd: '../backend', url: `${API}/api/health`, reuseExistingServer: !process.env.CI, timeout: 180_000, stdout: 'ignore', stderr: 'pipe', }, { command: 'npm start', cwd: '../frontend', url: WEB, reuseExistingServer: !process.env.CI, timeout: 240_000, stdout: 'ignore', stderr: 'pipe', }, ], });