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:
41
admin/tests/app/runtime.test.ts
Normal file
41
admin/tests/app/runtime.test.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { DEFAULT_BASE, readBase, runtime } from '../../src/app/runtime'
|
||||
|
||||
function docWith(content: string | null): Document {
|
||||
const doc = document.implementation.createHTMLDocument('test')
|
||||
if (content !== null) {
|
||||
const meta = doc.createElement('meta')
|
||||
meta.setAttribute('name', 'summer-admin-base')
|
||||
meta.setAttribute('content', content)
|
||||
doc.head.appendChild(meta)
|
||||
}
|
||||
return doc
|
||||
}
|
||||
|
||||
describe('runtime base', () => {
|
||||
it('derives the router base and the API base from the served meta', () => {
|
||||
expect(runtime.base).toBe('/admin-test')
|
||||
expect(runtime.api).toBe('/admin-test/api/v1')
|
||||
})
|
||||
|
||||
it('reads a custom prefix and trims trailing slashes and whitespace', () => {
|
||||
expect(readBase(docWith('/acp'))).toBe('/acp')
|
||||
expect(readBase(docWith(' /acp/panel// '))).toBe('/acp/panel')
|
||||
})
|
||||
|
||||
it.each([
|
||||
['a missing meta', null],
|
||||
['an empty value', ''],
|
||||
['the unreplaced build token', '__SUMMER_ADMIN_BASE__'],
|
||||
['a relative path', 'backend'],
|
||||
['an absolute URL', 'https://evil.example/backend'],
|
||||
['the root alone', '/'],
|
||||
['slashes only', '///'],
|
||||
])('falls back to the default for %s', (_label, content) => {
|
||||
expect(readBase(docWith(content))).toBe(DEFAULT_BASE)
|
||||
})
|
||||
|
||||
it('uses /backend as the default', () => {
|
||||
expect(DEFAULT_BASE).toBe('/backend')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user