66 lines
2.0 KiB
TypeScript
66 lines
2.0 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test';
|
|
|
|
const OPERATOR_URL = 'http://localhost:3000';
|
|
const ADMIN_URL = 'http://localhost:3001';
|
|
|
|
export const ADMIN_BASE = ADMIN_URL;
|
|
|
|
/**
|
|
* Playwright config for real-login E2E tests.
|
|
*
|
|
* Key differences from playwright.config.ts:
|
|
* - testDir: './tests-auth' (separate from the autologin tests in ./tests)
|
|
* - AUTH_DEV_AUTOLOGIN: 'false' on both servers → middleware enforces login
|
|
* - reuseExistingServer: false → always starts fresh servers without autologin
|
|
*
|
|
* IMPORTANT: this config starts its own dev servers on ports 3000 and 3001.
|
|
* Do NOT run `pnpm test:e2e:auth` while those ports are already in use.
|
|
* Stop any running dev servers first:
|
|
* Windows: Get-Process node | Stop-Process -Force
|
|
*/
|
|
export default defineConfig({
|
|
testDir: './tests-auth',
|
|
fullyParallel: false,
|
|
forbidOnly: !!process.env.CI,
|
|
retries: process.env.CI ? 2 : 0,
|
|
workers: 1,
|
|
reporter: [['list'], ['html', { open: 'never' }]],
|
|
use: {
|
|
baseURL: OPERATOR_URL,
|
|
trace: 'retain-on-failure',
|
|
screenshot: 'only-on-failure',
|
|
},
|
|
projects: [
|
|
{
|
|
name: 'chromium',
|
|
use: { ...devices['Desktop Chrome'] },
|
|
},
|
|
],
|
|
webServer: [
|
|
{
|
|
command: 'pnpm --filter @repo/operator-pwa dev',
|
|
cwd: '..',
|
|
url: OPERATOR_URL,
|
|
reuseExistingServer: false,
|
|
timeout: 120_000,
|
|
stdout: 'pipe',
|
|
stderr: 'pipe',
|
|
// 'false' → dotenv-cli does not override env vars already in the process,
|
|
// so this wins over whatever AUTH_DEV_AUTOLOGIN is set in .env.
|
|
env: { AUTH_DEV_AUTOLOGIN: 'false' },
|
|
},
|
|
{
|
|
command: 'pnpm --filter @repo/admin-web dev',
|
|
cwd: '..',
|
|
url: ADMIN_URL,
|
|
reuseExistingServer: false,
|
|
timeout: 120_000,
|
|
stdout: 'pipe',
|
|
stderr: 'pipe',
|
|
// AUTH_URL must point to the admin server — .env has it at 3000 (operator)
|
|
// which causes Auth.js to redirect unauthenticated users to localhost:3000.
|
|
env: { AUTH_DEV_AUTOLOGIN: 'false', AUTH_URL: ADMIN_URL },
|
|
},
|
|
],
|
|
});
|