Skip to content

Commit bc707b5

Browse files
committed
test(e2e): check that room is in section
1 parent 379caa7 commit bc707b5

1 file changed

Lines changed: 19 additions & 16 deletions

File tree

apps/web/playwright/e2e/left-panel/room-list-panel/room-list-custom-sections.spec.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ test.describe("Room list custom sections", () => {
4040
await expect(dialog).not.toBeVisible();
4141
}
4242

43+
/**
44+
* Asserts a room is nested under a specific section using the treegrid aria-level hierarchy.
45+
* Section header rows sit at aria-level=1; room rows nested within a section sit at aria-level=2.
46+
* Verifies that the closest preceding aria-level=1 row is the expected section header.
47+
*/
48+
async function assertRoomInSection(page: Page, sectionName: string, roomName: string): Promise<void> {
49+
const roomList = getRoomList(page);
50+
const roomRow = roomList.getByRole("row", { name: `Open room ${roomName}` });
51+
// Room row must be at aria-level=2 (i.e. inside a section)
52+
await expect(roomRow).toHaveAttribute("aria-level", "2");
53+
// The closest preceding aria-level=1 row must be the expected section header.
54+
// XPath preceding:: axis returns nodes before the context in document order; [1] picks the nearest one.
55+
const closestSectionHeader = roomRow.locator(`xpath=preceding::*[@role="row" and @aria-level="1"][1]`);
56+
await expect(closestSectionHeader).toContainText(sectionName);
57+
}
58+
4359
test.beforeEach(async ({ page, app, user }) => {
4460
// The notification toast is displayed above the search section
4561
await app.closeNotificationToast();
@@ -97,6 +113,9 @@ test.describe("Room list custom sections", () => {
97113

98114
// The custom section should be created
99115
await expect(getSectionHeader(page, "Projects")).toBeVisible();
116+
117+
// Room should be moved to the new section
118+
await assertRoomInSection(page, "Projects", "my room");
100119
});
101120

102121
test("should cancel section creation when dialog is dismissed", async ({ page, app }) => {
@@ -177,22 +196,6 @@ test.describe("Room list custom sections", () => {
177196
});
178197

179198
test.describe("Adding a room to a custom section", () => {
180-
/**
181-
* Asserts a room is nested under a specific section using the treegrid aria-level hierarchy.
182-
* Section header rows sit at aria-level=1; room rows nested within a section sit at aria-level=2.
183-
* Verifies that the closest preceding aria-level=1 row is the expected section header.
184-
*/
185-
async function assertRoomInSection(page: Page, sectionName: string, roomName: string): Promise<void> {
186-
const roomList = getRoomList(page);
187-
const roomRow = roomList.getByRole("row", { name: `Open room ${roomName}` });
188-
// Room row must be at aria-level=2 (i.e. inside a section)
189-
await expect(roomRow).toHaveAttribute("aria-level", "2");
190-
// The closest preceding aria-level=1 row must be the expected section header.
191-
// XPath preceding:: axis returns nodes before the context in document order; [1] picks the nearest one.
192-
const closestSectionHeader = roomRow.locator(`xpath=preceding::*[@role="row" and @aria-level="1"][1]`);
193-
await expect(closestSectionHeader).toContainText(sectionName);
194-
}
195-
196199
test("should add a room to a custom section via the More Options menu", async ({ page, app }) => {
197200
await app.client.createRoom({ name: "my room" });
198201
await createCustomSection(page, "Work");

0 commit comments

Comments
 (0)