|
| 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 { type Page } from "@playwright/test"; |
| 9 | + |
| 10 | +import { test, expect } from "../../../element-web-test"; |
| 11 | + |
| 12 | +test.describe("Search section of the room list", () => { |
| 13 | + test.use({ |
| 14 | + labsFlags: ["feature_new_room_list"], |
| 15 | + }); |
| 16 | + |
| 17 | + /** |
| 18 | + * Get the search section of the room list |
| 19 | + * @param page |
| 20 | + */ |
| 21 | + function getSearchSection(page: Page) { |
| 22 | + return page.getByRole("search"); |
| 23 | + } |
| 24 | + |
| 25 | + test.beforeEach(async ({ page, app, user }) => { |
| 26 | + // The notification toast is displayed above the search section |
| 27 | + await app.closeNotificationToast(); |
| 28 | + }); |
| 29 | + |
| 30 | + test("should render the search section", { tag: "@screenshot" }, async ({ page, app, user }) => { |
| 31 | + const searchSection = getSearchSection(page); |
| 32 | + // exact=false to ignore the shortcut which is related to the OS |
| 33 | + await expect(searchSection.getByRole("button", { name: "Search", exact: false })).toBeVisible(); |
| 34 | + await expect(searchSection).toMatchScreenshot("search-section.png"); |
| 35 | + }); |
| 36 | + |
| 37 | + test("should open the spotlight when the search button is clicked", async ({ page, app, user }) => { |
| 38 | + const searchSection = getSearchSection(page); |
| 39 | + await searchSection.getByRole("button", { name: "Search", exact: false }).click(); |
| 40 | + // The spotlight should be displayed |
| 41 | + await expect(page.getByRole("dialog", { name: "Search Dialog" })).toBeVisible(); |
| 42 | + }); |
| 43 | + |
| 44 | + test("should open the room directory when the search button is clicked", async ({ page, app, user }) => { |
| 45 | + const searchSection = getSearchSection(page); |
| 46 | + await searchSection.getByRole("button", { name: "Explore rooms" }).click(); |
| 47 | + const dialog = page.getByRole("dialog", { name: "Search Dialog" }); |
| 48 | + // The room directory should be displayed |
| 49 | + await expect(dialog).toBeVisible(); |
| 50 | + // The public room filter should be displayed |
| 51 | + await expect(dialog.getByText("Public rooms")).toBeVisible(); |
| 52 | + }); |
| 53 | +}); |
0 commit comments