From b21485fd9b861d91db6aeaa061b96aab93d988c9 Mon Sep 17 00:00:00 2001 From: David Langley Date: Fri, 30 Jan 2026 16:27:18 +0000 Subject: [PATCH] Remove old component, tests and snapshot --- .../views/rooms/NotificationDecoration.tsx | 89 --------- .../rooms/NotificationDecoration-test.tsx | 109 ---------- .../NotificationDecoration-test.tsx.snap | 187 ------------------ 3 files changed, 385 deletions(-) delete mode 100644 src/components/views/rooms/NotificationDecoration.tsx delete mode 100644 test/unit-tests/components/views/rooms/NotificationDecoration-test.tsx delete mode 100644 test/unit-tests/components/views/rooms/__snapshots__/NotificationDecoration-test.tsx.snap diff --git a/src/components/views/rooms/NotificationDecoration.tsx b/src/components/views/rooms/NotificationDecoration.tsx deleted file mode 100644 index 732793551b..0000000000 --- a/src/components/views/rooms/NotificationDecoration.tsx +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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, { type HTMLProps, type JSX } from "react"; -import { - MentionIcon, - ErrorIcon, - NotificationsOffSolidIcon, - VideoCallSolidIcon, - EmailSolidIcon, - VoiceCallSolidIcon, -} from "@vector-im/compound-design-tokens/assets/web/icons"; -import { UnreadCounter, Unread } from "@vector-im/compound-web"; -import { CallType } from "matrix-js-sdk/src/webrtc/call"; -import { Flex } from "@element-hq/web-shared-components"; - -import { type RoomNotificationState } from "../../../stores/notifications/RoomNotificationState"; -import { useTypedEventEmitterState } from "../../../hooks/useEventEmitter"; -import { NotificationStateEvents } from "../../../stores/notifications/NotificationState"; - -interface NotificationDecorationProps extends HTMLProps { - /** - * The notification state of the room or thread. - */ - notificationState: RoomNotificationState; - /** - * Whether the room has a voice or video call. - */ - callType?: CallType; -} - -/** - * Displays the notification decoration for a room or a thread. - */ -export function NotificationDecoration({ - notificationState, - callType, - ...props -}: NotificationDecorationProps): JSX.Element | null { - // Listen to the notification state and update the component when it changes - const { - hasAnyNotificationOrActivity, - isUnsentMessage, - invited, - isMention, - isActivityNotification, - isNotification, - count, - muted, - } = useTypedEventEmitterState(notificationState, NotificationStateEvents.Update, () => ({ - hasAnyNotificationOrActivity: notificationState.hasAnyNotificationOrActivity, - isUnsentMessage: notificationState.isUnsentMessage, - invited: notificationState.invited, - isMention: notificationState.isMention, - isActivityNotification: notificationState.isActivityNotification, - isNotification: notificationState.isNotification, - count: notificationState.count, - muted: notificationState.muted, - })); - - if (!hasAnyNotificationOrActivity && !muted && !callType) return null; - - return ( - - {isUnsentMessage && } - {callType === CallType.Video && ( - - )} - {callType === CallType.Voice && ( - - )} - {invited && } - {isMention && } - {(isMention || isNotification) && } - {isActivityNotification && } - {muted && } - - ); -} diff --git a/test/unit-tests/components/views/rooms/NotificationDecoration-test.tsx b/test/unit-tests/components/views/rooms/NotificationDecoration-test.tsx deleted file mode 100644 index deeab46bc5..0000000000 --- a/test/unit-tests/components/views/rooms/NotificationDecoration-test.tsx +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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 { CallType } from "matrix-js-sdk/src/webrtc/call"; - -import { RoomNotificationState } from "../../../../../src/stores/notifications/RoomNotificationState"; -import { NotificationDecoration } from "../../../../../src/components/views/rooms/NotificationDecoration"; -import { createTestClient, mkStubRoom } from "../../../../test-utils"; - -describe("", () => { - let roomNotificationState: RoomNotificationState; - beforeEach(() => { - const matrixClient = createTestClient(); - const room = mkStubRoom("roomId", "roomName", matrixClient); - roomNotificationState = new RoomNotificationState(room, false); - }); - - it("should not render if RoomNotificationState.hasAnyNotificationOrActivity=true", () => { - jest.spyOn(roomNotificationState, "hasAnyNotificationOrActivity", "get").mockReturnValue(false); - render(); - expect(screen.queryByTestId("notification-decoration")).toBeNull(); - }); - - it("should render the unset message decoration", () => { - jest.spyOn(roomNotificationState, "hasAnyNotificationOrActivity", "get").mockReturnValue(true); - jest.spyOn(roomNotificationState, "isUnsentMessage", "get").mockReturnValue(true); - const { asFragment } = render( - , - ); - expect(asFragment()).toMatchSnapshot(); - }); - - it("should render the invitation decoration", () => { - jest.spyOn(roomNotificationState, "hasAnyNotificationOrActivity", "get").mockReturnValue(true); - jest.spyOn(roomNotificationState, "invited", "get").mockReturnValue(true); - const { asFragment } = render( - , - ); - expect(asFragment()).toMatchSnapshot(); - }); - - it("should render the mention decoration", () => { - jest.spyOn(roomNotificationState, "hasAnyNotificationOrActivity", "get").mockReturnValue(true); - jest.spyOn(roomNotificationState, "isMention", "get").mockReturnValue(true); - jest.spyOn(roomNotificationState, "count", "get").mockReturnValue(1); - const { asFragment } = render( - , - ); - expect(asFragment()).toMatchSnapshot(); - }); - - it("should render the notification decoration", () => { - jest.spyOn(roomNotificationState, "hasAnyNotificationOrActivity", "get").mockReturnValue(true); - jest.spyOn(roomNotificationState, "isNotification", "get").mockReturnValue(true); - jest.spyOn(roomNotificationState, "count", "get").mockReturnValue(1); - const { asFragment } = render( - , - ); - expect(asFragment()).toMatchSnapshot(); - }); - - it("should render the notification decoration without count", () => { - jest.spyOn(roomNotificationState, "hasAnyNotificationOrActivity", "get").mockReturnValue(true); - jest.spyOn(roomNotificationState, "isNotification", "get").mockReturnValue(true); - jest.spyOn(roomNotificationState, "count", "get").mockReturnValue(0); - const { asFragment } = render( - , - ); - expect(asFragment()).toMatchSnapshot(); - }); - - it("should render the activity decoration", () => { - jest.spyOn(roomNotificationState, "hasAnyNotificationOrActivity", "get").mockReturnValue(true); - jest.spyOn(roomNotificationState, "isActivityNotification", "get").mockReturnValue(true); - const { asFragment } = render( - , - ); - expect(asFragment()).toMatchSnapshot(); - }); - - it("should render the muted decoration", () => { - jest.spyOn(roomNotificationState, "hasAnyNotificationOrActivity", "get").mockReturnValue(true); - jest.spyOn(roomNotificationState, "muted", "get").mockReturnValue(true); - const { asFragment } = render( - , - ); - expect(asFragment()).toMatchSnapshot(); - }); - it("should render the video call decoration", () => { - jest.spyOn(roomNotificationState, "hasAnyNotificationOrActivity", "get").mockReturnValue(false); - const { asFragment } = render( - , - ); - expect(asFragment()).toMatchSnapshot(); - }); - it("should render the audio call decoration", () => { - jest.spyOn(roomNotificationState, "hasAnyNotificationOrActivity", "get").mockReturnValue(false); - const { asFragment } = render( - , - ); - expect(asFragment()).toMatchSnapshot(); - }); -}); diff --git a/test/unit-tests/components/views/rooms/__snapshots__/NotificationDecoration-test.tsx.snap b/test/unit-tests/components/views/rooms/__snapshots__/NotificationDecoration-test.tsx.snap deleted file mode 100644 index 9706fb7024..0000000000 --- a/test/unit-tests/components/views/rooms/__snapshots__/NotificationDecoration-test.tsx.snap +++ /dev/null @@ -1,187 +0,0 @@ -// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing - -exports[` should render the activity decoration 1`] = ` - -
-
-
-
-
- -`; - -exports[` should render the audio call decoration 1`] = ` - -
- - - -
-
-`; - -exports[` should render the invitation decoration 1`] = ` - -
- - - -
-
-`; - -exports[` should render the mention decoration 1`] = ` - -
- - - - - 1 - -
-
-`; - -exports[` should render the muted decoration 1`] = ` - -
- - - - -
-
-`; - -exports[` should render the notification decoration 1`] = ` - -
- - 1 - -
-
-`; - -exports[` should render the notification decoration without count 1`] = ` - -
-
-
- -`; - -exports[` should render the unset message decoration 1`] = ` - -
- - - -
-
-`; - -exports[` should render the video call decoration 1`] = ` - -
- - - -
-
-`;