fix(call): leave call along with room (#33162)
* make sure to disconnect from possibly active calls for a room when leaving the room * log error on log call * Update apps/web/src/utils/leave-behaviour.ts Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * fix wrong logger import * hang up calls properly on empty rooms for both legacy and element calls (listen for room event and leave call if only one member left). add tests for both legacy and element calls. * format Call-test.ts * revert async on function def * revert Call.ts and Call-test.ts. Wrap legacy call hangup in try --------- Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
co-authored by
Michael Telatynski
parent
abae870b83
commit
1044a95687
@@ -22,6 +22,9 @@ import SpaceStore from "../../../src/stores/spaces/SpaceStore";
|
||||
import { MetaSpace } from "../../../src/stores/spaces";
|
||||
import { type ActionPayload } from "../../../src/dispatcher/payloads";
|
||||
import SettingsStore from "../../../src/settings/SettingsStore";
|
||||
import { CallStore } from "../../../src/stores/CallStore";
|
||||
import { type Call } from "../../../src/models/Call";
|
||||
import LegacyCallHandler from "../../../src/LegacyCallHandler";
|
||||
|
||||
describe("leaveRoomBehaviour", () => {
|
||||
SdkContextClass.instance.constructEagerStores(); // Initialize RoomViewStore
|
||||
@@ -76,6 +79,28 @@ describe("leaveRoomBehaviour", () => {
|
||||
defaultDispatcher.unregister(dispatcherRef);
|
||||
};
|
||||
|
||||
it("hangs up legacy calls when leaving a room", async () => {
|
||||
const hangupSpy = jest.spyOn(LegacyCallHandler.instance, "hangupOrReject").mockImplementation(() => {});
|
||||
|
||||
viewRoom(room);
|
||||
await leaveRoomBehaviour(client, room.roomId);
|
||||
|
||||
expect(hangupSpy).toHaveBeenCalledWith(room.roomId);
|
||||
});
|
||||
|
||||
it("disconnects widget-based calls when leaving a room", async () => {
|
||||
const mockCall = {
|
||||
disconnect: jest.fn().mockResolvedValue(undefined),
|
||||
} as unknown as Call;
|
||||
|
||||
jest.spyOn(CallStore.instance, "getActiveCall").mockReturnValue(mockCall);
|
||||
|
||||
viewRoom(room);
|
||||
await leaveRoomBehaviour(client, room.roomId);
|
||||
|
||||
expect(mockCall.disconnect).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("returns to the home page after leaving a room outside of a space that was being viewed", async () => {
|
||||
viewRoom(room);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user