test(16.3): retarget panel create test after WR-02 submit gate

Assert submit stays disabled with no scopes; keep the 422 focus path
with a selected scope so check-phase16.3.sh --all stays green.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-11 14:05:59 +02:00
parent 502fae3e90
commit d1b043a361

View File

@@ -382,6 +382,21 @@ describe('ApiTokensPanel', () => {
expect(await post!.clone().json()).toEqual({ name: 'Full', expires: '90d', scopes: ['*'] }) expect(await post!.clone().json()).toEqual({ name: 'Full', expires: '90d', scopes: ['*'] })
}) })
it('keeps submit disabled until a scope is selected', async () => {
await openCreateDialog()
await fillName('No scope')
expect(dialog()!.querySelector<HTMLButtonElement>('[data-action="create-token-submit"]')!.disabled).toBe(
true,
)
const scope = dialog()!.querySelector<HTMLInputElement>('[data-scope="admin:read"] input')!
scope.checked = true
scope.dispatchEvent(new Event('change', { bubbles: true }))
await flushPromises()
expect(dialog()!.querySelector<HTMLButtonElement>('[data-action="create-token-submit"]')!.disabled).toBe(
false,
)
})
it('renders a 422 on scopes and focuses the first scope checkbox', async () => { it('renders a 422 on scopes and focuses the first scope checkbox', async () => {
await openCreateDialog({ await openCreateDialog({
[`POST ${TOKENS}`]: { [`POST ${TOKENS}`]: {
@@ -395,7 +410,11 @@ describe('ApiTokensPanel', () => {
}, },
}, },
}) })
await fillName('No scope') await fillName('Scoped')
const scope = dialog()!.querySelector<HTMLInputElement>('[data-scope="admin:read"] input')!
scope.checked = true
scope.dispatchEvent(new Event('change', { bubbles: true }))
await flushPromises()
await click('[data-action="create-token-submit"]', dialog()!) await click('[data-action="create-token-submit"]', dialog()!)
expect(dialog()!.textContent).toContain('Wybierz co najmniej jeden zakres.') expect(dialog()!.textContent).toContain('Wybierz co najmniej jeden zakres.')
expect(document.activeElement).toBe(dialog()!.querySelector('[data-scope="*"] input')) expect(document.activeElement).toBe(dialog()!.querySelector('[data-scope="*"] input'))