Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
fix test to adapt to reduced session manager event usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
toger5 committed Jun 14, 2024
1 parent 036937e commit 10074d3
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions test/toasts/IncomingCallToast-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ import { mocked, Mocked } from "jest-mock";
import { Room, RoomStateEvent, MatrixEvent, MatrixEventEvent, MatrixClient } from "matrix-js-sdk/src/matrix";
import { ClientWidgetApi, Widget } from "matrix-widget-api";
// eslint-disable-next-line no-restricted-imports
import { MatrixRTCSessionManagerEvents } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSessionManager";
// eslint-disable-next-line no-restricted-imports
import { MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession";
// eslint-disable-next-line no-restricted-imports
import { ICallNotifyContent } from "matrix-js-sdk/src/matrixrtc/types";

import type { RoomMember } from "matrix-js-sdk/src/matrix";
Expand Down Expand Up @@ -82,14 +78,14 @@ describe("IncomingCallEvent", () => {
client.getRoom.mockImplementation((roomId) => (roomId === room.roomId ? room : null));
client.getRooms.mockReturnValue([room]);
client.reEmitter.reEmit(room, [RoomStateEvent.Events]);
MockedCall.create(room, "1");

await Promise.all(
[CallStore.instance, WidgetMessagingStore.instance].map((store) =>
setupAsyncStoreWithClient(store, client),
),
);

MockedCall.create(room, "1");
const maybeCall = CallStore.instance.getCall(room.roomId);
if (!(maybeCall instanceof MockedCall)) throw new Error("Failed to create call");
call = maybeCall;
Expand Down Expand Up @@ -179,7 +175,7 @@ describe("IncomingCallEvent", () => {

defaultDispatcher.unregister(dispatcherRef);
});
it("skips lobby when using shift key click", async () => {
it("Dismiss toast if user starts call and skips lobby when using shift key click", async () => {
renderToast();

const dispatcherSpy = jest.fn();
Expand Down Expand Up @@ -250,11 +246,7 @@ describe("IncomingCallEvent", () => {

it("closes toast when the matrixRTC session has ended", async () => {
renderToast();

client.matrixRTC.emit(MatrixRTCSessionManagerEvents.SessionEnded, room.roomId, {
callId: notifyContent.call_id,
room: room,
} as unknown as MatrixRTCSession);
call.destroy();

await waitFor(() =>
expect(toastStore.dismissToast).toHaveBeenCalledWith(
Expand Down

0 comments on commit 10074d3

Please sign in to comment.