@planningcenter/chat-react-native 4.5.1-qa-staging.5 → 4.5.1-qa-staging.7
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/assets/powered_by_giphy.png +0 -0
- package/assets/powered_by_giphy_dark.png +0 -0
- package/build/components/conversation/attachments/giphy_attachment.d.ts.map +1 -1
- package/build/components/conversation/attachments/giphy_attachment.js +2 -2
- package/build/components/conversation/attachments/giphy_attachment.js.map +1 -1
- package/build/components/conversation/attachments/image_attachment.d.ts.map +1 -1
- package/build/components/conversation/attachments/image_attachment.js +5 -3
- package/build/components/conversation/attachments/image_attachment.js.map +1 -1
- package/build/components/conversation/message_form.d.ts.map +1 -1
- package/build/components/conversation/message_form.js +2 -2
- package/build/components/conversation/message_form.js.map +1 -1
- package/build/components/display/conversation_avatar.d.ts +3 -1
- package/build/components/display/conversation_avatar.d.ts.map +1 -1
- package/build/components/display/conversation_avatar.js +77 -66
- package/build/components/display/conversation_avatar.js.map +1 -1
- package/build/hooks/use_conversation_avatar_update.d.ts +3 -2
- package/build/hooks/use_conversation_avatar_update.d.ts.map +1 -1
- package/build/hooks/use_conversation_avatar_update.js +37 -4
- package/build/hooks/use_conversation_avatar_update.js.map +1 -1
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +2 -4
- package/build/navigation/index.js.map +1 -1
- package/build/screens/age_check/age_check_underage_screen.d.ts.map +1 -1
- package/build/screens/age_check/age_check_underage_screen.js +2 -1
- package/build/screens/age_check/age_check_underage_screen.js.map +1 -1
- package/build/screens/attachment_actions/attachment_actions_screen.d.ts.map +1 -1
- package/build/screens/attachment_actions/attachment_actions_screen.js +5 -2
- package/build/screens/attachment_actions/attachment_actions_screen.js.map +1 -1
- package/build/screens/bug_report_screen.d.ts.map +1 -1
- package/build/screens/bug_report_screen.js +3 -3
- package/build/screens/bug_report_screen.js.map +1 -1
- package/build/screens/conversation_new/components/form_list.d.ts.map +1 -1
- package/build/screens/conversation_new/components/form_list.js +1 -0
- package/build/screens/conversation_new/components/form_list.js.map +1 -1
- package/build/screens/conversation_select_recipients/conversation_select_group_recipients_screen.js +1 -1
- package/build/screens/conversation_select_recipients/conversation_select_group_recipients_screen.js.map +1 -1
- package/build/screens/get_help_screen.js +2 -2
- package/build/screens/get_help_screen.js.map +1 -1
- package/build/screens/send_giphy_screen.d.ts.map +1 -1
- package/build/screens/send_giphy_screen.js +93 -136
- package/build/screens/send_giphy_screen.js.map +1 -1
- package/build/utils/native_adapters/linking.d.ts +11 -3
- package/build/utils/native_adapters/linking.d.ts.map +1 -1
- package/build/utils/native_adapters/linking.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/components/conversation/attachments/giphy_attachment.test.tsx +76 -0
- package/src/__tests__/screens/get_help_screen.test.ts +36 -0
- package/src/__utils__/render_with_query_client.tsx +13 -0
- package/src/components/conversation/attachments/giphy_attachment.tsx +2 -3
- package/src/components/conversation/attachments/image_attachment.tsx +2 -3
- package/src/components/conversation/message_form.tsx +1 -1
- package/src/components/conversations/__tests__/conversation_preview.test.tsx +2 -2
- package/src/components/display/__tests__/conversation_avatar.test.tsx +84 -0
- package/src/components/display/conversation_avatar.tsx +9 -2
- package/src/hooks/use_conversation_avatar_update.ts +18 -8
- package/src/navigation/index.tsx +0 -2
- package/src/screens/age_check/age_check_underage_screen.tsx +2 -1
- package/src/screens/attachment_actions/__tests__/attachment_actions_screen.test.tsx +37 -1
- package/src/screens/attachment_actions/attachment_actions_screen.tsx +3 -2
- package/src/screens/bug_report_screen.tsx +3 -11
- package/src/screens/conversation_new/components/form_list.tsx +1 -0
- package/src/screens/conversation_select_recipients/conversation_select_group_recipients_screen.tsx +1 -1
- package/src/screens/get_help_screen.tsx +2 -2
- package/src/screens/search/__tests__/search_screen.test.tsx +6 -5
- package/src/screens/search/components/__tests__/conversation_results.test.tsx +14 -5
- package/src/screens/search/components/__tests__/message_result_row.test.tsx +5 -4
- package/src/screens/search/components/__tests__/search_results_list.test.tsx +4 -3
- package/src/screens/send_giphy_screen.tsx +13 -44
- package/src/utils/native_adapters/__tests__/linking.test.ts +12 -0
- package/src/utils/native_adapters/linking.ts +12 -3
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PlatformPressable } from '@react-navigation/elements'
|
|
2
2
|
import React from 'react'
|
|
3
|
-
import { Text, StyleSheet
|
|
3
|
+
import { Text, StyleSheet } from 'react-native'
|
|
4
4
|
import { useTheme } from '../../../hooks'
|
|
5
5
|
import { DenormalizedGiphyAttachmentResource } from '../../../types/resources/denormalized_attachment_resource'
|
|
6
|
-
import { assertKeysAreNumbers } from '../../../utils'
|
|
6
|
+
import { assertKeysAreNumbers, Linking } from '../../../utils'
|
|
7
7
|
import { tokens } from '../../../vendor/tapestry/tokens'
|
|
8
8
|
import { Image } from '../../display'
|
|
9
9
|
|
|
@@ -22,7 +22,6 @@ export function GiphyAttachment({
|
|
|
22
22
|
|
|
23
23
|
function handlePress() {
|
|
24
24
|
if (titleLink) {
|
|
25
|
-
// Open Giphy link in the default web browser
|
|
26
25
|
Linking.openURL(titleLink)
|
|
27
26
|
}
|
|
28
27
|
}
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
StyleSheet,
|
|
7
7
|
Modal,
|
|
8
8
|
View,
|
|
9
|
-
Linking,
|
|
10
9
|
Dimensions,
|
|
11
10
|
NativeSyntheticEvent,
|
|
12
11
|
NativeScrollEvent,
|
|
@@ -30,7 +29,7 @@ import Animated, {
|
|
|
30
29
|
import { useSafeAreaInsets, SafeAreaProvider } from 'react-native-safe-area-context'
|
|
31
30
|
import { useTheme } from '../../../hooks'
|
|
32
31
|
import { DenormalizedMessageAttachmentResource } from '../../../types/resources/denormalized_attachment_resource'
|
|
33
|
-
import { Haptic, platformFontWeightMedium } from '../../../utils'
|
|
32
|
+
import { Haptic, Linking, platformFontWeightMedium } from '../../../utils'
|
|
34
33
|
import { formatDatePreview } from '../../../utils/date'
|
|
35
34
|
import { tokens } from '../../../vendor/tapestry/tokens'
|
|
36
35
|
import { IconButton, Image, Heading, Text } from '../../display'
|
|
@@ -212,7 +211,7 @@ const LightboxGallery = ({
|
|
|
212
211
|
HANDLERS
|
|
213
212
|
============================ */
|
|
214
213
|
const handleOpenInBrowser = useCallback(() => {
|
|
215
|
-
Linking.openURL(urlMedium || url)
|
|
214
|
+
Linking.openURL(urlMedium || url, { forceOpenInBrowser: true })
|
|
216
215
|
}, [urlMedium, url])
|
|
217
216
|
|
|
218
217
|
// Helper to enable or disable FlatList scroll state after gestures have ended
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useNavigation, useTheme as useNavigationTheme, useRoute } from '@react-navigation/native'
|
|
2
2
|
import React, { useCallback, useContext, useEffect, useRef, useState } from 'react'
|
|
3
3
|
import {
|
|
4
|
-
Linking,
|
|
5
4
|
Platform,
|
|
6
5
|
Pressable,
|
|
7
6
|
ScrollView,
|
|
@@ -34,6 +33,7 @@ import {
|
|
|
34
33
|
FileAttachment,
|
|
35
34
|
} from '../../types/resources/denormalized_attachment_resource_for_create'
|
|
36
35
|
import {
|
|
36
|
+
Linking,
|
|
37
37
|
Log,
|
|
38
38
|
MAX_FONT_SIZE_MULTIPLIER_LANDMARK,
|
|
39
39
|
platformFontWeightMedium,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { render } from '@testing-library/react-native'
|
|
2
1
|
import React from 'react'
|
|
2
|
+
import { renderWithQueryClient } from '../../../__utils__/render_with_query_client'
|
|
3
3
|
import type { ConversationPreviewData, ConversationResource } from '../../../types'
|
|
4
4
|
import { formatDatePreview } from '../../../utils/date'
|
|
5
5
|
import { ConversationPreview } from '../conversation_preview'
|
|
@@ -49,7 +49,7 @@ const renderPreview = (
|
|
|
49
49
|
preview: ConversationPreviewData,
|
|
50
50
|
overrides: Partial<ConversationResource> = {}
|
|
51
51
|
) =>
|
|
52
|
-
|
|
52
|
+
renderWithQueryClient(
|
|
53
53
|
<ConversationPreview conversation={conversation(preview, overrides)} onPress={jest.fn()} />
|
|
54
54
|
)
|
|
55
55
|
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
2
|
+
import { render, waitFor } from '@testing-library/react-native'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import { Image } from 'react-native'
|
|
5
|
+
import { buildTestQueryClient } from '../../../__utils__/query_client'
|
|
6
|
+
import type { AvatarUpdatePayload } from '../../../hooks/use_conversation_avatar_update'
|
|
7
|
+
import { ConversationAvatar } from '../conversation_avatar'
|
|
8
|
+
|
|
9
|
+
const conversation = {
|
|
10
|
+
id: 7,
|
|
11
|
+
customAvatarType: 'emoji' as const,
|
|
12
|
+
customAvatarKey: '🎉',
|
|
13
|
+
customAvatarColor: 'cosmic',
|
|
14
|
+
customAvatarImageUrl: null,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const imagePayload: AvatarUpdatePayload = {
|
|
18
|
+
kind: 'image',
|
|
19
|
+
color: 'cosmic',
|
|
20
|
+
imageAsset: { uri: 'file:///photo.jpg', width: 100, height: 100 },
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let queryClient: QueryClient
|
|
24
|
+
let inFlight: { settle: () => void; done: Promise<unknown> }[]
|
|
25
|
+
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
queryClient = buildTestQueryClient()
|
|
28
|
+
inFlight = []
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
afterEach(async () => {
|
|
32
|
+
inFlight.forEach(({ settle }) => settle())
|
|
33
|
+
await Promise.all(inFlight.map(({ done }) => done))
|
|
34
|
+
queryClient.clear()
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
function startAvatarUpdate(conversationId: number) {
|
|
38
|
+
let settle = () => {}
|
|
39
|
+
const upload = new Promise<void>(resolve => (settle = resolve))
|
|
40
|
+
const mutation = queryClient.getMutationCache().build(queryClient, {
|
|
41
|
+
mutationKey: ['updateConversationAvatar', conversationId],
|
|
42
|
+
mutationFn: () => upload,
|
|
43
|
+
networkMode: 'always',
|
|
44
|
+
})
|
|
45
|
+
const done = mutation.execute(imagePayload)
|
|
46
|
+
inFlight.push({ settle, done })
|
|
47
|
+
return settle
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function renderAvatar() {
|
|
51
|
+
return render(
|
|
52
|
+
<QueryClientProvider client={queryClient}>
|
|
53
|
+
<ConversationAvatar conversation={conversation} />
|
|
54
|
+
</QueryClientProvider>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
describe('ConversationAvatar', () => {
|
|
59
|
+
it('renders the pending avatar update over the cached conversation data', () => {
|
|
60
|
+
startAvatarUpdate(conversation.id)
|
|
61
|
+
|
|
62
|
+
const view = renderAvatar()
|
|
63
|
+
|
|
64
|
+
expect(view.UNSAFE_getByType(Image).props.source).toEqual({ uri: 'file:///photo.jpg' })
|
|
65
|
+
expect(view.queryByText('🎉')).toBeNull()
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('ignores pending avatar updates for other conversations', () => {
|
|
69
|
+
startAvatarUpdate(conversation.id + 1)
|
|
70
|
+
|
|
71
|
+
const view = renderAvatar()
|
|
72
|
+
|
|
73
|
+
expect(view.getByText('🎉')).toBeTruthy()
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it('returns to the cached conversation data once the update settles', async () => {
|
|
77
|
+
const settle = startAvatarUpdate(conversation.id)
|
|
78
|
+
const view = renderAvatar()
|
|
79
|
+
|
|
80
|
+
settle()
|
|
81
|
+
|
|
82
|
+
await waitFor(() => expect(view.getByText('🎉')).toBeTruthy())
|
|
83
|
+
})
|
|
84
|
+
})
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import type { ViewStyle } from 'react-native'
|
|
3
|
+
import {
|
|
4
|
+
applyAvatarUpdate,
|
|
5
|
+
usePendingConversationAvatarUpdate,
|
|
6
|
+
} from '../../hooks/use_conversation_avatar_update'
|
|
3
7
|
import type { ConversationAvatarData } from '../../types'
|
|
4
8
|
import AvatarPrimitive, { type AvatarRootProps } from '../primitive/avatar_primitive'
|
|
5
9
|
import { AvatarGroup } from './avatar_group'
|
|
@@ -38,7 +42,7 @@ function resolveAvatar(conversation: ConversationAvatarData): ResolvedAvatar {
|
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
interface ConversationAvatarProps {
|
|
41
|
-
conversation: ConversationAvatarData
|
|
45
|
+
conversation: ConversationAvatarData & { id?: number }
|
|
42
46
|
size?: AvatarRootProps['size']
|
|
43
47
|
showFallback?: boolean
|
|
44
48
|
fallbackIconName?: IconString
|
|
@@ -54,7 +58,10 @@ export function ConversationAvatar({
|
|
|
54
58
|
style,
|
|
55
59
|
maxFontSizeMultiplier,
|
|
56
60
|
}: ConversationAvatarProps) {
|
|
57
|
-
const
|
|
61
|
+
const pendingUpdate = usePendingConversationAvatarUpdate(conversation.id)
|
|
62
|
+
const avatar = resolveAvatar(
|
|
63
|
+
pendingUpdate ? applyAvatarUpdate(conversation, pendingUpdate) : conversation
|
|
64
|
+
)
|
|
58
65
|
const sizeProps = { size, maxFontSizeMultiplier, style }
|
|
59
66
|
|
|
60
67
|
switch (avatar.kind) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
|
1
|
+
import { useMutation, useMutationState, useQueryClient } from '@tanstack/react-query'
|
|
2
2
|
import { Alert } from 'react-native'
|
|
3
|
-
import type { ConversationResource } from '../types'
|
|
4
|
-
import type { ApiResource } from '../types'
|
|
3
|
+
import type { ApiResource, ConversationAvatarData, ConversationResource } from '../types'
|
|
5
4
|
import { transformGetToPost } from '../utils/client/request_helpers'
|
|
6
5
|
import type { ImagePickerAsset } from '../utils/native_adapters/image_picker'
|
|
7
6
|
import { ApiClient, useApiClient } from './use_api_client'
|
|
@@ -16,6 +15,17 @@ export type AvatarUpdatePayload =
|
|
|
16
15
|
| { kind: Extract<AvatarType, 'image'>; imageAsset: ImagePickerAsset; color: string }
|
|
17
16
|
| { kind: 'clear' }
|
|
18
17
|
|
|
18
|
+
const MUTATION_KEY = 'updateConversationAvatar'
|
|
19
|
+
|
|
20
|
+
export const usePendingConversationAvatarUpdate = (conversationId: number | undefined) => {
|
|
21
|
+
const pendingPayloads = useMutationState({
|
|
22
|
+
filters: { mutationKey: [MUTATION_KEY, conversationId], exact: true, status: 'pending' },
|
|
23
|
+
select: mutation => mutation.state.variables as AvatarUpdatePayload,
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
return conversationId === undefined ? undefined : pendingPayloads.at(-1)
|
|
27
|
+
}
|
|
28
|
+
|
|
19
29
|
export const useConversationAvatarUpdate = ({ conversationId }: { conversationId: number }) => {
|
|
20
30
|
const apiClient = useApiClient()
|
|
21
31
|
const uploadClient = useUploadClient()
|
|
@@ -24,7 +34,7 @@ export const useConversationAvatarUpdate = ({ conversationId }: { conversationId
|
|
|
24
34
|
const queryKey = getRequestQueryKey(requestArgs)
|
|
25
35
|
|
|
26
36
|
return useMutation({
|
|
27
|
-
mutationKey: [
|
|
37
|
+
mutationKey: [MUTATION_KEY, conversationId],
|
|
28
38
|
mutationFn: async (payload: AvatarUpdatePayload) => {
|
|
29
39
|
const postArgs = transformGetToPost(requestArgs).data
|
|
30
40
|
const attributes = await buildAttributes(payload, uploadClient)
|
|
@@ -41,7 +51,7 @@ export const useConversationAvatarUpdate = ({ conversationId }: { conversationId
|
|
|
41
51
|
|
|
42
52
|
queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {
|
|
43
53
|
if (!prev?.data) return prev
|
|
44
|
-
return { ...prev, data:
|
|
54
|
+
return { ...prev, data: applyAvatarUpdate(prev.data, payload) }
|
|
45
55
|
})
|
|
46
56
|
|
|
47
57
|
return { previous }
|
|
@@ -83,10 +93,10 @@ export async function patchConversationAvatar(
|
|
|
83
93
|
}
|
|
84
94
|
}
|
|
85
95
|
|
|
86
|
-
function
|
|
87
|
-
data:
|
|
96
|
+
export function applyAvatarUpdate<T extends ConversationAvatarData>(
|
|
97
|
+
data: T,
|
|
88
98
|
payload: AvatarUpdatePayload
|
|
89
|
-
):
|
|
99
|
+
): T {
|
|
90
100
|
switch (payload.kind) {
|
|
91
101
|
case 'icon':
|
|
92
102
|
return {
|
package/src/navigation/index.tsx
CHANGED
|
@@ -153,7 +153,6 @@ export const NewConversationStack = createNativeStackNavigator({
|
|
|
153
153
|
{
|
|
154
154
|
title: 'New conversation',
|
|
155
155
|
headerLeft: () => null,
|
|
156
|
-
headerTransparent: false,
|
|
157
156
|
},
|
|
158
157
|
withRightClose({
|
|
159
158
|
onPress: () => {
|
|
@@ -330,7 +329,6 @@ export const ChatStack = createNativeStackNavigator({
|
|
|
330
329
|
{
|
|
331
330
|
title: 'New conversation',
|
|
332
331
|
headerLeft: () => null,
|
|
333
|
-
headerTransparent: false,
|
|
334
332
|
},
|
|
335
333
|
withRightClose({ onPress: () => navigation.getParent()?.goBack() })
|
|
336
334
|
),
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { useRoute, RouteProp } from '@react-navigation/native'
|
|
2
2
|
import React from 'react'
|
|
3
|
-
import {
|
|
3
|
+
import { StyleSheet, View, ScrollView } from 'react-native'
|
|
4
4
|
import { Heading } from '../../components'
|
|
5
5
|
import { Icon, Text, TextInlineButton } from '../../components/display'
|
|
6
6
|
import { useTheme } from '../../hooks'
|
|
7
|
+
import { Linking } from '../../utils'
|
|
7
8
|
import type { AgeCheckParams } from './screen_props'
|
|
8
9
|
|
|
9
10
|
export interface AgeCheckUnderageScreenProps {
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { HeaderHeightContext } from '@react-navigation/elements'
|
|
2
2
|
import { DefaultTheme, ThemeProvider } from '@react-navigation/native'
|
|
3
|
-
import { render } from '@testing-library/react-native'
|
|
3
|
+
import { fireEvent, render } from '@testing-library/react-native'
|
|
4
4
|
import React from 'react'
|
|
5
5
|
import { SafeAreaProvider } from 'react-native-safe-area-context'
|
|
6
6
|
import type { ConversationResource } from '../../../types'
|
|
7
|
+
import {
|
|
8
|
+
AudioAdapter,
|
|
9
|
+
ChatAdapters,
|
|
10
|
+
ClipboardAdapter,
|
|
11
|
+
ImagePickerAdapter,
|
|
12
|
+
LinkingAdapter,
|
|
13
|
+
VideoAdapter,
|
|
14
|
+
} from '../../../utils/native_adapters'
|
|
7
15
|
import { AttachmentActionsScreen, AttachmentActionsScreenProps } from '../attachment_actions_screen'
|
|
8
16
|
|
|
9
17
|
let mockConversation = { id: 1, disabled: false } as ConversationResource
|
|
@@ -19,6 +27,8 @@ jest.mock('../hooks/useDeleteAttachment', () => ({
|
|
|
19
27
|
useDeleteAttachment: () => ({ handleDeleteAttachment: jest.fn() }),
|
|
20
28
|
}))
|
|
21
29
|
|
|
30
|
+
const hostOpenURL = jest.fn(async (_url: string, _options?: object) => {})
|
|
31
|
+
|
|
22
32
|
const safeAreaMetrics = {
|
|
23
33
|
frame: { x: 0, y: 0, width: 390, height: 844 },
|
|
24
34
|
insets: { top: 0, right: 0, bottom: 0, left: 0 },
|
|
@@ -51,6 +61,22 @@ const renderScreen = (params: Partial<AttachmentActionsScreenProps['route']['par
|
|
|
51
61
|
}
|
|
52
62
|
|
|
53
63
|
describe('AttachmentActionsScreen', () => {
|
|
64
|
+
beforeAll(() => {
|
|
65
|
+
ChatAdapters.configure({
|
|
66
|
+
clipboard: new ClipboardAdapter({
|
|
67
|
+
getStringAsync: async () => '',
|
|
68
|
+
setStringAsync: async () => {},
|
|
69
|
+
}),
|
|
70
|
+
audio: new AudioAdapter({ useAudio: () => ({}) as any }),
|
|
71
|
+
video: new VideoAdapter({ Player: React.forwardRef(() => null) }),
|
|
72
|
+
imagePicker: new ImagePickerAdapter({
|
|
73
|
+
openCameraAsync: async () => ({ canceled: true, assets: null }),
|
|
74
|
+
openImageLibraryAsync: async () => ({ canceled: true, assets: null }),
|
|
75
|
+
}),
|
|
76
|
+
linking: new LinkingAdapter({ openURL: hostOpenURL, canOpenURL: async () => true }),
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
|
|
54
80
|
beforeEach(() => {
|
|
55
81
|
mockConversation = { id: 1, disabled: false } as ConversationResource
|
|
56
82
|
})
|
|
@@ -69,4 +95,14 @@ describe('AttachmentActionsScreen', () => {
|
|
|
69
95
|
expect(queryByText('Delete image')).toBeNull()
|
|
70
96
|
expect(getByText('Open in browser')).toBeTruthy()
|
|
71
97
|
})
|
|
98
|
+
|
|
99
|
+
it('asks the host app to open the attachment in the browser', () => {
|
|
100
|
+
const { getByText } = renderScreen()
|
|
101
|
+
|
|
102
|
+
fireEvent.press(getByText('Open in browser'))
|
|
103
|
+
|
|
104
|
+
expect(hostOpenURL).toHaveBeenCalledWith('https://example.com/a1.png', {
|
|
105
|
+
forceOpenInBrowser: true,
|
|
106
|
+
})
|
|
107
|
+
})
|
|
72
108
|
})
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { StaticScreenProps, useNavigation } from '@react-navigation/native'
|
|
2
2
|
import React, { useCallback } from 'react'
|
|
3
|
-
import { Alert,
|
|
3
|
+
import { Alert, StyleSheet } from 'react-native'
|
|
4
4
|
import FormSheet, { getFormSheetScreenOptions } from '../../components/primitive/form_sheet'
|
|
5
5
|
import { useConversation } from '../../hooks/use_conversation'
|
|
6
|
+
import { Linking } from '../../utils'
|
|
6
7
|
import { useDeleteAttachment } from './hooks/useDeleteAttachment'
|
|
7
8
|
|
|
8
9
|
export const AttachmentActionsScreenOptions = getFormSheetScreenOptions({
|
|
@@ -59,7 +60,7 @@ export function AttachmentActionsScreen({ route }: AttachmentActionsScreenProps)
|
|
|
59
60
|
}, [attachmentName, handleDeleteAttachment, navigation])
|
|
60
61
|
|
|
61
62
|
const handleOpenInBrowser = () => {
|
|
62
|
-
Linking.openURL(attachmentUrl)
|
|
63
|
+
Linking.openURL(attachmentUrl, { forceOpenInBrowser: true })
|
|
63
64
|
navigation.goBack()
|
|
64
65
|
}
|
|
65
66
|
|
|
@@ -5,15 +5,7 @@ import type {
|
|
|
5
5
|
} from '@react-navigation/native-stack'
|
|
6
6
|
import { startsWith } from 'lodash'
|
|
7
7
|
import React, { useCallback, useState } from 'react'
|
|
8
|
-
import {
|
|
9
|
-
View,
|
|
10
|
-
StyleSheet,
|
|
11
|
-
TextInput,
|
|
12
|
-
Linking,
|
|
13
|
-
ScrollView,
|
|
14
|
-
TouchableOpacity,
|
|
15
|
-
Platform,
|
|
16
|
-
} from 'react-native'
|
|
8
|
+
import { View, StyleSheet, TextInput, ScrollView, TouchableOpacity, Platform } from 'react-native'
|
|
17
9
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
18
10
|
import {
|
|
19
11
|
Button,
|
|
@@ -38,7 +30,7 @@ import { useTheme } from '../hooks'
|
|
|
38
30
|
import { useAppName } from '../hooks/use_app_name'
|
|
39
31
|
import { useReportBugAction } from '../hooks/use_report_bug_action'
|
|
40
32
|
import { useUploadClient } from '../hooks/use_upload_client'
|
|
41
|
-
import { ImagePicker, ImagePickerResult, platformFontWeightBold } from '../utils'
|
|
33
|
+
import { ImagePicker, ImagePickerResult, Linking, platformFontWeightBold } from '../utils'
|
|
42
34
|
|
|
43
35
|
const MAX_DESCRIPTION_LENGTH = 2000
|
|
44
36
|
|
|
@@ -292,7 +284,7 @@ export function BugReportScreen() {
|
|
|
292
284
|
|
|
293
285
|
<View style={styles.textInputContainer}>
|
|
294
286
|
<Text style={styles.fieldLabel}>
|
|
295
|
-
What did you expect to happen? Please describe what actually happened.{' '}
|
|
287
|
+
What did you expect to happen? Please also describe what actually happened.{' '}
|
|
296
288
|
<Text style={styles.required}>*</Text>
|
|
297
289
|
</Text>
|
|
298
290
|
<TextInput
|
package/src/screens/conversation_select_recipients/conversation_select_group_recipients_screen.tsx
CHANGED
|
@@ -23,7 +23,7 @@ const SECTION_CONFIG = {
|
|
|
23
23
|
},
|
|
24
24
|
[SectionKey.more]: {
|
|
25
25
|
title: 'More groups',
|
|
26
|
-
subtitle:
|
|
26
|
+
subtitle: "You can't start a new conversation in these groups",
|
|
27
27
|
ListItemComponent: RestrictedGroupRow,
|
|
28
28
|
},
|
|
29
29
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { StaticScreenProps, useNavigation } from '@react-navigation/native'
|
|
2
2
|
import { useCallback, useMemo } from 'react'
|
|
3
|
-
import { Alert,
|
|
3
|
+
import { Alert, ScrollView, StyleSheet, View } from 'react-native'
|
|
4
4
|
import { Heading, PressableRow, Text, TextInlineButton } from '../components'
|
|
5
5
|
import { useApiGet, useTheme } from '../hooks'
|
|
6
6
|
import { useAppName } from '../hooks/use_app_name'
|
|
7
7
|
import { useOrganization } from '../hooks/use_organization'
|
|
8
8
|
import { ResourceObject } from '../types'
|
|
9
|
-
import { Clipboard } from '../utils'
|
|
9
|
+
import { Clipboard, Linking } from '../utils'
|
|
10
10
|
|
|
11
11
|
type GetHelpScreenRouteProps = {
|
|
12
12
|
type?: 'chat' | 'general'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { act, fireEvent
|
|
1
|
+
import { act, fireEvent } from '@testing-library/react-native'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
import { Keyboard, ScrollView } from 'react-native'
|
|
4
|
+
import { renderWithQueryClient } from '../../../__utils__/render_with_query_client'
|
|
4
5
|
import type { useSearchResults } from '../../../hooks/use_search_results'
|
|
5
6
|
import type {
|
|
6
7
|
ConversationSearchResultResource,
|
|
@@ -71,7 +72,7 @@ const renderWithResults = () => {
|
|
|
71
72
|
hasNextPage: false,
|
|
72
73
|
isFetchingNextPage: false,
|
|
73
74
|
})
|
|
74
|
-
const view =
|
|
75
|
+
const view = renderWithQueryClient(<SearchScreen />)
|
|
75
76
|
const input = view.getByLabelText(inputLabel)
|
|
76
77
|
fireEvent.changeText(input, 'bud')
|
|
77
78
|
fireEvent.changeText(input, 'budget')
|
|
@@ -99,7 +100,7 @@ afterEach(() => jest.useRealTimers())
|
|
|
99
100
|
|
|
100
101
|
describe('SearchScreen', () => {
|
|
101
102
|
it('searches once with the trimmed term after typing settles', () => {
|
|
102
|
-
const view =
|
|
103
|
+
const view = renderWithQueryClient(<SearchScreen />)
|
|
103
104
|
const input = view.getByLabelText(inputLabel)
|
|
104
105
|
|
|
105
106
|
fireEvent.changeText(input, 'bud')
|
|
@@ -118,7 +119,7 @@ describe('SearchScreen', () => {
|
|
|
118
119
|
})
|
|
119
120
|
|
|
120
121
|
it('lets the prompt scroll while taps still reach the field', () => {
|
|
121
|
-
const view =
|
|
122
|
+
const view = renderWithQueryClient(<SearchScreen />)
|
|
122
123
|
|
|
123
124
|
const scrollView = view.UNSAFE_getByType(ScrollView)
|
|
124
125
|
expect(scrollView.props.keyboardShouldPersistTaps).toBe('handled')
|
|
@@ -127,7 +128,7 @@ describe('SearchScreen', () => {
|
|
|
127
128
|
})
|
|
128
129
|
|
|
129
130
|
it('returns to the prompt as soon as the term is cleared', () => {
|
|
130
|
-
const view =
|
|
131
|
+
const view = renderWithQueryClient(<SearchScreen />)
|
|
131
132
|
const input = view.getByLabelText(inputLabel)
|
|
132
133
|
|
|
133
134
|
fireEvent.changeText(input, 'budget')
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { fireEvent
|
|
1
|
+
import { fireEvent } from '@testing-library/react-native'
|
|
2
2
|
import React from 'react'
|
|
3
|
+
import { renderWithQueryClient } from '../../../../__utils__/render_with_query_client'
|
|
3
4
|
import type { ConversationSearchResultResource } from '../../../../types'
|
|
4
5
|
import { ConversationResults } from '../conversation_results'
|
|
5
6
|
|
|
@@ -14,7 +15,9 @@ const buildResults = (count: number, prefix = 'Conversation') =>
|
|
|
14
15
|
|
|
15
16
|
describe('ConversationResults', () => {
|
|
16
17
|
it('caps at five rows until View more is pressed, then offers View less', () => {
|
|
17
|
-
const view =
|
|
18
|
+
const view = renderWithQueryClient(
|
|
19
|
+
<ConversationResults results={buildResults(6)} onSelect={jest.fn()} />
|
|
20
|
+
)
|
|
18
21
|
|
|
19
22
|
expect(view.getByText('Conversation 5')).toBeTruthy()
|
|
20
23
|
expect(view.queryByText('Conversation 6')).toBeNull()
|
|
@@ -27,14 +30,18 @@ describe('ConversationResults', () => {
|
|
|
27
30
|
})
|
|
28
31
|
|
|
29
32
|
it('renders no footer for five or fewer results', () => {
|
|
30
|
-
const view =
|
|
33
|
+
const view = renderWithQueryClient(
|
|
34
|
+
<ConversationResults results={buildResults(4)} onSelect={jest.fn()} />
|
|
35
|
+
)
|
|
31
36
|
|
|
32
37
|
expect(view.getByText('Conversation 4')).toBeTruthy()
|
|
33
38
|
expect(view.queryByText('View more')).toBeNull()
|
|
34
39
|
})
|
|
35
40
|
|
|
36
41
|
it('stays expanded when the parent re-renders with a new results array', () => {
|
|
37
|
-
const view =
|
|
42
|
+
const view = renderWithQueryClient(
|
|
43
|
+
<ConversationResults results={buildResults(6)} onSelect={jest.fn()} />
|
|
44
|
+
)
|
|
38
45
|
fireEvent.press(view.getByText('View more'))
|
|
39
46
|
|
|
40
47
|
view.rerender(<ConversationResults results={buildResults(6)} onSelect={jest.fn()} />)
|
|
@@ -46,7 +53,9 @@ describe('ConversationResults', () => {
|
|
|
46
53
|
it('passes the pressed result and its position to onSelect', () => {
|
|
47
54
|
const onSelect = jest.fn()
|
|
48
55
|
const results = buildResults(2)
|
|
49
|
-
const view =
|
|
56
|
+
const view = renderWithQueryClient(
|
|
57
|
+
<ConversationResults results={results} onSelect={onSelect} />
|
|
58
|
+
)
|
|
50
59
|
|
|
51
60
|
fireEvent.press(view.getByText('Conversation 2'))
|
|
52
61
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { fireEvent
|
|
1
|
+
import { fireEvent } from '@testing-library/react-native'
|
|
2
2
|
import React from 'react'
|
|
3
|
+
import { renderWithQueryClient } from '../../../../__utils__/render_with_query_client'
|
|
3
4
|
import type { MessageSearchResultResource } from '../../../../types/resources/search_result'
|
|
4
5
|
import { formatDatePreview } from '../../../../utils/date'
|
|
5
6
|
import { defaultTheme } from '../../../../utils/theme'
|
|
@@ -33,7 +34,7 @@ const interactionColor = defaultTheme('light').colors.interaction
|
|
|
33
34
|
|
|
34
35
|
describe('MessageResultRow', () => {
|
|
35
36
|
it('renders the title, author, snippet, and date', () => {
|
|
36
|
-
const view =
|
|
37
|
+
const view = renderWithQueryClient(<MessageResultRow result={result} onPress={jest.fn()} />)
|
|
37
38
|
|
|
38
39
|
expect(view.getByText('Worship Team')).toBeTruthy()
|
|
39
40
|
expect(view.getByText('Ada Lovelace:', { exact: false })).toBeTruthy()
|
|
@@ -44,7 +45,7 @@ describe('MessageResultRow', () => {
|
|
|
44
45
|
})
|
|
45
46
|
|
|
46
47
|
it('colors matched segments with the interaction color', () => {
|
|
47
|
-
const view =
|
|
48
|
+
const view = renderWithQueryClient(<MessageResultRow result={result} onPress={jest.fn()} />)
|
|
48
49
|
|
|
49
50
|
expect(view.getByText('budget')).toHaveStyle({ color: interactionColor })
|
|
50
51
|
expect(view.getByText('…planning the ')).not.toHaveStyle({ color: interactionColor })
|
|
@@ -53,7 +54,7 @@ describe('MessageResultRow', () => {
|
|
|
53
54
|
it('exposes the row as a button with a composed label and reports presses', () => {
|
|
54
55
|
const onPress = jest.fn()
|
|
55
56
|
const date = formatDatePreview(result.extra.createdAt)
|
|
56
|
-
const view =
|
|
57
|
+
const view = renderWithQueryClient(<MessageResultRow result={result} onPress={onPress} />)
|
|
57
58
|
|
|
58
59
|
const row = view.getByRole('button', {
|
|
59
60
|
name: `Worship Team, Ada Lovelace: …planning the budget meeting for next week, ${date}`,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { fireEvent
|
|
1
|
+
import { fireEvent } from '@testing-library/react-native'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
import { FlatList } from 'react-native'
|
|
4
|
+
import { renderWithQueryClient } from '../../../../__utils__/render_with_query_client'
|
|
4
5
|
import type { useSearchResults } from '../../../../hooks/use_search_results'
|
|
5
6
|
import type {
|
|
6
7
|
ConversationSearchResultResource,
|
|
@@ -56,7 +57,7 @@ const renderList = (state: Partial<SearchState>, onSettled = jest.fn()) => {
|
|
|
56
57
|
const list = () => (
|
|
57
58
|
<SearchResultsList term="potluck" onSelect={jest.fn()} onSettled={onSettled} {...slots} />
|
|
58
59
|
)
|
|
59
|
-
const view =
|
|
60
|
+
const view = renderWithQueryClient(list())
|
|
60
61
|
const rerenderWith = (next: Partial<SearchState>) => {
|
|
61
62
|
mockUseSearchResults.mockReturnValue(searchState(next))
|
|
62
63
|
view.rerender(list())
|
|
@@ -133,7 +134,7 @@ describe('SearchResultsList', () => {
|
|
|
133
134
|
const onSelect = jest.fn()
|
|
134
135
|
const results = [conversationResult('1'), messageResult('1'), messageResult('2')]
|
|
135
136
|
mockUseSearchResults.mockReturnValue(searchState({ results }))
|
|
136
|
-
const view =
|
|
137
|
+
const view = renderWithQueryClient(
|
|
137
138
|
<SearchResultsList term="potluck" onSelect={onSelect} onSettled={jest.fn()} {...slots} />
|
|
138
139
|
)
|
|
139
140
|
|