test(e2e): explicitly focus Desktop to stabilize keyboard flow
CI / test (pull_request) Successful in 37s

This commit is contained in:
2025-11-14 18:33:37 +09:00
parent 233ff7e900
commit 7a0bfcf60f
+7 -4
View File
@@ -4,11 +4,14 @@ const builderUrl = '/en/builder'
test('Preview viewport toggle via keyboard (Tab + Enter/Space)', async ({ page }) => { test('Preview viewport toggle via keyboard (Tab + Enter/Space)', async ({ page }) => {
await page.goto(builderUrl) await page.goto(builderUrl)
await page.waitForLoadState('domcontentloaded')
// Ensure the page has focus before sending keyboard events
await page.locator('body').click({ position: { x: 1, y: 1 } })
// Tab to first button (Desktop) // Focus the Desktop button explicitly to avoid flakiness from skip-link/initial focus
await page.keyboard.press('Tab') const desktopBtn = page.getByRole('button', { name: 'Desktop' })
await page.keyboard.press('Tab') await desktopBtn.focus()
await expect(page.getByRole('button', { name: 'Desktop' })).toBeFocused() await expect(desktopBtn).toBeFocused()
// Press Space to toggle Mobile (first ensure Desktop is selected, then move to Mobile with Tab) // Press Space to toggle Mobile (first ensure Desktop is selected, then move to Mobile with Tab)
await page.keyboard.press('Tab') await page.keyboard.press('Tab')