From 00daf834b655140d402515beb52505946e79b7d0 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 8 Oct 2025 17:53:11 -0400 Subject: [PATCH] Remove local participant case (now enforced by types) from audio tests --- src/livekit/MatrixAudioRenderer.test.tsx | 44 +++++++----------------- 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/src/livekit/MatrixAudioRenderer.test.tsx b/src/livekit/MatrixAudioRenderer.test.tsx index 9519ccc2..b78b274d 100644 --- a/src/livekit/MatrixAudioRenderer.test.tsx +++ b/src/livekit/MatrixAudioRenderer.test.tsx @@ -65,27 +65,25 @@ let tracks: TrackReference[] = []; function renderTestComponent( rtcMembers: { userId: string; deviceId: string }[], - livekitParticipantIdentities: ({ id: string; isLocal?: boolean } | string)[], + livekitParticipantIdentities: string[], ): RenderResult { - const liveKitParticipants = livekitParticipantIdentities.map((p) => { - const identity = typeof p === "string" ? p : p.id; - const isLocal = typeof p === "string" ? false : (p.isLocal ?? false); - return vi.mocked({ - identity, - isLocal, - } as unknown as RemoteParticipant); - }); + const liveKitParticipants = livekitParticipantIdentities.map( + (identity) => + ({ + identity, + }) as unknown as RemoteParticipant, + ); const participants = rtcMembers.flatMap(({ userId, deviceId }) => { const p = liveKitParticipants.find( (p) => p.identity === `${userId}:${deviceId}`, ); return p === undefined ? [] : [p]; }); - const livekitRoom = vi.mocked({ + const livekitRoom = { remoteParticipants: new Map( liveKitParticipants.map((p) => [p.identity, p]), ), - } as unknown as Room); + } as unknown as Room; tracks = participants.map((p) => mockTrack(p)); @@ -121,7 +119,7 @@ it("should not render without member", () => { const TEST_CASES: { rtcUsers: { userId: string; deviceId: string }[]; - livekitParticipantIdentities: (string | { id: string; isLocal?: boolean })[]; + livekitParticipantIdentities: string[]; expectedAudioTracks: number; }[] = [ { @@ -130,27 +128,9 @@ const TEST_CASES: { { userId: "@alice", deviceId: "DEV1" }, { userId: "@bob", deviceId: "DEV0" }, ], - livekitParticipantIdentities: [ - { id: "@alice:DEV0" }, - "@bob:DEV0", - "@alice:DEV1", - ], + livekitParticipantIdentities: ["@alice:DEV0", "@bob:DEV0", "@alice:DEV1"], expectedAudioTracks: 3, }, - // Alice DEV0 is local participant, should not render - { - rtcUsers: [ - { userId: "@alice", deviceId: "DEV0" }, - { userId: "@alice", deviceId: "DEV1" }, - { userId: "@bob", deviceId: "DEV0" }, - ], - livekitParticipantIdentities: [ - { id: "@alice:DEV0", isLocal: true }, - "@bob:DEV0", - "@alice:DEV1", - ], - expectedAudioTracks: 2, - }, // Charlie is a rtc member but not in livekit { rtcUsers: [ @@ -158,7 +138,7 @@ const TEST_CASES: { { userId: "@bob", deviceId: "DEV0" }, { userId: "@charlie", deviceId: "DEV0" }, ], - livekitParticipantIdentities: ["@alice:DEV0", { id: "@bob:DEV0" }], + livekitParticipantIdentities: ["@alice:DEV0", "@bob:DEV0"], expectedAudioTracks: 2, }, // Charlie is in livekit but not rtc member