|
5 | 5 | * Please see LICENSE files in the repository root for full details. |
6 | 6 | */ |
7 | 7 |
|
8 | | -import { rejectToast } from "@element-hq/element-web-playwright-common"; |
| 8 | +import { rejectToast, rejectToastIfExists } from "@element-hq/element-web-playwright-common"; |
9 | 9 |
|
10 | 10 | import { expect, test } from "../../../element-web-test"; |
11 | 11 | import { SettingLevel } from "../../../../src/settings/SettingLevel"; |
@@ -229,6 +229,52 @@ test.describe("Room list sections", () => { |
229 | 229 | }); |
230 | 230 | }); |
231 | 231 |
|
| 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 | + |
232 | 278 | test.describe("Rooms placement in sections", () => { |
233 | 279 | test("should move a room between sections when tags change", async ({ page, app }) => { |
234 | 280 | await app.client.createRoom({ name: "my room" }); |
|
0 commit comments