fix: precache only stable shell paths so SW install survives a production build

This commit is contained in:
2026-07-20 14:31:26 +01:00
parent a78f8e9a3a
commit d0c9378c40
2 changed files with 12 additions and 2 deletions
+7 -1
View File
@@ -18,9 +18,15 @@ describe('PWA wiring', () => {
expect(js).toContain('serviceWorker');
expect(js).toContain("register('/sw.js')");
});
it('service worker precaches the shell', () => {
it('service worker precaches only stable shell paths', () => {
const sw = readFileSync('public/sw.js', 'utf8');
expect(sw).toContain('addEventListener');
expect(sw).toContain('caches');
const shellMatch = sw.match(/SHELL\s*=\s*\[([^\]]*)\]/);
expect(shellMatch).not.toBe(null);
const shell = shellMatch[1];
expect(shell).toContain("'/'");
expect(shell).toContain("'/index.html'");
expect(shell).not.toContain('/src/');
});
});