feat: roles SPA foundations

This commit is contained in:
Florian Sylvain committed 2026-10-27 22:21:12 +01:00
1 parent 80f7037d3a
commit 907949aa12
180 files changed
+4308 -835

No files matched your search

@@ -5,7 +5,7 @@ import { classifyFailure, type FailureContext, type FailureKind } from '@/lib/di
const CASES: [FailureContext, number, string | undefined, FailureKind][] = [
['site', 401, undefined, 'session'],
['site', 403, 'default_site', 'defaultSite'],
['site', 403, 'Only the owner can do this.', 'forbidden'],
['site', 403, 'Only the owner can do this.', 'permission'],
['site', 404, 'site_not_found', 'gone'],
['site', 409, 'site_key_taken', 'keyTaken'],
['site', 409, 'site_has_articles', 'hasArticles'],
@@ -0,0 +1,34 @@
import { afterEach, describe, expect, it } from 'vitest'
import { setLocale } from '@/i18n'
import { messages } from '@/i18n/messages'
import { PERMISSION_KEYS, permissionName } from '@/lib/permissionNames'
import { CATALOGUE_KEYS } from '@/test/access'
afterEach(() => setLocale('en'))
describe('permissionName', () => {
it('knows every key of the catalogue', () => {
expect([...PERMISSION_KEYS].sort()).toEqual([...CATALOGUE_KEYS].sort())
expect(PERMISSION_KEYS).toHaveLength(34)
})
it.each(CATALOGUE_KEYS)('%s has an English and a French name', (key) => {
const english = permissionName(key)
expect(english).toBeTruthy()
expect(messages[english as keyof typeof messages]).toBeTruthy()
setLocale('fr')
expect(permissionName(key)).not.toBe(english)
})
it('names content.delete Delete entries', () => {
expect(permissionName('content.delete')).toBe('Delete entries')
})
it('shows the base-key name for a typed key', () => {
expect(permissionName('content.publish:events')).toBe('Publish entries')
})
it('has no name for an unknown key', () => {
expect(permissionName('content.explode')).toBeUndefined()
})
})