Kundenansicht neu P10: Service Worker legt die weiße Offline-Seite neu ab (Cache v2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-29 13:53:39 +00:00
1 parent f28ece913d
commit a270ff51da
2 files changed
+13 -1

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
// P10 Task 12: Nach dem Umschalten liegt unter /offline.html die weiße Seite. Der Service Worker legt sie nur beim Installieren ab, und
// installiert wird nur, wenn sich sw.js ändert: darum Cache v2. Die alten Caches löscht activate.
const sw = readFileSync(new URL('../public/sw.js', import.meta.url), 'utf8')
test('sw.js: Cache v2, Offline-Seite unverändert, alte Caches werden gelöscht', () => {
assert.match(sw, /const CACHE = 'kb-offline-v2'/); assert.doesNotMatch(sw, /kb-offline-v1/)
assert.match(sw, /const OFFLINE_URL = '\/offline\.html'/); assert.match(sw, /cache\.add\(new Request\(OFFLINE_URL, \{ cache: 'reload' \}\)\)/)
assert.match(sw, /if \(key !== CACHE\) await caches\.delete\(key\)/); assert.doesNotMatch(sw, /auftrag/)
})