Skip to content

Commit

Permalink
test(e2e): add tests for room list header
Browse files Browse the repository at this point in the history
  • Loading branch information
florianduros committed Feb 19, 2025
1 parent f6944d8 commit 6d796b0
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions playwright/e2e/left-panel/room-list-view/room-list-header.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2025 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
* Please see LICENSE files in the repository root for full details.
*/

import { test, expect } from "../../../element-web-test";
import type { Page } from "@playwright/test";

test.describe("Header section of the room list", () => {
test.use({
labsFlags: ["feature_new_room_list"],
});

/**
* Get the header section of the room list
* @param page
*/
function getHeaderSection(page: Page) {
return page.getByTestId("room-list-header");
}

test.beforeEach(async ({ page, app, user }) => {
// The notification toast is displayed above the search section
await app.closeNotificationToast();
});

test("should render the header section", { tag: "@screenshot" }, async ({ page, app, user }) => {
const roomListHeader = getHeaderSection(page);
await expect(roomListHeader).toMatchScreenshot("room-list-header.png");

const composeMenu = roomListHeader.getByRole("button", { name: "Add" });
await composeMenu.click();

await expect(page.getByRole("menu")).toMatchScreenshot("room-list-header-compose-menu.png");

// New message should open the direct messages dialog
await page.getByRole("menuitem", { name: "New message" }).click();
await expect(page.getByRole("heading", { name: "Direct Messages" })).toBeVisible();
await app.closeDialog();

// New room should open the room creation dialog
await composeMenu.click();
await page.getByRole("menuitem", { name: "New room" }).click();
await expect(page.getByRole("heading", { name: "Create a private room" })).toBeVisible();
await app.closeDialog();
});

test("should render the header section for a space", async ({ page, app, user }) => {
await app.client.createSpace({ name: "MySpace" });
await page.getByRole("button", { name: "MySpace" }).click();

const roomListHeader = getHeaderSection(page);
await expect(roomListHeader.getByRole("heading", { name: "MySpace" })).toBeVisible();
await expect(roomListHeader.getByRole("button", { name: "Add" })).not.toBeVisible();
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6d796b0

Please sign in to comment.