Skip to content

Commit 63a70fb

Browse files
committed
test(e2e): add playwright tests to edit and remove a section
1 parent 906e0f0 commit 63a70fb

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

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

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,67 @@ test.describe("Room list custom sections", () => {
195195
});
196196
});
197197

198+
test.describe("Section editing", () => {
199+
test("should edit a custom section name via the section header menu", async ({ page, app }) => {
200+
await app.client.createRoom({ name: "my room" });
201+
await createCustomSection(page, "Work");
202+
203+
// Open the section header menu
204+
const sectionHeader = getSectionHeader(page, "Work");
205+
await sectionHeader.hover();
206+
await sectionHeader.getByRole("button", { name: "More options" }).click();
207+
208+
// Click "Edit section"
209+
await page.getByRole("menuitem", { name: "Edit section" }).click();
210+
211+
// The edit dialog should appear pre-filled with the current name
212+
const dialog = page.getByRole("dialog", { name: "Edit a section" });
213+
await expect(dialog).toBeVisible();
214+
await expect(dialog.getByRole("textbox", { name: "Section name" })).toHaveValue("Work");
215+
216+
// Change the name and confirm
217+
await dialog.getByRole("textbox", { name: "Section name" }).fill("Personal");
218+
await dialog.getByRole("button", { name: "Edit section" }).click();
219+
220+
// Dialog should close
221+
await expect(dialog).not.toBeVisible();
222+
223+
// Section should have the new name
224+
await expect(getSectionHeader(page, "Personal")).toBeVisible();
225+
await expect(getSectionHeader(page, "Work")).not.toBeVisible();
226+
});
227+
});
228+
229+
test.describe("Section removal", () => {
230+
test("should move rooms back to Chats when their section is removed", async ({ page, app }) => {
231+
await app.client.createRoom({ name: "my room" });
232+
await createCustomSection(page, "Work");
233+
234+
const roomList = getRoomList(page);
235+
236+
// Move room to Work section
237+
const roomItem = roomList.getByRole("row", { name: "Open room my room" });
238+
await roomItem.hover();
239+
await roomItem.getByRole("button", { name: "More Options" }).click();
240+
await page.getByRole("menuitem", { name: "Move to" }).hover();
241+
await page.getByRole("menuitem", { name: "Work" }).click();
242+
await assertRoomInSection(page, "Work", "my room");
243+
244+
// Remove the Work section
245+
const sectionHeader = getSectionHeader(page, "Work");
246+
await sectionHeader.hover();
247+
await sectionHeader.getByRole("button", { name: "More options" }).click();
248+
await page.getByRole("menuitem", { name: "Remove section" }).click();
249+
const dialog = page.getByRole("dialog", { name: "Remove section?" });
250+
await dialog.getByRole("button", { name: "Remove section" }).click();
251+
252+
// Section should be gone
253+
await expect(getSectionHeader(page, "Work")).not.toBeVisible();
254+
// Room should now be in the Chats section
255+
await assertRoomInSection(page, "Chats", "my room");
256+
});
257+
});
258+
198259
test.describe("Adding a room to a custom section", () => {
199260
test("should add a room to a custom section via the More Options menu", async ({ page, app }) => {
200261
await app.client.createRoom({ name: "my room" });

0 commit comments

Comments
 (0)