From 2135918d0263580b16caa7bddf133c406ea99a93 Mon Sep 17 00:00:00 2001 From: Timo Date: Mon, 10 Feb 2025 17:43:53 +0100 Subject: [PATCH] test fixing --- src/stores/RoomViewStore.tsx | 4 ++-- .../components/views/voip/CallView-test.tsx | 2 +- test/unit-tests/stores/RoomViewStore-test.ts | 12 +++++++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/stores/RoomViewStore.tsx b/src/stores/RoomViewStore.tsx index 95d2b7a494..207c966376 100644 --- a/src/stores/RoomViewStore.tsx +++ b/src/stores/RoomViewStore.tsx @@ -354,14 +354,14 @@ export class RoomViewStore extends EventEmitter { }); } - // Start call when requested + // Start a call if requested const currentRoomCall = this.state.roomId ? CallStore.instance.getCall(this.state.roomId) : null; if (payload.view_call && room) { if (!currentRoomCall) { ElementCall.create(room, false); } } - // Destroy call when requested leaving call view + // Destroy the call when leaving call view const prevRoomCall = this.state.roomId ? CallStore.instance.getCall(this.state.roomId) : null; if (prevRoomCall && !prevRoomCall.connected) { currentRoomCall?.destroy(); diff --git a/test/unit-tests/components/views/voip/CallView-test.tsx b/test/unit-tests/components/views/voip/CallView-test.tsx index 7f891ce984..93e84c343d 100644 --- a/test/unit-tests/components/views/voip/CallView-test.tsx +++ b/test/unit-tests/components/views/voip/CallView-test.tsx @@ -35,7 +35,7 @@ import { WidgetMessagingStore } from "../../../../../src/stores/widgets/WidgetMe import { CallStore } from "../../../../../src/stores/CallStore"; import { Call, ConnectionState } from "../../../../../src/models/Call"; import { RoomViewStore } from "../../../../../src/stores/RoomViewStore"; -import { ViewRoomPayload } from "../../../../../src/dispatcher/payloads/ViewRoomPayload"; +import { type ViewRoomPayload } from "../../../../../src/dispatcher/payloads/ViewRoomPayload"; import { MatrixDispatcher } from "../../../../../src/dispatcher/dispatcher"; import { Action } from "../../../../../src/dispatcher/actions"; import { TestSdkContext } from "../../../TestSdkContext"; diff --git a/test/unit-tests/stores/RoomViewStore-test.ts b/test/unit-tests/stores/RoomViewStore-test.ts index 74aa952036..5116f8452d 100644 --- a/test/unit-tests/stores/RoomViewStore-test.ts +++ b/test/unit-tests/stores/RoomViewStore-test.ts @@ -72,7 +72,15 @@ jest.mock("../../../src/utils/DMRoomMap", () => { }; }); -jest.mock("../../../src/stores/WidgetStore"); +jest.mock("../../../src/stores/WidgetStore", () => { + return { + instance: { + getApps: () => [], + addVirtualWidget: jest.fn(), + emit: jest.fn(), + }, + }; +}); jest.mock("../../../src/stores/widgets/WidgetLayoutStore"); describe("RoomViewStore", function () { @@ -97,6 +105,7 @@ describe("RoomViewStore", function () { knockRoom: jest.fn(), leave: jest.fn(), setRoomAccountData: jest.fn(), + getAccountData: jest.fn(), }); const room = new Room(roomId, mockClient, userId); const room2 = new Room(roomId2, mockClient, userId); @@ -307,6 +316,7 @@ describe("RoomViewStore", function () { it("should display an error message when the room is unreachable via the roomId", async () => { // When // View and wait for the room + // jest.spyOn(WidgetStore).mockReturnValue({ getApps: () => [] } as unknown as void & WidgetStore); dis.dispatch({ action: Action.ViewRoom, room_id: roomId }); await untilDispatch(Action.ActiveRoomChanged, dis); // Generate error to display the expected error message