Skip to content

Commit dc457f4

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

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

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

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

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

0 commit comments

Comments
 (0)