Skip to content

Commit 6bd4cc8

Browse files
committed
test(e2e): more OverflowMenu tests
1 parent 081f2c9 commit 6bd4cc8

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

e2e/overflow-menu.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,34 @@ test.describe("OverflowMenu", () => {
4747
page.getByRole("menuitem", { name: "Action 1" }),
4848
).toBeVisible();
4949
});
50+
51+
test("opens menu with Enter key", async ({ page }) => {
52+
const trigger = page.getByRole("button", { name: "Actions" });
53+
await trigger.focus();
54+
await page.keyboard.press("Enter");
55+
await expect(
56+
page.getByRole("menuitem", { name: "Action 1" }),
57+
).toBeVisible();
58+
});
59+
60+
test("closes menu with Escape", async ({ page }) => {
61+
await page.getByRole("button", { name: "Actions" }).click();
62+
await expect(
63+
page.getByRole("menuitem", { name: "Action 1" }),
64+
).toBeVisible();
65+
await page.keyboard.press("Escape");
66+
await expect(
67+
page.getByRole("menuitem", { name: "Action 1" }),
68+
).not.toBeVisible();
69+
});
70+
71+
test("focus returns to trigger after Escape", async ({ page }) => {
72+
const trigger = page.getByRole("button", { name: "Actions" });
73+
await trigger.click();
74+
await expect(
75+
page.getByRole("menuitem", { name: "Action 1" }),
76+
).toBeVisible();
77+
await page.keyboard.press("Escape");
78+
await expect(trigger).toBeFocused();
79+
});
5080
});

0 commit comments

Comments
 (0)