Files
ThothII/frontend/playwright.config.ts
marcopanandClaude Sonnet 4.6 1171181f9a test(frontend): Playwright e2e F1 vs backend+fake-pi (hermetic)
Adds a real-browser Playwright e2e of the full F1 disambiguation loop,
driven against the real backend + fake binaries (no VPN, no real Pi, no Python).

- frontend/e2e/fixtures/fake-tht.mjs: stubs tht CLI (session new/list/show)
- frontend/e2e/fixtures/fake-pi.mjs: wraps harness fake-pi-rpc with f1_disambiguation.json
- frontend/playwright.config.ts: two webServer entries (backend:8799, frontend:5199)
- frontend/e2e/f1.spec.ts: open app → create session → wait for SelectWidget → respond

Bug fixes discovered during e2e:
- useSessionStream: add addEventListener for named SSE events (backend sends
  'event: ui_request' etc.; onmessage only fires for unnamed 'event: message')
- FakeEventSource: add no-op addEventListener/removeEventListener stubs
- backend SSE route: add CORS headers manually in writeHead() since
  reply.raw bypasses the @fastify/cors onSend hook
- backend: install and register @fastify/cors for all non-SSE routes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-28 13:27:00 +02:00

51 lines
1.3 KiB
TypeScript

import { defineConfig, devices } from "@playwright/test";
import { resolve } from "node:path";
const __dir = new URL(".", import.meta.url).pathname;
const fakePi = resolve(__dir, "e2e/fixtures/fake-pi.mjs");
const fakeTht = resolve(__dir, "e2e/fixtures/fake-tht.mjs");
const harnessDir = resolve(__dir, "..", "harness");
export default defineConfig({
testDir: "./e2e",
timeout: 60_000,
retries: process.env.CI ? 2 : 0,
use: {
baseURL: "http://localhost:5199",
},
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
],
webServer: [
{
// Backend — wired to both fakes; no VPN/Pi/Python required.
command: "npm run dev",
cwd: resolve(__dir, "..", "backend"),
url: "http://localhost:8799/health",
timeout: 30_000,
reuseExistingServer: !process.env.CI,
env: {
PI_BIN: fakePi,
THT_BIN: fakeTht,
THT_HARNESS_DIR: harnessDir,
PORT: "8799",
AUTH_MODE: "none",
},
},
{
// Frontend dev server pointing at the hermetic backend.
command: "npm run dev -- --port 5199",
cwd: __dir,
url: "http://localhost:5199",
timeout: 30_000,
reuseExistingServer: !process.env.CI,
env: {
VITE_BACKEND_URL: "http://localhost:8799",
},
},
],
});