Clear offline data on logout, test offline plan and recipe reads, drop Pillow
- POST /auth/logout answers with Clear-Site-Data: "storage", "cache", which removes the verified-session marker, the service worker and its caches, so an offline visit after logout cannot reopen household data. The 401/403 clearing path is unchanged. - The service worker no longer answers network-only requests; it leaves them to the browser. Chrome stalls a Clear-Site-Data navigation that the worker answered, so the logout POST must bypass it. - New tests send plan and recipe reads through the real API client and the real network-first strategy online, then serve them from the cache offline. - The icon generator is now Go on golang.org/x/image (approved) instead of Python on Pillow; the icons are regenerated with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// The service worker itself needs worker globals, so these tests read its
|
||||
// source: they pin the parts routes.ts cannot express — the API cache's
|
||||
// strategy, the font strategy's expiration and the font route's place ahead of
|
||||
// the precache route.
|
||||
// strategy, the font strategy's expiration, the font route's place ahead of
|
||||
// the precache route and network-only requests left to the browser.
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import source from '../sw.ts?raw'
|
||||
|
||||
@@ -27,6 +27,16 @@ describe('service worker source', () => {
|
||||
expect(precache).toBeGreaterThan(fontRoute)
|
||||
})
|
||||
|
||||
it('leaves network-only requests to the browser instead of answering them', () => {
|
||||
// Chrome stalls a navigation whose Clear-Site-Data response (POST
|
||||
// /auth/logout) the worker answered, so the worker must not match it.
|
||||
expect(source).toMatch(
|
||||
/function answered\(options: \{ request: Request; url: URL \}\): boolean \{\s*return routeOf\(options\)\.strategy !== 'network-only'/,
|
||||
)
|
||||
expect(source).toContain('registerRoute(answered, handle, method)')
|
||||
expect(source).not.toContain('registerRoute(() => true')
|
||||
})
|
||||
|
||||
it('activates a waiting worker when the update prompt sends SKIP_WAITING', () => {
|
||||
expect(source).toMatch(
|
||||
/self\.addEventListener\('message', \(event\) => \{\s*if \(event\.data\?\.type === 'SKIP_WAITING'\) void self\.skipWaiting\(\)/,
|
||||
|
||||
Reference in New Issue
Block a user