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:
@@ -102,10 +102,16 @@ export const winterIcons: Readonly<Record<string, string>> = {
|
||||
/** Neutral icon for names neither lucide map knows. */
|
||||
export const fallbackIcon: Component = Square
|
||||
|
||||
/** An own entry of a map: names come from the server, so inherited object
|
||||
* members such as "constructor" or "toString" never count as icons. */
|
||||
function own<T>(map: Readonly<Record<string, T>>, key: string): T | undefined {
|
||||
return Object.hasOwn(map, key) ? map[key] : undefined
|
||||
}
|
||||
|
||||
export function iconFor(name: string | null | undefined): Component {
|
||||
if (!name) {
|
||||
return fallbackIcon
|
||||
}
|
||||
const key = name.trim()
|
||||
return icons[key] ?? icons[winterIcons[key] ?? ''] ?? fallbackIcon
|
||||
return own(icons, key) ?? own(icons, own(winterIcons, key) ?? '') ?? fallbackIcon
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user