Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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 <n>` 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,
},
}),
});
8 changes: 8 additions & 0 deletions scripts/preflight.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading