From 6823cf5afbf996170346cc3fa22c1e9c8e4b4c35 Mon Sep 17 00:00:00 2001 From: Adam Wright Date: Fri, 18 Sep 2026 04:37:57 +0000 Subject: [PATCH] fix(e2e): make the pre-push gate test the working tree, not port 4200 `playwright.config.ts` had `reuseExistingServer: !process.env['CI']`, and this host always has `serve-prod.js` on :4200 serving beta out of `dist/`. So a local run tested the last deployed build rather than the commit about to be pushed. It showed up as `diagram-behaviour.spec.ts:48` failing on a clean `main` while CI was green on the same commit. The served build predated the fix that test asserts by eight hours: dist/reactome/browser/index.html 2026-09-17 13:14:18 b11c0e3 (#236, the fix asserted) 2026-09-17 21:43:58 Today's failure direction was harmless -- red on good code -- and it cost a `--no-verify` push on a branch that was fine. The same mechanism passes on a tree that is broken, which is the direction that matters. E2E_PORT now asks for a server of our own. Preflight sets 4201, so it builds and serves the tree under test while beta keeps 4200. A distinct port rather than `reuseExistingServer: false`, because that aborts on "port already in use" and would mean stopping beta before every push. Measured, same two specs, same commit: reusing :4200 (beta's build) 1 failed, 21 passed own server on :4201 17 passed, 5 skipped, exit 0 The five new skips are the point rather than a loss. They are the render-service tests, which skip with a reason when `/RenderService/health` does not answer -- so `RENDER_TARGET=127.0.0.1:1` had been silently ineffective all along. The reused server proxied to this box's real render service, so the local smoke exercised the *present*-service path while its own comment said it existed to reproduce CI's absent one. It now reproduces it, and matches CI, which has no render service either. Interactive runs keep the reuse: one `ng serve` with hot reload and many test runs is the right trade while developing. It is only the gate that must not. Refs #243 Co-Authored-By: Claude Opus 5 --- playwright.config.ts | 32 +++++++++++++++++++++++++++----- scripts/preflight.sh | 8 ++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index f56ed507e..1a167068c 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -12,7 +12,23 @@ import { defineConfig, devices } from '@playwright/test'; // /AnalysisService and /GSAServer entries in proxy.conf.json to reach a real // backend. A deployed environment already routes those itself. const externalBaseURL = process.env['E2E_BASE_URL']; -const baseURL = externalBaseURL || 'http://localhost:4200'; + +// E2E_PORT asks for a server of our own on a port nothing else is using, and is +// what the pre-push gate sets. +// +// The default of 4200 reuses whatever is already serving there, which is what +// you want while developing -- one `ng serve` with hot reload, many test runs. +// It is emphatically not what a gate wants. On a host that keeps a deployed +// build on 4200, reuse means the suite tests that build and not the working +// tree: `diagram-behaviour.spec.ts` failed for eight hours against a `dist/` +// that predated the fix it asserts, while CI was green (#243). The dangerous +// direction is the other one -- passing on a tree that is broken. +// +// A distinct port rather than `reuseExistingServer: false` on 4200, because the +// latter makes playwright abort on "port already in use", which on this host +// would mean stopping beta before every push. +const ownPort = process.env['E2E_PORT']; +const baseURL = externalBaseURL || `http://localhost:${ownPort || '4200'}`; export default defineConfig({ testDir: './e2e', @@ -64,11 +80,17 @@ export default defineConfig({ ? {} : { webServer: { - command: 'npm run start:simple', + // npm appends extra args to the end of the script string, so this + // becomes `... && ng serve --port ` and still runs the content + // staging that the search specs need. + command: ownPort ? `npm run start:simple -- --port ${ownPort}` : 'npm run start:simple', url: baseURL, - reuseExistingServer: !process.env['CI'], - // A cold Angular build well exceeds playwright's 60s default. - timeout: 180_000, + // Never reuse when we asked for our own port: the point is to serve + // the tree under test. + reuseExistingServer: !process.env['CI'] && !ownPort, + // A cold Angular build well exceeds playwright's 60s default, and the + // gate always pays for one because it never reuses. + timeout: ownPort ? 300_000 : 180_000, }, }), }); diff --git a/scripts/preflight.sh b/scripts/preflight.sh index e32fde681..d35bcedaa 100755 --- a/scripts/preflight.sh +++ b/scripts/preflight.sh @@ -83,7 +83,15 @@ if [ "$mode" != "fast" ]; then # what the asset regression broke; downloads exercises the render service, which # is what the probe change broke. Chosen because each caught a real failure -- # pathway-browser.spec.ts was in here first and caught neither. + # + # E2E_PORT is what makes this check the working tree rather than whatever is + # already serving on 4200. Without it, playwright reuses an existing server -- + # and on a host that keeps a deployed build there, this step silently tested + # that build instead of the commit about to be pushed (#243). It cost a + # `--no-verify` push on a branch that was in fact fine, and it could as easily + # have waved through one that was not. step "diagram + download smoke" env \ + E2E_PORT=4201 \ REACTOME_BACKEND=http://127.0.0.1:9 \ RENDER_TARGET=http://127.0.0.1:1 \ npx playwright test e2e/diagram-behaviour.spec.ts e2e/downloads.spec.ts --project=code --reporter=line