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.
This commit is contained in:
Marc-André Bombeck committed 2026-06-14 10:57:03 +02:00
1 parent f846b0681d
commit 458cb91b92
1 file changed
+5 -2
@@ -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/,
);
});
});