e2e/CI: dual-engine suites, per-engine screenshots, SwiftShader retired, prod web suite, CI-coverage gate

Squash of experiment/ff-big-modules vs main.

Big-module routing removed: native-EH shrank kicad_editor below
SpiderMonkey's x86-64 code budget (runs 29355049705/29356152413 green on
stock Firefox), so BIG_MODULE_SPECS routing and the baseline-only-JIT
crutch are gone — kicad-firefox and kicad-chromium both run the full
suite, with the module compiled the way real users' browsers compile it.

Per-engine screenshots end to end: stableShot/shotPath write
test-results/<engine>/<name>.png; baselines move to
baseline-screenshots/{chromium,firefox}/ and the whole tools/screenshots
pipeline (compare/promote/manifest/spec-map/changelog/Discord) keys on
<engine>/<name>. Previously Firefox and Chromium renders of one spec
overwrote each other and Firefox renders were never actually gated.
Seeded from CI run 29421380806 (92 new firefox baselines, +24 chromium
web-suite shots); manifest generated from the baseline tree.

One merged playwright.config.ts (kicad/asyncify/coroutine/perf as
projects); ~25 dead npm scripts dropped. The web suite is gated in CI for
the first time ever (4 rotted specs fixed, 5 broken lib-bridge specs
triaged as fixme in docs/features/web-e2e-rot/); cheap lint step after
npm ci; last 26 blind-sleep violations fixed.

SwiftShader retired: CI Chromium renders WebGL on ANGLE → Mesa llvmpipe
(--use-gl=angle --use-angle=gl --ignore-gpu-blocklist; the blocklist flag
is mandatory — llvmpipe is blocklisted and WebGL is silently unavailable
without it) in BOTH configs. Under WORKERS=4 congestion SwiftShader
transiently failed the first post-board-load draw and the recovery
cascade ended in a silent permanent Cairo fallback — that engine flip was
the "~1.2% changedRatio both directions" occ-export baseline flake.
Validated 160/160 across two 80-repeat rigs; full analysis in
docs/features/wx-parity-bugs/occ-export-context-eviction.md. Chromium
baselines shift slightly on llvmpipe — promote once from the first green
run. Deflakes the new coverage exposed: presence baselines settle before
capture; presence fixtures declare current file formats; perf gets its
own outputDir so CI evidence survives; occ-export settles the board paint
before the export dialog; menu-item waits (waitForRenderedByLabel before
clickMenuItem) in 4 specs + the TESTING.md rule.

Web suite runs the PROD build, in parallel: webServer becomes backend
`start` + the standalone's e2e:preview (build-preview.mjs: link-wasm →
stash the public/wasm symlink aside during vite build, build-demo.mjs's
move — then vite preview as the persistent server). The wasm middleware
serves /wasm/* in preview and emits COOP/COEP/CORP itself (a pthread
worker script's own response must carry COEP or Chrome kills it with
ERR_BLOCKED_BY_RESPONSE). VITE_* flags bake at build time;
VITE_ALLOW_USER_OVERRIDE joins turbo globalEnv. fullyParallel + default
workers: 5.2m → 1.4m. Determinism fixes the parallel run exposed:
shared-page specs become serial groups; locks.spec grabs alice's exact
item via the new kicadCollabTestSelectByUuid hook (cross-tab "first
footprint" order is not a ysync invariant); quit specs poll page.url()
(quit supersedes its own navigation — NS_BINDING_ABORTED on Firefox).
Suite: 51 passed / 12 skipped / 0 failed in 1.6m.

CI-coverage gate (lint:ci-coverage): every tests/**/*.spec.ts must be
reachable from the npm scripts the workflows invoke — scraped from
.github/workflows/, resolved through package.json, coverage asked from
playwright --list itself. Rules: uncovered-spec + orphan-project (with a
documented LOCAL_ONLY_PROJECTS allowlist). Gating next to
lint:determinism; 138 spec files / 13 projects accounted for.

Product fixes kept from the investigations (reachable on real GPUs too):
wx 7799fd1be5 — paint flags clear before dispatch + Invalidate always
propagates; kicad 3dcfea5e45 — SwiftShader pass-boundary flush +
per-instance font texture + first-frame GL-error drain (GAL recovery
recovers instead of falling back to Cairo) + the user-facing eeschema
switch navigates again under __EMSCRIPTEN__ (project-sync's
FaceRegistered gate had rerouted it into the hidden sync player; caught
by the newly-gated web suite).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018eUxiPApHgGiu9NFyQfhAq
This commit is contained in:
Viktor Vaczi 2026-07-17 12:10:40 +02:00
commit 63ed1f3c1f
556 changed files with 2470 additions and 1389 deletions

