- 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
54 lines
2.5 KiB
TypeScript
54 lines
2.5 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { mapWinterUrl } from '../../src/app/winterUrl'
|
|
|
|
const ID = 'acme.demo.widgets'
|
|
const LIST = '/acme/demo/widgets'
|
|
|
|
describe('mapWinterUrl', () => {
|
|
it('maps an empty, null or missing URL to the list', () => {
|
|
expect(mapWinterUrl('', ID)).toBe(LIST)
|
|
expect(mapWinterUrl(null, ID)).toBe(LIST)
|
|
expect(mapWinterUrl(undefined, ID)).toBe(LIST)
|
|
expect(mapWinterUrl(' ', ID)).toBe(LIST)
|
|
})
|
|
|
|
it('maps the controller root and create', () => {
|
|
expect(mapWinterUrl('acme/demo/widgets', ID)).toBe(LIST)
|
|
expect(mapWinterUrl('/acme/demo/widgets/', ID)).toBe(LIST)
|
|
expect(mapWinterUrl('acme/demo/widgets/create', ID)).toBe(`${LIST}/create`)
|
|
})
|
|
|
|
it('substitutes :id in update/:id and accepts a literal numeric id', () => {
|
|
expect(mapWinterUrl('acme/demo/widgets/update/:id', ID, 42)).toBe(`${LIST}/42`)
|
|
expect(mapWinterUrl('acme/demo/widgets/update/:id', ID, '7')).toBe(`${LIST}/7`)
|
|
expect(mapWinterUrl('acme/demo/widgets/update/9', ID)).toBe(`${LIST}/9`)
|
|
})
|
|
|
|
it('falls back to the list when update has no usable id', () => {
|
|
expect(mapWinterUrl('acme/demo/widgets/update/:id', ID)).toBe(LIST)
|
|
expect(mapWinterUrl('acme/demo/widgets/update/:id', ID, null)).toBe(LIST)
|
|
expect(mapWinterUrl('acme/demo/widgets/update/:id', ID, 'abc')).toBe(LIST)
|
|
expect(mapWinterUrl('acme/demo/widgets/update/1e3', ID)).toBe(LIST)
|
|
})
|
|
|
|
it('never leaves the current controller for a foreign or absolute URL (T-10-20)', () => {
|
|
expect(mapWinterUrl('acme/demo/gadgets/update/:id', ID, 1)).toBe(LIST)
|
|
expect(mapWinterUrl('https://evil.example/acme/demo/widgets/create', ID)).toBe(LIST)
|
|
expect(mapWinterUrl('//evil.example/x', ID)).toBe(LIST)
|
|
expect(mapWinterUrl('javascript:alert(1)', ID)).toBe(LIST)
|
|
})
|
|
|
|
it('ignores the query and hash, matches the owner case-insensitively and rejects unknown actions', () => {
|
|
expect(mapWinterUrl('acme/demo/widgets/create?x=1#top', ID)).toBe(`${LIST}/create`)
|
|
expect(mapWinterUrl('Acme/Demo/Widgets/update/:id', ID, 3)).toBe(`${LIST}/3`)
|
|
expect(mapWinterUrl('acme/demo/widgets/preview/3', ID)).toBe(LIST)
|
|
expect(mapWinterUrl('acme/demo/widgets/update/3/extra', ID)).toBe(LIST)
|
|
expect(mapWinterUrl('acme/demo/widgets/CREATE', ID)).toBe(LIST)
|
|
})
|
|
|
|
it('answers the root for a malformed controller id', () => {
|
|
expect(mapWinterUrl('acme/demo/widgets', 'acme.demo')).toBe('/')
|
|
expect(mapWinterUrl('acme/demo/widgets', 'acme.demo.wid gets')).toBe('/')
|
|
})
|
|
})
|