b90ff252d1
Public archive with sidebar navigation, project pages, month archive, search and entry pages with image blocks. Admin area for brands, projects, post types, users, api clients, media and the entry editor with drag and drop images, preview per audience, scheduling and publish checks. Read and write API with bearer tokens, audience scoping, idempotent creation, OpenAPI document and editorial guide. Magic link login with configurable allowed domains, whole app behind the session gate. 456 tests including design rule checks.
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { isOpenPath, loginTarget, requiresSession } from '~/domain/access-paths'
|
|
|
|
describe('isOpenPath', () => {
|
|
const open = [
|
|
'/login',
|
|
'/api/auth/sign-in/email',
|
|
'/api/auth/callback/magic-link',
|
|
'/api/v1/posts',
|
|
'/api/v1/media/file/2026/07/bild.webp',
|
|
'/_next/static/chunks/main.js',
|
|
'/favicon.ico',
|
|
'/robots.txt',
|
|
]
|
|
|
|
for (const path of open) {
|
|
it(`lässt ${path} ohne Anmeldung durch`, () => {
|
|
expect(isOpenPath(path)).toBe(true)
|
|
})
|
|
}
|
|
|
|
const closed = ['/', '/trakk', '/trakk/2026/07', '/trakk/ein-beitrag', '/search', '/admin', '/admin/entries/new']
|
|
|
|
for (const path of closed) {
|
|
it(`verlangt für ${path} eine Anmeldung`, () => {
|
|
expect(requiresSession(path)).toBe(true)
|
|
})
|
|
}
|
|
|
|
it('lässt sich nicht durch einen ähnlichen Anfang austricksen', () => {
|
|
expect(isOpenPath('/loginversuch')).toBe(false)
|
|
expect(isOpenPath('/api/v1x/posts')).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('loginTarget', () => {
|
|
it('merkt sich das gewünschte Ziel', () => {
|
|
expect(loginTarget('/trakk/ein-beitrag', '')).toBe('/login?next=%2Ftrakk%2Fein-beitrag')
|
|
})
|
|
|
|
it('nimmt die Abfrageparameter mit', () => {
|
|
expect(loginTarget('/search', '?q=regel')).toBe('/login?next=%2Fsearch%3Fq%3Dregel')
|
|
})
|
|
|
|
it('lässt die Startseite ohne Ziel', () => {
|
|
expect(loginTarget('/', '')).toBe('/login')
|
|
})
|
|
})
|