test fixing
This commit is contained in:
@@ -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;
|
const currentRoomCall = this.state.roomId ? CallStore.instance.getCall(this.state.roomId) : null;
|
||||||
if (payload.view_call && room) {
|
if (payload.view_call && room) {
|
||||||
if (!currentRoomCall) {
|
if (!currentRoomCall) {
|
||||||
ElementCall.create(room, false);
|
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;
|
const prevRoomCall = this.state.roomId ? CallStore.instance.getCall(this.state.roomId) : null;
|
||||||
if (prevRoomCall && !prevRoomCall.connected) {
|
if (prevRoomCall && !prevRoomCall.connected) {
|
||||||
currentRoomCall?.destroy();
|
currentRoomCall?.destroy();
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import { WidgetMessagingStore } from "../../../../../src/stores/widgets/WidgetMe
|
|||||||
import { CallStore } from "../../../../../src/stores/CallStore";
|
import { CallStore } from "../../../../../src/stores/CallStore";
|
||||||
import { Call, ConnectionState } from "../../../../../src/models/Call";
|
import { Call, ConnectionState } from "../../../../../src/models/Call";
|
||||||
import { RoomViewStore } from "../../../../../src/stores/RoomViewStore";
|
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 { MatrixDispatcher } from "../../../../../src/dispatcher/dispatcher";
|
||||||
import { Action } from "../../../../../src/dispatcher/actions";
|
import { Action } from "../../../../../src/dispatcher/actions";
|
||||||
import { TestSdkContext } from "../../../TestSdkContext";
|
import { TestSdkContext } from "../../../TestSdkContext";
|
||||||
|
|||||||
@@ -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");
|
jest.mock("../../../src/stores/widgets/WidgetLayoutStore");
|
||||||
|
|
||||||
describe("RoomViewStore", function () {
|
describe("RoomViewStore", function () {
|
||||||
@@ -97,6 +105,7 @@ describe("RoomViewStore", function () {
|
|||||||
knockRoom: jest.fn(),
|
knockRoom: jest.fn(),
|
||||||
leave: jest.fn(),
|
leave: jest.fn(),
|
||||||
setRoomAccountData: jest.fn(),
|
setRoomAccountData: jest.fn(),
|
||||||
|
getAccountData: jest.fn(),
|
||||||
});
|
});
|
||||||
const room = new Room(roomId, mockClient, userId);
|
const room = new Room(roomId, mockClient, userId);
|
||||||
const room2 = new Room(roomId2, 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 () => {
|
it("should display an error message when the room is unreachable via the roomId", async () => {
|
||||||
// When
|
// When
|
||||||
// View and wait for the room
|
// View and wait for the room
|
||||||
|
// jest.spyOn(WidgetStore).mockReturnValue({ getApps: () => [] } as unknown as void & WidgetStore);
|
||||||
dis.dispatch({ action: Action.ViewRoom, room_id: roomId });
|
dis.dispatch({ action: Action.ViewRoom, room_id: roomId });
|
||||||
await untilDispatch(Action.ActiveRoomChanged, dis);
|
await untilDispatch(Action.ActiveRoomChanged, dis);
|
||||||
// Generate error to display the expected error message
|
// Generate error to display the expected error message
|
||||||
|
|||||||
Reference in New Issue
Block a user