Skip to content

Commit e78c337

Browse files
committed
Add e2e test on section state persistence
1 parent ff194ec commit e78c337

1 file changed

Lines changed: 47 additions & 1 deletion

File tree

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

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Please see LICENSE files in the repository root for full details.
66
*/
77

8-
import { rejectToast } from "@element-hq/element-web-playwright-common";
8+
import { rejectToast, rejectToastIfExists } from "@element-hq/element-web-playwright-common";
99

1010
import { expect, test } from "../../../element-web-test";
1111
import { SettingLevel } from "../../../../src/settings/SettingLevel";
@@ -229,6 +229,52 @@ test.describe("Room list sections", () => {
229229
});
230230
});
231231

232+
test.describe("Section collapse state persistence", () => {
233+
test.beforeEach(async ({ app }) => {
234+
// A favourite room (so we get a Favourites section) and a regular room in Chats,
235+
// giving us two independent sections whose expansion state we can assert.
236+
const favouriteId = await app.client.createRoom({ name: "favourite room" });
237+
await app.client.evaluate(async (client, roomId) => {
238+
await client.setRoomTag(roomId, "m.favourite");
239+
}, favouriteId);
240+
await app.client.createRoom({ name: "regular room" });
241+
});
242+
243+
test("persists the collapsed/expanded state across reloads", async ({ page }) => {
244+
const roomList = getRoomList(page);
245+
const favouritesHeader = getSectionHeader(page, "Favourites");
246+
const favRoom = roomList.getByRole("row", { name: "Open room favourite room" });
247+
248+
// Collapse the Favourites section
249+
await expect(favouritesHeader).toHaveAttribute("aria-expanded", "true");
250+
await favouritesHeader.click();
251+
await expect(favouritesHeader).toHaveAttribute("aria-expanded", "false");
252+
await expect(favRoom).not.toBeVisible();
253+
254+
// Reload the page: the collapsed state is persisted at the device level and should survive
255+
await page.reload();
256+
await rejectToastIfExists(page, "Verify this device");
257+
await rejectToastIfExists(page, "Notifications");
258+
259+
// Favourites is still collapsed and its room stays hidden, while Chats remains expanded
260+
await expect(getSectionHeader(page, "Favourites")).toHaveAttribute("aria-expanded", "false");
261+
await expect(getRoomList(page).getByRole("row", { name: "Open room favourite room" })).not.toBeVisible();
262+
await expect(getSectionHeader(page, "Chats")).toHaveAttribute("aria-expanded", "true");
263+
await expect(getRoomList(page).getByRole("row", { name: "Open room regular room" })).toBeVisible();
264+
265+
// Expand it again and reload: the expanded state is likewise persisted
266+
await getSectionHeader(page, "Favourites").click();
267+
await expect(getSectionHeader(page, "Favourites")).toHaveAttribute("aria-expanded", "true");
268+
269+
await page.reload();
270+
await rejectToastIfExists(page, "Verify this device");
271+
await rejectToastIfExists(page, "Notifications");
272+
273+
await expect(getSectionHeader(page, "Favourites")).toHaveAttribute("aria-expanded", "true");
274+
await expect(getRoomList(page).getByRole("row", { name: "Open room favourite room" })).toBeVisible();
275+
});
276+
});
277+
232278
test.describe("Rooms placement in sections", () => {
233279
test("should move a room between sections when tags change", async ({ page, app }) => {
234280
await app.client.createRoom({ name: "my room" });

0 commit comments

Comments
 (0)