test(10-05): bring every SPA module, composable and component under Vitest
- 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
This commit is contained in:
34
admin/tests/app/theme.test.ts
Normal file
34
admin/tests/app/theme.test.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { applyColorScheme, DARK_QUERY } from '../../src/app/theme'
|
||||
import { fakeMedia } from '../helpers'
|
||||
|
||||
afterEach(() => {
|
||||
document.documentElement.classList.remove('dark')
|
||||
})
|
||||
|
||||
describe('applyColorScheme (A6: system preference only)', () => {
|
||||
it('sets .dark from prefers-color-scheme and follows changes until unsubscribed', () => {
|
||||
const media = fakeMedia({ [DARK_QUERY]: true })
|
||||
const stop = applyColorScheme()
|
||||
expect(document.documentElement.classList.contains('dark')).toBe(true)
|
||||
expect(media.listeners(DARK_QUERY)).toBe(1)
|
||||
|
||||
media.change(DARK_QUERY, false)
|
||||
expect(document.documentElement.classList.contains('dark')).toBe(false)
|
||||
media.change(DARK_QUERY, true)
|
||||
expect(document.documentElement.classList.contains('dark')).toBe(true)
|
||||
|
||||
stop()
|
||||
expect(media.listeners(DARK_QUERY)).toBe(0)
|
||||
media.change(DARK_QUERY, false)
|
||||
expect(document.documentElement.classList.contains('dark')).toBe(true)
|
||||
})
|
||||
|
||||
it('stays light without matchMedia', () => {
|
||||
document.documentElement.classList.add('dark')
|
||||
const win = { document } as unknown as Window
|
||||
const stop = applyColorScheme(win)
|
||||
expect(document.documentElement.classList.contains('dark')).toBe(false)
|
||||
expect(stop()).toBeUndefined()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user