@@ -10,37 +10,6 @@ const here = path.dirname(fileURLToPath(import.meta.url));
1010const serviceWorkerPath = path . join ( here , "../../public/sw.js" ) ;
1111
1212describe ( "Control UI service worker cache versioning" , ( ) => {
13- it ( "registers the service worker with a build id and bounds prior build caches" , ( ) => {
14- const mainSource = fs . readFileSync ( path . join ( here , "../main.ts" ) , "utf8" ) ;
15- const serviceWorkerSource = fs . readFileSync ( serviceWorkerPath , "utf8" ) ;
16- const viteConfigSource = fs . readFileSync ( path . join ( here , "../../vite.config.ts" ) , "utf8" ) ;
17-
18- expect ( mainSource ) . toContain ( 'swUrl.searchParams.set("v"' ) ;
19- expect ( mainSource ) . toContain ( "CONTROL_UI_BUILD_INFO.buildId" ) ;
20- expect ( mainSource ) . toContain ( 'updateViaCache: "none"' ) ;
21- expect ( mainSource ) . toContain ( 'navigator.serviceWorker.addEventListener("message"' ) ;
22- expect ( mainSource ) . toContain ( "event.data.version !== currentControlUiBuildId" ) ;
23- expect ( serviceWorkerSource ) . toContain (
24- 'const EMBEDDED_CACHE_VERSION = "__OPENCLAW_CONTROL_UI_BUILD_ID__"' ,
25- ) ;
26- expect ( serviceWorkerSource ) . toContain ( "URL_CACHE_VERSION" ) ;
27- expect ( serviceWorkerSource ) . toContain ( "CONTROL_CACHE_LIMIT = 3" ) ;
28- expect ( serviceWorkerSource ) . toContain ( "slice(-priorCacheLimit)" ) ;
29- expect ( serviceWorkerSource ) . toContain ( "caches.delete" ) ;
30- expect ( serviceWorkerSource ) . toContain ( "includeUncontrolled: true" ) ;
31- expect ( serviceWorkerSource ) . not . toContain (
32- 'postMessage({ type: "sw-updated", version: CACHE_VERSION },' ,
33- ) ;
34- expect ( viteConfigSource ) . toContain ( "source.replace(placeholder, JSON.stringify(buildId))" ) ;
35- expect ( viteConfigSource ) . toContain (
36- '"globalThis.OPENCLAW_CONTROL_UI_BUILD_INFO": JSON.stringify(buildInfo)' ,
37- ) ;
38- expect ( viteConfigSource ) . not . toContain (
39- "OPENCLAW_CONTROL_UI_BUILD_ID: JSON.stringify(controlUiBuildId)" ,
40- ) ;
41- expect ( serviceWorkerSource ) . not . toContain ( 'const CACHE_NAME = "openclaw-control-v1"' ) ;
42- } ) ;
43-
4413 it ( "broadcasts updated versions to uncontrolled window clients during activation" , async ( ) => {
4514 const serviceWorkerSource = fs . readFileSync ( serviceWorkerPath , "utf8" ) ;
4615 const windowClient = { postMessage : vi . fn ( ) } ;
0 commit comments