1
0

feat: pwa manifest, icon and minimal service worker

This commit is contained in:
2026-09-03 18:57:31 +02:00
parent 3efde1a828
commit c1852435c8
6 changed files with 64 additions and 0 deletions

26
web/test/pwa.test.ts Normal file
View File

@@ -0,0 +1,26 @@
import { describe, it, expect } from 'vitest'
import { readFileSync } from 'node:fs'
import path from 'node:path'
const pub = path.resolve(__dirname, '../public')
describe('PWA assets', () => {
it('manifest has required fields and the icon exists', () => {
const manifest = JSON.parse(readFileSync(path.join(pub, 'manifest.webmanifest'), 'utf8')) as {
name: string
display: string
start_url: string
icons: { src: string; sizes: string; type: string }[]
}
expect(manifest.name).toContain('record-shop')
expect(manifest.display).toBe('standalone')
expect(manifest.start_url).toBe('/')
expect(manifest.icons.some((i) => i.src === '/icon.svg')).toBe(true)
expect(() => readFileSync(path.join(pub, 'icon.svg'))).not.toThrow()
})
it('service worker registers a fetch handler', () => {
const sw = readFileSync(path.join(pub, 'sw.js'), 'utf8')
expect(sw).toContain("addEventListener('fetch'")
})
})