Add more debugging for why audio ring/ringback might not be playing (#9642)
* Add more debugging for why audio might not be playing More debugging for https://github.com/vector-im/element-web/issues/20832 * Listen to events from <audio> * Make it easier to spot event type * Move to start/stop functions * Fix some lints * Protect from potentially undefined element * Needs more mocked functions * More code coverage * Test formatting * Add return types See https://github.com/matrix-org/matrix-react-sdk/pull/9642#discussion_r1036274817 * Add comment on when magic comment is applicable See https://github.com/matrix-org/matrix-react-sdk/pull/9642#discussion_r1036258757
This commit is contained in:
parent
5583d07f25
commit
ca58617cee
3 changed files with 116 additions and 3 deletions
|
@ -28,7 +28,7 @@ import { mocked } from 'jest-mock';
|
|||
import { CallEventHandlerEvent } from 'matrix-js-sdk/src/webrtc/callEventHandler';
|
||||
|
||||
import LegacyCallHandler, {
|
||||
LegacyCallHandlerEvent, PROTOCOL_PSTN, PROTOCOL_PSTN_PREFIXED, PROTOCOL_SIP_NATIVE, PROTOCOL_SIP_VIRTUAL,
|
||||
LegacyCallHandlerEvent, AudioID, PROTOCOL_PSTN, PROTOCOL_PSTN_PREFIXED, PROTOCOL_SIP_NATIVE, PROTOCOL_SIP_VIRTUAL,
|
||||
} from '../src/LegacyCallHandler';
|
||||
import { stubClient, mkStubRoom, untilDispatch } from './test-utils';
|
||||
import { MatrixClientPeg } from '../src/MatrixClientPeg';
|
||||
|
@ -445,6 +445,9 @@ describe('LegacyCallHandler without third party protocols', () => {
|
|||
const mockAudioElement = {
|
||||
play: jest.fn(),
|
||||
pause: jest.fn(),
|
||||
addEventListener: jest.fn(),
|
||||
removeEventListener: jest.fn(),
|
||||
muted: false,
|
||||
} as unknown as HTMLMediaElement;
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
|
@ -488,6 +491,19 @@ describe('LegacyCallHandler without third party protocols', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should unmute <audio> before playing', () => {
|
||||
// Test setup: set the audio element as muted
|
||||
mockAudioElement.muted = true;
|
||||
expect(mockAudioElement.muted).toStrictEqual(true);
|
||||
|
||||
callHandler.play(AudioID.Ring);
|
||||
|
||||
// Ensure audio is no longer muted
|
||||
expect(mockAudioElement.muted).toStrictEqual(false);
|
||||
// Ensure the audio was played
|
||||
expect(mockAudioElement.play).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('listens for incoming call events when voip is enabled', () => {
|
||||
const call = new MatrixCall({
|
||||
client: MatrixClientPeg.get(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue