mirror of
https://github.com/vector-im/element-call.git
synced 2026-03-28 06:50:26 +00:00
Merge branch 'livekit' into robin/switch-camera-tile
This commit is contained in:
@@ -17,6 +17,7 @@ export enum ErrorCode {
|
||||
INSUFFICIENT_CAPACITY_ERROR = "INSUFFICIENT_CAPACITY_ERROR",
|
||||
E2EE_NOT_SUPPORTED = "E2EE_NOT_SUPPORTED",
|
||||
OPEN_ID_ERROR = "OPEN_ID_ERROR",
|
||||
SFU_ERROR = "SFU_ERROR",
|
||||
UNKNOWN_ERROR = "UNKNOWN_ERROR",
|
||||
}
|
||||
|
||||
@@ -129,3 +130,14 @@ export class InsufficientCapacityError extends ElementCallError {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class SFURoomCreationRestrictedError extends ElementCallError {
|
||||
public constructor() {
|
||||
super(
|
||||
t("error.room_creation_restricted"),
|
||||
ErrorCode.SFU_ERROR,
|
||||
ErrorCategory.CONFIGURATION_ISSUE,
|
||||
t("error.room_creation_restricted_description"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,11 @@ import {
|
||||
mockLocalParticipant,
|
||||
} 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 localParticipant = mockLocalParticipant({ identity: "" });
|
||||
export const localId = `${local.userId}:${localRtcMember.deviceId}`;
|
||||
|
||||
@@ -139,7 +139,7 @@ export function getBasicCallViewModelEnvironment(
|
||||
liveKitRoom,
|
||||
mockMediaDevices({}),
|
||||
{
|
||||
kind: E2eeType.PER_PARTICIPANT,
|
||||
encryptionSystem: { kind: E2eeType.PER_PARTICIPANT },
|
||||
},
|
||||
of(ConnectionState.Connected),
|
||||
handRaisedSubject$,
|
||||
|
||||
@@ -47,6 +47,8 @@ import {
|
||||
} from "../config/ConfigOptions";
|
||||
import { Config } from "../config/Config";
|
||||
import { type MediaDevices } from "../state/MediaDevices";
|
||||
import { type Behavior, constant } from "../state/Behavior";
|
||||
import { ObservableScope } from "../state/ObservableScope";
|
||||
|
||||
export function withFakeTimers(continuation: () => void): void {
|
||||
vi.useFakeTimers();
|
||||
@@ -67,6 +69,12 @@ export interface OurRunHelpers extends RunHelpers {
|
||||
* diagram.
|
||||
*/
|
||||
schedule: (marbles: string, actions: Record<string, () => void>) => void;
|
||||
behavior<T = string>(
|
||||
marbles: string,
|
||||
values?: { [marble: string]: T },
|
||||
error?: unknown,
|
||||
): Behavior<T>;
|
||||
scope: ObservableScope;
|
||||
}
|
||||
|
||||
interface TestRunnerGlobal {
|
||||
@@ -82,12 +90,14 @@ export function withTestScheduler(
|
||||
const scheduler = new TestScheduler((actual, expected) => {
|
||||
expect(actual).deep.equals(expected);
|
||||
});
|
||||
const scope = new ObservableScope();
|
||||
// we set the test scheduler as a global so that you can watch it in a debugger
|
||||
// and get the frame number. e.g. `rxjsTestScheduler?.now()`
|
||||
(global as unknown as TestRunnerGlobal).rxjsTestScheduler = scheduler;
|
||||
scheduler.run((helpers) =>
|
||||
continuation({
|
||||
...helpers,
|
||||
scope,
|
||||
schedule(marbles, actions) {
|
||||
const actionsObservable$ = helpers
|
||||
.cold(marbles)
|
||||
@@ -98,8 +108,36 @@ export function withTestScheduler(
|
||||
// Run the actions and verify that none of them error
|
||||
helpers.expectObservable(actionsObservable$).toBe(marbles, results);
|
||||
},
|
||||
behavior<T>(
|
||||
marbles: string,
|
||||
values?: { [marble: string]: T },
|
||||
error?: unknown,
|
||||
) {
|
||||
// Generate a hot Observable with helpers.hot and use it as a Behavior.
|
||||
// To do this, we need to ensure that the initial value emits
|
||||
// synchronously upon subscription. The issue is that helpers.hot emits
|
||||
// frame 0 of the marble diagram *asynchronously*, only once we return
|
||||
// from the continuation, so we need to splice out the initial marble
|
||||
// and turn it into a proper initial value.
|
||||
const initialMarbleIndex = marbles.search(/[^ ]/);
|
||||
if (initialMarbleIndex === -1)
|
||||
throw new Error("Behavior must have an initial value");
|
||||
const initialMarble = marbles[initialMarbleIndex];
|
||||
const initialValue =
|
||||
values === undefined ? (initialMarble as T) : values[initialMarble];
|
||||
// The remainder of the marble diagram should start on frame 1
|
||||
return scope.behavior(
|
||||
helpers.hot(
|
||||
`-${marbles.slice(initialMarbleIndex + 1)}`,
|
||||
values,
|
||||
error,
|
||||
),
|
||||
initialValue,
|
||||
);
|
||||
},
|
||||
}),
|
||||
);
|
||||
scope.end();
|
||||
}
|
||||
|
||||
interface EmitterMock<T> {
|
||||
@@ -212,15 +250,15 @@ export async function withLocalMedia(
|
||||
const vm = new LocalUserMediaViewModel(
|
||||
"local",
|
||||
mockMatrixRoomMember(localRtcMember, roomMember),
|
||||
of(localParticipant),
|
||||
constant(localParticipant),
|
||||
{
|
||||
kind: E2eeType.PER_PARTICIPANT,
|
||||
},
|
||||
mockLivekitRoom({ localParticipant }),
|
||||
mediaDevices,
|
||||
of(roomMember.rawDisplayName ?? "nodisplayname"),
|
||||
of(null),
|
||||
of(null),
|
||||
constant(roomMember.rawDisplayName ?? "nodisplayname"),
|
||||
constant(null),
|
||||
constant(null),
|
||||
);
|
||||
try {
|
||||
await continuation(vm);
|
||||
@@ -257,9 +295,9 @@ export async function withRemoteMedia(
|
||||
kind: E2eeType.PER_PARTICIPANT,
|
||||
},
|
||||
mockLivekitRoom({}, { remoteParticipants$: of([remoteParticipant]) }),
|
||||
of(roomMember.rawDisplayName ?? "nodisplayname"),
|
||||
of(null),
|
||||
of(null),
|
||||
constant(roomMember.rawDisplayName ?? "nodisplayname"),
|
||||
constant(null),
|
||||
constant(null),
|
||||
);
|
||||
try {
|
||||
await continuation(vm);
|
||||
@@ -301,7 +339,7 @@ export class MockRTCSession extends TypedEventEmitter<
|
||||
}
|
||||
|
||||
public withMemberships(
|
||||
rtcMembers$: Observable<Partial<CallMembership>[]>,
|
||||
rtcMembers$: Behavior<Partial<CallMembership>[]>,
|
||||
): MockRTCSession {
|
||||
rtcMembers$.subscribe((m) => {
|
||||
const old = this.memberships;
|
||||
|
||||
Reference in New Issue
Block a user