start fixing CallViewModel tests.
Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
@@ -210,6 +210,7 @@ export const InCallView: FC<InCallViewProps> = ({
|
|||||||
// annoyingly we don't get the disconnection reason this way,
|
// annoyingly we don't get the disconnection reason this way,
|
||||||
// only by listening for the emitted event
|
// only by listening for the emitted event
|
||||||
// This needs to be done differential. with the vm connection state we start with Disconnected.
|
// This needs to be done differential. with the vm connection state we start with Disconnected.
|
||||||
|
// TODO-MULTI-SFU decide how to handle this properly
|
||||||
// if (connectionState === ConnectionState.Disconnected)
|
// if (connectionState === ConnectionState.Disconnected)
|
||||||
// throw new ConnectionLostError();
|
// throw new ConnectionLostError();
|
||||||
|
|
||||||
|
|||||||
@@ -9,15 +9,8 @@ import { expect, describe, it, vi, beforeAll } from "vitest";
|
|||||||
import { render } from "@testing-library/react";
|
import { render } from "@testing-library/react";
|
||||||
|
|
||||||
import { type MatrixInfo, VideoPreview } from "./VideoPreview";
|
import { type MatrixInfo, VideoPreview } from "./VideoPreview";
|
||||||
import { type MuteStates } from "./MuteStates";
|
|
||||||
import { E2eeType } from "../e2ee/e2eeType";
|
import { E2eeType } from "../e2ee/e2eeType";
|
||||||
|
import { mockMuteStates } from "../utils/test";
|
||||||
function mockMuteStates({ audio = true, video = true } = {}): MuteStates {
|
|
||||||
return {
|
|
||||||
audio: { enabled: audio, setEnabled: vi.fn() },
|
|
||||||
video: { enabled: video, setEnabled: vi.fn() },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
describe("VideoPreview", () => {
|
describe("VideoPreview", () => {
|
||||||
const matrixInfo: MatrixInfo = {
|
const matrixInfo: MatrixInfo = {
|
||||||
@@ -49,7 +42,7 @@ describe("VideoPreview", () => {
|
|||||||
const { queryByRole } = render(
|
const { queryByRole } = render(
|
||||||
<VideoPreview
|
<VideoPreview
|
||||||
matrixInfo={matrixInfo}
|
matrixInfo={matrixInfo}
|
||||||
muteStates={mockMuteStates({ video: false })}
|
muteStates={mockMuteStates()}
|
||||||
videoTrack={null}
|
videoTrack={null}
|
||||||
children={<></>}
|
children={<></>}
|
||||||
/>,
|
/>,
|
||||||
@@ -61,7 +54,7 @@ describe("VideoPreview", () => {
|
|||||||
const { queryByRole } = render(
|
const { queryByRole } = render(
|
||||||
<VideoPreview
|
<VideoPreview
|
||||||
matrixInfo={matrixInfo}
|
matrixInfo={matrixInfo}
|
||||||
muteStates={mockMuteStates({ video: true })}
|
muteStates={mockMuteStates()}
|
||||||
videoTrack={null}
|
videoTrack={null}
|
||||||
children={<></>}
|
children={<></>}
|
||||||
/>,
|
/>,
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ import {
|
|||||||
type Layout,
|
type Layout,
|
||||||
} from "./CallViewModel";
|
} from "./CallViewModel";
|
||||||
import {
|
import {
|
||||||
mockLivekitRoom,
|
|
||||||
mockLocalParticipant,
|
mockLocalParticipant,
|
||||||
mockMatrixRoom,
|
mockMatrixRoom,
|
||||||
mockMatrixRoomMember,
|
mockMatrixRoomMember,
|
||||||
@@ -62,6 +61,7 @@ import {
|
|||||||
mockRtcMembership,
|
mockRtcMembership,
|
||||||
MockRTCSession,
|
MockRTCSession,
|
||||||
mockMediaDevices,
|
mockMediaDevices,
|
||||||
|
mockMuteStates,
|
||||||
} from "../utils/test";
|
} from "../utils/test";
|
||||||
import {
|
import {
|
||||||
ECAddonConnectionState,
|
ECAddonConnectionState,
|
||||||
@@ -340,21 +340,15 @@ function withCallViewModel(
|
|||||||
const roomEventSelectorSpy = vi
|
const roomEventSelectorSpy = vi
|
||||||
.spyOn(ComponentsCore, "roomEventSelector")
|
.spyOn(ComponentsCore, "roomEventSelector")
|
||||||
.mockImplementation((_room, _eventType) => of());
|
.mockImplementation((_room, _eventType) => of());
|
||||||
|
const muteStates = mockMuteStates();
|
||||||
const livekitRoom = mockLivekitRoom(
|
|
||||||
{ localParticipant },
|
|
||||||
{ remoteParticipants$ },
|
|
||||||
);
|
|
||||||
|
|
||||||
const raisedHands$ = new BehaviorSubject<Record<string, RaisedHandInfo>>({});
|
const raisedHands$ = new BehaviorSubject<Record<string, RaisedHandInfo>>({});
|
||||||
|
|
||||||
const vm = new CallViewModel(
|
const vm = new CallViewModel(
|
||||||
rtcSession as unknown as MatrixRTCSession,
|
rtcSession as unknown as MatrixRTCSession,
|
||||||
room,
|
room,
|
||||||
livekitRoom,
|
|
||||||
mediaDevices,
|
mediaDevices,
|
||||||
|
muteStates,
|
||||||
options,
|
options,
|
||||||
connectionState$,
|
|
||||||
raisedHands$,
|
raisedHands$,
|
||||||
new BehaviorSubject({}),
|
new BehaviorSubject({}),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ import { Config } from "../config/Config";
|
|||||||
import { type MediaDevices } from "../state/MediaDevices";
|
import { type MediaDevices } from "../state/MediaDevices";
|
||||||
import { type Behavior, constant } from "../state/Behavior";
|
import { type Behavior, constant } from "../state/Behavior";
|
||||||
import { ObservableScope } from "../state/ObservableScope";
|
import { ObservableScope } from "../state/ObservableScope";
|
||||||
|
import { Handler, MuteStates } from "../state/MuteStates";
|
||||||
|
|
||||||
export function withFakeTimers(continuation: () => void): void {
|
export function withFakeTimers(continuation: () => void): void {
|
||||||
vi.useFakeTimers();
|
vi.useFakeTimers();
|
||||||
@@ -417,3 +418,10 @@ export function mockMediaDevices(data: Partial<MediaDevices>): MediaDevices {
|
|||||||
...data,
|
...data,
|
||||||
} as MediaDevices;
|
} as MediaDevices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function mockMuteStates(
|
||||||
|
joined$: Observable<boolean> = of(true),
|
||||||
|
): MuteStates {
|
||||||
|
const observableScope = new ObservableScope();
|
||||||
|
return new MuteStates(observableScope, mockMediaDevices({}), joined$);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user