Restore LocalMembership tests

This commit is contained in:
Robin
2025-11-14 10:48:24 -05:00
parent 8ce8067956
commit da85e74596
2 changed files with 7 additions and 25 deletions

View File

@@ -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.
*/
import {
type LivekitTransport,
type MatrixRTCSession,
} from "matrix-js-sdk/lib/matrixrtc";
import { type MatrixRTCSession } from "matrix-js-sdk/lib/matrixrtc";
import { expect, test, vi } from "vitest";
import { AutoDiscovery } from "matrix-js-sdk/lib/autodiscovery";
import EventEmitter from "events";
import { MatrixRTCMode } from "../../../settings/settings";
import { mockConfig } from "../../../utils/test";
import * as LocalMembership 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;
import { enterRTCSession } from "./LocalMembership";
const MATRIX_RTC_MODE = MatrixRTCMode.Legacy;
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", () => ({
...actualWidget,
vi.mock("../../../widget", async (importOriginal) => ({
...(await importOriginal()),
widget: {
api: {
setAlwaysOnScreen: (): void => {},

View File

@@ -22,7 +22,6 @@ import { ClientEvent, SyncState, type Room as MatrixRoom } from "matrix-js-sdk";
import {
BehaviorSubject,
combineLatest,
distinctUntilChanged,
fromEvent,
map,
type Observable,
@@ -553,7 +552,8 @@ interface EnterRTCSessionOptions {
* @param options
* @throws If the widget could not send ElementWidgetActions.JoinCall action.
*/
async function enterRTCSession(
// Exported for unit testing
export async function enterRTCSession(
rtcSession: MatrixRTCSession,
transport: LivekitTransport,
{ encryptMedia, matrixRTCMode }: EnterRTCSessionOptions,