diff --git a/test/unit-tests/components/views/beacon/RoomCallBanner-test.tsx b/test/unit-tests/components/views/beacon/RoomCallBanner-test.tsx
index 38cb77eb03..908f8bdf6f 100644
--- a/test/unit-tests/components/views/beacon/RoomCallBanner-test.tsx
+++ b/test/unit-tests/components/views/beacon/RoomCallBanner-test.tsx
@@ -30,7 +30,9 @@ import { CallStore } from "../../../../../src/stores/CallStore";
import { WidgetMessagingStore } from "../../../../../src/stores/widgets/WidgetMessagingStore";
import { MatrixClientPeg } from "../../../../../src/MatrixClientPeg";
import { ConnectionState } from "../../../../../src/models/Call";
-import { SdkContextClass } from "../../../../../src/contexts/SDKContext";
+import { ScopedRoomContextProvider } from "../../../../../src/contexts/ScopedRoomContext";
+import { type IRoomState } from "../../../../../src/components/structures/RoomView";
+import RoomContext from "../../../../../src/contexts/RoomContext";
describe("", () => {
let client: Mocked;
@@ -42,6 +44,15 @@ describe("", () => {
roomId: "!1:example.org",
};
+ const mockRoomViewStore = {
+ isViewingCall: jest.fn().mockReturnValue(false),
+ on: jest.fn(),
+ off: jest.fn(),
+ emit: jest.fn(),
+ };
+
+ let roomContext: IRoomState;
+
beforeEach(() => {
stubClient();
@@ -59,6 +70,16 @@ describe("", () => {
setupAsyncStoreWithClient(CallStore.instance, client);
setupAsyncStoreWithClient(WidgetMessagingStore.instance, client);
+
+ // Reset the mock RoomViewStore
+ mockRoomViewStore.isViewingCall.mockReturnValue(false);
+
+ // Create a stable room context for this test
+ roomContext = {
+ ...RoomContext,
+ roomId: room.roomId,
+ roomViewStore: mockRoomViewStore,
+ } as unknown as IRoomState;
});
afterEach(async () => {
@@ -66,7 +87,11 @@ describe("", () => {
});
const renderBanner = async (props = {}): Promise => {
- render();
+ render(
+
+
+ ,
+ );
await act(() => Promise.resolve()); // Let effects settle
};
@@ -117,8 +142,7 @@ describe("", () => {
});
it("doesn't show banner if the call is shown", async () => {
- jest.spyOn(SdkContextClass.instance.roomViewStore, "isViewingCall");
- mocked(SdkContextClass.instance.roomViewStore.isViewingCall).mockReturnValue(true);
+ mockRoomViewStore.isViewingCall.mockReturnValue(true);
await renderBanner();
const banner = await screen.queryByText("Video call");
expect(banner).toBeFalsy();