Skip to content

Commit 58e91f1

Browse files
authored
feat(voip): navigate to call DM from message button and header (#7082)
1 parent 2637261 commit 58e91f1

File tree

18 files changed

+761
-168
lines changed

18 files changed

+761
-168
lines changed

app/containers/MediaCallHeader/MediaCallHeader.stories.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const setStoreState = (overrides: Partial<ReturnType<typeof useCallStore.getStat
2121
contact: {
2222
displayName: 'Bob Burnquist',
2323
username: 'bob.burnquist',
24-
sipExtension: '2244'
24+
sipExtension: ''
2525
},
2626
setMuted: () => {},
2727
setHeld: () => {},
@@ -44,8 +44,9 @@ const setStoreState = (overrides: Partial<ReturnType<typeof useCallStore.getStat
4444
id: 'user-1',
4545
displayName: 'Bob Burnquist',
4646
username: 'bob.burnquist',
47-
sipExtension: '2244'
47+
sipExtension: ''
4848
},
49+
roomId: 'story-room-rid',
4950
focused: true,
5051
remoteMute: false,
5152
remoteHeld: false,

app/containers/MediaCallHeader/MediaCallHeader.test.tsx

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ import { fireEvent, render } from '@testing-library/react-native';
33
import { Provider } from 'react-redux';
44

55
import MediaCallHeader from './MediaCallHeader';
6+
import { navigateToCallRoom } from '../../lib/services/voip/navigateToCallRoom';
67
import { useCallStore } from '../../lib/services/voip/useCallStore';
78
import { mockedStore } from '../../reducers/mockedStore';
89
import * as stories from './MediaCallHeader.stories';
910
import { generateSnapshots } from '../../../.rnstorybook/generateSnapshots';
1011

11-
// Mock alert
12-
global.alert = jest.fn();
12+
const mockNavigateToCallRoom = jest.mocked(navigateToCallRoom);
13+
14+
jest.mock('../../lib/services/voip/navigateToCallRoom', () => ({
15+
navigateToCallRoom: jest.fn().mockResolvedValue(undefined)
16+
}));
1317

1418
const mockCallStartTime = 1713340800000;
1519

@@ -21,7 +25,7 @@ const createMockCall = (overrides: Record<string, unknown> = {}) => ({
2125
contact: {
2226
displayName: 'Bob Burnquist',
2327
username: 'bob.burnquist',
24-
sipExtension: '2244'
28+
sipExtension: ''
2529
},
2630
setMuted: jest.fn(),
2731
setHeld: jest.fn(),
@@ -48,8 +52,9 @@ const setStoreState = (overrides: Partial<ReturnType<typeof useCallStore.getStat
4852
id: 'user-1',
4953
displayName: 'Bob Burnquist',
5054
username: 'bob.burnquist',
51-
sipExtension: '2244'
55+
sipExtension: ''
5256
},
57+
roomId: 'test-room-rid',
5358
focused: true,
5459
remoteMute: false,
5560
remoteHeld: false,
@@ -209,7 +214,7 @@ describe('MediaCallHeader', () => {
209214
expect(getByTestId('media-call-header')).toHaveProp('pointerEvents', 'auto');
210215
});
211216

212-
it('should show alert when content is pressed', () => {
217+
it('should call navigateToCallRoom when content is pressed and navigation is enabled', () => {
213218
setStoreState();
214219
const { getByTestId } = render(
215220
<Wrapper>
@@ -218,7 +223,39 @@ describe('MediaCallHeader', () => {
218223
);
219224

220225
fireEvent.press(getByTestId('media-call-header-content'));
221-
expect(global.alert).toHaveBeenCalledWith('nav to call room');
226+
expect(mockNavigateToCallRoom).toHaveBeenCalledTimes(1);
227+
});
228+
229+
it('does not call navigateToCallRoom when content is pressed for SIP calls', () => {
230+
setStoreState({
231+
contact: {
232+
id: 'user-1',
233+
displayName: 'Bob Burnquist',
234+
username: 'bob.burnquist',
235+
sipExtension: '2244'
236+
},
237+
roomId: 'test-room-rid'
238+
});
239+
const { getByTestId } = render(
240+
<Wrapper>
241+
<MediaCallHeader />
242+
</Wrapper>
243+
);
244+
245+
fireEvent.press(getByTestId('media-call-header-content'));
246+
expect(mockNavigateToCallRoom).not.toHaveBeenCalled();
247+
});
248+
249+
it('does not call navigateToCallRoom when roomId is null', () => {
250+
setStoreState({ roomId: null });
251+
const { getByTestId } = render(
252+
<Wrapper>
253+
<MediaCallHeader />
254+
</Wrapper>
255+
);
256+
257+
fireEvent.press(getByTestId('media-call-header-content'));
258+
expect(mockNavigateToCallRoom).not.toHaveBeenCalled();
222259
});
223260
});
224261

app/containers/MediaCallHeader/__snapshots__/MediaCallHeader.test.tsx.snap

Lines changed: 20 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ exports[`Story Snapshots: ActiveCall should match snapshot 1`] = `
6161
collapsable={false}
6262
delayLongPress={600}
6363
enabled={true}
64-
handlerTag={19}
64+
handlerTag={23}
6565
handlerType="NativeViewGestureHandler"
6666
hitSlop={
6767
{
@@ -132,7 +132,7 @@ exports[`Story Snapshots: ActiveCall should match snapshot 1`] = `
132132
{
133133
"busy": undefined,
134134
"checked": undefined,
135-
"disabled": undefined,
135+
"disabled": false,
136136
"expanded": undefined,
137137
"selected": undefined,
138138
}
@@ -244,27 +244,6 @@ exports[`Story Snapshots: ActiveCall should match snapshot 1`] = `
244244
</Text>
245245
</Text>
246246
</View>
247-
<Text
248-
numberOfLines={1}
249-
style={
250-
[
251-
{
252-
"backgroundColor": "transparent",
253-
"fontFamily": "Inter",
254-
"fontSize": 12,
255-
"fontWeight": "400",
256-
"lineHeight": 16,
257-
"textAlign": "left",
258-
},
259-
{
260-
"color": "#6C727A",
261-
},
262-
]
263-
}
264-
testID="call-view-header-subtitle"
265-
>
266-
2244
267-
</Text>
268247
</View>
269248
</View>
270249
<View
@@ -288,7 +267,7 @@ exports[`Story Snapshots: ActiveCall should match snapshot 1`] = `
288267
collapsable={false}
289268
delayLongPress={600}
290269
enabled={true}
291-
handlerTag={20}
270+
handlerTag={24}
292271
handlerType="NativeViewGestureHandler"
293272
hitSlop={
294273
{
@@ -419,7 +398,7 @@ exports[`Story Snapshots: Collapsed should match snapshot 1`] = `
419398
collapsable={false}
420399
delayLongPress={600}
421400
enabled={true}
422-
handlerTag={21}
401+
handlerTag={25}
423402
handlerType="NativeViewGestureHandler"
424403
hitSlop={
425404
{
@@ -490,7 +469,7 @@ exports[`Story Snapshots: Collapsed should match snapshot 1`] = `
490469
{
491470
"busy": undefined,
492471
"checked": undefined,
493-
"disabled": undefined,
472+
"disabled": false,
494473
"expanded": undefined,
495474
"selected": undefined,
496475
}
@@ -602,27 +581,6 @@ exports[`Story Snapshots: Collapsed should match snapshot 1`] = `
602581
</Text>
603582
</Text>
604583
</View>
605-
<Text
606-
numberOfLines={1}
607-
style={
608-
[
609-
{
610-
"backgroundColor": "transparent",
611-
"fontFamily": "Inter",
612-
"fontSize": 12,
613-
"fontWeight": "400",
614-
"lineHeight": 16,
615-
"textAlign": "left",
616-
},
617-
{
618-
"color": "#6C727A",
619-
},
620-
]
621-
}
622-
testID="call-view-header-subtitle"
623-
>
624-
2244
625-
</Text>
626584
</View>
627585
</View>
628586
<View
@@ -646,7 +604,7 @@ exports[`Story Snapshots: Collapsed should match snapshot 1`] = `
646604
collapsable={false}
647605
delayLongPress={600}
648606
enabled={true}
649-
handlerTag={22}
607+
handlerTag={26}
650608
handlerType="NativeViewGestureHandler"
651609
hitSlop={
652610
{
@@ -777,7 +735,7 @@ exports[`Story Snapshots: ConnectingCall should match snapshot 1`] = `
777735
collapsable={false}
778736
delayLongPress={600}
779737
enabled={true}
780-
handlerTag={23}
738+
handlerTag={27}
781739
handlerType="NativeViewGestureHandler"
782740
hitSlop={
783741
{
@@ -848,7 +806,7 @@ exports[`Story Snapshots: ConnectingCall should match snapshot 1`] = `
848806
{
849807
"busy": undefined,
850808
"checked": undefined,
851-
"disabled": undefined,
809+
"disabled": false,
852810
"expanded": undefined,
853811
"selected": undefined,
854812
}
@@ -1000,7 +958,7 @@ exports[`Story Snapshots: ConnectingCall should match snapshot 1`] = `
1000958
collapsable={false}
1001959
delayLongPress={600}
1002960
enabled={true}
1003-
handlerTag={24}
961+
handlerTag={28}
1004962
handlerType="NativeViewGestureHandler"
1005963
hitSlop={
1006964
{
@@ -1131,7 +1089,7 @@ exports[`Story Snapshots: Focused should match snapshot 1`] = `
11311089
collapsable={false}
11321090
delayLongPress={600}
11331091
enabled={true}
1134-
handlerTag={25}
1092+
handlerTag={29}
11351093
handlerType="NativeViewGestureHandler"
11361094
hitSlop={
11371095
{
@@ -1202,7 +1160,7 @@ exports[`Story Snapshots: Focused should match snapshot 1`] = `
12021160
{
12031161
"busy": undefined,
12041162
"checked": undefined,
1205-
"disabled": undefined,
1163+
"disabled": false,
12061164
"expanded": undefined,
12071165
"selected": undefined,
12081166
}
@@ -1314,27 +1272,6 @@ exports[`Story Snapshots: Focused should match snapshot 1`] = `
13141272
</Text>
13151273
</Text>
13161274
</View>
1317-
<Text
1318-
numberOfLines={1}
1319-
style={
1320-
[
1321-
{
1322-
"backgroundColor": "transparent",
1323-
"fontFamily": "Inter",
1324-
"fontSize": 12,
1325-
"fontWeight": "400",
1326-
"lineHeight": 16,
1327-
"textAlign": "left",
1328-
},
1329-
{
1330-
"color": "#6C727A",
1331-
},
1332-
]
1333-
}
1334-
testID="call-view-header-subtitle"
1335-
>
1336-
2244
1337-
</Text>
13381275
</View>
13391276
</View>
13401277
<View
@@ -1358,7 +1295,7 @@ exports[`Story Snapshots: Focused should match snapshot 1`] = `
13581295
collapsable={false}
13591296
delayLongPress={600}
13601297
enabled={true}
1361-
handlerTag={26}
1298+
handlerTag={30}
13621299
handlerType="NativeViewGestureHandler"
13631300
hitSlop={
13641301
{
@@ -1509,7 +1446,7 @@ exports[`Story Snapshots: WithRemoteHeld should match snapshot 1`] = `
15091446
collapsable={false}
15101447
delayLongPress={600}
15111448
enabled={true}
1512-
handlerTag={27}
1449+
handlerTag={31}
15131450
handlerType="NativeViewGestureHandler"
15141451
hitSlop={
15151452
{
@@ -1580,7 +1517,7 @@ exports[`Story Snapshots: WithRemoteHeld should match snapshot 1`] = `
15801517
{
15811518
"busy": undefined,
15821519
"checked": undefined,
1583-
"disabled": undefined,
1520+
"disabled": false,
15841521
"expanded": undefined,
15851522
"selected": undefined,
15861523
}
@@ -1711,7 +1648,7 @@ exports[`Story Snapshots: WithRemoteHeld should match snapshot 1`] = `
17111648
}
17121649
testID="call-view-header-subtitle"
17131650
>
1714-
2244 - On hold
1651+
On hold
17151652
</Text>
17161653
</View>
17171654
</View>
@@ -1736,7 +1673,7 @@ exports[`Story Snapshots: WithRemoteHeld should match snapshot 1`] = `
17361673
collapsable={false}
17371674
delayLongPress={600}
17381675
enabled={true}
1739-
handlerTag={28}
1676+
handlerTag={32}
17401677
handlerType="NativeViewGestureHandler"
17411678
hitSlop={
17421679
{
@@ -1867,7 +1804,7 @@ exports[`Story Snapshots: WithRemoteMuted should match snapshot 1`] = `
18671804
collapsable={false}
18681805
delayLongPress={600}
18691806
enabled={true}
1870-
handlerTag={29}
1807+
handlerTag={33}
18711808
handlerType="NativeViewGestureHandler"
18721809
hitSlop={
18731810
{
@@ -1938,7 +1875,7 @@ exports[`Story Snapshots: WithRemoteMuted should match snapshot 1`] = `
19381875
{
19391876
"busy": undefined,
19401877
"checked": undefined,
1941-
"disabled": undefined,
1878+
"disabled": false,
19421879
"expanded": undefined,
19431880
"selected": undefined,
19441881
}
@@ -2069,7 +2006,7 @@ exports[`Story Snapshots: WithRemoteMuted should match snapshot 1`] = `
20692006
}
20702007
testID="call-view-header-subtitle"
20712008
>
2072-
2244 - Muted
2009+
Muted
20732010
</Text>
20742011
</View>
20752012
</View>
@@ -2094,7 +2031,7 @@ exports[`Story Snapshots: WithRemoteMuted should match snapshot 1`] = `
20942031
collapsable={false}
20952032
delayLongPress={600}
20962033
enabled={true}
2097-
handlerTag={30}
2034+
handlerTag={34}
20982035
handlerType="NativeViewGestureHandler"
20992036
hitSlop={
21002037
{

0 commit comments

Comments
 (0)