Skip to content

Commit acc3e8d

Browse files
committed
test(voip): restore InMemoryVoipNative.recorded assertions; update endCall test
A1 (answerCall markActive), C4 (setSpeaker on/off), and E1 (stateChange markActive) assertions were reverted by the previous agent to direct RNCallKeep/InCallManager mock checks, which slice-04 no longer hits. Restore the InMemoryVoipNative.recorded seam assertions matching the slice-04 base. Also remove the re-added `import InCallManager` that was no longer needed. In MediaCallEvents.test.ts: add a jest.mock for CallLifecycle and update the endCall test to assert callLifecycle.end('remote') is called rather than the now-removed mediaSessionInstance.endCall delegation.
1 parent 9303ff5 commit acc3e8d

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

app/containers/NewMediaCall/VoipCallLifecycle.integration.test.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import React from 'react';
1515
import { act, fireEvent, render } from '@testing-library/react-native';
1616
import { Provider } from 'react-redux';
1717
import RNCallKeep from 'react-native-callkeep';
18-
import InCallManager from 'react-native-incall-manager';
1918
import type { IClientMediaCall } from '@rocket.chat/media-signaling';
2019

2120
import { NewMediaCall } from './NewMediaCall';
@@ -569,7 +568,7 @@ describe('VoIP call lifecycle (integration)', () => {
569568
await flushMicrotasks();
570569
});
571570

572-
expect(RNCallKeep.setCurrentCallActive as jest.Mock).toHaveBeenCalledWith('incoming-1');
571+
expect((voipNative as InMemoryVoipNative).recorded).toContainEqual({ cmd: 'markActive', callUuid: 'incoming-1' });
573572
expect(Navigation.navigate).toHaveBeenCalledWith('CallView');
574573
expect(useCallStore.getState().call?.callId).toBe('incoming-1');
575574
});
@@ -762,13 +761,13 @@ describe('VoIP call lifecycle (integration)', () => {
762761
await act(async () => {
763762
await useCallStore.getState().toggleSpeaker();
764763
});
765-
expect(InCallManager.setForceSpeakerphoneOn as jest.Mock).toHaveBeenCalledWith(true);
764+
expect((voipNative as InMemoryVoipNative).recorded).toContainEqual({ cmd: 'setSpeaker', on: true });
766765
expect(useCallStore.getState().isSpeakerOn).toBe(true);
767766

768767
await act(async () => {
769768
await useCallStore.getState().toggleSpeaker();
770769
});
771-
expect(InCallManager.setForceSpeakerphoneOn as jest.Mock).toHaveBeenCalledWith(false);
770+
expect((voipNative as InMemoryVoipNative).recorded).toContainEqual({ cmd: 'setSpeaker', on: false });
772771
expect(useCallStore.getState().isSpeakerOn).toBe(false);
773772
});
774773
});
@@ -859,7 +858,7 @@ describe('VoIP call lifecycle (integration)', () => {
859858

860859
expect(useCallStore.getState().callState).toBe('active');
861860
expect(useCallStore.getState().callStartTime).not.toBeNull();
862-
expect(RNCallKeep.setCurrentCallActive as jest.Mock).toHaveBeenCalledWith('state-1');
861+
expect((voipNative as InMemoryVoipNative).recorded).toContainEqual({ cmd: 'markActive', callUuid: 'state-1' });
863862
});
864863
});
865864

app/lib/services/voip/MediaCallEvents.test.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ jest.mock('./MediaSessionInstance', () => ({
5858
}
5959
}));
6060

61+
jest.mock('./CallLifecycle', () => ({
62+
callLifecycle: {
63+
end: jest.fn(() => Promise.resolve()),
64+
emitter: { on: jest.fn(), off: jest.fn(), emit: jest.fn() }
65+
}
66+
}));
67+
6168
jest.mock('../restApi', () => ({
6269
registerPushToken: jest.fn(() => Promise.resolve())
6370
}));
@@ -351,11 +358,11 @@ describe('createVoipEventDispatcher — hold', () => {
351358
describe('createVoipEventDispatcher — endCall', () => {
352359
beforeEach(() => jest.clearAllMocks());
353360

354-
it('calls mediaSessionInstance.endCall with callUuid', () => {
355-
const { mediaSessionInstance } = jest.requireMock('./MediaSessionInstance');
361+
it('tags OS-originated end-call as remote by calling callLifecycle.end("remote")', () => {
362+
const { callLifecycle } = jest.requireMock('./CallLifecycle');
356363
const dispatch = createVoipEventDispatcher(makeTestAdapters());
357364
dispatch({ type: 'endCall', callUuid: 'end-uuid' });
358-
expect(mediaSessionInstance.endCall).toHaveBeenCalledWith('end-uuid');
365+
expect(callLifecycle.end).toHaveBeenCalledWith('remote');
359366
});
360367
});
361368

0 commit comments

Comments
 (0)