mirror of
https://github.com/vector-im/element-web.git
synced 2025-12-26 03:31:56 +01:00
Revert "try mocking useCall rather than just useParticipantCount"
This reverts commit 92034aaff9b46fd135ee4dbcd93dd62ad5985e5e.
This commit is contained in:
parent
667827eeb3
commit
3900a1e20d
@ -96,9 +96,6 @@ describe("RoomHeader", () => {
|
||||
|
||||
setCardSpy = jest.spyOn(RightPanelStore.instance, "setCard");
|
||||
jest.spyOn(ShieldUtils, "shieldStatusForRoom").mockResolvedValue(ShieldUtils.E2EStatus.Normal);
|
||||
|
||||
// Mock useCall to return a Call object with stable participants to prevent React dependency errors
|
||||
jest.spyOn(UseCall, 'useCall').mockReturnValue(createMockCall());
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@ -558,8 +555,7 @@ describe("RoomHeader", () => {
|
||||
|
||||
it("join button is shown if there is an ongoing call", async () => {
|
||||
mockRoomMembers(room, 3);
|
||||
// Mock a call with 3 participants instead of mocking useParticipantCount
|
||||
jest.spyOn(UseCall, 'useCall').mockReturnValue(createMockCall(ROOM_ID, 3));
|
||||
jest.spyOn(UseCall, "useParticipantCount").mockReturnValue(3);
|
||||
render(<RoomHeader room={room} />, getWrapper());
|
||||
const joinButton = getByLabelText(document.body, "Join");
|
||||
expect(joinButton).not.toHaveAttribute("aria-disabled", "true");
|
||||
@ -567,8 +563,7 @@ describe("RoomHeader", () => {
|
||||
|
||||
it("join button is disabled if there is an other ongoing call", async () => {
|
||||
mockRoomMembers(room, 3);
|
||||
// Mock a call with 3 participants instead of mocking useParticipantCount
|
||||
jest.spyOn(UseCall, 'useCall').mockReturnValue(createMockCall(ROOM_ID, 3));
|
||||
jest.spyOn(UseCall, "useParticipantCount").mockReturnValue(3);
|
||||
jest.spyOn(CallStore.prototype, "connectedCalls", "get").mockReturnValue(
|
||||
new Set([{ roomId: "some_other_room" } as Call]),
|
||||
);
|
||||
@ -588,8 +583,7 @@ describe("RoomHeader", () => {
|
||||
|
||||
it("close lobby button is shown if there is an ongoing call but we are viewing the lobby", async () => {
|
||||
mockRoomMembers(room, 3);
|
||||
// Mock a call with 3 participants instead of mocking useParticipantCount
|
||||
jest.spyOn(UseCall, 'useCall').mockReturnValue(createMockCall(ROOM_ID, 3));
|
||||
jest.spyOn(UseCall, "useParticipantCount").mockReturnValue(3);
|
||||
jest.spyOn(SdkContextClass.instance.roomViewStore, "isViewingCall").mockReturnValue(true);
|
||||
|
||||
render(<RoomHeader room={room} />, getWrapper());
|
||||
@ -795,34 +789,6 @@ describe("RoomHeader", () => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Creates a mock Call object with stable participants to prevent React dependency errors
|
||||
*/
|
||||
function createMockCall(roomId: string = "!1:example.org", participantCount: number = 0): Call {
|
||||
const participants = new Map();
|
||||
|
||||
// Create mock participants with devices
|
||||
for (let i = 0; i < participantCount; i++) {
|
||||
const mockMember = {
|
||||
userId: `@user-${i}:example.org`,
|
||||
name: `Member ${i}`,
|
||||
} as RoomMember;
|
||||
|
||||
const deviceSet = new Set([`device-${i}`]);
|
||||
participants.set(mockMember, deviceSet);
|
||||
}
|
||||
|
||||
return {
|
||||
roomId,
|
||||
participants,
|
||||
widget: { id: "test-widget" },
|
||||
connectionState: "disconnected",
|
||||
on: jest.fn(),
|
||||
off: jest.fn(),
|
||||
emit: jest.fn(),
|
||||
} as unknown as Call;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param count the number of users to create
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user