From d1b043a3616e90a1fccbeb02bac277f9deb6a678 Mon Sep 17 00:00:00 2001 From: Jakub Zych Date: Sun, 11 Oct 2026 14:05:59 +0200 Subject: [PATCH] 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 --- admin/tests/account/ApiTokensPanel.test.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/admin/tests/account/ApiTokensPanel.test.ts b/admin/tests/account/ApiTokensPanel.test.ts index a3e4cd6..0276915 100644 --- a/admin/tests/account/ApiTokensPanel.test.ts +++ b/admin/tests/account/ApiTokensPanel.test.ts @@ -382,6 +382,21 @@ describe('ApiTokensPanel', () => { 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('[data-action="create-token-submit"]')!.disabled).toBe( + true, + ) + const scope = dialog()!.querySelector('[data-scope="admin:read"] input')! + scope.checked = true + scope.dispatchEvent(new Event('change', { bubbles: true })) + await flushPromises() + expect(dialog()!.querySelector('[data-action="create-token-submit"]')!.disabled).toBe( + false, + ) + }) + it('renders a 422 on scopes and focuses the first scope checkbox', async () => { await openCreateDialog({ [`POST ${TOKENS}`]: { @@ -395,7 +410,11 @@ describe('ApiTokensPanel', () => { }, }, }) - await fillName('No scope') + await fillName('Scoped') + const scope = dialog()!.querySelector('[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()!) expect(dialog()!.textContent).toContain('Wybierz co najmniej jeden zakres.') expect(document.activeElement).toBe(dialog()!.querySelector('[data-scope="*"] input'))