Remove local participant case (now enforced by types) from audio tests
This commit is contained in:
@@ -65,27 +65,25 @@ let tracks: TrackReference[] = [];
|
|||||||
|
|
||||||
function renderTestComponent(
|
function renderTestComponent(
|
||||||
rtcMembers: { userId: string; deviceId: string }[],
|
rtcMembers: { userId: string; deviceId: string }[],
|
||||||
livekitParticipantIdentities: ({ id: string; isLocal?: boolean } | string)[],
|
livekitParticipantIdentities: string[],
|
||||||
): RenderResult {
|
): RenderResult {
|
||||||
const liveKitParticipants = livekitParticipantIdentities.map((p) => {
|
const liveKitParticipants = livekitParticipantIdentities.map(
|
||||||
const identity = typeof p === "string" ? p : p.id;
|
(identity) =>
|
||||||
const isLocal = typeof p === "string" ? false : (p.isLocal ?? false);
|
({
|
||||||
return vi.mocked<RemoteParticipant>({
|
identity,
|
||||||
identity,
|
}) as unknown as RemoteParticipant,
|
||||||
isLocal,
|
);
|
||||||
} as unknown as RemoteParticipant);
|
|
||||||
});
|
|
||||||
const participants = rtcMembers.flatMap(({ userId, deviceId }) => {
|
const participants = rtcMembers.flatMap(({ userId, deviceId }) => {
|
||||||
const p = liveKitParticipants.find(
|
const p = liveKitParticipants.find(
|
||||||
(p) => p.identity === `${userId}:${deviceId}`,
|
(p) => p.identity === `${userId}:${deviceId}`,
|
||||||
);
|
);
|
||||||
return p === undefined ? [] : [p];
|
return p === undefined ? [] : [p];
|
||||||
});
|
});
|
||||||
const livekitRoom = vi.mocked<Room>({
|
const livekitRoom = {
|
||||||
remoteParticipants: new Map<string, Participant>(
|
remoteParticipants: new Map<string, Participant>(
|
||||||
liveKitParticipants.map((p) => [p.identity, p]),
|
liveKitParticipants.map((p) => [p.identity, p]),
|
||||||
),
|
),
|
||||||
} as unknown as Room);
|
} as unknown as Room;
|
||||||
|
|
||||||
tracks = participants.map((p) => mockTrack(p));
|
tracks = participants.map((p) => mockTrack(p));
|
||||||
|
|
||||||
@@ -121,7 +119,7 @@ it("should not render without member", () => {
|
|||||||
|
|
||||||
const TEST_CASES: {
|
const TEST_CASES: {
|
||||||
rtcUsers: { userId: string; deviceId: string }[];
|
rtcUsers: { userId: string; deviceId: string }[];
|
||||||
livekitParticipantIdentities: (string | { id: string; isLocal?: boolean })[];
|
livekitParticipantIdentities: string[];
|
||||||
expectedAudioTracks: number;
|
expectedAudioTracks: number;
|
||||||
}[] = [
|
}[] = [
|
||||||
{
|
{
|
||||||
@@ -130,27 +128,9 @@ const TEST_CASES: {
|
|||||||
{ userId: "@alice", deviceId: "DEV1" },
|
{ userId: "@alice", deviceId: "DEV1" },
|
||||||
{ userId: "@bob", deviceId: "DEV0" },
|
{ userId: "@bob", deviceId: "DEV0" },
|
||||||
],
|
],
|
||||||
livekitParticipantIdentities: [
|
livekitParticipantIdentities: ["@alice:DEV0", "@bob:DEV0", "@alice:DEV1"],
|
||||||
{ id: "@alice:DEV0" },
|
|
||||||
"@bob:DEV0",
|
|
||||||
"@alice:DEV1",
|
|
||||||
],
|
|
||||||
expectedAudioTracks: 3,
|
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
|
// Charlie is a rtc member but not in livekit
|
||||||
{
|
{
|
||||||
rtcUsers: [
|
rtcUsers: [
|
||||||
@@ -158,7 +138,7 @@ const TEST_CASES: {
|
|||||||
{ userId: "@bob", deviceId: "DEV0" },
|
{ userId: "@bob", deviceId: "DEV0" },
|
||||||
{ userId: "@charlie", deviceId: "DEV0" },
|
{ userId: "@charlie", deviceId: "DEV0" },
|
||||||
],
|
],
|
||||||
livekitParticipantIdentities: ["@alice:DEV0", { id: "@bob:DEV0" }],
|
livekitParticipantIdentities: ["@alice:DEV0", "@bob:DEV0"],
|
||||||
expectedAudioTracks: 2,
|
expectedAudioTracks: 2,
|
||||||
},
|
},
|
||||||
// Charlie is in livekit but not rtc member
|
// Charlie is in livekit but not rtc member
|
||||||
|
|||||||
Reference in New Issue
Block a user