Skip to content

Commit 53565dd

Browse files
committed
Test that participants adjust order when screen size changes
1 parent 00056a7 commit 53565dd

File tree

1 file changed

+56
-6
lines changed

1 file changed

+56
-6
lines changed

src/state/CallViewModel.test.ts

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -376,16 +376,16 @@ test("screen sharing activates spotlight layout", () => {
376376

377377
test("participants stay in the same order unless to appear/disappear", () => {
378378
withTestScheduler(({ hot, schedule, expectObservable }) => {
379-
const modeInputMarbles = " a";
379+
const visibilityInputMarbles = "a";
380380
// First Bob speaks, then Dave, then Alice
381-
const aSpeakingInputMarbles = "n- 1998ms - 1999ms y";
382-
const bSpeakingInputMarbles = "ny 1998ms n 1999ms -";
383-
const dSpeakingInputMarbles = "n- 1998ms y 1999ms n";
381+
const aSpeakingInputMarbles = " n- 1998ms - 1999ms y";
382+
const bSpeakingInputMarbles = " ny 1998ms n 1999ms -";
383+
const dSpeakingInputMarbles = " n- 1998ms y 1999ms n";
384384
// Nothing should change when Bob speaks, because Bob is already on screen.
385385
// When Dave speaks he should switch with Alice because she's the one who
386386
// hasn't spoken at all. Then when Alice speaks, she should return to her
387387
// place at the top.
388-
const expectedLayoutMarbles = "a 1999ms b 1999ms a 57999ms c 1999ms a";
388+
const expectedLayoutMarbles = " a 1999ms b 1999ms a 57999ms c 1999ms a";
389389

390390
withCallViewModel(
391391
of([aliceParticipant, bobParticipant, daveParticipant]),
@@ -397,7 +397,7 @@ test("participants stay in the same order unless to appear/disappear", () => {
397397
[daveParticipant, hot(dSpeakingInputMarbles, { y: true, n: false })],
398398
]),
399399
(vm) => {
400-
schedule(modeInputMarbles, {
400+
schedule(visibilityInputMarbles, {
401401
a: () => {
402402
// We imagine that only three tiles (the first three) will be visible
403403
// on screen at a time
@@ -432,6 +432,56 @@ test("participants stay in the same order unless to appear/disappear", () => {
432432
});
433433
});
434434

435+
test("participants adjust order when space becomes constrained", () => {
436+
withTestScheduler(({ hot, schedule, expectObservable }) => {
437+
// Start with all tiles on screen then shrink to 3
438+
const visibilityInputMarbles = "a-b";
439+
// Bob and Dave speak
440+
const bSpeakingInputMarbles = " ny";
441+
const dSpeakingInputMarbles = " ny";
442+
// Nothing should change when Bob or Dave initially speak, because they are
443+
// on screen. When the screen becomes smaller Alice should move off screen
444+
// to make way for the speakers (specifically, she should swap with Dave).
445+
const expectedLayoutMarbles = " a-b";
446+
447+
withCallViewModel(
448+
of([aliceParticipant, bobParticipant, daveParticipant]),
449+
of([aliceRtcMember, bobRtcMember, daveRtcMember]),
450+
of(ConnectionState.Connected),
451+
new Map([
452+
[bobParticipant, hot(bSpeakingInputMarbles, { y: true, n: false })],
453+
[daveParticipant, hot(dSpeakingInputMarbles, { y: true, n: false })],
454+
]),
455+
(vm) => {
456+
let setVisibleTiles: ((value: number) => void) | null = null;
457+
vm.layout.subscribe((layout) => {
458+
if (layout.type === "grid") setVisibleTiles = layout.setVisibleTiles;
459+
});
460+
schedule(visibilityInputMarbles, {
461+
a: () => setVisibleTiles!(Infinity),
462+
b: () => setVisibleTiles!(3),
463+
});
464+
465+
expectObservable(summarizeLayout(vm.layout)).toBe(
466+
expectedLayoutMarbles,
467+
{
468+
a: {
469+
type: "grid",
470+
spotlight: undefined,
471+
grid: ["local:0", `${aliceId}:0`, `${bobId}:0`, `${daveId}:0`],
472+
},
473+
b: {
474+
type: "grid",
475+
spotlight: undefined,
476+
grid: ["local:0", `${daveId}:0`, `${bobId}:0`, `${aliceId}:0`],
477+
},
478+
},
479+
);
480+
},
481+
);
482+
});
483+
});
484+
435485
test("spotlight speakers swap places", () => {
436486
withTestScheduler(({ hot, schedule, expectObservable }) => {
437487
// Go immediately into spotlight mode for the test

0 commit comments

Comments
 (0)