mirror of
https://github.com/vector-im/element-call.git
synced 2026-09-25 22:35:49 +00:00
Use the shared audio capture stub in the lobby test
- Drop the lobby test's own stub, which left the analyser buffer zeroed and so read as full scale rather than silence. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -20,7 +20,12 @@ import {
|
|||||||
|
|
||||||
import { LobbyView } from "./LobbyView";
|
import { LobbyView } from "./LobbyView";
|
||||||
import { E2eeType } from "../e2ee/e2eeType";
|
import { E2eeType } from "../e2ee/e2eeType";
|
||||||
import { mockMediaDevices, mockMuteStates } from "../utils/test";
|
import {
|
||||||
|
mockMediaDevices,
|
||||||
|
mockMuteStates,
|
||||||
|
restoreAudioCapture,
|
||||||
|
stubAudioCapture,
|
||||||
|
} from "../utils/test";
|
||||||
import { type MediaDevices } from "../state/MediaDevices";
|
import { type MediaDevices } from "../state/MediaDevices";
|
||||||
import { MediaDevicesContext } from "../MediaDevicesContext";
|
import { MediaDevicesContext } from "../MediaDevicesContext";
|
||||||
import { type ProcessorState } from "../livekit/TrackProcessorContext";
|
import { type ProcessorState } from "../livekit/TrackProcessorContext";
|
||||||
@@ -184,48 +189,11 @@ describe("LobbyView", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("LobbyView microphone level", () => {
|
describe("LobbyView microphone level", () => {
|
||||||
const realMediaDevices = Object.getOwnPropertyDescriptor(
|
afterEach(restoreAudioCapture);
|
||||||
navigator,
|
|
||||||
"mediaDevices",
|
|
||||||
);
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
vi.unstubAllGlobals();
|
|
||||||
if (realMediaDevices === undefined) {
|
|
||||||
Reflect.deleteProperty(navigator, "mediaDevices");
|
|
||||||
} else {
|
|
||||||
Object.defineProperty(navigator, "mediaDevices", realMediaDevices);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function stubAudioCapture(): void {
|
|
||||||
vi.stubGlobal(
|
|
||||||
"AudioContext",
|
|
||||||
class {
|
|
||||||
public readonly state = "running";
|
|
||||||
public createAnalyser(): object {
|
|
||||||
return {
|
|
||||||
fftSize: 1024,
|
|
||||||
getByteTimeDomainData: (): void => {},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public createMediaStreamSource(): object {
|
|
||||||
return { connect: (): void => {} };
|
|
||||||
}
|
|
||||||
public close(): void {}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
// Only this property: replacing navigator loses getters like userAgent.
|
|
||||||
Object.defineProperty(navigator, "mediaDevices", {
|
|
||||||
configurable: true,
|
|
||||||
value: {
|
|
||||||
getUserMedia: vi.fn().mockResolvedValue({ getTracks: () => [] }),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
it("shows the microphone level meter", async () => {
|
it("shows the microphone level meter", async () => {
|
||||||
stubAudioCapture();
|
const capture = stubAudioCapture();
|
||||||
|
capture.grant();
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
const { getByRole } = renderLobbyView({}, false, "desktop", {
|
const { getByRole } = renderLobbyView({}, false, "desktop", {
|
||||||
requestDeviceNames: (): void => {},
|
requestDeviceNames: (): void => {},
|
||||||
|
|||||||
Reference in New Issue
Block a user