Fix RTC members in tes

This commit is contained in:
Hugh Nimmo-Smith 2024-11-06 17:05:29 +00:00
parent 462f0349d5
commit efe9c9b8fe

View File

@ -49,21 +49,24 @@ import { MockRoom, MockRTCSession } from "../useReactions.test";
vi.mock("@livekit/components-core"); vi.mock("@livekit/components-core");
const local = mockRoomMember({ userId: "@local:example.org" });
const alice = mockRoomMember({ userId: "@alice:example.org" }); const alice = mockRoomMember({ userId: "@alice:example.org" });
const bob = mockRoomMember({ userId: "@bob:example.org" }); const bob = mockRoomMember({ userId: "@bob:example.org" });
const carol = mockRoomMember({ userId: "@carol:example.org" }); const carol = mockRoomMember({ userId: "@carol:example.org" });
const dave = mockRoomMember({ userId: "@dave:example.org" }); const dave = mockRoomMember({ userId: "@dave:example.org" });
const localDev = "LLLL";
const aliceDev = "AAAA"; const aliceDev = "AAAA";
const bobDev = "BBBB"; const bobDev = "BBBB";
const carolDev = "CCCC"; const carolDev = "CCCC";
const daveDev = "DDDD"; const daveDev = "DDDD";
const localId = `${local.userId}:${localDev}`;
const aliceId = `${alice.userId}:${aliceDev}`; const aliceId = `${alice.userId}:${aliceDev}`;
const bobId = `${bob.userId}:${bobDev}`; const bobId = `${bob.userId}:${bobDev}`;
const carolId = `${carol.userId}:${carolDev}`; const carolId = `${carol.userId}:${carolDev}`;
const daveId = `${dave.userId}:${daveDev}`; const daveId = `${dave.userId}:${daveDev}`;
const localParticipant = mockLocalParticipant({ identity: "" }); const localParticipant = mockLocalParticipant({ identity: localId });
const aliceParticipant = mockRemoteParticipant({ identity: aliceId }); const aliceParticipant = mockRemoteParticipant({ identity: aliceId });
const aliceSharingScreen = mockRemoteParticipant({ const aliceSharingScreen = mockRemoteParticipant({
@ -79,6 +82,7 @@ const daveParticipant = mockRemoteParticipant({ identity: daveId });
const members = new Map([alice, bob, carol, dave].map((p) => [p.userId, p])); const members = new Map([alice, bob, carol, dave].map((p) => [p.userId, p]));
const localRtcMember = mockMembership(local, localDev);
const aliceRtcMember = mockMembership(alice, aliceDev); const aliceRtcMember = mockMembership(alice, aliceDev);
const bobRtcMember = mockMembership(bob, bobDev); const bobRtcMember = mockMembership(bob, bobDev);
// const carolRtcMember = mockMembership(carol, carolDev); // const carolRtcMember = mockMembership(carol, carolDev);
@ -268,7 +272,7 @@ test("participants are retained during a focus switch", () => {
a: [aliceParticipant, bobParticipant], a: [aliceParticipant, bobParticipant],
b: [], b: [],
}), }),
of([aliceRtcMember, bobRtcMember]), of([localRtcMember, aliceRtcMember, bobRtcMember]),
cold(connectionMarbles, { cold(connectionMarbles, {
c: ConnectionState.Connected, c: ConnectionState.Connected,
s: ECAddonConnectionState.ECSwitchingFocus, s: ECAddonConnectionState.ECSwitchingFocus,
@ -279,7 +283,7 @@ test("participants are retained during a focus switch", () => {
a: { a: {
type: "grid", type: "grid",
spotlight: undefined, spotlight: undefined,
grid: ["local:0", `${aliceId}:0`, `${bobId}:0`], grid: [`${localId}:0`, `${aliceId}:0`, `${bobId}:0`],
}, },
}); });
}, },
@ -307,7 +311,7 @@ test("screen sharing activates spotlight layout", () => {
c: [aliceSharingScreen, bobSharingScreen], c: [aliceSharingScreen, bobSharingScreen],
d: [aliceParticipant, bobSharingScreen], d: [aliceParticipant, bobSharingScreen],
}), }),
of([aliceRtcMember, bobRtcMember]), of([localRtcMember, aliceRtcMember, bobRtcMember]),
of(ConnectionState.Connected), of(ConnectionState.Connected),
new Map(), new Map(),
(vm) => { (vm) => {
@ -320,37 +324,37 @@ test("screen sharing activates spotlight layout", () => {
a: { a: {
type: "grid", type: "grid",
spotlight: undefined, spotlight: undefined,
grid: ["local:0", `${aliceId}:0`, `${bobId}:0`], grid: [`${localId}:0`, `${aliceId}:0`, `${bobId}:0`],
}, },
b: { b: {
type: "spotlight-landscape", type: "spotlight-landscape",
spotlight: [`${aliceId}:0:screen-share`], spotlight: [`${aliceId}:0:screen-share`],
grid: ["local:0", `${aliceId}:0`, `${bobId}:0`], grid: [`${localId}:0`, `${aliceId}:0`, `${bobId}:0`],
}, },
c: { c: {
type: "spotlight-landscape", type: "spotlight-landscape",
spotlight: [`${aliceId}:0:screen-share`, `${bobId}:0:screen-share`], spotlight: [`${aliceId}:0:screen-share`, `${bobId}:0:screen-share`],
grid: ["local:0", `${aliceId}:0`, `${bobId}:0`], grid: [`${localId}:0`, `${aliceId}:0`, `${bobId}:0`],
}, },
d: { d: {
type: "spotlight-landscape", type: "spotlight-landscape",
spotlight: [`${bobId}:0:screen-share`], spotlight: [`${bobId}:0:screen-share`],
grid: ["local:0", `${aliceId}:0`, `${bobId}:0`], grid: [`${localId}:0`, `${aliceId}:0`, `${bobId}:0`],
}, },
e: { e: {
type: "spotlight-landscape", type: "spotlight-landscape",
spotlight: [`${aliceId}:0`], spotlight: [`${aliceId}:0`],
grid: ["local:0", `${bobId}:0`], grid: [`${localId}:0`, `${bobId}:0`],
}, },
f: { f: {
type: "spotlight-landscape", type: "spotlight-landscape",
spotlight: [`${aliceId}:0:screen-share`], spotlight: [`${aliceId}:0:screen-share`],
grid: ["local:0", `${bobId}:0`, `${aliceId}:0`], grid: [`${localId}:0`, `${bobId}:0`, `${aliceId}:0`],
}, },
g: { g: {
type: "grid", type: "grid",
spotlight: undefined, spotlight: undefined,
grid: ["local:0", `${bobId}:0`, `${aliceId}:0`], grid: [`${localId}:0`, `${bobId}:0`, `${aliceId}:0`],
}, },
}); });
expectObservable(vm.showSpeakingIndicators).toBe(showSpeakingMarbles, { expectObservable(vm.showSpeakingIndicators).toBe(showSpeakingMarbles, {
@ -377,7 +381,7 @@ test("participants stay in the same order unless to appear/disappear", () => {
withCallViewModel( withCallViewModel(
of([aliceParticipant, bobParticipant, daveParticipant]), of([aliceParticipant, bobParticipant, daveParticipant]),
of([aliceRtcMember, bobRtcMember, daveRtcMember]), of([localRtcMember, aliceRtcMember, bobRtcMember, daveRtcMember]),
of(ConnectionState.Connected), of(ConnectionState.Connected),
new Map([ new Map([
[aliceParticipant, cold(aSpeakingMarbles, { y: true, n: false })], [aliceParticipant, cold(aSpeakingMarbles, { y: true, n: false })],
@ -402,17 +406,17 @@ test("participants stay in the same order unless to appear/disappear", () => {
a: { a: {
type: "grid", type: "grid",
spotlight: undefined, spotlight: undefined,
grid: ["local:0", `${aliceId}:0`, `${bobId}:0`, `${daveId}:0`], grid: [`${localId}:0`, `${aliceId}:0`, `${bobId}:0`, `${daveId}:0`],
}, },
b: { b: {
type: "grid", type: "grid",
spotlight: undefined, spotlight: undefined,
grid: ["local:0", `${daveId}:0`, `${bobId}:0`, `${aliceId}:0`], grid: [`${localId}:0`, `${daveId}:0`, `${bobId}:0`, `${aliceId}:0`],
}, },
c: { c: {
type: "grid", type: "grid",
spotlight: undefined, spotlight: undefined,
grid: ["local:0", `${aliceId}:0`, `${daveId}:0`, `${bobId}:0`], grid: [`${localId}:0`, `${aliceId}:0`, `${daveId}:0`, `${bobId}:0`],
}, },
}); });
}, },
@ -436,7 +440,7 @@ test("spotlight speakers swap places", () => {
withCallViewModel( withCallViewModel(
of([aliceParticipant, bobParticipant, daveParticipant]), of([aliceParticipant, bobParticipant, daveParticipant]),
of([aliceRtcMember, bobRtcMember, daveRtcMember]), of([localRtcMember, aliceRtcMember, bobRtcMember, daveRtcMember]),
of(ConnectionState.Connected), of(ConnectionState.Connected),
new Map([ new Map([
[aliceParticipant, cold(aSpeakingMarbles, { y: true, n: false })], [aliceParticipant, cold(aSpeakingMarbles, { y: true, n: false })],
@ -450,22 +454,22 @@ test("spotlight speakers swap places", () => {
a: { a: {
type: "spotlight-landscape", type: "spotlight-landscape",
spotlight: [`${aliceId}:0`], spotlight: [`${aliceId}:0`],
grid: ["local:0", `${bobId}:0`, `${daveId}:0`], grid: [`${localId}:0`, `${bobId}:0`, `${daveId}:0`],
}, },
b: { b: {
type: "spotlight-landscape", type: "spotlight-landscape",
spotlight: [`${bobId}:0`], spotlight: [`${bobId}:0`],
grid: ["local:0", `${aliceId}:0`, `${daveId}:0`], grid: [`${localId}:0`, `${aliceId}:0`, `${daveId}:0`],
}, },
c: { c: {
type: "spotlight-landscape", type: "spotlight-landscape",
spotlight: [`${daveId}:0`], spotlight: [`${daveId}:0`],
grid: ["local:0", `${aliceId}:0`, `${bobId}:0`], grid: [`${localId}:0`, `${aliceId}:0`, `${bobId}:0`],
}, },
d: { d: {
type: "spotlight-landscape", type: "spotlight-landscape",
spotlight: [`${aliceId}:0`], spotlight: [`${aliceId}:0`],
grid: ["local:0", `${daveId}:0`, `${bobId}:0`], grid: [`${localId}:0`, `${daveId}:0`, `${bobId}:0`],
}, },
}); });
}, },
@ -482,7 +486,7 @@ test("layout enters picture-in-picture mode when requested", () => {
withCallViewModel( withCallViewModel(
of([aliceParticipant, bobParticipant]), of([aliceParticipant, bobParticipant]),
of([aliceRtcMember, bobRtcMember]), of([localRtcMember, aliceRtcMember, bobRtcMember]),
of(ConnectionState.Connected), of(ConnectionState.Connected),
new Map(), new Map(),
(vm) => { (vm) => {
@ -495,7 +499,7 @@ test("layout enters picture-in-picture mode when requested", () => {
a: { a: {
type: "grid", type: "grid",
spotlight: undefined, spotlight: undefined,
grid: ["local:0", `${aliceId}:0`, `${bobId}:0`], grid: [`${localId}:0`, `${aliceId}:0`, `${bobId}:0`],
}, },
b: { b: {
type: "pip", type: "pip",
@ -520,7 +524,7 @@ test("spotlight remembers whether it's expanded", () => {
withCallViewModel( withCallViewModel(
of([aliceParticipant, bobParticipant]), of([aliceParticipant, bobParticipant]),
of([aliceRtcMember, bobRtcMember]), of([localRtcMember, aliceRtcMember, bobRtcMember]),
of(ConnectionState.Connected), of(ConnectionState.Connected),
new Map(), new Map(),
(vm) => { (vm) => {
@ -540,22 +544,22 @@ test("spotlight remembers whether it's expanded", () => {
a: { a: {
type: "spotlight-landscape", type: "spotlight-landscape",
spotlight: [`${aliceId}:0`], spotlight: [`${aliceId}:0`],
grid: ["local:0", `${bobId}:0`], grid: [`${localId}:0`, `${bobId}:0`],
}, },
b: { b: {
type: "spotlight-expanded", type: "spotlight-expanded",
spotlight: [`${aliceId}:0`], spotlight: [`${aliceId}:0`],
pip: "local:0", pip: `${localId}:0`,
}, },
c: { c: {
type: "grid", type: "grid",
spotlight: undefined, spotlight: undefined,
grid: ["local:0", `${aliceId}:0`, `${bobId}:0`], grid: [`${localId}:0`, `${aliceId}:0`, `${bobId}:0`],
}, },
d: { d: {
type: "grid", type: "grid",
spotlight: undefined, spotlight: undefined,
grid: ["local:0", `${bobId}:0`, `${aliceId}:0`], grid: [`${localId}:0`, `${bobId}:0`, `${aliceId}:0`],
}, },
}); });
}, },