@planningcenter/chat-react-native 4.0.1-qa-staging.2 → 4.0.1-qa-staging.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/screens/conversation_new/components/groups_form.js +80 -71
- package/build/screens/conversation_new/components/groups_form.js.map +1 -1
- package/build/screens/conversations/components/chat_group_badge.d.ts.map +1 -1
- package/build/screens/conversations/components/chat_group_badge.js +1 -0
- package/build/screens/conversations/components/chat_group_badge.js.map +1 -1
- package/build/screens/conversations/components/list_header_component.d.ts.map +1 -1
- package/build/screens/conversations/components/list_header_component.js +157 -150
- package/build/screens/conversations/components/list_header_component.js.map +1 -1
- package/package.json +3 -3
- package/src/screens/conversation_new/components/groups_form.tsx +7 -2
- package/src/screens/conversations/components/__tests__/chat_group_badge.test.tsx +32 -0
- package/src/screens/conversations/components/__tests__/list_header_component.test.tsx +66 -0
- package/src/screens/conversations/components/chat_group_badge.tsx +1 -0
- package/src/screens/conversations/components/list_header_component.tsx +18 -28
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { fireEvent, render } from '@testing-library/react-native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { ChatGroupBadge } from '../chat_group_badge'
|
|
4
|
+
|
|
5
|
+
const mockSetParams = jest.fn()
|
|
6
|
+
|
|
7
|
+
jest.mock('@react-navigation/native', () => ({
|
|
8
|
+
...jest.requireActual('@react-navigation/native'),
|
|
9
|
+
useNavigation: () => ({ setParams: mockSetParams }),
|
|
10
|
+
useRoute: () => ({
|
|
11
|
+
params: { chat_group_graph_id: 'Groups/Group/1', title: 'Waco Family Group' },
|
|
12
|
+
}),
|
|
13
|
+
}))
|
|
14
|
+
|
|
15
|
+
jest.mock('../../../../hooks/use_api', () => ({
|
|
16
|
+
useApiGet: () => ({ data: { name: 'Waco Family Group' } }),
|
|
17
|
+
}))
|
|
18
|
+
|
|
19
|
+
describe('ChatGroupBadge', () => {
|
|
20
|
+
it('clears the group filter and its title when dismissed', () => {
|
|
21
|
+
const view = render(<ChatGroupBadge rowPaddingHorizontal={16} />)
|
|
22
|
+
|
|
23
|
+
fireEvent.press(view.getByText('Waco Family Group'))
|
|
24
|
+
|
|
25
|
+
expect(mockSetParams).toHaveBeenCalledTimes(1)
|
|
26
|
+
expect(mockSetParams.mock.calls[0][0]).toStrictEqual({
|
|
27
|
+
title: undefined,
|
|
28
|
+
chat_group_graph_id: undefined,
|
|
29
|
+
group_source_app_name: undefined,
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { fireEvent, render } from '@testing-library/react-native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { ListHeaderComponent } from '../list_header_component'
|
|
4
|
+
|
|
5
|
+
const mockSetParams = jest.fn()
|
|
6
|
+
|
|
7
|
+
jest.mock('@react-navigation/native', () => ({
|
|
8
|
+
...jest.requireActual('@react-navigation/native'),
|
|
9
|
+
useNavigation: () => ({ setParams: mockSetParams, navigate: jest.fn() }),
|
|
10
|
+
useRoute: () => ({
|
|
11
|
+
params: { chat_group_graph_id: 'Groups/Group/1', title: 'Waco Family Group' },
|
|
12
|
+
}),
|
|
13
|
+
}))
|
|
14
|
+
|
|
15
|
+
jest.mock('../../../../hooks/use_groups', () => ({
|
|
16
|
+
useCanDisplayGroups: () => true,
|
|
17
|
+
}))
|
|
18
|
+
jest.mock('../../../../hooks/use_direct_messages_eligible', () => ({
|
|
19
|
+
useDirectMessagesEligible: () => true,
|
|
20
|
+
}))
|
|
21
|
+
jest.mock('../../../../hooks/use_has_direct_messages', () => ({
|
|
22
|
+
useHasDirectMessages: () => true,
|
|
23
|
+
}))
|
|
24
|
+
jest.mock('../../../../hooks/use_chat_permissions', () => ({
|
|
25
|
+
useCanCreateConversations: () => false,
|
|
26
|
+
}))
|
|
27
|
+
jest.mock('../../../../hooks/use_new_conversation_entry', () => ({
|
|
28
|
+
useNewConversationEntry: () => 'select_type',
|
|
29
|
+
}))
|
|
30
|
+
jest.mock('../../../../hooks/use_current_person', () => ({
|
|
31
|
+
useCurrentPersonCache: () => ({ update: jest.fn() }),
|
|
32
|
+
}))
|
|
33
|
+
jest.mock('../../../../hooks/use_conversations_actions', () => ({
|
|
34
|
+
useMarkAllRead: () => ({ markAllRead: jest.fn(), isPending: false }),
|
|
35
|
+
}))
|
|
36
|
+
jest.mock('../../../../hooks/use_new_conversation_from_filter', () => ({
|
|
37
|
+
useNewConversationFromFilter: () => undefined,
|
|
38
|
+
}))
|
|
39
|
+
jest.mock('../../../../hooks/use_api', () => ({
|
|
40
|
+
useApiGet: () => ({ data: undefined }),
|
|
41
|
+
}))
|
|
42
|
+
|
|
43
|
+
const clearedFilter = {
|
|
44
|
+
title: undefined,
|
|
45
|
+
chat_group_graph_id: undefined,
|
|
46
|
+
group_source_app_name: undefined,
|
|
47
|
+
show_direct_messages: undefined,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
describe('ListHeaderComponent filter toggles', () => {
|
|
51
|
+
beforeEach(() => mockSetParams.mockClear())
|
|
52
|
+
|
|
53
|
+
it.each([
|
|
54
|
+
['Show all conversations', clearedFilter],
|
|
55
|
+
['Filter to group conversations', { ...clearedFilter, group_source_app_name: 'Groups' }],
|
|
56
|
+
['Filter to team conversations', { ...clearedFilter, group_source_app_name: 'Services' }],
|
|
57
|
+
['Filter to direct message conversations', { ...clearedFilter, show_direct_messages: true }],
|
|
58
|
+
])('%s drops the group title along with the group filter', (label, expected) => {
|
|
59
|
+
const view = render(<ListHeaderComponent />)
|
|
60
|
+
|
|
61
|
+
fireEvent.press(view.getByLabelText(label))
|
|
62
|
+
|
|
63
|
+
expect(mockSetParams).toHaveBeenCalledTimes(1)
|
|
64
|
+
expect(mockSetParams.mock.calls[0][0]).toStrictEqual(expected)
|
|
65
|
+
})
|
|
66
|
+
})
|
|
@@ -17,6 +17,7 @@ import { useNewConversationFromFilter } from '../../../hooks/use_new_conversatio
|
|
|
17
17
|
import { GraphId } from '../../../types/resources/group_resource'
|
|
18
18
|
import { MAX_FONT_SIZE_MULTIPLIER_LANDMARK } from '../../../utils'
|
|
19
19
|
import { Haptic } from '../../../utils/native_adapters'
|
|
20
|
+
import { ConversationFiltersParams } from '../../conversation_filters/screen_props'
|
|
20
21
|
import { ConversationsScreenProps } from '../conversations_screen'
|
|
21
22
|
import { ChatGroupBadge } from './chat_group_badge'
|
|
22
23
|
import { ListHeaderActionButton } from './list_header_action_button'
|
|
@@ -96,6 +97,19 @@ export const ListHeaderComponent = () => {
|
|
|
96
97
|
}
|
|
97
98
|
}, [navigation, route.params, entryMode, newConversationFromFilter])
|
|
98
99
|
|
|
100
|
+
const handleSetFilter = useCallback(
|
|
101
|
+
(params: ConversationFiltersParams) => {
|
|
102
|
+
navigation.setParams({
|
|
103
|
+
title: undefined,
|
|
104
|
+
chat_group_graph_id: undefined,
|
|
105
|
+
group_source_app_name: undefined,
|
|
106
|
+
show_direct_messages: undefined,
|
|
107
|
+
...params,
|
|
108
|
+
})
|
|
109
|
+
},
|
|
110
|
+
[navigation]
|
|
111
|
+
)
|
|
112
|
+
|
|
99
113
|
const handleChatSettings = useCallback(() => {
|
|
100
114
|
navigation.navigate('ChatSettings', {})
|
|
101
115
|
}, [navigation])
|
|
@@ -187,13 +201,7 @@ export const ListHeaderComponent = () => {
|
|
|
187
201
|
<ToggleButton
|
|
188
202
|
title={FilterTypes.All}
|
|
189
203
|
active={active === FilterTypes.All}
|
|
190
|
-
onPress={() =>
|
|
191
|
-
navigation.setParams({
|
|
192
|
-
chat_group_graph_id: undefined,
|
|
193
|
-
group_source_app_name: undefined,
|
|
194
|
-
show_direct_messages: undefined,
|
|
195
|
-
})
|
|
196
|
-
}
|
|
204
|
+
onPress={() => handleSetFilter({})}
|
|
197
205
|
accessibilityLabel="Show all conversations"
|
|
198
206
|
style={styles.filterButton}
|
|
199
207
|
/>
|
|
@@ -201,13 +209,7 @@ export const ListHeaderComponent = () => {
|
|
|
201
209
|
<ToggleButton
|
|
202
210
|
title={FilterTypes.Groups}
|
|
203
211
|
active={active === FilterTypes.Groups}
|
|
204
|
-
onPress={() =>
|
|
205
|
-
navigation.setParams({
|
|
206
|
-
chat_group_graph_id: undefined,
|
|
207
|
-
group_source_app_name: 'Groups',
|
|
208
|
-
show_direct_messages: undefined,
|
|
209
|
-
})
|
|
210
|
-
}
|
|
212
|
+
onPress={() => handleSetFilter({ group_source_app_name: 'Groups' })}
|
|
211
213
|
accessibilityLabel="Filter to group conversations"
|
|
212
214
|
style={styles.filterButton}
|
|
213
215
|
/>
|
|
@@ -216,13 +218,7 @@ export const ListHeaderComponent = () => {
|
|
|
216
218
|
<ToggleButton
|
|
217
219
|
title={FilterTypes.Teams}
|
|
218
220
|
active={active === FilterTypes.Teams}
|
|
219
|
-
onPress={() =>
|
|
220
|
-
navigation.setParams({
|
|
221
|
-
chat_group_graph_id: undefined,
|
|
222
|
-
group_source_app_name: 'Services',
|
|
223
|
-
show_direct_messages: undefined,
|
|
224
|
-
})
|
|
225
|
-
}
|
|
221
|
+
onPress={() => handleSetFilter({ group_source_app_name: 'Services' })}
|
|
226
222
|
accessibilityLabel="Filter to team conversations"
|
|
227
223
|
style={styles.filterButton}
|
|
228
224
|
/>
|
|
@@ -231,13 +227,7 @@ export const ListHeaderComponent = () => {
|
|
|
231
227
|
<ToggleButton
|
|
232
228
|
title={FilterTypes.DMs}
|
|
233
229
|
active={active === FilterTypes.DMs}
|
|
234
|
-
onPress={() =>
|
|
235
|
-
navigation.setParams({
|
|
236
|
-
chat_group_graph_id: undefined,
|
|
237
|
-
group_source_app_name: undefined,
|
|
238
|
-
show_direct_messages: true,
|
|
239
|
-
})
|
|
240
|
-
}
|
|
230
|
+
onPress={() => handleSetFilter({ show_direct_messages: true })}
|
|
241
231
|
accessibilityLabel="Filter to direct message conversations"
|
|
242
232
|
style={styles.filterButton}
|
|
243
233
|
/>
|