From 0115242a2b5dcc976d6dbb71b57f94efc7d99c68 Mon Sep 17 00:00:00 2001 From: Timo K Date: Thu, 13 Nov 2025 11:35:37 +0100 Subject: [PATCH] tests first batch --- src/room/InCallView.test.tsx | 7 +- src/room/InCallView.tsx | 14 +- .../__snapshots__/InCallView.test.tsx.snap | 52 +------ src/state/CallViewModel/CallViewModel.test.ts | 5 +- .../remoteMembers/Connection.test.ts | 146 ++++-------------- .../CallViewModel/remoteMembers/Connection.ts | 3 +- .../remoteMembers/ConnectionManager.test.ts | 7 +- src/state/ObservableScope.test.ts | 32 ++-- src/state/ObservableScope.ts | 25 ++- src/utils/test-viewmodel.ts | 5 + 10 files changed, 98 insertions(+), 198 deletions(-) diff --git a/src/room/InCallView.test.tsx b/src/room/InCallView.test.tsx index d388ebc3..a137074b 100644 --- a/src/room/InCallView.test.tsx +++ b/src/room/InCallView.test.tsx @@ -43,9 +43,6 @@ import { LivekitRoomAudioRenderer } from "../livekit/MatrixAudioRenderer"; import { MediaDevicesContext } from "../MediaDevicesContext"; import { HeaderStyle } from "../UrlParams"; -// vi.hoisted(() => { -// localStorage = {} as unknown as Storage; -// }); vi.hoisted( () => (global.ImageData = class MockImageData { @@ -109,6 +106,7 @@ function createInCallView(): RenderResult & { getUserId: () => localRtcMember.userId, getDeviceId: () => localRtcMember.deviceId, getRoom: (rId) => (rId === roomId ? room : null), + getDomain: () => "example.com", } as Partial as MatrixClient; const room = mockMatrixRoom({ relations: { @@ -119,7 +117,8 @@ function createInCallView(): RenderResult & { } as unknown as RelationsContainer, client, roomId, - getMember: (userId) => roomMembers.get(userId) ?? null, + // getMember: (userId) => roomMembers.get(userId) ?? null, + getMembers: () => Array.from(roomMembers.values()), getMxcAvatarUrl: () => null, hasEncryptionStateEvent: vi.fn().mockReturnValue(true), getCanonicalAlias: () => null, diff --git a/src/room/InCallView.tsx b/src/room/InCallView.tsx index c506e96b..1474fb81 100644 --- a/src/room/InCallView.tsx +++ b/src/room/InCallView.tsx @@ -118,16 +118,16 @@ export interface ActiveCallProps } export const ActiveCall: FC = (props) => { - const mediaDevices = useMediaDevices(); const [vm, setVm] = useState(null); - const { autoLeaveWhenOthersLeft, waitForCallPickup, sendNotificationType } = - useUrlParams(); - + const urlParams = useUrlParams(); + const mediaDevices = useMediaDevices(); const trackProcessorState$ = useTrackProcessorObservable$(); useEffect(() => { const scope = new ObservableScope(); const reactionsReader = new ReactionsReader(scope, props.rtcSession); + const { autoLeaveWhenOthersLeft, waitForCallPickup, sendNotificationType } = + urlParams; const vm = new CallViewModel( scope, props.rtcSession, @@ -152,13 +152,11 @@ export const ActiveCall: FC = (props) => { }, [ props.rtcSession, props.matrixRoom, - mediaDevices, props.muteStates, props.e2eeSystem, - autoLeaveWhenOthersLeft, - sendNotificationType, - waitForCallPickup, props.onLeft, + urlParams, + mediaDevices, trackProcessorState$, ]); diff --git a/src/room/__snapshots__/InCallView.test.tsx.snap b/src/room/__snapshots__/InCallView.test.tsx.snap index 661d13ad..a1b0d226 100644 --- a/src/room/__snapshots__/InCallView.test.tsx.snap +++ b/src/room/__snapshots__/InCallView.test.tsx.snap @@ -49,66 +49,26 @@ exports[`InCallView > rendering > renders 1`] = ` -
- - - - - - - 2 - -