Skip to content

Commit c445a47

Browse files
committed
test(e2e): add keyboard navigation tests
1 parent c925e40 commit c445a47

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

playwright/e2e/left-panel/room-list-panel/room-list.spec.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,49 @@ test.describe("Room list", () => {
182182
await expect(page.getByRole("heading", { name: "1 notification", level: 1 })).toBeVisible();
183183
});
184184
});
185+
186+
test.describe("Keyboard navigation", () => {
187+
test("should navigate to the room list", async ({ page, app, user }) => {
188+
const roomListView = getRoomList(page);
189+
190+
const room29 = roomListView.getByRole("gridcell", { name: "Open room room29" });
191+
const room28 = roomListView.getByRole("gridcell", { name: "Open room room28" });
192+
await expect(room29).toBeFocused();
193+
194+
await page.keyboard.press("ArrowDown");
195+
await expect(room28).toBeFocused();
196+
await expect(room29).not.toBeFocused();
197+
198+
await page.keyboard.press("ArrowUp");
199+
await expect(room29).toBeFocused();
200+
await expect(room28).not.toBeFocused();
201+
});
202+
203+
test("should navigate to the notification menu", async ({ page, app, user }) => {
204+
const roomListView = getRoomList(page);
205+
const room29 = roomListView.getByRole("gridcell", { name: "Open room room29" });
206+
const moreButton = room29.getByRole("button", { name: "More options" });
207+
const notificationButton = room29.getByRole("button", { name: "Notification options" });
208+
209+
await page.keyboard.press("Tab");
210+
await expect(moreButton).toBeFocused();
211+
await page.keyboard.press("Tab");
212+
await expect(notificationButton).toBeFocused();
213+
214+
// Open the menu
215+
await notificationButton.click();
216+
// Wait for the menu to be open
217+
await expect(page.getByRole("menuitem", { name: "Match default settings" })).toHaveAttribute(
218+
"aria-selected",
219+
"true",
220+
);
221+
222+
// Close the menu
223+
await page.keyboard.press("Escape");
224+
// Focus should be back on the room list item
225+
await expect(room29).toBeFocused();
226+
});
227+
});
185228
});
186229

187230
test.describe("Avatar decoration", () => {

0 commit comments

Comments
 (0)