Logged-out requests were redirected to /login, and logged-in non-admin roles were bounced to their home page, which blocked PWA install and the service worker. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
21 lines
600 B
TypeScript
21 lines
600 B
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { config } from '@/middleware'
|
|
|
|
const re = new RegExp(`^${config.matcher[0]}$`)
|
|
|
|
describe('middleware matcher', () => {
|
|
it.each(['/manifest.json', '/sw.js', '/_next/static/chunks/a.js', '/favicon.ico', '/icons/icon-192.png'])(
|
|
'skips public asset %s so PWA files load without a session',
|
|
path => {
|
|
expect(re.test(path)).toBe(false)
|
|
},
|
|
)
|
|
|
|
it.each(['/', '/login', '/hse/incidents', '/api/incidents', '/manifest.jsonx', '/app/sw.js'])(
|
|
'still guards %s',
|
|
path => {
|
|
expect(re.test(path)).toBe(true)
|
|
},
|
|
)
|
|
})
|