- 41 unit and component suites under admin/tests/{app,state,shell,list,form,relation,views,ui}
covering states and a11y roles; every src module is imported by a test
- typed fixture helper assigns each JSON fixture to its generated OpenAPI type
- fix: iconFor ignores inherited object members such as "constructor"
- fix: field controls import ./control instead of the registry (import cycle
left a renderer unregistered depending on module load order)
- fix: dropdown shows the placeholder for an unknown stored value next to an emptyOption
- fix: list announces a failed schema load even when the rows arrive after it
- tailwind no longer scans admin/tests; boardwalk/dist rebuilt
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import { beforeEach, describe, expect, it } from 'vitest'
|
|
import {
|
|
hasSettings,
|
|
loadSettings,
|
|
setSettings,
|
|
settings,
|
|
settingsEntry,
|
|
settingsGroups,
|
|
useSettings,
|
|
} from '../../src/state/useSettings'
|
|
import { settingsFixture } from '../fixtures/typed'
|
|
import { API, mockApi, resetState } from '../helpers'
|
|
|
|
beforeEach(() => {
|
|
resetState()
|
|
})
|
|
|
|
describe('useSettings (D-21)', () => {
|
|
it('is hidden until at least one settings page is permitted', async () => {
|
|
expect(hasSettings.value).toBe(false)
|
|
mockApi({ [`GET ${API}/settings`]: { body: settingsFixture.list } })
|
|
expect(await loadSettings()).toHaveLength(3)
|
|
expect(hasSettings.value).toBe(true)
|
|
expect(useSettings().settings).toBe(settings)
|
|
})
|
|
|
|
it('hides settings again when the request fails', async () => {
|
|
setSettings(settingsFixture.list.data)
|
|
mockApi({ [`GET ${API}/settings`]: { status: 403, body: { error: { code: 'forbidden', message: 'x', details: {} } } } })
|
|
expect(await loadSettings()).toEqual([])
|
|
expect(hasSettings.value).toBe(false)
|
|
})
|
|
|
|
it('finds an entry by code', () => {
|
|
setSettings(settingsFixture.list.data)
|
|
expect(settingsEntry('mail')?.label).toBe('Mail')
|
|
expect(settingsEntry('nope')).toBeNull()
|
|
})
|
|
|
|
it('groups by category in first-seen order after sorting by order', () => {
|
|
setSettings(settingsFixture.list.data)
|
|
expect(settingsGroups.value.map((group) => [group.category, group.entries.map((entry) => entry.code)])).toEqual([
|
|
['Appearance', ['branding']],
|
|
['System', ['mail', 'search']],
|
|
])
|
|
})
|
|
})
|