From 458cb91b92a26dc1dae3006c7d6411f8014663fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 14 Jun 2026 10:57:03 +0200 Subject: [PATCH] test(pwa): tolerate the sw-version rewrite marker in the fallback assertion The app-wide service-worker work routes the fallback literal through a `@sw-version-fallback` block-comment anchor that the prebuild generator keys on, placed between the `||` and the literal. The pre-existing fallback-shape assertion predates the marker and matched only the inline form, so it failed on the marker comment. Widen the pattern to allow the optional anchor while still pinning that a reachable "v" literal exists. --- scripts/__tests__/generate-sw-version.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/__tests__/generate-sw-version.test.ts b/scripts/__tests__/generate-sw-version.test.ts index f47c8e503..1df0cf177 100644 --- a/scripts/__tests__/generate-sw-version.test.ts +++ b/scripts/__tests__/generate-sw-version.test.ts @@ -43,8 +43,11 @@ describe("public/sw.js CACHE_VERSION wiring", () => { const sw = readFileSync(SW_PATH, "utf8"); // The fallback OR-expression keeps the SW functional in dev mode // where the build script has not run. Pin the shape so the fallback - // can never silently vanish. - expect(sw).toMatch(/self\.__APP_VERSION__\s*\)?\s*\|\|\s*"v\d/); + // can never silently vanish. The optional block comment is the + // `@sw-version-fallback` rewrite anchor the prebuild generator keys on. + expect(sw).toMatch( + /self\.__APP_VERSION__\s*\)?\s*\|\|\s*(?:\/\*[^]*?\*\/\s*)?"v\d/, + ); }); });