* feat: add video call and EC call to room list item vm * feat: add video call notification decoration to notification decoration component * feat: add video call support to room list item view * feat: add new RoomAvatarView component * feat: deprecate `DecoratedRoomAvatar` * feat: use `RoomAvatarView` in room list item * feat: allow custom class for `RoomAvatar` * test: update notification decoration * test: update room list item view * test: update room list snapshot * test: add tests for room avatar vm * test: add tests for room avatar view * test(e2e): update snapshots * fix: video room creation rights * test: e2e add test for public and video room
102 lines
3.6 KiB
TypeScript
102 lines
3.6 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 React from "react";
|
|
import { render, screen } from "jest-matrix-react";
|
|
import { mocked } from "jest-mock";
|
|
|
|
import { RoomAvatarView } from "../../../../../src/components/views/avatars/RoomAvatarView";
|
|
import { mkStubRoom, stubClient } from "../../../../test-utils";
|
|
import {
|
|
type Presence,
|
|
type RoomAvatarViewState,
|
|
useRoomAvatarViewModel,
|
|
} from "../../../../../src/components/viewmodels/avatars/RoomAvatarViewModel";
|
|
import DMRoomMap from "../../../../../src/utils/DMRoomMap";
|
|
|
|
jest.mock("../../../../../src/components/viewmodels/avatars/RoomAvatarViewModel", () => ({
|
|
useRoomAvatarViewModel: jest.fn(),
|
|
}));
|
|
|
|
describe("<RoomAvatarView />", () => {
|
|
const matrixClient = stubClient();
|
|
const room = mkStubRoom("roomId", "roomName", matrixClient);
|
|
|
|
DMRoomMap.makeShared(matrixClient);
|
|
jest.spyOn(DMRoomMap.shared(), "getUserIdForRoomId").mockReturnValue(null);
|
|
|
|
let defaultValue: RoomAvatarViewState;
|
|
|
|
beforeEach(() => {
|
|
defaultValue = {
|
|
hasDecoration: true,
|
|
isPublic: true,
|
|
isVideoRoom: true,
|
|
presence: null,
|
|
};
|
|
|
|
mocked(useRoomAvatarViewModel).mockReturnValue(defaultValue);
|
|
});
|
|
|
|
it("should not render a decoration", () => {
|
|
mocked(useRoomAvatarViewModel).mockReturnValue({ ...defaultValue, hasDecoration: false });
|
|
const { asFragment } = render(<RoomAvatarView room={room} />);
|
|
expect(asFragment()).toMatchSnapshot();
|
|
});
|
|
|
|
it("should render a video room decoration", () => {
|
|
mocked(useRoomAvatarViewModel).mockReturnValue({ ...defaultValue, hasDecoration: true, isVideoRoom: true });
|
|
const { asFragment } = render(<RoomAvatarView room={room} />);
|
|
|
|
expect(screen.getByLabelText("This room is a video room")).toBeInTheDocument();
|
|
expect(asFragment()).toMatchSnapshot();
|
|
});
|
|
|
|
it("should render a public room decoration", () => {
|
|
mocked(useRoomAvatarViewModel).mockReturnValue({
|
|
...defaultValue,
|
|
hasDecoration: true,
|
|
isPublic: true,
|
|
isVideoRoom: false,
|
|
});
|
|
const { asFragment } = render(<RoomAvatarView room={room} />);
|
|
|
|
expect(screen.getByLabelText("This room is public")).toBeInTheDocument();
|
|
expect(asFragment()).toMatchSnapshot();
|
|
});
|
|
|
|
it("should not render a public room decoration if the room is a video room", () => {
|
|
mocked(useRoomAvatarViewModel).mockReturnValue({
|
|
...defaultValue,
|
|
hasDecoration: true,
|
|
isPublic: true,
|
|
isVideoRoom: true,
|
|
});
|
|
render(<RoomAvatarView room={room} />);
|
|
|
|
expect(screen.getByLabelText("This room is a video room")).toBeInTheDocument();
|
|
expect(screen.queryByLabelText("This room is public")).toBeNull();
|
|
});
|
|
|
|
it.each([
|
|
{ presence: "online" as Presence, label: "Online" },
|
|
{ presence: "offline" as Presence, label: "Offline" },
|
|
{ presence: "busy" as Presence, label: "Busy" },
|
|
{ presence: "unavailable" as Presence, label: "Away" },
|
|
])("should render the $presence presence", ({ presence, label }) => {
|
|
mocked(useRoomAvatarViewModel).mockReturnValue({
|
|
...defaultValue,
|
|
hasDecoration: true,
|
|
presence,
|
|
});
|
|
const { asFragment } = render(<RoomAvatarView room={room} />);
|
|
|
|
expect(screen.getByLabelText(label)).toBeInTheDocument();
|
|
expect(asFragment()).toMatchSnapshot();
|
|
});
|
|
});
|