diff --git a/tests/e2e/service-worker-update.spec.ts b/tests/e2e/service-worker-update.spec.ts index 6906d97c..3d0f2a75 100644 --- a/tests/e2e/service-worker-update.spec.ts +++ b/tests/e2e/service-worker-update.spec.ts @@ -1,4 +1,4 @@ -import { readdir, readFile } from "node:fs/promises"; +import { appendFile, readdir, readFile } from "node:fs/promises"; import path from "node:path"; import { expect, test, type Page } from "../support/browser/strict-browser-test.ts"; @@ -35,9 +35,24 @@ type Probe = typeof globalThis & { let builds: ServiceWorkerBuilds | undefined; +// B changes one route chunk on purpose. Route chunks used to differ only +// because they embedded the build ID; since 09-02 they do not, so two builds +// of the same source emit the same route chunks. A dynamically imported +// module keeps all its exports, so the extra export survives the bundler. +const CHANGED_ROUTE_SOURCE = + "src/presentation/pages/not-found-page.tsx"; + test.beforeAll(async () => { test.setTimeout(180_000); - builds = await prepareServiceWorkerBuilds(); + builds = await prepareServiceWorkerBuilds({ + beforeBuild: async (name, root) => { + if (name !== "b") return; + await appendFile( + path.join(root, CHANGED_ROUTE_SOURCE), + '\nexport const serviceWorkerE2eBuild = "b";\n', + ); + }, + }); }); test.afterAll(async () => {