Restore LocalMembership tests
This commit is contained in:
@@ -5,39 +5,21 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|||||||
Please see LICENSE in the repository root for full details.
|
Please see LICENSE in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { type MatrixRTCSession } from "matrix-js-sdk/lib/matrixrtc";
|
||||||
type LivekitTransport,
|
|
||||||
type MatrixRTCSession,
|
|
||||||
} from "matrix-js-sdk/lib/matrixrtc";
|
|
||||||
import { expect, test, vi } from "vitest";
|
import { expect, test, vi } from "vitest";
|
||||||
import { AutoDiscovery } from "matrix-js-sdk/lib/autodiscovery";
|
import { AutoDiscovery } from "matrix-js-sdk/lib/autodiscovery";
|
||||||
import EventEmitter from "events";
|
import EventEmitter from "events";
|
||||||
|
|
||||||
import { MatrixRTCMode } from "../../../settings/settings";
|
import { MatrixRTCMode } from "../../../settings/settings";
|
||||||
import { mockConfig } from "../../../utils/test";
|
import { mockConfig } from "../../../utils/test";
|
||||||
import * as LocalMembership from "./LocalMembership";
|
import { enterRTCSession } from "./LocalMembership";
|
||||||
|
|
||||||
// Read private function so we do not have to make it public
|
|
||||||
const enterRTCSession = (
|
|
||||||
LocalMembership as unknown as {
|
|
||||||
enterRTCSession: (
|
|
||||||
rtcSession: MatrixRTCSession,
|
|
||||||
transport: LivekitTransport,
|
|
||||||
{
|
|
||||||
encryptMedia,
|
|
||||||
matrixRTCMode,
|
|
||||||
}: { encryptMedia: boolean; matrixRTCMode: MatrixRTCMode },
|
|
||||||
) => Promise<void>;
|
|
||||||
}
|
|
||||||
).enterRTCSession;
|
|
||||||
|
|
||||||
const MATRIX_RTC_MODE = MatrixRTCMode.Legacy;
|
const MATRIX_RTC_MODE = MatrixRTCMode.Legacy;
|
||||||
const getUrlParams = vi.hoisted(() => vi.fn(() => ({})));
|
const getUrlParams = vi.hoisted(() => vi.fn(() => ({})));
|
||||||
vi.mock("./UrlParams", () => ({ getUrlParams }));
|
vi.mock("../../../UrlParams", () => ({ getUrlParams }));
|
||||||
|
|
||||||
const actualWidget = await vi.hoisted(async () => vi.importActual("./widget"));
|
vi.mock("../../../widget", async (importOriginal) => ({
|
||||||
vi.mock("./widget", () => ({
|
...(await importOriginal()),
|
||||||
...actualWidget,
|
|
||||||
widget: {
|
widget: {
|
||||||
api: {
|
api: {
|
||||||
setAlwaysOnScreen: (): void => {},
|
setAlwaysOnScreen: (): void => {},
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import { ClientEvent, SyncState, type Room as MatrixRoom } from "matrix-js-sdk";
|
|||||||
import {
|
import {
|
||||||
BehaviorSubject,
|
BehaviorSubject,
|
||||||
combineLatest,
|
combineLatest,
|
||||||
distinctUntilChanged,
|
|
||||||
fromEvent,
|
fromEvent,
|
||||||
map,
|
map,
|
||||||
type Observable,
|
type Observable,
|
||||||
@@ -553,7 +552,8 @@ interface EnterRTCSessionOptions {
|
|||||||
* @param options
|
* @param options
|
||||||
* @throws If the widget could not send ElementWidgetActions.JoinCall action.
|
* @throws If the widget could not send ElementWidgetActions.JoinCall action.
|
||||||
*/
|
*/
|
||||||
async function enterRTCSession(
|
// Exported for unit testing
|
||||||
|
export async function enterRTCSession(
|
||||||
rtcSession: MatrixRTCSession,
|
rtcSession: MatrixRTCSession,
|
||||||
transport: LivekitTransport,
|
transport: LivekitTransport,
|
||||||
{ encryptMedia, matrixRTCMode }: EnterRTCSessionOptions,
|
{ encryptMedia, matrixRTCMode }: EnterRTCSessionOptions,
|
||||||
|
|||||||
Reference in New Issue
Block a user