veritas-kanban/e2e/focused-control-shortcuts.spec.ts
Brad Groux 8ef78e17f8
Stabilize workflow recovery transition timing (#1412)
* test: control workflow recovery time without bypassing persistence

* fix: share focus lifecycle for policy dialogs
2026-09-03 19:46:08 -05:00

26 lines
1.1 KiB
TypeScript

import { expect, test } from '@playwright/test';
import { bypassAuth, cleanupRoutes } from './helpers/auth';
test('focused Policy actions activate by Enter and regain focus after Escape', async ({ page }) => {
await bypassAuth(page);
await page.goto('/policies');
for (const name of ['Edit', 'Test', 'Edit', 'Test']) {
const action = page.getByRole('button', { name, exact: true }).first();
await action.focus();
await expect(action).toBeFocused();
await page.keyboard.press('Enter');
await expect(page.getByRole('dialog')).toContainText(
name === 'Edit' ? 'Edit Policy' : 'Test Policy'
);
// Intentionally do not wait for initial dialog focus or an animation timeout.
await page.keyboard.press('Escape');
await expect(page.getByRole('dialog')).toHaveCount(0);
await expect(action).toBeFocused();
}
const edit = page.getByRole('button', { name: 'Edit', exact: true }).first();
await edit.click();
await page.getByRole('dialog').getByRole('button', { name: 'Cancel', exact: true }).click();
await expect(page.getByRole('dialog')).toHaveCount(0);
await expect(edit).toBeFocused();
await cleanupRoutes(page);
});