@planningcenter/chat-react-native 4.8.0-qa-staging.8 → 4.8.0-qa-staging.10
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/contexts/session_context.d.ts +0 -1
- package/build/contexts/session_context.d.ts.map +1 -1
- package/build/contexts/session_context.js.map +1 -1
- package/build/utils/theme.js +20 -21
- package/build/utils/theme.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/contexts/session_context.tsx +19 -39
- package/src/__tests__/hooks/useTheme.tsx +0 -7
- package/src/__tests__/hooks/use_async_storage.test.tsx +1 -87
- package/src/__tests__/hooks/use_attachment_uploader.test.tsx +0 -11
- package/src/__tests__/hooks/use_font_scale.test.ts +0 -25
- package/src/__tests__/utils/cache/page_mutations.ts +3 -68
- package/src/__tests__/utils/client.ts +6 -15
- package/src/__tests__/utils/native_adapters/configuration.ts +15 -50
- package/src/__tests__/utils/parse_simple_markdown.ts +0 -6
- package/src/__tests__/utils/session.ts +0 -11
- package/src/__tests__/utils/theme.ts +0 -17
- package/src/components/conversations/__tests__/conversations.test.tsx +4 -1
- package/src/components/display/__tests__/filter_dropdown.test.tsx +1 -19
- package/src/components/display/__tests__/icon_tile.test.tsx +24 -7
- package/src/components/page/__tests__/component_error_boundary.test.tsx +0 -12
- package/src/contexts/session_context.tsx +0 -1
- package/src/hooks/__tests__/jolt_refresh_throttling.test.tsx +0 -35
- package/src/screens/__tests__/conversation_details_screen.test.tsx +0 -19
- package/src/screens/avatar_picker/__tests__/avatar_picker_state.test.ts +0 -14
- package/src/screens/conversations/__tests__/conversations_screen.test.tsx +0 -6
- package/src/screens/conversations/components/__tests__/filter_dropdown_list_header_component.test.tsx +0 -8
- package/src/screens/conversations/components/__tests__/search_list_header_component.test.tsx +0 -10
- package/src/screens/search/components/__tests__/search_results_list.test.tsx +1 -0
- package/src/utils/__tests__/attachment_kind.test.ts +0 -4
- package/src/utils/__tests__/convert_attachments_for_create.test.ts +0 -28
- package/src/utils/__tests__/is_input_editable.test.ts +1 -2
- package/src/utils/__tests__/message_text.test.ts +0 -5
- package/src/utils/__tests__/session_manager.test.ts +0 -83
- package/src/utils/__tests__/sha_256.test.ts +0 -34
- package/src/utils/__tests__/uri.test.ts +51 -0
- package/src/utils/theme.ts +20 -21
- package/src/__tests__/event-polyfill.test.ts +0 -313
- package/src/__tests__/index.tsx +0 -5
- package/src/__tests__/jest.ts +0 -11
- package/src/__tests__/utils/uri.ts +0 -65
- package/src/components/display/__tests__/version_footer.test.tsx +0 -48
- package/src/screens/search/components/__tests__/search_blank_states.test.tsx +0 -20
- package/src/utils/__tests__/membership_sync_info_text.test.ts +0 -15
|
@@ -127,75 +127,8 @@ describe('updateOrCreateRecordInPagesData', () => {
|
|
|
127
127
|
],
|
|
128
128
|
})
|
|
129
129
|
})
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
describe('updateOrCreateRecordInPagesData function', () => {
|
|
133
|
-
it('should update the record in the pages data', () => {
|
|
134
|
-
const id = '3'
|
|
135
|
-
const record = createRecord({ id })
|
|
136
|
-
const result = updateOrCreateRecordInPagesData({ data, record })
|
|
137
|
-
|
|
138
|
-
expect(result).toEqual({
|
|
139
|
-
pageParams: {},
|
|
140
|
-
pages: [
|
|
141
|
-
{
|
|
142
|
-
data: [
|
|
143
|
-
{ id: '1', type: 'Message', text: 'message 1' },
|
|
144
|
-
{ id: '2', type: 'Message', text: 'message 2' },
|
|
145
|
-
],
|
|
146
|
-
included: [],
|
|
147
|
-
links: {},
|
|
148
|
-
meta: { count: 2, totalCount: 2 },
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
data: [
|
|
152
|
-
{ id: '3', type: 'Message', text: 'example 3' },
|
|
153
|
-
{ id: '4', type: 'Message', text: 'message 4' },
|
|
154
|
-
],
|
|
155
|
-
included: [],
|
|
156
|
-
links: {},
|
|
157
|
-
meta: { count: 2, totalCount: 2 },
|
|
158
|
-
},
|
|
159
|
-
],
|
|
160
|
-
})
|
|
161
|
-
})
|
|
162
130
|
|
|
163
|
-
it('should
|
|
164
|
-
const id = '2'
|
|
165
|
-
const record = createRecord({ id })
|
|
166
|
-
|
|
167
|
-
const result = updateOrCreateRecordInPagesData<typeof record>({
|
|
168
|
-
data,
|
|
169
|
-
record,
|
|
170
|
-
processRecord: r => ({ ...r, text: 'updated ' + r.text }),
|
|
171
|
-
})
|
|
172
|
-
|
|
173
|
-
expect(result).toEqual({
|
|
174
|
-
pageParams: {},
|
|
175
|
-
pages: [
|
|
176
|
-
{
|
|
177
|
-
data: [
|
|
178
|
-
{ id: '1', type: 'Message', text: 'message 1' },
|
|
179
|
-
{ id, type: 'Message', text: `updated example ${id}` },
|
|
180
|
-
],
|
|
181
|
-
included: [],
|
|
182
|
-
links: {},
|
|
183
|
-
meta: { count: 2, totalCount: 2 },
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
data: [
|
|
187
|
-
{ id: '3', type: 'Message', text: 'message 3' },
|
|
188
|
-
{ id: '4', type: 'Message', text: 'message 4' },
|
|
189
|
-
],
|
|
190
|
-
included: [],
|
|
191
|
-
links: {},
|
|
192
|
-
meta: { count: 2, totalCount: 2 },
|
|
193
|
-
},
|
|
194
|
-
],
|
|
195
|
-
})
|
|
196
|
-
})
|
|
197
|
-
|
|
198
|
-
it('should add records that do not yet exist, but does not run processRecord', () => {
|
|
131
|
+
it('should add records that do not yet exist and run processRecord on them', () => {
|
|
199
132
|
const id = '5'
|
|
200
133
|
const record = createRecord({ id })
|
|
201
134
|
|
|
@@ -230,7 +163,9 @@ describe('updateOrCreateRecordInPagesData function', () => {
|
|
|
230
163
|
],
|
|
231
164
|
})
|
|
232
165
|
})
|
|
166
|
+
})
|
|
233
167
|
|
|
168
|
+
describe('updateRecordInPagesData', () => {
|
|
234
169
|
it('should skip the record if it does not exist', () => {
|
|
235
170
|
const id = '5'
|
|
236
171
|
const record = createRecord({ id })
|
|
@@ -65,6 +65,12 @@ describe('get', () => {
|
|
|
65
65
|
})
|
|
66
66
|
|
|
67
67
|
it('respects opting out of pagination walks', async () => {
|
|
68
|
+
const nextUrl = APP_BASE_URL + '/records?fields%5BRecord%5D=id&per_page=1&offset=1'
|
|
69
|
+
|
|
70
|
+
MockServer.get(url, { ...DefaultFixtures.records(), links: { next: nextUrl } }, 200, {
|
|
71
|
+
once: true,
|
|
72
|
+
})
|
|
73
|
+
|
|
68
74
|
await client.get({
|
|
69
75
|
url,
|
|
70
76
|
data: { fields: { Record: ['id', 'name'] }, perPage: 1, walk: false },
|
|
@@ -230,9 +236,6 @@ describe('post', () => {
|
|
|
230
236
|
})
|
|
231
237
|
|
|
232
238
|
it('uses client default headers', async () => {
|
|
233
|
-
MockServer.post('https://api-staging.planningcenteronline.com/chat/v2/records/:id', {}, 200, {
|
|
234
|
-
once: true,
|
|
235
|
-
})
|
|
236
239
|
await clientWithDefaultHeaders.post({
|
|
237
240
|
url,
|
|
238
241
|
data: { fields: { Record: 'id' } },
|
|
@@ -283,9 +286,6 @@ describe('patch', () => {
|
|
|
283
286
|
})
|
|
284
287
|
|
|
285
288
|
it('uses client default headers', async () => {
|
|
286
|
-
MockServer.patch('https://api-staging.planningcenteronline.com/chat/v2/records/:id', {}, 200, {
|
|
287
|
-
once: true,
|
|
288
|
-
})
|
|
289
289
|
await clientWithDefaultHeaders.patch({
|
|
290
290
|
url,
|
|
291
291
|
data: { fields: { Record: 'id' } },
|
|
@@ -318,15 +318,6 @@ describe('delete', () => {
|
|
|
318
318
|
})
|
|
319
319
|
|
|
320
320
|
it('uses client default headers', async () => {
|
|
321
|
-
MockServer.delete(
|
|
322
|
-
'https://api-staging.planningcenteronline.com/chat/v2/records/:id',
|
|
323
|
-
undefined,
|
|
324
|
-
200,
|
|
325
|
-
{
|
|
326
|
-
once: true,
|
|
327
|
-
}
|
|
328
|
-
)
|
|
329
|
-
|
|
330
321
|
await clientWithDefaultHeaders.delete({
|
|
331
322
|
url,
|
|
332
323
|
headers: { 'X-Custom-Header': 'value!' },
|
|
@@ -54,10 +54,6 @@ describe('ChatAdapters', () => {
|
|
|
54
54
|
notificationError: jest.fn(),
|
|
55
55
|
})
|
|
56
56
|
|
|
57
|
-
it('should be defined', () => {
|
|
58
|
-
expect(ChatAdapters).toBeDefined()
|
|
59
|
-
})
|
|
60
|
-
|
|
61
57
|
it('should configure the clipboard', () => {
|
|
62
58
|
ChatAdapters.configure({
|
|
63
59
|
clipboard,
|
|
@@ -71,42 +67,30 @@ describe('ChatAdapters', () => {
|
|
|
71
67
|
})
|
|
72
68
|
|
|
73
69
|
describe('linking adapter', () => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
ChatAdapters.configure({
|
|
77
|
-
clipboard,
|
|
78
|
-
audio,
|
|
79
|
-
video,
|
|
80
|
-
imagePicker,
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
expect(Linking).toBeDefined()
|
|
84
|
-
expect(Linking.openURL).toBeDefined()
|
|
85
|
-
expect(Linking.canOpenURL).toBeDefined()
|
|
86
|
-
})
|
|
70
|
+
it('opens URLs through React Native Linking by default', async () => {
|
|
71
|
+
ChatAdapters.configure({ clipboard, audio, video, imagePicker })
|
|
87
72
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
})
|
|
73
|
+
await Linking.openURL('https://www.google.com')
|
|
74
|
+
|
|
75
|
+
expect(RNLinking.openURL).toHaveBeenCalledWith('https://www.google.com')
|
|
92
76
|
})
|
|
93
77
|
|
|
94
|
-
|
|
78
|
+
it('calls the host methods bound to React Native Linking', async () => {
|
|
79
|
+
const receivers: unknown[] = []
|
|
95
80
|
const linking = new LinkingAdapter({
|
|
96
|
-
openURL: async function (
|
|
97
|
-
|
|
98
|
-
expect(this).toBe(RNLinking)
|
|
81
|
+
openURL: async function (this: unknown) {
|
|
82
|
+
receivers.push(this)
|
|
99
83
|
},
|
|
100
|
-
canOpenURL: async function (
|
|
101
|
-
|
|
102
|
-
expect(this).toBe(RNLinking)
|
|
103
|
-
|
|
84
|
+
canOpenURL: async function (this: unknown) {
|
|
85
|
+
receivers.push(this)
|
|
104
86
|
return true
|
|
105
87
|
},
|
|
106
88
|
})
|
|
107
89
|
|
|
108
|
-
linking.openURL('https://www.google.com')
|
|
109
|
-
linking.canOpenURL('https://www.google.com')
|
|
90
|
+
await linking.openURL('https://www.google.com')
|
|
91
|
+
await linking.canOpenURL('https://www.google.com')
|
|
92
|
+
|
|
93
|
+
expect(receivers).toEqual([RNLinking, RNLinking])
|
|
110
94
|
})
|
|
111
95
|
})
|
|
112
96
|
|
|
@@ -157,24 +141,5 @@ describe('ChatAdapters', () => {
|
|
|
157
141
|
|
|
158
142
|
expect(Haptic).toEqual(haptic)
|
|
159
143
|
})
|
|
160
|
-
|
|
161
|
-
it('should be configured with defaults', () => {
|
|
162
|
-
ChatAdapters.configure({
|
|
163
|
-
clipboard,
|
|
164
|
-
audio,
|
|
165
|
-
video,
|
|
166
|
-
imagePicker,
|
|
167
|
-
})
|
|
168
|
-
|
|
169
|
-
expect(Haptic).toBeDefined()
|
|
170
|
-
expect(Haptic.impactLight).toBeDefined()
|
|
171
|
-
expect(Haptic.impactMedium).toBeDefined()
|
|
172
|
-
expect(Haptic.impactHeavy).toBeDefined()
|
|
173
|
-
expect(Haptic.rigid).toBeDefined()
|
|
174
|
-
expect(Haptic.soft).toBeDefined()
|
|
175
|
-
expect(Haptic.notificationSuccess).toBeDefined()
|
|
176
|
-
expect(Haptic.notificationWarning).toBeDefined()
|
|
177
|
-
expect(Haptic.notificationError).toBeDefined()
|
|
178
|
-
})
|
|
179
144
|
})
|
|
180
145
|
})
|
|
@@ -51,12 +51,6 @@ describe('parseSimpleMarkdown', () => {
|
|
|
51
51
|
expect(result).toEqual([{ type: 'text', content: '* Item 1\n* Item 2\n* Item 3' }])
|
|
52
52
|
})
|
|
53
53
|
|
|
54
|
-
it('parses ordered lists correctly', () => {
|
|
55
|
-
const input = '1. Item 1\n2. Item 2\n3. Item 3'
|
|
56
|
-
const result = parseSimpleMarkdown(input)
|
|
57
|
-
expect(result).toEqual([{ type: 'text', content: '1. Item 1\n2. Item 2\n3. Item 3' }])
|
|
58
|
-
})
|
|
59
|
-
|
|
60
54
|
it('handles plain text without formatting', () => {
|
|
61
55
|
const input = 'Just plain text'
|
|
62
56
|
const result = parseSimpleMarkdown(input)
|
|
@@ -37,17 +37,6 @@ describe('Session', () => {
|
|
|
37
37
|
expect(hydratedSession.token).toEqual(token)
|
|
38
38
|
expect(hydratedSession.isAuthenticated).toEqual(true)
|
|
39
39
|
})
|
|
40
|
-
|
|
41
|
-
it('should store the environment of hydrated Session instance', () => {
|
|
42
|
-
const env = 'production'
|
|
43
|
-
const session = new Session({ token, env })
|
|
44
|
-
|
|
45
|
-
const sessionString = session.toString()
|
|
46
|
-
const hydratedSession = Session.hydrate(sessionString)
|
|
47
|
-
expect(hydratedSession.env).toEqual(env)
|
|
48
|
-
expect(hydratedSession.token).toEqual(token)
|
|
49
|
-
expect(hydratedSession.isAuthenticated).toEqual(true)
|
|
50
|
-
})
|
|
51
40
|
})
|
|
52
41
|
|
|
53
42
|
describe('failure', () => {
|
|
@@ -10,10 +10,6 @@ describe('defaultTheme', () => {
|
|
|
10
10
|
expect(defaultTheme('light').colors).toMatchObject(aliasTokensColorMap.light)
|
|
11
11
|
})
|
|
12
12
|
|
|
13
|
-
test('falls back to the light palette when colorScheme is null', () => {
|
|
14
|
-
expect(defaultTheme(null).colors).toMatchObject(aliasTokensColorMap.light)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
13
|
test('falls back to the light palette for React Native 0.83\'s "unspecified" variant', () => {
|
|
18
14
|
// RN 0.83 added "unspecified" to ColorSchemeName. Anything that is not
|
|
19
15
|
// literally "dark" should fall through to the light palette so we never
|
|
@@ -22,19 +18,6 @@ describe('defaultTheme', () => {
|
|
|
22
18
|
})
|
|
23
19
|
|
|
24
20
|
describe('chip tokens', () => {
|
|
25
|
-
test('seeds static defaults for the non-selected chip trio in both schemes', () => {
|
|
26
|
-
const light = defaultTheme('light').colors
|
|
27
|
-
const dark = defaultTheme('dark').colors
|
|
28
|
-
|
|
29
|
-
expect(light.borderColorChip).toBe('hsl(0, 0%, 88%)')
|
|
30
|
-
expect(light.fillColorChip).toBe('transparent')
|
|
31
|
-
expect(light.textColorChip).toBe('hsl(0, 0%, 45%)')
|
|
32
|
-
|
|
33
|
-
expect(dark.borderColorChip).toBe('hsl(0, 0%, 24%)')
|
|
34
|
-
expect(dark.fillColorChip).toBe('transparent')
|
|
35
|
-
expect(dark.textColorChip).toBe('hsl(0, 0%, 68%)')
|
|
36
|
-
})
|
|
37
|
-
|
|
38
21
|
test('never seeds a static default for the selected chip trio', () => {
|
|
39
22
|
const { colors } = defaultTheme('light')
|
|
40
23
|
|
|
@@ -58,12 +58,15 @@ describe('Conversations archived footer', () => {
|
|
|
58
58
|
|
|
59
59
|
fireEvent.press(view.getByLabelText('View active conversations'))
|
|
60
60
|
|
|
61
|
-
expect(mockSetParams).
|
|
61
|
+
expect(mockSetParams).toHaveBeenCalledTimes(1)
|
|
62
|
+
expect(mockSetParams.mock.calls[0][0]).toStrictEqual({
|
|
62
63
|
title: undefined,
|
|
63
64
|
chat_group_graph_id: undefined,
|
|
64
65
|
group_source_app_name: undefined,
|
|
65
66
|
show_direct_messages: undefined,
|
|
66
67
|
show_archived: undefined,
|
|
68
|
+
show_hidden: undefined,
|
|
69
|
+
show_unread: undefined,
|
|
67
70
|
})
|
|
68
71
|
})
|
|
69
72
|
|
|
@@ -62,7 +62,7 @@ const options = [
|
|
|
62
62
|
{ id: 'teams', label: 'Teams' },
|
|
63
63
|
]
|
|
64
64
|
|
|
65
|
-
const renderFilterDropdown = (
|
|
65
|
+
const renderFilterDropdown = () => {
|
|
66
66
|
const onSelect = jest.fn()
|
|
67
67
|
const onMoreFilters = jest.fn()
|
|
68
68
|
|
|
@@ -73,7 +73,6 @@ const renderFilterDropdown = ({ showMoreFilters }: { showMoreFilters?: boolean }
|
|
|
73
73
|
onSelect={onSelect}
|
|
74
74
|
onMoreFilters={onMoreFilters}
|
|
75
75
|
triggerLabel="Groups"
|
|
76
|
-
showMoreFilters={showMoreFilters}
|
|
77
76
|
/>
|
|
78
77
|
)
|
|
79
78
|
|
|
@@ -81,16 +80,6 @@ const renderFilterDropdown = ({ showMoreFilters }: { showMoreFilters?: boolean }
|
|
|
81
80
|
}
|
|
82
81
|
|
|
83
82
|
describe('FilterDropdown', () => {
|
|
84
|
-
it('hands the menu every option, the selected one checked, then More filters', () => {
|
|
85
|
-
renderFilterDropdown()
|
|
86
|
-
|
|
87
|
-
expect(screen.getByRole('button', { name: 'Groups' })).toBeTruthy()
|
|
88
|
-
expect(
|
|
89
|
-
screen.getAllByRole('menuitem').map(item => [item.props.accessibilityState.selected])
|
|
90
|
-
).toEqual([[false], [true], [false], [false]])
|
|
91
|
-
expect(screen.getByRole('menuitem', { name: 'More filters' })).toBeTruthy()
|
|
92
|
-
})
|
|
93
|
-
|
|
94
83
|
it('calls onSelect with the id of the pressed option', () => {
|
|
95
84
|
const { onSelect, onMoreFilters } = renderFilterDropdown()
|
|
96
85
|
|
|
@@ -100,13 +89,6 @@ describe('FilterDropdown', () => {
|
|
|
100
89
|
expect(onMoreFilters).not.toHaveBeenCalled()
|
|
101
90
|
})
|
|
102
91
|
|
|
103
|
-
it('leaves More filters out when showMoreFilters is false', () => {
|
|
104
|
-
renderFilterDropdown({ showMoreFilters: false })
|
|
105
|
-
|
|
106
|
-
expect(screen.queryByRole('menuitem', { name: 'More filters' })).toBeNull()
|
|
107
|
-
expect(screen.getAllByRole('menuitem')).toHaveLength(options.length)
|
|
108
|
-
})
|
|
109
|
-
|
|
110
92
|
it('calls onMoreFilters for the More filters action', () => {
|
|
111
93
|
const { onSelect, onMoreFilters } = renderFilterDropdown()
|
|
112
94
|
|
|
@@ -1,16 +1,33 @@
|
|
|
1
1
|
import { render } from '@testing-library/react-native'
|
|
2
2
|
import React from 'react'
|
|
3
|
+
import { StyleSheet } from 'react-native'
|
|
3
4
|
import { faBoxArchive } from '../../../vendor/font_awesome_pro_solid_icons'
|
|
4
5
|
import { IconTile } from '../icon_tile'
|
|
5
6
|
|
|
7
|
+
const clippingAncestors = (shape: 'circle' | 'square') => {
|
|
8
|
+
const view = render(
|
|
9
|
+
<IconTile icon={faBoxArchive} shape={shape} maxFontSizeMultiplier={1} testID="tile" />
|
|
10
|
+
)
|
|
11
|
+
const ancestors = []
|
|
12
|
+
let node = view.getByTestId('tile', { includeHiddenElements: true }).parent
|
|
13
|
+
while (node) {
|
|
14
|
+
ancestors.push(node)
|
|
15
|
+
node = node.parent
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return ancestors.filter(
|
|
19
|
+
ancestor =>
|
|
20
|
+
typeof ancestor.type === 'string' &&
|
|
21
|
+
StyleSheet.flatten(ancestor.props.style)?.overflow === 'hidden'
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
6
25
|
describe('IconTile', () => {
|
|
7
|
-
it('
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
)
|
|
26
|
+
it('masks a circle tile', () => {
|
|
27
|
+
expect(clippingAncestors('circle')).not.toHaveLength(0)
|
|
28
|
+
})
|
|
11
29
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
})
|
|
30
|
+
it('keeps a square tile out of the circular mask', () => {
|
|
31
|
+
expect(clippingAncestors('square')).toHaveLength(0)
|
|
15
32
|
})
|
|
16
33
|
})
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { render } from '@testing-library/react-native'
|
|
2
2
|
import React from 'react'
|
|
3
|
-
import { Text } from 'react-native'
|
|
4
3
|
import { Log } from '../../../utils/native_adapters/configuration'
|
|
5
4
|
import { ComponentErrorBoundary } from '../component_error_boundary'
|
|
6
5
|
|
|
@@ -32,15 +31,4 @@ describe('ComponentErrorBoundary', () => {
|
|
|
32
31
|
expect(toJSON()).toBeNull()
|
|
33
32
|
expect(reportError.mock.calls[0][1]).toMatchObject({ scope: 'component' })
|
|
34
33
|
})
|
|
35
|
-
|
|
36
|
-
it('lets callers override the defaults', () => {
|
|
37
|
-
const { getByText } = render(
|
|
38
|
-
<ComponentErrorBoundary scope="screen" fallback={<Text>overridden</Text>}>
|
|
39
|
-
<Boom thrown={new Error('boom')} />
|
|
40
|
-
</ComponentErrorBoundary>
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
expect(getByText('overridden')).toBeTruthy()
|
|
44
|
-
expect(reportError.mock.calls[0][1]).toMatchObject({ scope: 'screen' })
|
|
45
|
-
})
|
|
46
34
|
})
|
|
@@ -155,41 +155,6 @@ describe('conversation.updated across two lists and two screens', () => {
|
|
|
155
155
|
expect(requestsFor(listUrl)).toBe(2)
|
|
156
156
|
expect(requestsFor(conversationUrl)).toBe(2)
|
|
157
157
|
})
|
|
158
|
-
|
|
159
|
-
it('refreshes immediately for a lone event and makes no second request', async () => {
|
|
160
|
-
conversationUpdated()
|
|
161
|
-
await advance(1)
|
|
162
|
-
|
|
163
|
-
expect(requestsFor(listUrl)).toBe(1)
|
|
164
|
-
expect(requestsFor(conversationUrl)).toBe(1)
|
|
165
|
-
|
|
166
|
-
await advance(REFRESH_THROTTLE_MS * 2)
|
|
167
|
-
|
|
168
|
-
expect(requestsFor(listUrl)).toBe(1)
|
|
169
|
-
expect(requestsFor(conversationUrl)).toBe(1)
|
|
170
|
-
})
|
|
171
|
-
|
|
172
|
-
it('gives an event inside the window a trailing refresh opened its own trailing refresh', async () => {
|
|
173
|
-
conversationUpdated()
|
|
174
|
-
await advance(1000)
|
|
175
|
-
conversationUpdated()
|
|
176
|
-
await advance(REFRESH_THROTTLE_MS - 1000)
|
|
177
|
-
|
|
178
|
-
expect(requestsFor(listUrl)).toBe(2)
|
|
179
|
-
expect(requestsFor(conversationUrl)).toBe(2)
|
|
180
|
-
|
|
181
|
-
await advance(500)
|
|
182
|
-
conversationUpdated()
|
|
183
|
-
await advance(1)
|
|
184
|
-
|
|
185
|
-
expect(requestsFor(listUrl)).toBe(2)
|
|
186
|
-
expect(requestsFor(conversationUrl)).toBe(2)
|
|
187
|
-
|
|
188
|
-
await advance(REFRESH_THROTTLE_MS)
|
|
189
|
-
|
|
190
|
-
expect(requestsFor(listUrl)).toBe(3)
|
|
191
|
-
expect(requestsFor(conversationUrl)).toBe(3)
|
|
192
|
-
})
|
|
193
158
|
})
|
|
194
159
|
|
|
195
160
|
describe('/me refreshes', () => {
|
|
@@ -257,16 +257,6 @@ describe('ConversationDetailsScreen archive', () => {
|
|
|
257
257
|
expect(queryByText('Archive conversation…')).toBeNull()
|
|
258
258
|
})
|
|
259
259
|
|
|
260
|
-
it.each(['QA_MOBILE_manual_archiving', 'ROLLOUT_MOBILE_manual_archiving'])(
|
|
261
|
-
'offers archiving with only %s on',
|
|
262
|
-
flag => {
|
|
263
|
-
mockEnabledFeatures = [flag]
|
|
264
|
-
const { getByText } = renderScreen()
|
|
265
|
-
|
|
266
|
-
expect(getByText('Archive conversation…')).toBeTruthy()
|
|
267
|
-
}
|
|
268
|
-
)
|
|
269
|
-
|
|
270
260
|
it('hides archiving when neither mobile flag is on', () => {
|
|
271
261
|
mockEnabledFeatures = ['ROLLOUT_WEB_manual_archiving']
|
|
272
262
|
const { queryByText } = renderScreen()
|
|
@@ -299,15 +289,6 @@ describe('ConversationDetailsScreen archive', () => {
|
|
|
299
289
|
expect(mockNavigation.goBack).not.toHaveBeenCalled()
|
|
300
290
|
expect(mockNavigation.navigate).not.toHaveBeenCalled()
|
|
301
291
|
})
|
|
302
|
-
|
|
303
|
-
it('does nothing when the confirmation is cancelled', () => {
|
|
304
|
-
const { getByText } = renderScreen()
|
|
305
|
-
fireEvent.press(getByText('Archive conversation…'))
|
|
306
|
-
|
|
307
|
-
alertButton('Cancel')?.onPress?.()
|
|
308
|
-
|
|
309
|
-
expect(mockArchive).not.toHaveBeenCalled()
|
|
310
|
-
})
|
|
311
292
|
})
|
|
312
293
|
|
|
313
294
|
describe('ConversationDetailsScreen hide', () => {
|
|
@@ -10,20 +10,6 @@ import {
|
|
|
10
10
|
|
|
11
11
|
const emptyState = initEmptyAvatarPickerState()
|
|
12
12
|
|
|
13
|
-
describe('initEmptyAvatarPickerState', () => {
|
|
14
|
-
it('starts clean', () => {
|
|
15
|
-
expect(emptyState).toMatchObject({
|
|
16
|
-
activeTab: 'icon',
|
|
17
|
-
selectedType: null,
|
|
18
|
-
selectedKey: null,
|
|
19
|
-
selectedColor: DEFAULT_AVATAR_COLOR_KEY,
|
|
20
|
-
imagePreviewUri: null,
|
|
21
|
-
imageAsset: null,
|
|
22
|
-
isDirty: false,
|
|
23
|
-
})
|
|
24
|
-
})
|
|
25
|
-
})
|
|
26
|
-
|
|
27
13
|
describe('initAvatarPickerState', () => {
|
|
28
14
|
it('seeds from icon avatar', () => {
|
|
29
15
|
const conversation = {
|
|
@@ -116,12 +116,6 @@ describe('ConversationsScreen header gating', () => {
|
|
|
116
116
|
expect(await view.findByText('Filter dropdown header')).toBeTruthy()
|
|
117
117
|
})
|
|
118
118
|
|
|
119
|
-
it('shows the filter dropdown header with only its rollout flag on', async () => {
|
|
120
|
-
const view = renderWithFeatures(['ROLLOUT_MOBILE_filter_dropdown'])
|
|
121
|
-
|
|
122
|
-
expect(await view.findByText('Filter dropdown header')).toBeTruthy()
|
|
123
|
-
})
|
|
124
|
-
|
|
125
119
|
it('shows the default header with neither flag on', async () => {
|
|
126
120
|
const view = renderWithFeatures(['ROLLOUT_WEB_search'])
|
|
127
121
|
|
|
@@ -326,14 +326,6 @@ describe('FilterDropdownListHeaderComponent', () => {
|
|
|
326
326
|
)
|
|
327
327
|
})
|
|
328
328
|
|
|
329
|
-
it('More filters opens the filters sheet', () => {
|
|
330
|
-
render(<FilterDropdownListHeaderComponent />)
|
|
331
|
-
|
|
332
|
-
fireEvent.press(screen.getByRole('menuitem', { name: 'More filters' }))
|
|
333
|
-
|
|
334
|
-
expect(mockNavigate).toHaveBeenCalledWith('ConversationFilters', expect.any(Object))
|
|
335
|
-
})
|
|
336
|
-
|
|
337
329
|
it('More filters carries the Unread filter into the sheet', () => {
|
|
338
330
|
setRouteParams({ show_unread: true })
|
|
339
331
|
|
package/src/screens/conversations/components/__tests__/search_list_header_component.test.tsx
CHANGED
|
@@ -49,14 +49,4 @@ describe('SearchListHeaderComponent search button', () => {
|
|
|
49
49
|
expect(mockNavigate).toHaveBeenCalledTimes(1)
|
|
50
50
|
expect(mockNavigate).toHaveBeenCalledWith('Search')
|
|
51
51
|
})
|
|
52
|
-
|
|
53
|
-
it('renders the search button after the other actions', () => {
|
|
54
|
-
const view = render(<SearchListHeaderComponent />)
|
|
55
|
-
|
|
56
|
-
const buttons = view.getAllByRole('button').map(button => button.props.accessibilityLabel)
|
|
57
|
-
|
|
58
|
-
expect(buttons.indexOf('Search')).toBeGreaterThanOrEqual(0)
|
|
59
|
-
expect(buttons.indexOf('Search')).toBeGreaterThan(buttons.indexOf('Chat settings'))
|
|
60
|
-
expect(buttons.indexOf('Search')).toBeGreaterThan(buttons.indexOf('New conversation'))
|
|
61
|
-
})
|
|
62
52
|
})
|
|
@@ -81,6 +81,7 @@ describe('SearchResultsList', () => {
|
|
|
81
81
|
it('shows the no-results state with the term when nothing matches', () => {
|
|
82
82
|
const view = renderList({})
|
|
83
83
|
|
|
84
|
+
expect(view.getByText('No results')).toBeTruthy()
|
|
84
85
|
expect(view.getByText(/Nothing matches “potluck\.”/)).toBeTruthy()
|
|
85
86
|
})
|
|
86
87
|
|
|
@@ -4,12 +4,8 @@ describe('pickAttachmentPreviewKind', () => {
|
|
|
4
4
|
describe('with a usable MIME type', () => {
|
|
5
5
|
it.each([
|
|
6
6
|
['image/png', 'image'],
|
|
7
|
-
['image/jpeg', 'image'],
|
|
8
7
|
['video/mp4', 'video'],
|
|
9
|
-
['video/quicktime', 'video'],
|
|
10
8
|
['application/pdf', 'file'],
|
|
11
|
-
['text/plain', 'file'],
|
|
12
|
-
['application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'file'],
|
|
13
9
|
['', 'file'],
|
|
14
10
|
[undefined, 'file'],
|
|
15
11
|
])('classifies %p as %p', (input, expected) => {
|
|
@@ -144,32 +144,4 @@ describe('convertAttachmentsForCreate', () => {
|
|
|
144
144
|
expect(result).toHaveLength(1)
|
|
145
145
|
expect(result[0]).toEqual(expandedLinkAttachment)
|
|
146
146
|
})
|
|
147
|
-
|
|
148
|
-
it('converts mixed attachment types correctly', () => {
|
|
149
|
-
const messageAttachment: DenormalizedMessageAttachmentResourceForCreate = {
|
|
150
|
-
type: 'MessageAttachment',
|
|
151
|
-
id: 'msg-id',
|
|
152
|
-
file: {
|
|
153
|
-
uri: 'file://test.jpg',
|
|
154
|
-
name: 'test.jpg',
|
|
155
|
-
type: 'image/jpeg',
|
|
156
|
-
size: 1024,
|
|
157
|
-
},
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const expandedLinkAttachment: DenormalizedExpandedLinkAttachmentResource = {
|
|
161
|
-
type: 'ExpandedLink',
|
|
162
|
-
attributes: {
|
|
163
|
-
url: 'https://example.com',
|
|
164
|
-
title: 'Example Link',
|
|
165
|
-
},
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const result = convertAttachmentsForCreate([messageAttachment, expandedLinkAttachment])
|
|
169
|
-
|
|
170
|
-
expect(result).toHaveLength(2)
|
|
171
|
-
expect(result[0].type).toBe('MessageAttachment')
|
|
172
|
-
expect(result[1].type).toBe('ExpandedLink')
|
|
173
|
-
expect(result[1]).toEqual(expandedLinkAttachment)
|
|
174
|
-
})
|
|
175
147
|
})
|
|
@@ -7,8 +7,7 @@ const base = {
|
|
|
7
7
|
|
|
8
8
|
describe('isInputEditable', () => {
|
|
9
9
|
it.each([
|
|
10
|
-
['active conversation
|
|
11
|
-
['active conversation with text', base, true],
|
|
10
|
+
['active conversation', base, true],
|
|
12
11
|
['pending request locks input', { ...base, isPending: true }, false],
|
|
13
12
|
['disabled conversation locks input', { ...base, conversationDisabled: true }, false],
|
|
14
13
|
])('%s', (_label, args, expected) => {
|
|
@@ -37,9 +37,4 @@ describe('hasMessageText', () => {
|
|
|
37
37
|
])('%s -> %s', (_name, input, expected) => {
|
|
38
38
|
expect(hasMessageText(input)).toBe(expected)
|
|
39
39
|
})
|
|
40
|
-
|
|
41
|
-
it('is not fooled by trim alone, which does not treat the character as whitespace', () => {
|
|
42
|
-
expect(EMPTY.trim()).toBe(EMPTY)
|
|
43
|
-
expect(hasMessageText(EMPTY)).toBe(false)
|
|
44
|
-
})
|
|
45
40
|
})
|