View file

@ -2,9 +2,11 @@ import { defineConfig, devices } from '@playwright/test';
/**
* E2E config for the React WEB APP (web/standalone editor at :3048 + the
* @pcbjam/backend-example reference backend at :3060), as opposed to
* playwright-kicad.config.ts which drives the standalone tool harness HTMLs
* under tests/apps/kicad.
* @pcbjam/backend-example reference backend at :3060), as opposed to the
* merged playwright.config.ts which drives the standalone tool harness HTMLs
* under tests/apps. Kept separate because this suite runs a different server
* stack (`pnpm dev` two-server turbo), its own globalSetup health checks and a
* fixed base URL.
*
* These tests exercise the real web open paths: navigate to /:scope/projects/:name/<file>,
* let WasmTool boot the tool in-document (boot.ts), drive the project into MEMFS
@ -12,12 +14,16 @@ import { defineConfig, devices } from '@playwright/test';
* editor loaded wizard-free.
*
* The backend serves a single project off the local filesystem — no DB, no
* seeding. The webServer block reuses an already-running stack (`pnpm dev` from
* web/) or cold-starts it with the env below, pointing PROJECT_DIR at the
* seeding. The suite runs against the PRODUCTION stack: the standalone is
* `vite build`-built and served by `vite preview` (build-preview.mjs — wasm
* stays out of dist/, served same-origin at /wasm via the serveWasm plugin),
* and the backend runs its no-watch `start` script. Locally an already-running
* stack on the ports is reused as before (the common dev case); CI always
* cold-starts both servers with the env below, pointing PROJECT_DIR at the
* committed tests/fixtures/demo project (slug "demo").
*
* Firefox is the reliable headless target on ARM Mac (Chromium SwiftShader WebGL
* bug); use --project=chromium (system Chrome) for headed debugging.
* All projects use the BUNDLED browsers so the suite runs identically on CI
* (no system-Chrome channel; ANGLE/Mesa-llvmpipe GL for GPU-less runners).
*/
const FRONTEND_URL = process.env.WEB_APP_URL ?? 'http://localhost:3048';
@ -31,15 +37,49 @@ const FRONTEND_PORT = new URL(FRONTEND_URL).port || '3048';
const BACKEND_URL = process.env.BACKEND_URL ?? 'http://localhost:3060';
const BACKEND_PORT = new URL(BACKEND_URL).port || '3060';
// Bundled Chromium on GPU-less CI: WebGL via ANGLE over desktop GL (Mesa
// llvmpipe under the Xvfb display CI provides) — NOT SwiftShader, which under
// multi-worker contention transiently fails WebGL calls and drove KiCad's GAL
// error-recovery into silent Cairo fallbacks (the occ-export flake; see
// docs/features/wx-parity-bugs/occ-export-context-eviction.md). Keep this in
// lockstep with CHROMIUM_CI_ARGS in playwright.config.ts. --ignore-gpu-blocklist
// is mandatory: llvmpipe is on Chromium's software-GL blocklist and WebGL is
// silently unavailable without it.
const CHROMIUM_CI_ARGS = process.env.CI
? {
launchOptions: {
args: ['--use-gl=angle', '--use-angle=gl', '--ignore-gpu-blocklist'],
},
}
: {};
// Headless Firefox can't create a GL context on GPU-less CI VMs — run headed
// under Xvfb (the CI step wraps in xvfb-run) with the no-GPU blocklist bypassed,
// same as the kicad-firefox project in playwright.config.ts.
const FIREFOX_CI_OPTS = process.env.CI
? {
headless: false,
launchOptions: { firefoxUserPrefs: { 'webgl.force-enabled': true } },
}
: {};
export default defineConfig({
globalSetup: './web/global-setup-web.ts',
testDir: './web',
fullyParallel: false,
// On CI, keep Playwright's start-of-run cleanup away from test-results/ — the
// engine-scoped gate screenshots of the main e2e invocation accumulate there.
outputDir: process.env.CI ? 'pw-artifacts/web' : 'test-results',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 1 : 0,
// KiCad WASM is process-global (one runtime per page) and each tool wasm is
// 40–200 MB; run serially to avoid loading several giant runtimes at once.
workers: 1,
// retries:0 — same determinism doctrine as the merged config (the suite's
// blind sleeps were replaced with condition waits when it was wired into CI).
retries: 0,
// Parallel workers (Playwright default ≈ 50% of cores), same as the merged
// config — the kicad suite already runs 4 workers of giant wasm runtimes on
// the same class of CI runner. Cross-worker isolation holds: each worker is
// its own browser instance, so BroadcastChannel rooms and IndexedDB stores
// never cross, and presence/comments specs mint per-run users via ?user=.
workers: undefined,
reporter: 'html',
timeout: 180000, // tool wasm download + boot + open can take minutes
@ -51,49 +91,75 @@ export default defineConfig({
projects: [
{
name: 'firefox',
name: 'web-firefox',
testIgnore: /mobile-.*\.spec\.ts/,
use: { ...devices['Desktop Firefox'], viewport: { width: 1280, height: 720 } },
use: {
...devices['Desktop Firefox'],
viewport: { width: 1280, height: 720 },
...FIREFOX_CI_OPTS,
},
},
{
name: 'chromium',
name: 'web-chromium',
testIgnore: /mobile-.*\.spec\.ts/,
use: { channel: 'chrome', viewport: { width: 1280, height: 720 } },
use: {
...devices['Desktop Chrome'],
viewport: { width: 1280, height: 720 },
...CHROMIUM_CI_ARGS,
},
},
{
// Canvas-only mobile mode (features/mobile). Mobile emulation is
// Chromium-only, and headless SwiftShader WebGL is broken on ARM Mac (see
// header) — run this project headed locally: --project=mobile-chromium --headed.
name: 'mobile-chromium',
// Canvas-only mobile mode (features/mobile): Pixel 7 emulation on the
// bundled Chromium (mobile emulation is Chromium-only).
name: 'web-mobile',
testMatch: /mobile-.*\.spec\.ts/,
use: { ...devices['Pixel 7'], channel: 'chrome' },
use: { ...devices['Pixel 7'], ...CHROMIUM_CI_ARGS },
},
],
webServer: {
// Best-effort: reuse the dev stack if it's already up (the common case);
// otherwise cold-start turbo dev with the env a fresh checkout needs
// (turbo passes these through, so no hand-copied .env files required).
command: 'pnpm --dir ../web dev',
url: FRONTEND_URL,
reuseExistingServer: true,
timeout: 120000,
env: {
...process.env,
// resolved against web/backend/ (the backend's cwd)
PROJECT_DIR: '../../tests/fixtures/demo',
PORT: BACKEND_PORT,
VITE_API_BASE_URL: BACKEND_URL,
CORS_ORIGIN: FRONTEND_URL,
STANDALONE_PORT: FRONTEND_PORT,
// The missing-file tool-switch spec builds a browser-local (IDB) project
// through the home page — same flag the dev/demo stacks set
// (scripts/dev-gpl.mjs). Only effective on cold starts: with
// reuseExistingServer an already-running stack must have set it itself.
VITE_LOCAL_PROJECTS: 'idb',
// e2e identity isolation: presence/comments specs mint per-run users via
// `?user=` — only builds that set this honor the param (0009).
VITE_ALLOW_USER_OVERRIDE: '1',
// Two independent prod servers, started in parallel and health-checked on
// their URLs. cwd (not --dir/--filter from tests/): corepack resolves pnpm
// from the packageManager pin in web/package.json only when the process
// STARTS in web/ — launched from tests/ it falls back to latest pnpm, which
// needs a newer Node than CI's. Locally an already-running stack is reused
// (the common dev case — note that stack must have set the VITE_* flags
// below itself, and a dev server is accepted too).
webServer: [
{
// Reference backend, prod mode (tsx src/server.ts, no watch).
command: 'pnpm --filter @pcbjam/backend-example start',
cwd: '../web',
url: `${BACKEND_URL}/health`,
reuseExistingServer: !process.env.CI,
timeout: 180000,
env: {
...process.env,
// resolved against web/backend/ (the backend's cwd)
PROJECT_DIR: '../../tests/fixtures/demo',
PORT: BACKEND_PORT,
CORS_ORIGIN: FRONTEND_URL,
},
},
},
{
// Standalone editor: vite build → vite preview (build-preview.mjs).
// The VITE_* flags are baked in at BUILD time here (the dev server used
// to read them live): API base, the browser-local IDB project store the
// missing-file tool-switch spec needs, and per-run e2e identity via
// ?user= (0009). turbo.json lists them in globalEnv so the build cache
// re-keys when they change.
command: 'pnpm --filter @pcbjam/standalone e2e:preview',
cwd: '../web',
url: FRONTEND_URL,
reuseExistingServer: !process.env.CI,
// Cold build (turbo: shared + sync-client + standalone) + preview boot.
timeout: 600000,
env: {
...process.env,
STANDALONE_PORT: FRONTEND_PORT,
VITE_API_BASE_URL: BACKEND_URL,
VITE_LOCAL_PROJECTS: 'idb',
VITE_ALLOW_USER_OVERRIDE: '1',
},
},
],
});