Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/containers/MediaCallHeader/MediaCallHeader.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const setStoreState = (overrides: Partial<ReturnType<typeof useCallStore.getStat
contact: {
displayName: 'Bob Burnquist',
username: 'bob.burnquist',
sipExtension: '2244'
sipExtension: ''
},
setMuted: () => {},
setHeld: () => {},
Expand All @@ -44,8 +44,9 @@ const setStoreState = (overrides: Partial<ReturnType<typeof useCallStore.getStat
id: 'user-1',
displayName: 'Bob Burnquist',
username: 'bob.burnquist',
sipExtension: '2244'
sipExtension: ''
},
roomId: 'story-room-rid',
focused: true,
remoteMute: false,
remoteHeld: false,
Expand Down
49 changes: 43 additions & 6 deletions app/containers/MediaCallHeader/MediaCallHeader.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ import { fireEvent, render } from '@testing-library/react-native';
import { Provider } from 'react-redux';

import MediaCallHeader from './MediaCallHeader';
import { navigateToCallRoom } from '../../lib/services/voip/navigateToCallRoom';
import { useCallStore } from '../../lib/services/voip/useCallStore';
import { mockedStore } from '../../reducers/mockedStore';
import * as stories from './MediaCallHeader.stories';
import { generateSnapshots } from '../../../.rnstorybook/generateSnapshots';

// Mock alert
global.alert = jest.fn();
const mockNavigateToCallRoom = jest.mocked(navigateToCallRoom);

jest.mock('../../lib/services/voip/navigateToCallRoom', () => ({
navigateToCallRoom: jest.fn().mockResolvedValue(undefined)
}));

const mockCallStartTime = 1713340800000;

Expand All @@ -21,7 +25,7 @@ const createMockCall = (overrides: Record<string, unknown> = {}) => ({
contact: {
displayName: 'Bob Burnquist',
username: 'bob.burnquist',
sipExtension: '2244'
sipExtension: ''
},
setMuted: jest.fn(),
setHeld: jest.fn(),
Expand All @@ -48,8 +52,9 @@ const setStoreState = (overrides: Partial<ReturnType<typeof useCallStore.getStat
id: 'user-1',
displayName: 'Bob Burnquist',
username: 'bob.burnquist',
sipExtension: '2244'
sipExtension: ''
},
roomId: 'test-room-rid',
focused: true,
remoteMute: false,
remoteHeld: false,
Expand Down Expand Up @@ -209,7 +214,7 @@ describe('MediaCallHeader', () => {
expect(getByTestId('media-call-header')).toHaveProp('pointerEvents', 'auto');
});

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

fireEvent.press(getByTestId('media-call-header-content'));
expect(global.alert).toHaveBeenCalledWith('nav to call room');
expect(mockNavigateToCallRoom).toHaveBeenCalledTimes(1);
});

it('does not call navigateToCallRoom when content is pressed for SIP calls', () => {
setStoreState({
contact: {
id: 'user-1',
displayName: 'Bob Burnquist',
username: 'bob.burnquist',
sipExtension: '2244'
},
roomId: 'test-room-rid'
});
const { getByTestId } = render(
<Wrapper>
<MediaCallHeader />
</Wrapper>
);

fireEvent.press(getByTestId('media-call-header-content'));
expect(mockNavigateToCallRoom).not.toHaveBeenCalled();
});

it('does not call navigateToCallRoom when roomId is null', () => {
setStoreState({ roomId: null });
const { getByTestId } = render(
<Wrapper>
<MediaCallHeader />
</Wrapper>
);

fireEvent.press(getByTestId('media-call-header-content'));
expect(mockNavigateToCallRoom).not.toHaveBeenCalled();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ exports[`Story Snapshots: ActiveCall should match snapshot 1`] = `
collapsable={false}
delayLongPress={600}
enabled={true}
handlerTag={19}
handlerTag={23}
handlerType="NativeViewGestureHandler"
hitSlop={
{
Expand Down Expand Up @@ -132,7 +132,7 @@ exports[`Story Snapshots: ActiveCall should match snapshot 1`] = `
{
"busy": undefined,
"checked": undefined,
"disabled": undefined,
"disabled": false,
"expanded": undefined,
"selected": undefined,
}
Expand Down Expand Up @@ -244,27 +244,6 @@ exports[`Story Snapshots: ActiveCall should match snapshot 1`] = `
</Text>
</Text>
</View>
<Text
numberOfLines={1}
style={
[
{
"backgroundColor": "transparent",
"fontFamily": "Inter",
"fontSize": 12,
"fontWeight": "400",
"lineHeight": 16,
"textAlign": "left",
},
{
"color": "#6C727A",
},
]
}
testID="call-view-header-subtitle"
>
2244
</Text>
</View>
</View>
<View
Expand All @@ -288,7 +267,7 @@ exports[`Story Snapshots: ActiveCall should match snapshot 1`] = `
collapsable={false}
delayLongPress={600}
enabled={true}
handlerTag={20}
handlerTag={24}
handlerType="NativeViewGestureHandler"
hitSlop={
{
Expand Down Expand Up @@ -419,7 +398,7 @@ exports[`Story Snapshots: Collapsed should match snapshot 1`] = `
collapsable={false}
delayLongPress={600}
enabled={true}
handlerTag={21}
handlerTag={25}
handlerType="NativeViewGestureHandler"
hitSlop={
{
Expand Down Expand Up @@ -490,7 +469,7 @@ exports[`Story Snapshots: Collapsed should match snapshot 1`] = `
{
"busy": undefined,
"checked": undefined,
"disabled": undefined,
"disabled": false,
"expanded": undefined,
"selected": undefined,
}
Expand Down Expand Up @@ -602,27 +581,6 @@ exports[`Story Snapshots: Collapsed should match snapshot 1`] = `
</Text>
</Text>
</View>
<Text
numberOfLines={1}
style={
[
{
"backgroundColor": "transparent",
"fontFamily": "Inter",
"fontSize": 12,
"fontWeight": "400",
"lineHeight": 16,
"textAlign": "left",
},
{
"color": "#6C727A",
},
]
}
testID="call-view-header-subtitle"
>
2244
</Text>
</View>
</View>
<View
Expand All @@ -646,7 +604,7 @@ exports[`Story Snapshots: Collapsed should match snapshot 1`] = `
collapsable={false}
delayLongPress={600}
enabled={true}
handlerTag={22}
handlerTag={26}
handlerType="NativeViewGestureHandler"
hitSlop={
{
Expand Down Expand Up @@ -777,7 +735,7 @@ exports[`Story Snapshots: ConnectingCall should match snapshot 1`] = `
collapsable={false}
delayLongPress={600}
enabled={true}
handlerTag={23}
handlerTag={27}
handlerType="NativeViewGestureHandler"
hitSlop={
{
Expand Down Expand Up @@ -848,7 +806,7 @@ exports[`Story Snapshots: ConnectingCall should match snapshot 1`] = `
{
"busy": undefined,
"checked": undefined,
"disabled": undefined,
"disabled": false,
"expanded": undefined,
"selected": undefined,
}
Expand Down Expand Up @@ -1000,7 +958,7 @@ exports[`Story Snapshots: ConnectingCall should match snapshot 1`] = `
collapsable={false}
delayLongPress={600}
enabled={true}
handlerTag={24}
handlerTag={28}
handlerType="NativeViewGestureHandler"
hitSlop={
{
Expand Down Expand Up @@ -1131,7 +1089,7 @@ exports[`Story Snapshots: Focused should match snapshot 1`] = `
collapsable={false}
delayLongPress={600}
enabled={true}
handlerTag={25}
handlerTag={29}
handlerType="NativeViewGestureHandler"
hitSlop={
{
Expand Down Expand Up @@ -1202,7 +1160,7 @@ exports[`Story Snapshots: Focused should match snapshot 1`] = `
{
"busy": undefined,
"checked": undefined,
"disabled": undefined,
"disabled": false,
"expanded": undefined,
"selected": undefined,
}
Expand Down Expand Up @@ -1314,27 +1272,6 @@ exports[`Story Snapshots: Focused should match snapshot 1`] = `
</Text>
</Text>
</View>
<Text
numberOfLines={1}
style={
[
{
"backgroundColor": "transparent",
"fontFamily": "Inter",
"fontSize": 12,
"fontWeight": "400",
"lineHeight": 16,
"textAlign": "left",
},
{
"color": "#6C727A",
},
]
}
testID="call-view-header-subtitle"
>
2244
</Text>
</View>
</View>
<View
Expand All @@ -1358,7 +1295,7 @@ exports[`Story Snapshots: Focused should match snapshot 1`] = `
collapsable={false}
delayLongPress={600}
enabled={true}
handlerTag={26}
handlerTag={30}
handlerType="NativeViewGestureHandler"
hitSlop={
{
Expand Down Expand Up @@ -1509,7 +1446,7 @@ exports[`Story Snapshots: WithRemoteHeld should match snapshot 1`] = `
collapsable={false}
delayLongPress={600}
enabled={true}
handlerTag={27}
handlerTag={31}
handlerType="NativeViewGestureHandler"
hitSlop={
{
Expand Down Expand Up @@ -1580,7 +1517,7 @@ exports[`Story Snapshots: WithRemoteHeld should match snapshot 1`] = `
{
"busy": undefined,
"checked": undefined,
"disabled": undefined,
"disabled": false,
"expanded": undefined,
"selected": undefined,
}
Expand Down Expand Up @@ -1711,7 +1648,7 @@ exports[`Story Snapshots: WithRemoteHeld should match snapshot 1`] = `
}
testID="call-view-header-subtitle"
>
2244 - On hold
On hold
</Text>
</View>
</View>
Expand All @@ -1736,7 +1673,7 @@ exports[`Story Snapshots: WithRemoteHeld should match snapshot 1`] = `
collapsable={false}
delayLongPress={600}
enabled={true}
handlerTag={28}
handlerTag={32}
handlerType="NativeViewGestureHandler"
hitSlop={
{
Expand Down Expand Up @@ -1867,7 +1804,7 @@ exports[`Story Snapshots: WithRemoteMuted should match snapshot 1`] = `
collapsable={false}
delayLongPress={600}
enabled={true}
handlerTag={29}
handlerTag={33}
handlerType="NativeViewGestureHandler"
hitSlop={
{
Expand Down Expand Up @@ -1938,7 +1875,7 @@ exports[`Story Snapshots: WithRemoteMuted should match snapshot 1`] = `
{
"busy": undefined,
"checked": undefined,
"disabled": undefined,
"disabled": false,
"expanded": undefined,
"selected": undefined,
}
Expand Down Expand Up @@ -2069,7 +2006,7 @@ exports[`Story Snapshots: WithRemoteMuted should match snapshot 1`] = `
}
testID="call-view-header-subtitle"
>
2244 - Muted
Muted
</Text>
</View>
</View>
Expand All @@ -2094,7 +2031,7 @@ exports[`Story Snapshots: WithRemoteMuted should match snapshot 1`] = `
collapsable={false}
delayLongPress={600}
enabled={true}
handlerTag={30}
handlerTag={34}
handlerType="NativeViewGestureHandler"
hitSlop={
{
Expand Down
Loading
Loading