mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-04 10:32:44 +00:00
Add low priority avatar decoration to room tile (#30065)
* Add avatar decoration for low priority rooms * Write tests * Remove unnecesasry step in test * Make the vm expose which decoration to render * Fix jest test * Fix broken e2e test
This commit is contained in:
@@ -12,6 +12,7 @@ import { mocked } from "jest-mock";
|
||||
import { RoomAvatarView } from "../../../../../src/components/views/avatars/RoomAvatarView";
|
||||
import { mkStubRoom, stubClient } from "../../../../test-utils";
|
||||
import {
|
||||
AvatarBadgeDecoration,
|
||||
type RoomAvatarViewState,
|
||||
useRoomAvatarViewModel,
|
||||
} from "../../../../../src/components/viewmodels/avatars/RoomAvatarViewModel";
|
||||
@@ -19,6 +20,7 @@ import DMRoomMap from "../../../../../src/utils/DMRoomMap";
|
||||
import { Presence } from "../../../../../src/components/views/avatars/WithPresenceIndicator";
|
||||
|
||||
jest.mock("../../../../../src/components/viewmodels/avatars/RoomAvatarViewModel", () => ({
|
||||
...jest.requireActual("../../../../../src/components/viewmodels/avatars/RoomAvatarViewModel"),
|
||||
useRoomAvatarViewModel: jest.fn(),
|
||||
}));
|
||||
|
||||
@@ -33,9 +35,7 @@ describe("<RoomAvatarView />", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
defaultValue = {
|
||||
hasDecoration: true,
|
||||
isPublic: true,
|
||||
isVideoRoom: true,
|
||||
badgeDecoration: undefined,
|
||||
presence: null,
|
||||
};
|
||||
|
||||
@@ -43,13 +43,27 @@ describe("<RoomAvatarView />", () => {
|
||||
});
|
||||
|
||||
it("should not render a decoration", () => {
|
||||
mocked(useRoomAvatarViewModel).mockReturnValue({ ...defaultValue, hasDecoration: false });
|
||||
mocked(useRoomAvatarViewModel).mockReturnValue({ ...defaultValue });
|
||||
const { asFragment } = render(<RoomAvatarView room={room} />);
|
||||
expect(asFragment()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should render a low priority room decoration", () => {
|
||||
mocked(useRoomAvatarViewModel).mockReturnValue({
|
||||
...defaultValue,
|
||||
badgeDecoration: AvatarBadgeDecoration.LowPriority,
|
||||
});
|
||||
const { asFragment } = render(<RoomAvatarView room={room} />);
|
||||
|
||||
expect(screen.getByLabelText("This is a low priority room")).toBeInTheDocument();
|
||||
expect(asFragment()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should render a video room decoration", () => {
|
||||
mocked(useRoomAvatarViewModel).mockReturnValue({ ...defaultValue, hasDecoration: true, isVideoRoom: true });
|
||||
mocked(useRoomAvatarViewModel).mockReturnValue({
|
||||
...defaultValue,
|
||||
badgeDecoration: AvatarBadgeDecoration.VideoRoom,
|
||||
});
|
||||
const { asFragment } = render(<RoomAvatarView room={room} />);
|
||||
|
||||
expect(screen.getByLabelText("This room is a video room")).toBeInTheDocument();
|
||||
@@ -59,9 +73,7 @@ describe("<RoomAvatarView />", () => {
|
||||
it("should render a public room decoration", () => {
|
||||
mocked(useRoomAvatarViewModel).mockReturnValue({
|
||||
...defaultValue,
|
||||
hasDecoration: true,
|
||||
isPublic: true,
|
||||
isVideoRoom: false,
|
||||
badgeDecoration: AvatarBadgeDecoration.PublicRoom,
|
||||
});
|
||||
const { asFragment } = render(<RoomAvatarView room={room} />);
|
||||
|
||||
@@ -69,19 +81,6 @@ describe("<RoomAvatarView />", () => {
|
||||
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: Presence.Online, label: "Online" },
|
||||
{ presence: Presence.Offline, label: "Offline" },
|
||||
@@ -90,7 +89,7 @@ describe("<RoomAvatarView />", () => {
|
||||
])("should render the $presence presence", ({ presence, label }) => {
|
||||
mocked(useRoomAvatarViewModel).mockReturnValue({
|
||||
...defaultValue,
|
||||
hasDecoration: true,
|
||||
badgeDecoration: AvatarBadgeDecoration.Presence,
|
||||
presence,
|
||||
});
|
||||
const { asFragment } = render(<RoomAvatarView room={room} />);
|
||||
|
||||
Reference in New Issue
Block a user