test(e2e): check focus after a mobile drawer link navigation (R3-6)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
aac7a32862
commit
def38b5e36
@@ -42,3 +42,38 @@ test("provides an escape-dismissible mobile navigation", async ({ page }) => {
|
||||
await expect(page.getByRole("navigation", { name: "주요 탐색" })).toBeHidden();
|
||||
await expect(menu).toBeFocused();
|
||||
});
|
||||
|
||||
// R3-6. A drawer link closes the modal drawer and changes the route in the
|
||||
// same click. The drawer's deferred focus restore must not win over the new
|
||||
// page's heading focus; Escape (no navigation) still returns to the menu.
|
||||
test("moves focus to the new page after a mobile drawer link, not back to the menu", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
await page.goto("/");
|
||||
const menu = page.getByRole("button", { name: "메뉴", exact: true });
|
||||
const navigation = page.getByRole("navigation", { name: "주요 탐색" });
|
||||
|
||||
await menu.click();
|
||||
await navigation.getByRole("link", { name: "화면 상태" }).click();
|
||||
|
||||
await expect(page).toHaveURL(/\/examples\/states$/);
|
||||
await expect(menu).toHaveAttribute("aria-expanded", "false");
|
||||
const heading = page.getByRole("heading", { level: 1, name: "화면 상태" });
|
||||
await expect(heading).toBeFocused();
|
||||
// Give any late restore (dialog close timer, lazy route commit) time to run.
|
||||
await page.waitForTimeout(300);
|
||||
expect(
|
||||
await page.evaluate(() => {
|
||||
const active = document.activeElement;
|
||||
return active?.matches("h1, main") === true;
|
||||
}),
|
||||
).toBe(true);
|
||||
await expect(menu).not.toBeFocused();
|
||||
|
||||
await menu.click();
|
||||
await expect(navigation).toBeVisible();
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(navigation).toBeHidden();
|
||||
await expect(menu).toBeFocused();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user