mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-10 09:15:16 +00:00
f3dbe81ef4
* refactor(room list item): rename `RoomListCell` into `RoomListItemView` * refactor(room list item): move open room action to new room list item view model * feat(hover menu): add `hasAccessToOptionsMenu` * feat(hover menu): add to `RoomListItemViewModel` the condition to display or not the hover menu * feat(hover menu): add view model for the hover menu * feat(hover menu): add hover menu view * feat(hover menu): add hover menu to room list item * feat(hover menu): update i18n * test(view model list item): update test and add test to `showHoverMenu` * test(room list): update snapshot * test(room list item menu): add tests for view model * test(room list item menu): add tests for view * test(room list item): add tests * test(e2e): add tests for more options menu * chore: update compound web * test(e2e): fix typo
81 lines
3.1 KiB
TypeScript
81 lines
3.1 KiB
TypeScript
/*
|
|
* 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 { type Page } from "@playwright/test";
|
|
|
|
import { test, expect } from "../../../element-web-test";
|
|
|
|
test.describe("Room list", () => {
|
|
test.use({
|
|
displayName: "Alice",
|
|
labsFlags: ["feature_new_room_list"],
|
|
});
|
|
|
|
/**
|
|
* Get the room list
|
|
* @param page
|
|
*/
|
|
function getRoomList(page: Page) {
|
|
return page.getByTestId("room-list");
|
|
}
|
|
|
|
test.beforeEach(async ({ page, app, user }) => {
|
|
// The notification toast is displayed above the search section
|
|
await app.closeNotificationToast();
|
|
for (let i = 0; i < 30; i++) {
|
|
await app.client.createRoom({ name: `room${i}` });
|
|
}
|
|
});
|
|
|
|
test("should render the room list", { tag: "@screenshot" }, async ({ page, app, user }) => {
|
|
const roomListView = getRoomList(page);
|
|
await expect(roomListView.getByRole("gridcell", { name: "Open room room29" })).toBeVisible();
|
|
await expect(roomListView).toMatchScreenshot("room-list.png");
|
|
|
|
await roomListView.hover();
|
|
// Scroll to the end of the room list
|
|
await page.mouse.wheel(0, 1000);
|
|
await expect(roomListView.getByRole("gridcell", { name: "Open room room0" })).toBeVisible();
|
|
await expect(roomListView).toMatchScreenshot("room-list-scrolled.png");
|
|
});
|
|
|
|
test("should open the room when it is clicked", async ({ page, app, user }) => {
|
|
const roomListView = getRoomList(page);
|
|
await roomListView.getByRole("gridcell", { name: "Open room room29" }).click();
|
|
await expect(page.getByRole("heading", { name: "room29", level: 1 })).toBeVisible();
|
|
});
|
|
|
|
test("should open the more options menu", { tag: "@screenshot" }, async ({ page, app, user }) => {
|
|
const roomListView = getRoomList(page);
|
|
const roomItem = roomListView.getByRole("gridcell", { name: "Open room room29" });
|
|
await roomItem.hover();
|
|
|
|
await expect(roomItem).toMatchScreenshot("room-list-item-hover.png");
|
|
const roomItemMenu = roomItem.getByRole("button", { name: "More Options" });
|
|
await roomItemMenu.click();
|
|
await expect(page).toMatchScreenshot("room-list-item-open-more-options.png");
|
|
|
|
// It should make the room favourited
|
|
await page.getByRole("menuitemcheckbox", { name: "Favourited" }).click();
|
|
|
|
// Check that the room is favourited
|
|
await roomItem.hover();
|
|
await roomItemMenu.click();
|
|
await expect(page.getByRole("menuitemcheckbox", { name: "Favourited" })).toBeChecked();
|
|
// It should show the invite dialog
|
|
await page.getByRole("menuitem", { name: "invite" }).click();
|
|
await expect(page.getByRole("heading", { name: "Invite to room29" })).toBeVisible();
|
|
await app.closeDialog();
|
|
|
|
// It should leave the room
|
|
await roomItem.hover();
|
|
await roomItemMenu.click();
|
|
await page.getByRole("menuitem", { name: "leave room" }).click();
|
|
await expect(roomItem).not.toBeVisible();
|
|
});
|
|
});
|