|
| 1 | +/* |
| 2 | + * Copyright 2025 New Vector Ltd. |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial |
| 5 | + * Please see LICENSE files in the repository root for full details. |
| 6 | + */ |
| 7 | + |
| 8 | +import { test, expect } from "../../../element-web-test"; |
| 9 | +import type { Page } from "@playwright/test"; |
| 10 | + |
| 11 | +test.describe("Header section of the room list", () => { |
| 12 | + test.use({ |
| 13 | + labsFlags: ["feature_new_room_list"], |
| 14 | + }); |
| 15 | + |
| 16 | + /** |
| 17 | + * Get the header section of the room list |
| 18 | + * @param page |
| 19 | + */ |
| 20 | + function getHeaderSection(page: Page) { |
| 21 | + return page.getByTestId("room-list-header"); |
| 22 | + } |
| 23 | + |
| 24 | + test.beforeEach(async ({ page, app, user }) => { |
| 25 | + // The notification toast is displayed above the search section |
| 26 | + await app.closeNotificationToast(); |
| 27 | + }); |
| 28 | + |
| 29 | + test("should render the header section", { tag: "@screenshot" }, async ({ page, app, user }) => { |
| 30 | + const roomListHeader = getHeaderSection(page); |
| 31 | + await expect(roomListHeader).toMatchScreenshot("room-list-header.png"); |
| 32 | + |
| 33 | + const composeMenu = roomListHeader.getByRole("button", { name: "Add" }); |
| 34 | + await composeMenu.click(); |
| 35 | + |
| 36 | + await expect(page.getByRole("menu")).toMatchScreenshot("room-list-header-compose-menu.png"); |
| 37 | + |
| 38 | + // New message should open the direct messages dialog |
| 39 | + await page.getByRole("menuitem", { name: "New message" }).click(); |
| 40 | + await expect(page.getByRole("heading", { name: "Direct Messages" })).toBeVisible(); |
| 41 | + await app.closeDialog(); |
| 42 | + |
| 43 | + // New room should open the room creation dialog |
| 44 | + await composeMenu.click(); |
| 45 | + await page.getByRole("menuitem", { name: "New room" }).click(); |
| 46 | + await expect(page.getByRole("heading", { name: "Create a private room" })).toBeVisible(); |
| 47 | + await app.closeDialog(); |
| 48 | + }); |
| 49 | + |
| 50 | + test("should render the header section for a space", async ({ page, app, user }) => { |
| 51 | + await app.client.createSpace({ name: "MySpace" }); |
| 52 | + await page.getByRole("button", { name: "MySpace" }).click(); |
| 53 | + |
| 54 | + const roomListHeader = getHeaderSection(page); |
| 55 | + await expect(roomListHeader.getByRole("heading", { name: "MySpace" })).toBeVisible(); |
| 56 | + await expect(roomListHeader.getByRole("button", { name: "Add" })).not.toBeVisible(); |
| 57 | + }); |
| 58 | +}); |
0 commit comments