mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-29 21:15:19 +00:00
Improve tests
This commit is contained in:
@@ -105,6 +105,20 @@ test("plays a sound when a user leaves", () => {
|
|||||||
expect(playSound).toBeCalledWith("left");
|
expect(playSound).toBeCalledWith("left");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("does not play a sound before the call is successful", () => {
|
||||||
|
const { vm, rtcMemberships$ } = getBasicCallViewModelEnvironment(
|
||||||
|
[local, alice],
|
||||||
|
[localRtcMember],
|
||||||
|
{ waitForCallPickup: true },
|
||||||
|
);
|
||||||
|
render(<CallEventAudioRenderer vm={vm} />);
|
||||||
|
|
||||||
|
act(() => {
|
||||||
|
rtcMemberships$.next([localRtcMember]);
|
||||||
|
});
|
||||||
|
expect(playSound).not.toBeCalledWith("left");
|
||||||
|
});
|
||||||
|
|
||||||
test("plays no sound when the participant list is more than the maximum size", () => {
|
test("plays no sound when the participant list is more than the maximum size", () => {
|
||||||
const mockRtcMemberships: CallMembership[] = [localRtcMember];
|
const mockRtcMemberships: CallMembership[] = [localRtcMember];
|
||||||
for (let i = 0; i < MAX_PARTICIPANT_COUNT_FOR_SOUND; i++) {
|
for (let i = 0; i < MAX_PARTICIPANT_COUNT_FOR_SOUND; i++) {
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import {
|
|||||||
concat,
|
concat,
|
||||||
distinctUntilChanged,
|
distinctUntilChanged,
|
||||||
endWith,
|
endWith,
|
||||||
every,
|
|
||||||
filter,
|
filter,
|
||||||
forkJoin,
|
forkJoin,
|
||||||
fromEvent,
|
fromEvent,
|
||||||
@@ -976,17 +975,12 @@ export class CallViewModel extends ViewModel {
|
|||||||
)
|
)
|
||||||
: constant(null);
|
: constant(null);
|
||||||
|
|
||||||
public readonly callWasSuccessful$ = this.callPickupState$.pipe(
|
|
||||||
every((x) => x !== "success" && x === null),
|
|
||||||
map((v) => !v),
|
|
||||||
);
|
|
||||||
|
|
||||||
public readonly leaveSoundEffect$ = combineLatest([
|
public readonly leaveSoundEffect$ = combineLatest([
|
||||||
this.callWasSuccessful$,
|
this.callPickupState$,
|
||||||
this.userMedia$,
|
this.userMedia$,
|
||||||
]).pipe(
|
]).pipe(
|
||||||
// Until the call is successful, do not play a leave sound.
|
// Until the call is successful, do not play a leave sound.
|
||||||
skipWhile(([c]) => c === false),
|
skipWhile(([c]) => c !== null && c !== "success"),
|
||||||
map(([, userMedia]) => userMedia),
|
map(([, userMedia]) => userMedia),
|
||||||
pairwise(),
|
pairwise(),
|
||||||
filter(
|
filter(
|
||||||
|
|||||||
@@ -22,7 +22,10 @@ import {
|
|||||||
} from "matrix-js-sdk";
|
} from "matrix-js-sdk";
|
||||||
|
|
||||||
import { E2eeType } from "../e2ee/e2eeType";
|
import { E2eeType } from "../e2ee/e2eeType";
|
||||||
import { CallViewModel } from "../state/CallViewModel";
|
import {
|
||||||
|
CallViewModel,
|
||||||
|
type CallViewModelOptions,
|
||||||
|
} from "../state/CallViewModel";
|
||||||
import {
|
import {
|
||||||
mockLivekitRoom,
|
mockLivekitRoom,
|
||||||
mockMatrixRoom,
|
mockMatrixRoom,
|
||||||
@@ -122,6 +125,7 @@ export function getBasicRTCSession(
|
|||||||
export function getBasicCallViewModelEnvironment(
|
export function getBasicCallViewModelEnvironment(
|
||||||
members: RoomMember[],
|
members: RoomMember[],
|
||||||
initialRtcMemberships: CallMembership[] = [localRtcMember, aliceRtcMember],
|
initialRtcMemberships: CallMembership[] = [localRtcMember, aliceRtcMember],
|
||||||
|
callViewModelOptions: Partial<CallViewModelOptions> = {},
|
||||||
): {
|
): {
|
||||||
vm: CallViewModel;
|
vm: CallViewModel;
|
||||||
rtcMemberships$: BehaviorSubject<CallMembership[]>;
|
rtcMemberships$: BehaviorSubject<CallMembership[]>;
|
||||||
@@ -148,6 +152,7 @@ export function getBasicCallViewModelEnvironment(
|
|||||||
mockMediaDevices({}),
|
mockMediaDevices({}),
|
||||||
{
|
{
|
||||||
encryptionSystem: { kind: E2eeType.PER_PARTICIPANT },
|
encryptionSystem: { kind: E2eeType.PER_PARTICIPANT },
|
||||||
|
...callViewModelOptions,
|
||||||
},
|
},
|
||||||
of(ConnectionState.Connected),
|
of(ConnectionState.Connected),
|
||||||
handRaisedSubject$,
|
handRaisedSubject$,
|
||||||
|
|||||||
Reference in New Issue
Block a user