mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-29 21:15:19 +00:00
* Move MatrixRTCMode enum from settings.ts to ConfigOptions.ts * Add matrix_rtc_mode config option * add matrix_rtc_mode to config.sample.json * Update src/settings/DeveloperSettingsTab.tsx Co-authored-by: Johannes Marbach <n0-0ne+github@mailbox.org> * Update src/settings/DeveloperSettingsTab.test.tsx Co-authored-by: Johannes Marbach <n0-0ne+github@mailbox.org> * reviewer comments --------- Co-authored-by: Johannes Marbach <n0-0ne+github@mailbox.org>
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
/*
|
|
Copyright 2026 New Vector Ltd.
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
Please see LICENSE in the repository root for full details.
|
|
*/
|
|
|
|
import { describe, expect, it, vi, afterEach } from "vitest";
|
|
import { logger } from "matrix-js-sdk/lib/logger";
|
|
|
|
import { validateConfig } from "./Config";
|
|
import { MatrixRTCMode } from "./ConfigOptions";
|
|
|
|
describe("validateConfig", () => {
|
|
afterEach(() => {
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
it("passes through a missing matrix_rtc_mode unchanged", () => {
|
|
const result = validateConfig({});
|
|
expect(result.matrix_rtc_mode).toBeUndefined();
|
|
});
|
|
|
|
it.each(Object.values(MatrixRTCMode))(
|
|
"keeps a valid matrix_rtc_mode value (%s)",
|
|
(mode) => {
|
|
const warnSpy = vi.spyOn(logger, "warn").mockImplementation(() => {});
|
|
const result = validateConfig({ matrix_rtc_mode: mode });
|
|
expect(result.matrix_rtc_mode).toBe(mode);
|
|
expect(warnSpy).not.toHaveBeenCalled();
|
|
},
|
|
);
|
|
|
|
it("drops an invalid matrix_rtc_mode value and warns", () => {
|
|
const warnSpy = vi.spyOn(logger, "warn").mockImplementation(() => {});
|
|
const result = validateConfig({
|
|
// Intentionally bypass the type to simulate bad JSON.
|
|
matrix_rtc_mode: "nonsense" as unknown as MatrixRTCMode,
|
|
});
|
|
expect(result.matrix_rtc_mode).toBeUndefined();
|
|
expect(warnSpy).toHaveBeenCalledTimes(1);
|
|
expect(warnSpy.mock.calls[0][0]).toContain("nonsense");
|
|
});
|
|
|
|
it("does not touch unrelated fields when dropping an invalid mode", () => {
|
|
vi.spyOn(logger, "warn").mockImplementation(() => {});
|
|
const result = validateConfig({
|
|
matrix_rtc_mode: "nope" as unknown as MatrixRTCMode,
|
|
ssla: "https://example.invalid/ssla",
|
|
});
|
|
expect(result.matrix_rtc_mode).toBeUndefined();
|
|
expect(result.ssla).toBe("https://example.invalid/ssla");
|
|
});
|
|
});
|