test(10.1-04): bring the SPA extension point under Vitest

- WidgetField: skeleton and aria-busy, the 5000 ms whenDefined timeout,
  script failure, attributes only, fill-values and locale sync, one POST
  while busy, fill-key-only patching, danger toasts, unmount
- PartialHost and partialNodes: exhaustive tag, attribute and URL
  allowlist, depth and node caps, skeleton sizes, empty, failure,
  busy refetch and ?id= only with a record
- PartialField, ListToolbar, ListView, registry, formState, FormField and
  FormView: group labels, registered toolbar actions, header refetch
  rules, form context provision and asset loading
This commit is contained in:
Jakub Zych
2026-09-29 02:59:13 +02:00
parent 6b0ac15086
commit 11c4e5466b
9 changed files with 1194 additions and 9 deletions

View File

@@ -55,3 +55,56 @@ describe('list toolbar (D-14)', () => {
expect(wrapper.find('[data-action="delete"]').exists()).toBe(false)
})
})
describe('registered toolbar actions (D-12, UI-SPEC S4)', () => {
const actions = [
{ name: 'archive', label: 'Archive' },
{ name: 'recount', label: 'Recount' },
]
function names(wrapper: ReturnType<typeof mount>): (string | null)[] {
return wrapper.findAll('[data-action]').map((button) => button.attributes('data-action') ?? null)
}
it('renders custom names after delete in declared order as outline buttons', () => {
const wrapper = mount(ListToolbar, { props: { ...base, buttons: ['delete', 'recount', 'archive'], actions } })
expect(names(wrapper)).toEqual(['delete', 'recount', 'archive'])
const recount = wrapper.find('[data-action="recount"]')
expect(recount.text()).toBe('Recount')
expect(recount.classes()).toContain('border-border-strong')
expect(recount.find('svg').exists()).toBe(false)
})
it('keeps the actions enabled without a selection and while one exists', async () => {
const wrapper = mount(ListToolbar, { props: { ...base, buttons: ['delete', 'recount'], actions } })
const recount = () => wrapper.find('[data-action="recount"]')
expect(recount().attributes('disabled')).toBeUndefined()
expect(recount().attributes('aria-busy')).toBeUndefined()
await wrapper.setProps({ selectedCount: 3, selectedLabel: 'Selected 3' })
expect(recount().attributes('disabled')).toBeUndefined()
await recount().trigger('click')
expect(wrapper.emitted('action')).toEqual([['recount']])
expect(wrapper.emitted('delete')).toBeUndefined()
})
it('disables only the busy action and marks it aria-busy', async () => {
const wrapper = mount(ListToolbar, { props: { ...base, buttons: ['recount', 'archive'], actions, busyAction: 'recount' } })
const recount = wrapper.find('[data-action="recount"]')
expect(recount.attributes('disabled')).toBeDefined()
expect(recount.attributes('aria-busy')).toBe('true')
await recount.trigger('click')
expect(wrapper.emitted('action')).toBeUndefined()
const archive = wrapper.find('[data-action="archive"]')
expect(archive.attributes('disabled')).toBeUndefined()
expect(archive.attributes('aria-busy')).toBeUndefined()
await archive.trigger('click')
expect(wrapper.emitted('action')).toEqual([['archive']])
})
it('does not render names missing from actions or the create button', () => {
const wrapper = mount(ListToolbar, { props: { ...base, buttons: ['create', 'delete', 'launch', 'recount'], actions: [actions[1]!] } })
expect(names(wrapper)).toEqual(['delete', 'recount'])
const bare = mount(ListToolbar, { props: { ...base, buttons: ['recount'] } })
expect(bare.find('[data-action]').exists()).toBe(false)
})
})