// E2E of the co-worker WEB APP itself (separate from automation/'s mock-Fusion suite). // Starts mock-app (reused if already up) and the FastAPI backend serving web/dist on a throwaway FPT_HOME with a // bootstrap admin, then drives the UI. Stub Playwright mode inside the run (no nested browser runs). import { defineConfig, devices } from '@playwright/test'; import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path'; import { fileURLToPath } from 'node:url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const ROOT = path.resolve(__dirname, '..', '..'); const PORT = Number(process.env.FPT_E2E_PORT || 8811); if (!process.env.FPT_E2E_HOME) process.env.FPT_E2E_HOME = fs.mkdtempSync(path.join(os.tmpdir(), 'fpt-e2e-')); const HOME = process.env.FPT_E2E_HOME; const PY = [path.join(ROOT, 'architecture', '.venv', 'Scripts', 'python.exe'), path.join(ROOT, 'architecture', '.venv', 'bin', 'python')].find((p) => fs.existsSync(p)) || 'python'; export const E2E_USER = 'e2e_admin'; export const E2E_PASSWORD = process.env.FPT_E2E_PASSWORD || 'e2e-only-password-not-a-secret'; export default defineConfig({ testDir: '.', testMatch: /.*\.e2e\.ts$/, timeout: 240_000, expect: { timeout: 30_000 }, workers: 1, retries: 0, reporter: [['list'], ['html', { outputFolder: path.join(__dirname, '..', 'playwright-report'), open: 'never' }]], outputDir: path.join(__dirname, '..', 'test-results'), use: { baseURL: `http://127.0.0.1:${PORT}`, trace: 'retain-on-failure', screenshot: 'only-on-failure' }, projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }], webServer: [ { command: 'node mock-app/server.js', cwd: ROOT, url: 'http://127.0.0.1:3100/api/health', reuseExistingServer: true, timeout: 30_000 }, { command: `"${PY}" -m coworker api --port ${PORT}`, cwd: ROOT, url: `http://127.0.0.1:${PORT}/api/ready`, reuseExistingServer: false, timeout: 90_000, env: { FPT_HOME: HOME, FPT_LIBRARY_GIT: path.join(HOME, 'library.git'), FPT_CASE_WRITEBACK: '0', PATCH_WATCH_ENABLED: '0', FPT_BOOTSTRAP_ADMIN_USER: E2E_USER, FPT_BOOTSTRAP_ADMIN_PASSWORD: E2E_PASSWORD, PLAYWRIGHT_MODE: 'stub', // FPT_ORCHESTRATOR=temporal runs the same E2E through the Docker Temporal server with an in-process worker FPT_ORCHESTRATOR: process.env.FPT_ORCHESTRATOR || 'langgraph', FPT_EMBEDDED_WORKER: '1', TEMPORAL_TASK_QUEUE: 'fpt-webe2e-main', TEMPORAL_BROWSER_QUEUE: 'fpt-webe2e-browser', }, }, ], });