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:
Jakub Zych
2026-09-27 17:53:57 +02:00
parent 8259a456bb
commit 1c2a66df45
61 changed files with 4299 additions and 91 deletions

74
admin/tests/fixtures/typed.ts vendored Normal file
View File

@@ -0,0 +1,74 @@
// Typed views of the JSON fixtures. Each fixture is assigned to the generated
// OpenAPI schema type of the response it stands for, so a change to the
// admin document that the fixtures no longer match fails `npm run typecheck`
// instead of letting the tests drift from the wire (D-15, D-16). Fixtures are
// neutral acme.demo.* data; no application names appear in framework tests.
import type { components } from '../../src/api/schema'
import langJson from './lang.json'
import navigationJson from './navigation.json'
import settingsJson from './settings.json'
import formSchemaJson from './widgets.form-schema.json'
import listJson from './widgets.list.json'
import listSchemaJson from './widgets.list-schema.json'
import optionsJson from './widgets.options.json'
import recordJson from './widgets.record.json'
import candidatesJson from './widgets.relation-candidates.json'
import linkedJson from './widgets.relation-linked.json'
import relationSchemaJson from './widgets.relation-schema.json'
type S = components['schemas']
type Rows = S['cabana.ListEnvelope-array_cabana_AdminRecord']
export const langFixture: S['cabana.Envelope-cabana_LangBundle'] = langJson
export const navigationFixture: S['cabana.Envelope-array_cabana_NavigationEntry'] = navigationJson
export const settingsFixture: {
list: S['cabana.Envelope-array_cabana_SettingsEntry']
schema: S['cabana.Envelope-cabana_FormView']
values: S['cabana.Envelope-cabana_SettingsResult']
} = settingsJson
export const formSchemaFixture: S['cabana.Envelope-cabana_FormView'] = formSchemaJson
export const listFixture: Rows = listJson
export const listSchemaFixture: S['cabana.Envelope-cabana_ListSchema'] = listSchemaJson
export const optionsFixture: {
maker: S['cabana.Envelope-array_cabana_FilterOption']
makerField: S['cabana.ListEnvelope-array_cabana_RelationOption']
makerFieldPage2: S['cabana.ListEnvelope-array_cabana_RelationOption']
makerFieldSearch: S['cabana.ListEnvelope-array_cabana_RelationOption']
tagsField: S['cabana.ListEnvelope-array_cabana_RelationOption']
} = optionsJson
export const recordFixture: S['cabana.RecordEnvelope'] = recordJson
export const relationSchemaFixture: S['cabana.Envelope-cabana_RelationSchema'] = relationSchemaJson
export const linkedFixture: { all: Rows; search: Rows; empty: Rows } = linkedJson
export const candidatesFixture: { page1: Rows; page2: Rows; search: Rows; empty: Rows } = candidatesJson
/** A deep copy, so a test can reshape a fixture without touching the others. */
export function clone<T>(value: T): T {
return JSON.parse(JSON.stringify(value)) as T
}
/** The form schema's field by name; throws when the fixture lost it. */
export function formField(name: string): S['cabana.FormField'] {
const field = formSchemaFixture.data.fields.find((item) => item.name === name)
if (!field) {
throw new Error(`fixture field ${name} missing`)
}
return clone(field)
}
/** The list schema's column by key; throws when the fixture lost it. */
export function listColumn(key: string): S['cabana.ListColumn'] {
const column = listSchemaFixture.data.columns.find((item) => item.key === key)
if (!column) {
throw new Error(`fixture column ${key} missing`)
}
return clone(column)
}
/** The list schema's filter by name; throws when the fixture lost it. */
export function listFilter(name: string): S['cabana.ListFilter'] {
const filter = listSchemaFixture.data.filters.find((item) => item.name === name)
if (!filter) {
throw new Error(`fixture filter ${name} missing`)
}
return clone(filter)
}