// Tests for `pnpm e2e:all` (scripts/e2e-all.mjs): which suites, what a report // says, and the one summary. The run itself is the suites' own scripts. import assert from "node:assert/strict"; import fs from "node:fs"; import path from "node:path"; import test from "node:test"; import { LANES, REPO_ROOT, laneWaits, readReport, renderSummary, selectLanes } from "./e2e-all.mjs"; test("every lane names its package's real e2e scripts and their json reports", () => { for (const lane of LANES) { const scripts = JSON.parse(fs.readFileSync(path.join(REPO_ROOT, lane.pkg, "package.json"), "utf8")).scripts; for (const s of lane.suites) { assert.ok(scripts[s.script]?.includes("queue-lock.mjs"), `${lane.pkg} run ${s.script} is not a queued suite`); const config = /--config (\S+)/.exec(scripts[s.script])?.[1] ?? "playwright.config.ts"; const text = fs.readFileSync(path.join(REPO_ROOT, lane.pkg, config), "utf8"); const out = path.relative(lane.pkg, s.report); assert.ok(text.includes(`["json", { outputFile: "${out}" }]`), `${lane.pkg}/${config} does not write ${out}`); } } // Every queued e2e script of every package is in a lane. for (const pkg of ["editor", "export", "homepage", "umtool"]) { const scripts = JSON.parse(fs.readFileSync(path.join(REPO_ROOT, pkg, "package.json"), "utf8")).scripts; const queued = Object.keys(scripts).filter((k) => scripts[k].includes("queue-lock.mjs")); const lane = LANES.find((l) => l.pkg === pkg); assert.deepEqual(lane.suites.map((s) => s.script).sort(), queued.sort(), pkg); } }); test("--only picks packages or single suites, and refuses a name it does not know", () => { assert.deepEqual(selectLanes(null).map((l) => l.pkg), ["editor", "export", "homepage", "umtool"]); assert.deepEqual( selectLanes(["umtool", "export-hub"]).map((l) => [l.pkg, l.suites.map((s) => s.id)]), [["export", ["export-hub"]], ["umtool", ["umtool"]]], ); assert.throws(() => selectLanes(["editr"]), /no suite named editr/); }); const report = (over = {}) => ({ stats: { startTime: "2026-10-10T10:00:00.000Z", duration: 125_000, expected: 10, unexpected: 1, flaky: 1, skipped: 2, ...over }, suites: [ { file: "a.spec.ts", specs: [{ title: "passes", file: "a.spec.ts", line: 3, tests: [{ status: "expected" }] }], suites: [{ specs: [{ title: "breaks", file: "a.spec.ts", line: 9, tests: [{ status: "unexpected" }] }] }], }, ], }); test("readReport counts, lists failures by file:line, and rejects an earlier run's report", () => { const r = readReport(report()); assert.deepEqual( { ...r, failures: r.failures }, { passed: 10, failed: 1, flaky: 1, skipped: 2, durationMs: 125_000, startMs: Date.parse("2026-10-10T10:00:00.000Z"), failures: ["a.spec.ts:9 breaks"], }, ); assert.equal(readReport(report(), { startedAfter: Date.parse("2026-10-10T11:00:00.000Z") }), null); assert.ok(readReport(report(), { startedAfter: Date.parse("2026-10-10T09:59:00.000Z") })); assert.equal(readReport({}), null); }); test("the summary: one row per suite, totals, the wall against the sum, and the failures", () => { const launched = Date.parse("2026-10-10T09:58:00.000Z"); const out = renderSummary( [ { id: "editor", code: 1, launchedMs: launched, endedMs: launched + 300_000, report: readReport(report()), log: "test-results-e2e-all/editor.log" }, { id: "homepage", code: 0, launchedMs: launched, endedMs: launched + 60_000, report: readReport(report({ unexpected: 0, flaky: 0 })), log: "h.log" }, { id: "umtool", code: 1, launchedMs: launched, endedMs: launched + 20_000, report: null, log: "u.log" }, ], { wallMs: 300_000 }, ); assert.match(out, /^suite\s+result\s+passed\s+failed\s+flaky\s+skipped\s+tests\s+waited\s+log$/m); assert.match(out, /^editor\s+FAIL \(exit 1\)\s+10\s+1\s+1\s+2\s+2m05s\s+2m00s\s+test-results-e2e-all\/editor\.log$/m); assert.match(out, /^homepage\s+ok\s+10\s+0\s+0\s+2\s+2m05s/m); assert.match(out, /^umtool\s+FAIL \(exit 1, no report\)\s+—\s+—\s+—\s+—\s+20s\s+—\s+u\.log$/m); assert.match(out, /e2e:all FAILED — 20 passed, 1 failed, 1 flaky, 4 skipped; wall 5m00s \(the suites' own times add up to 4m30s\)/); assert.match(out, /editor — failed:\n {2}a\.spec\.ts:9 breaks/); }); test("lanes that share a tree of the checkout never overlap: export's starts after the editor's", () => { const waits = laneWaits(LANES); assert.deepEqual(waits.get("export"), ["editor"]); assert.deepEqual(waits.get("editor"), []); assert.deepEqual(waits.get("homepage"), []); assert.deepEqual(waits.get("umtool"), []); // A lane waits only for an EARLIER lane (e2e:all starts them in order), and // names what they share. LANES.forEach((lane, i) => { for (const a of lane.after ?? []) { assert.ok(LANES.slice(0, i).some((l) => l.pkg === a.pkg), `${lane.pkg} waits for a later lane ${a.pkg}`); assert.match(a.shares, /export\/public/); } }); // Not selected, not waited for. assert.deepEqual(laneWaits(selectLanes(["export"])).get("export"), []); assert.deepEqual(laneWaits(selectLanes(["editor", "export-hub"])).get("export"), ["editor"]); // And outside e2e:all, the editor suite holds export's queue for its whole run. const editorE2e = JSON.parse(fs.readFileSync(path.join(REPO_ROOT, "editor", "package.json"), "utf8")).scripts.e2e; assert.match(editorE2e, /--with e2e-export /); });