mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-29 21:15:19 +00:00
add test for multi device auto leave
Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
@@ -75,6 +75,7 @@ import {
|
|||||||
local,
|
local,
|
||||||
localId,
|
localId,
|
||||||
localRtcMember,
|
localRtcMember,
|
||||||
|
localRtcMemberDevice2,
|
||||||
} from "../utils/test-fixtures";
|
} from "../utils/test-fixtures";
|
||||||
import { ObservableScope } from "./ObservableScope";
|
import { ObservableScope } from "./ObservableScope";
|
||||||
import { MediaDevices } from "./MediaDevices";
|
import { MediaDevices } from "./MediaDevices";
|
||||||
@@ -1138,7 +1139,7 @@ test("autoLeaveWhenOthersLeft$ emits only when autoLeaveWhenOthersLeft option is
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("autoLeaveWhenOthersLeft$ never emits autoLeaveWhenOthersLeft option is enabled but noone is there", () => {
|
test("autoLeaveWhenOthersLeft$ never emits autoLeaveWhenOthersLeft option is enabled but no-one is there", () => {
|
||||||
withTestScheduler(({ hot, expectObservable, scope }) => {
|
withTestScheduler(({ hot, expectObservable, scope }) => {
|
||||||
withCallViewModel(
|
withCallViewModel(
|
||||||
scope.behavior(nooneEverThere$(hot), []),
|
scope.behavior(nooneEverThere$(hot), []),
|
||||||
@@ -1147,9 +1148,7 @@ test("autoLeaveWhenOthersLeft$ never emits autoLeaveWhenOthersLeft option is ena
|
|||||||
new Map(),
|
new Map(),
|
||||||
mockMediaDevices({}),
|
mockMediaDevices({}),
|
||||||
(vm) => {
|
(vm) => {
|
||||||
expectObservable(vm.autoLeaveWhenOthersLeft$).toBe(
|
expectObservable(vm.autoLeaveWhenOthersLeft$).toBe("-------");
|
||||||
"-------", // false initially, then at frame 6: true then false emissions in same frame
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
autoLeaveWhenOthersLeft: true,
|
autoLeaveWhenOthersLeft: true,
|
||||||
@@ -1159,7 +1158,7 @@ test("autoLeaveWhenOthersLeft$ never emits autoLeaveWhenOthersLeft option is ena
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("autoLeaveWhenOthersLeft$ emits when autoLeaveWhenOthersLeft option is enabled and all others left", () => {
|
test("autoLeaveWhenOthersLeft$ doesn't emit when autoLeaveWhenOthersLeft option is disabled and all others left", () => {
|
||||||
withTestScheduler(({ hot, expectObservable, scope }) => {
|
withTestScheduler(({ hot, expectObservable, scope }) => {
|
||||||
withCallViewModel(
|
withCallViewModel(
|
||||||
scope.behavior(participantJoinLeave$(hot), []),
|
scope.behavior(participantJoinLeave$(hot), []),
|
||||||
@@ -1170,6 +1169,47 @@ test("autoLeaveWhenOthersLeft$ emits when autoLeaveWhenOthersLeft option is enab
|
|||||||
(vm) => {
|
(vm) => {
|
||||||
expectObservable(vm.autoLeaveWhenOthersLeft$).toBe("-------");
|
expectObservable(vm.autoLeaveWhenOthersLeft$).toBe("-------");
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
autoLeaveWhenOthersLeft: false,
|
||||||
|
encryptionSystem: { kind: E2eeType.PER_PARTICIPANT },
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test("autoLeaveWhenOthersLeft$ doesn't emits when autoLeaveWhenOthersLeft option is enabled and all others left", () => {
|
||||||
|
withTestScheduler(({ hot, expectObservable, scope }) => {
|
||||||
|
withCallViewModel(
|
||||||
|
scope.behavior(
|
||||||
|
hot("a-b-c-d", {
|
||||||
|
a: [], // Alone
|
||||||
|
b: [aliceParticipant], // Alice joins
|
||||||
|
c: [aliceParticipant],
|
||||||
|
d: [], // Local joins with a second device
|
||||||
|
}),
|
||||||
|
[], //Alice leaves
|
||||||
|
),
|
||||||
|
scope.behavior(
|
||||||
|
hot("a-b-c-d", {
|
||||||
|
a: [localRtcMember], // Start empty
|
||||||
|
b: [localRtcMember, aliceRtcMember], // Alice joins
|
||||||
|
c: [localRtcMember, aliceRtcMember, localRtcMemberDevice2], // Alice still there
|
||||||
|
d: [localRtcMember, localRtcMemberDevice2], // The second Alice leaves
|
||||||
|
}),
|
||||||
|
[],
|
||||||
|
),
|
||||||
|
of(ConnectionState.Connected),
|
||||||
|
new Map(),
|
||||||
|
mockMediaDevices({}),
|
||||||
|
(vm) => {
|
||||||
|
expectObservable(vm.autoLeaveWhenOthersLeft$).toBe("------e", {
|
||||||
|
e: undefined,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
{
|
||||||
|
autoLeaveWhenOthersLeft: true,
|
||||||
|
encryptionSystem: { kind: E2eeType.PER_PARTICIPANT },
|
||||||
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,7 +12,11 @@ import {
|
|||||||
mockLocalParticipant,
|
mockLocalParticipant,
|
||||||
} from "./test";
|
} from "./test";
|
||||||
|
|
||||||
export const localRtcMember = mockRtcMembership("@carol:example.org", "CCCC");
|
export const localRtcMember = mockRtcMembership("@carol:example.org", "1111");
|
||||||
|
export const localRtcMemberDevice2 = mockRtcMembership(
|
||||||
|
"@carol:example.org",
|
||||||
|
"2222",
|
||||||
|
);
|
||||||
export const local = mockMatrixRoomMember(localRtcMember);
|
export const local = mockMatrixRoomMember(localRtcMember);
|
||||||
export const localParticipant = mockLocalParticipant({ identity: "" });
|
export const localParticipant = mockLocalParticipant({ identity: "" });
|
||||||
export const localId = `${local.userId}:${localRtcMember.deviceId}`;
|
export const localId = `${local.userId}:${localRtcMember.deviceId}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user