Skip to content

Commit 4e57094

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

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,52 @@ 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+
193+
await room29.click();
194+
await expect(room29).toBeFocused();
195+
196+
await page.keyboard.press("ArrowDown");
197+
await expect(room28).toBeFocused();
198+
await expect(room29).not.toBeFocused();
199+
200+
await page.keyboard.press("ArrowUp");
201+
await expect(room29).toBeFocused();
202+
await expect(room28).not.toBeFocused();
203+
});
204+
205+
test("should navigate to the notification menu", async ({ page, app, user }) => {
206+
const roomListView = getRoomList(page);
207+
const room29 = roomListView.getByRole("gridcell", { name: "Open room room29" });
208+
const moreButton = room29.getByRole("button", { name: "More options" });
209+
const notificationButton = room29.getByRole("button", { name: "Notification options" });
210+
211+
await room29.click();
212+
await page.keyboard.press("Tab");
213+
await expect(moreButton).toBeFocused();
214+
await page.keyboard.press("Tab");
215+
await expect(notificationButton).toBeFocused();
216+
217+
// Open the menu
218+
await notificationButton.click();
219+
// Wait for the menu to be open
220+
await expect(page.getByRole("menuitem", { name: "Match default settings" })).toHaveAttribute(
221+
"aria-selected",
222+
"true",
223+
);
224+
225+
// Close the menu
226+
await page.keyboard.press("Escape");
227+
// Focus should be back on the room list item
228+
await expect(room29).toBeFocused();
229+
});
230+
});
185231
});
186232

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

0 commit comments

Comments
 (0)