towerops/e2e/playwright.config.ts
Graham McIntire e91d74d52b
fix: run signup-flow tests unauthenticated and increase timeout
- Add signup-flow to unauthenticated test pattern
- Ignore signup-flow in authenticated chromium tests
- Increase global timeout from 20 to 30 minutes
- Fixes redirects to /dashboard when trying to access /users/register
2026-03-08 16:41:18 -05:00

116 lines
3.2 KiB
TypeScript

import { defineConfig, devices } from '@playwright/test';
import * as dotenv from 'dotenv';
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
dotenv.config();
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Run with limited parallelism in CI to balance speed and stability */
workers: process.env.CI ? 4 : undefined,
/* Maximum time one test can run */
timeout: 30 * 1000,
/* Maximum time for entire test run (1318 tests with 4 workers ~25 minutes) */
globalTimeout: 30 * 60 * 1000,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: process.env.CI
? [['list']]
: [['list'], ['html', { open: 'never' }]],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: process.env.BASE_URL || 'http://localhost:4000',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
/* Screenshot on failure */
screenshot: 'only-on-failure',
/* Video on failure */
video: 'retain-on-failure',
/* Run in headless mode by default */
headless: true,
},
/* Configure projects for major browsers */
projects: [
// Setup project - runs first to authenticate
{
name: 'setup',
testMatch: /.*\.setup\.ts/,
},
// Unauthenticated tests (registration, login flows, etc.)
{
name: 'chromium-unauthenticated',
use: {
...devices['Desktop Chrome'],
// No storageState - runs without authentication
},
testMatch: /tests\/(auth-flows|registration|signup-flow)\.spec\.ts/,
},
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
// Use prepared auth state
storageState: 'tests/.auth/user.json',
},
testIgnore: /tests\/(auth-flows|registration|signup-flow)\.spec\.ts/,
dependencies: ['setup'],
},
{
name: 'firefox',
use: {
...devices['Desktop Firefox'],
storageState: 'tests/.auth/user.json',
},
testIgnore: /tests\/(auth-flows|registration)\.spec\.ts/,
dependencies: ['setup'],
},
{
name: 'webkit',
use: {
...devices['Desktop Safari'],
storageState: 'tests/.auth/user.json',
},
testIgnore: /tests\/(auth-flows|registration)\.spec\.ts/,
dependencies: ['setup'],
},
/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: {
// ...devices['Pixel 5'],
// storageState: 'tests/.auth/user.json',
// },
// dependencies: ['setup'],
// },
],
/* Run your local dev server before starting the tests */
// webServer: {
// command: 'mix phx.server',
// url: 'http://localhost:4000',
// reuseExistingServer: !process.env.CI,
// cwd: '..',
// },
});