feat: SPA Roles screens
This commit is contained in:
1 parent
907949aa12
commit
3db490a615
47 files changed
+6947
-9
No files matched your search
@@ -0,0 +1,63 @@
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { messages } from './messages'
|
||||
import { setLocale, t } from './index'
|
||||
|
||||
const ROLE_KEYS = [
|
||||
'Access',
|
||||
'Roles',
|
||||
'New role',
|
||||
'Who can do what on this site. Each user has one role.',
|
||||
'No custom roles yet',
|
||||
"Couldn't load roles",
|
||||
'You can see roles but not change them',
|
||||
'Content permissions',
|
||||
'Quick presets',
|
||||
'Read only',
|
||||
'Write own',
|
||||
'Full content',
|
||||
'General permissions',
|
||||
'Expand all',
|
||||
'{0} unsaved changes',
|
||||
'Give the role a name.',
|
||||
'A role named "{0}" already exists. Choose a different name.',
|
||||
'This role changed while you were editing',
|
||||
'Your access changed',
|
||||
'The Owner role is locked',
|
||||
'Only the owner can edit built-in roles',
|
||||
'What this role can do',
|
||||
'Role created',
|
||||
'{0} is ready. Assign it from Users.',
|
||||
'Role saved',
|
||||
'{0} members have this role. Move them to another role first. Then {1} can be deleted.',
|
||||
'Move {0} members and delete role',
|
||||
"No one has this role. This can't be undone.",
|
||||
'Can {0}.',
|
||||
"Can't {0}.",
|
||||
] as const
|
||||
|
||||
const PLACEHOLDER = /\{\d+\}/g
|
||||
|
||||
afterEach(() => setLocale('en'))
|
||||
|
||||
describe('Roles screens copy', () => {
|
||||
it.each(ROLE_KEYS)('"%s" has a French entry', (key) => {
|
||||
expect((messages as Record<string, string>)[key]).toMatch(/\S/)
|
||||
})
|
||||
|
||||
it('keeps the same placeholders in French as in English for every entry', () => {
|
||||
const mismatches = Object.entries(messages).filter(([english, french]) => {
|
||||
const expected = (english.match(PLACEHOLDER) ?? []).sort().join()
|
||||
const actual = (french.match(PLACEHOLDER) ?? []).sort().join()
|
||||
return expected !== actual
|
||||
})
|
||||
|
||||
expect(mismatches.map(([english]) => english)).toEqual([])
|
||||
})
|
||||
|
||||
it('renders French with its values', () => {
|
||||
setLocale('fr')
|
||||
|
||||
expect(t('{0} unsaved changes', [3])).toBe('3 modifications non enregistrées')
|
||||
expect(t('Roles')).toBe('Rôles')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user