Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
@@ -0,0 +1,34 @@
|
||||
// @vitest-environment node
|
||||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
import { SERVICE_WORKER_VERSION } from "../app/lib/pwa/serviceWorkerRecoveryBootstrap";
|
||||
|
||||
const source = readFileSync(new URL("./sw.js", import.meta.url), "utf8");
|
||||
|
||||
describe("service worker cache boundary", () => {
|
||||
test("caches only fingerprinted build assets", () => {
|
||||
expect(source).toContain('url.pathname.startsWith("/assets/")');
|
||||
expect(source).toContain("event.respondWith(cacheFirst(request, ASSET_CACHE))");
|
||||
expect(source).not.toContain("RUNTIME_CACHE");
|
||||
expect(source).not.toContain("networkFirst(");
|
||||
});
|
||||
|
||||
test("activation removes legacy HiveGrid runtime caches", () => {
|
||||
expect(source).toContain('key.startsWith("hivegrid-") && key !== ASSET_CACHE');
|
||||
expect(source).toContain("caches.delete(key)");
|
||||
});
|
||||
|
||||
test("uses the same explicit version as the recovery bootstrap", () => {
|
||||
expect(source).toContain(`const SERVICE_WORKER_VERSION = "${SERVICE_WORKER_VERSION}"`);
|
||||
expect(source).toContain("const CACHE_VERSION = SERVICE_WORKER_VERSION");
|
||||
});
|
||||
|
||||
test("answers version handshakes and accepts only the explicit activation message", () => {
|
||||
expect(source).toContain('const VERSION_REQUEST = "HIVEGRID_SW_VERSION_REQUEST"');
|
||||
expect(source).toContain('const VERSION_RESPONSE = "HIVEGRID_SW_VERSION_RESPONSE"');
|
||||
expect(source).toContain('const SKIP_WAITING_REQUEST = "HIVEGRID_SW_SKIP_WAITING"');
|
||||
expect(source).toContain("event.source?.postMessage({");
|
||||
expect(source).toContain("event.waitUntil(self.skipWaiting())");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user