Remove legacy Safari/Firefox/IE compatibility aids (#29010)
* Remove legacy Safari prefix compatibility for AudioContext Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Remove more legacy webkit/ms/moz support Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Improve coverage, cull dead code Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Simplify Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Improve coverage Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Improve coverage Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
committed by
GitHub
parent
e235100dd0
commit
c84cf3c36c
@@ -47,7 +47,7 @@ describe("Playback", () => {
|
||||
beforeEach(() => {
|
||||
jest.spyOn(logger, "error").mockRestore();
|
||||
mockAudioBuffer.getChannelData.mockClear().mockReturnValue(mockChannelData);
|
||||
mockAudioContext.decodeAudioData.mockReset().mockImplementation((_b, callback) => callback(mockAudioBuffer));
|
||||
mockAudioContext.decodeAudioData.mockReset().mockResolvedValue(mockAudioBuffer);
|
||||
mockAudioContext.resume.mockClear().mockResolvedValue(undefined);
|
||||
mockAudioContext.suspend.mockClear().mockResolvedValue(undefined);
|
||||
mocked(decodeOgg).mockClear().mockResolvedValue(new ArrayBuffer(1));
|
||||
@@ -131,8 +131,8 @@ describe("Playback", () => {
|
||||
const buffer = new ArrayBuffer(8);
|
||||
const decodingError = new Error("test");
|
||||
mockAudioContext.decodeAudioData
|
||||
.mockImplementationOnce((_b, _callback, error) => error(decodingError))
|
||||
.mockImplementationOnce((_b, callback) => callback(mockAudioBuffer));
|
||||
.mockRejectedValueOnce(decodingError)
|
||||
.mockResolvedValueOnce(mockAudioBuffer);
|
||||
|
||||
const playback = new Playback(buffer);
|
||||
|
||||
|
||||
15
test/unit-tests/audio/compat-test.ts
Normal file
15
test/unit-tests/audio/compat-test.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
Copyright 2025 New Vector Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { createAudioContext } from "../../../src/audio/compat";
|
||||
|
||||
describe("createAudioContext", () => {
|
||||
it("should throw if AudioContext is not supported", () => {
|
||||
window.AudioContext = undefined as any;
|
||||
expect(createAudioContext).toThrow("Unsupported browser");
|
||||
});
|
||||
});
|
||||
@@ -65,7 +65,7 @@ describe("<RecordingPlayback />", () => {
|
||||
beforeEach(() => {
|
||||
jest.spyOn(logger, "error").mockRestore();
|
||||
mockAudioBuffer.getChannelData.mockClear().mockReturnValue(mockChannelData);
|
||||
mockAudioContext.decodeAudioData.mockReset().mockImplementation((_b, callback) => callback(mockAudioBuffer));
|
||||
mockAudioContext.decodeAudioData.mockReset().mockResolvedValue(mockAudioBuffer);
|
||||
mocked(createAudioContext).mockReturnValue(mockAudioContext as unknown as AudioContext);
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
Copyright 2025 New Vector Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import { render } from "jest-matrix-react";
|
||||
import { type MatrixCall } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import LegacyCallView from "../../../../../src/components/views/voip/LegacyCallView";
|
||||
import { stubClient } from "../../../../test-utils";
|
||||
|
||||
describe("LegacyCallView", () => {
|
||||
it("should exit full screen on unmount", () => {
|
||||
const element = document.createElement("div");
|
||||
// @ts-expect-error
|
||||
document.fullscreenElement = element;
|
||||
document.exitFullscreen = jest.fn();
|
||||
|
||||
stubClient();
|
||||
|
||||
const call = {
|
||||
on: jest.fn(),
|
||||
removeListener: jest.fn(),
|
||||
getFeeds: jest.fn().mockReturnValue([]),
|
||||
isLocalOnHold: jest.fn().mockReturnValue(false),
|
||||
isRemoteOnHold: jest.fn().mockReturnValue(false),
|
||||
isMicrophoneMuted: jest.fn().mockReturnValue(false),
|
||||
isLocalVideoMuted: jest.fn().mockReturnValue(false),
|
||||
isScreensharing: jest.fn().mockReturnValue(false),
|
||||
} as unknown as MatrixCall;
|
||||
|
||||
const { unmount } = render(<LegacyCallView call={call} />);
|
||||
expect(document.exitFullscreen).not.toHaveBeenCalled();
|
||||
unmount();
|
||||
expect(document.exitFullscreen).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
type TranslationKey,
|
||||
type IVariables,
|
||||
type Tags,
|
||||
getLanguagesFromBrowser,
|
||||
} from "../../src/languageHandler";
|
||||
import { stubClient } from "../test-utils";
|
||||
import { setupLanguageMock } from "../setup/setupLanguage";
|
||||
@@ -198,6 +199,29 @@ describe("languageHandler", () => {
|
||||
setupLanguageMock(); // restore language mock
|
||||
});
|
||||
});
|
||||
|
||||
describe("getLanguagesFromBrowser", () => {
|
||||
beforeEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
it("should return navigator.languages if available", () => {
|
||||
jest.spyOn(window.navigator, "languages", "get").mockReturnValue(["en", "de"]);
|
||||
expect(getLanguagesFromBrowser()).toEqual(["en", "de"]);
|
||||
});
|
||||
|
||||
it("should return navigator.language if available", () => {
|
||||
jest.spyOn(window.navigator, "languages", "get").mockReturnValue([]);
|
||||
jest.spyOn(window.navigator, "language", "get").mockReturnValue("de");
|
||||
expect(getLanguagesFromBrowser()).toEqual(["de"]);
|
||||
});
|
||||
|
||||
it("should return 'en' otherwise", () => {
|
||||
jest.spyOn(window.navigator, "languages", "get").mockReturnValue([]);
|
||||
jest.spyOn(window.navigator, "language", "get").mockReturnValue(undefined as any);
|
||||
expect(getLanguagesFromBrowser()).toEqual(["en"]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("languageHandler JSX", function () {
|
||||
|
||||
Reference in New Issue
Block a user