@planningcenter/chat-react-native 4.7.1-qa-1092.0 → 4.7.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/components/conversation/attachments/expanded_link.js +8 -8
- package/build/components/conversation/attachments/expanded_link.js.map +1 -1
- package/build/components/conversation/attachments/generic_file_attachment.d.ts.map +1 -1
- package/build/components/conversation/attachments/generic_file_attachment.js +2 -2
- package/build/components/conversation/attachments/generic_file_attachment.js.map +1 -1
- 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.js +2 -2
- package/build/components/conversation/attachments/image_attachment.js.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/conversation/message_markdown.js +2 -2
- package/build/components/conversation/message_markdown.js.map +1 -1
- package/build/components/conversations/conversation_actions.d.ts.map +1 -1
- package/build/components/conversations/conversation_actions.js +333 -193
- package/build/components/conversations/conversation_actions.js.map +1 -1
- package/build/components/conversations/conversation_preview.d.ts.map +1 -1
- package/build/components/conversations/conversation_preview.js +106 -91
- package/build/components/conversations/conversation_preview.js.map +1 -1
- package/build/components/conversations/conversations.d.ts.map +1 -1
- package/build/components/conversations/conversations.js +63 -56
- package/build/components/conversations/conversations.js.map +1 -1
- package/build/components/conversations/conversations_blank_state.d.ts +2 -1
- package/build/components/conversations/conversations_blank_state.d.ts.map +1 -1
- package/build/components/conversations/conversations_blank_state.js +71 -39
- package/build/components/conversations/conversations_blank_state.js.map +1 -1
- package/build/components/conversations/hidden_indicator.d.ts +4 -0
- package/build/components/conversations/hidden_indicator.d.ts.map +1 -0
- package/build/components/conversations/hidden_indicator.js +52 -0
- package/build/components/conversations/hidden_indicator.js.map +1 -0
- package/build/components/conversations/hidden_results_footer.d.ts +2 -0
- package/build/components/conversations/hidden_results_footer.d.ts.map +1 -0
- package/build/components/conversations/hidden_results_footer.js +34 -0
- package/build/components/conversations/hidden_results_footer.js.map +1 -0
- package/build/components/display/toast.d.ts +3 -0
- package/build/components/display/toast.d.ts.map +1 -0
- package/build/components/display/toast.js +224 -0
- package/build/components/display/toast.js.map +1 -0
- package/build/components/group_conversation_list.d.ts.map +1 -1
- package/build/components/group_conversation_list.js +1 -0
- package/build/components/group_conversation_list.js.map +1 -1
- package/build/contexts/conversations_context.d.ts +3 -1
- package/build/contexts/conversations_context.d.ts.map +1 -1
- package/build/contexts/conversations_context.js +39 -31
- package/build/contexts/conversations_context.js.map +1 -1
- package/build/hooks/groups/use_group_members_for_new_conversation.d.ts +6 -0
- package/build/hooks/groups/use_group_members_for_new_conversation.d.ts.map +1 -1
- package/build/hooks/use_api.d.ts +6 -0
- package/build/hooks/use_api.d.ts.map +1 -1
- package/build/hooks/use_api.js +8 -5
- package/build/hooks/use_api.js.map +1 -1
- package/build/hooks/use_clear_conversation_filters.d.ts.map +1 -1
- package/build/hooks/use_clear_conversation_filters.js +1 -0
- package/build/hooks/use_clear_conversation_filters.js.map +1 -1
- package/build/hooks/use_conversation.d.ts.map +1 -1
- package/build/hooks/use_conversation.js +1 -1
- package/build/hooks/use_conversation.js.map +1 -1
- package/build/hooks/use_features.d.ts +1 -0
- package/build/hooks/use_features.d.ts.map +1 -1
- package/build/hooks/use_features.js +2 -1
- package/build/hooks/use_features.js.map +1 -1
- package/build/hooks/use_groups.d.ts +6 -0
- package/build/hooks/use_groups.d.ts.map +1 -1
- package/build/hooks/use_groups_groups.d.ts +6 -0
- package/build/hooks/use_groups_groups.d.ts.map +1 -1
- package/build/hooks/use_hidden_conversations_count.d.ts +2 -0
- package/build/hooks/use_hidden_conversations_count.d.ts.map +1 -0
- package/build/hooks/use_hidden_conversations_count.js +32 -0
- package/build/hooks/use_hidden_conversations_count.js.map +1 -0
- package/build/hooks/use_hide_conversation.d.ts +108 -0
- package/build/hooks/use_hide_conversation.d.ts.map +1 -0
- package/build/hooks/use_hide_conversation.js +243 -0
- package/build/hooks/use_hide_conversation.js.map +1 -0
- package/build/hooks/use_hide_conversations_enabled.d.ts +2 -0
- package/build/hooks/use_hide_conversations_enabled.d.ts.map +1 -0
- package/build/hooks/use_hide_conversations_enabled.js +18 -0
- package/build/hooks/use_hide_conversations_enabled.js.map +1 -0
- package/build/hooks/use_teams.d.ts +6 -0
- package/build/hooks/use_teams.d.ts.map +1 -1
- package/build/navigation/index.d.ts +5 -0
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +5 -0
- package/build/navigation/index.js.map +1 -1
- package/build/screens/age_check/age_check_underage_screen.js +3 -3
- package/build/screens/age_check/age_check_underage_screen.js.map +1 -1
- package/build/screens/attachment_actions/attachment_actions_screen.js +2 -2
- package/build/screens/attachment_actions/attachment_actions_screen.js.map +1 -1
- package/build/screens/bug_report_screen.js +4 -4
- package/build/screens/bug_report_screen.js.map +1 -1
- package/build/screens/conversation_actions_screen.d.ts +7 -0
- package/build/screens/conversation_actions_screen.d.ts.map +1 -0
- package/build/screens/conversation_actions_screen.js +89 -0
- package/build/screens/conversation_actions_screen.js.map +1 -0
- package/build/screens/conversation_details_screen.d.ts.map +1 -1
- package/build/screens/conversation_details_screen.js +460 -394
- package/build/screens/conversation_details_screen.js.map +1 -1
- package/build/screens/conversation_filters/components/conversation_filters.d.ts.map +1 -1
- package/build/screens/conversation_filters/components/conversation_filters.js +53 -12
- package/build/screens/conversation_filters/components/conversation_filters.js.map +1 -1
- package/build/screens/conversation_filters/components/rows.d.ts +6 -3
- package/build/screens/conversation_filters/components/rows.d.ts.map +1 -1
- package/build/screens/conversation_filters/components/rows.js +99 -62
- package/build/screens/conversation_filters/components/rows.js.map +1 -1
- package/build/screens/conversation_filters/context/conversation_filter_context.d.ts.map +1 -1
- package/build/screens/conversation_filters/context/conversation_filter_context.js +4 -0
- package/build/screens/conversation_filters/context/conversation_filter_context.js.map +1 -1
- package/build/screens/conversation_filters/filter_types.d.ts +1 -0
- package/build/screens/conversation_filters/filter_types.d.ts.map +1 -1
- package/build/screens/conversation_filters/filter_types.js +1 -0
- package/build/screens/conversation_filters/filter_types.js.map +1 -1
- package/build/screens/conversation_filters/hooks/filters.d.ts +12 -0
- package/build/screens/conversation_filters/hooks/filters.d.ts.map +1 -1
- package/build/screens/conversation_filters/screen_props.d.ts +1 -0
- package/build/screens/conversation_filters/screen_props.d.ts.map +1 -1
- package/build/screens/conversation_filters/screen_props.js.map +1 -1
- package/build/screens/conversations/components/filter_dropdown_list_header_component.d.ts.map +1 -1
- package/build/screens/conversations/components/filter_dropdown_list_header_component.js +138 -126
- package/build/screens/conversations/components/filter_dropdown_list_header_component.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 +95 -90
- package/build/screens/conversations/components/list_header_component.js.map +1 -1
- package/build/screens/conversations/components/search_list_header_component.d.ts.map +1 -1
- package/build/screens/conversations/components/search_list_header_component.js +100 -95
- package/build/screens/conversations/components/search_list_header_component.js.map +1 -1
- package/build/screens/conversations/conversations_screen.d.ts +1 -0
- package/build/screens/conversations/conversations_screen.d.ts.map +1 -1
- package/build/screens/conversations/conversations_screen.js +18 -10
- package/build/screens/conversations/conversations_screen.js.map +1 -1
- package/build/screens/get_help_screen.d.ts.map +1 -1
- package/build/screens/get_help_screen.js +5 -21
- package/build/screens/get_help_screen.js.map +1 -1
- package/build/screens/index.d.ts +1 -0
- package/build/screens/index.d.ts.map +1 -1
- package/build/screens/index.js +1 -0
- package/build/screens/index.js.map +1 -1
- package/build/types/resources/conversation_membership.d.ts +1 -0
- package/build/types/resources/conversation_membership.d.ts.map +1 -1
- package/build/types/resources/conversation_membership.js.map +1 -1
- package/build/utils/index.d.ts +1 -0
- package/build/utils/index.d.ts.map +1 -1
- package/build/utils/index.js +1 -0
- package/build/utils/index.js.map +1 -1
- package/build/utils/open_url.d.ts +11 -0
- package/build/utils/open_url.d.ts.map +1 -0
- package/build/utils/open_url.js +46 -0
- package/build/utils/open_url.js.map +1 -0
- package/build/utils/request/conversation.d.ts +3 -1
- package/build/utils/request/conversation.d.ts.map +1 -1
- package/build/utils/request/conversation.js +4 -0
- package/build/utils/request/conversation.js.map +1 -1
- package/build/utils/toast_store.d.ts +21 -0
- package/build/utils/toast_store.d.ts.map +1 -0
- package/build/utils/toast_store.js +27 -0
- package/build/utils/toast_store.js.map +1 -0
- package/build/vendor/font_awesome_pro_solid_icons.d.ts +1 -0
- package/build/vendor/font_awesome_pro_solid_icons.d.ts.map +1 -1
- package/build/vendor/font_awesome_pro_solid_icons.js +5 -0
- package/build/vendor/font_awesome_pro_solid_icons.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/components/conversation/attachments/giphy_attachment.test.tsx +1 -1
- package/src/__tests__/screens/conversation_filters/components/conversation_filters.test.tsx +6 -0
- package/src/__tests__/screens/get_help_screen.test.ts +1 -1
- package/src/components/conversation/attachments/expanded_link.tsx +4 -4
- package/src/components/conversation/attachments/generic_file_attachment.tsx +2 -5
- package/src/components/conversation/attachments/giphy_attachment.tsx +2 -4
- package/src/components/conversation/attachments/image_attachment.tsx +2 -2
- package/src/components/conversation/message_form.tsx +2 -2
- package/src/components/conversation/message_markdown.tsx +2 -2
- package/src/components/conversations/__tests__/conversation_actions.test.tsx +77 -2
- package/src/components/conversations/__tests__/conversation_preview.test.tsx +29 -0
- package/src/components/conversations/__tests__/conversations.test.tsx +26 -0
- package/src/components/conversations/__tests__/conversations_blank_state.test.tsx +17 -0
- package/src/components/conversations/conversation_actions.tsx +73 -4
- package/src/components/conversations/conversation_preview.tsx +12 -1
- package/src/components/conversations/conversations.tsx +9 -0
- package/src/components/conversations/conversations_blank_state.tsx +18 -0
- package/src/components/conversations/hidden_indicator.tsx +30 -0
- package/src/components/conversations/hidden_results_footer.tsx +25 -0
- package/src/components/display/__tests__/toast.test.tsx +55 -0
- package/src/components/display/toast.tsx +115 -0
- package/src/components/group_conversation_list.tsx +4 -1
- package/src/contexts/conversations_context.tsx +8 -1
- package/src/hooks/__tests__/use_hide_conversation.test.tsx +189 -0
- package/src/hooks/use_api.ts +2 -1
- package/src/hooks/use_clear_conversation_filters.ts +1 -0
- package/src/hooks/use_conversation.ts +1 -0
- package/src/hooks/use_features.ts +1 -0
- package/src/hooks/use_hidden_conversations_count.ts +14 -0
- package/src/hooks/use_hide_conversation.ts +128 -0
- package/src/hooks/use_hide_conversations_enabled.ts +7 -0
- package/src/navigation/index.tsx +8 -0
- package/src/screens/__tests__/conversation_actions_screen.test.tsx +79 -0
- package/src/screens/__tests__/conversation_details_screen.test.tsx +49 -1
- package/src/screens/age_check/age_check_underage_screen.tsx +3 -3
- package/src/screens/attachment_actions/attachment_actions_screen.tsx +2 -2
- package/src/screens/bug_report_screen.tsx +4 -4
- package/src/screens/conversation_actions_screen.tsx +53 -0
- package/src/screens/conversation_details_screen.tsx +19 -0
- package/src/screens/conversation_filters/__tests__/conversation_filters.test.tsx +42 -0
- package/src/screens/conversation_filters/components/conversation_filters.tsx +22 -3
- package/src/screens/conversation_filters/components/rows.tsx +44 -10
- package/src/screens/conversation_filters/context/conversation_filter_context.tsx +4 -0
- package/src/screens/conversation_filters/filter_types.ts +1 -0
- package/src/screens/conversation_filters/screen_props.ts +1 -0
- package/src/screens/conversations/__tests__/conversations_screen.test.tsx +1 -0
- package/src/screens/conversations/components/__tests__/filter_dropdown_list_header_component.test.tsx +42 -0
- package/src/screens/conversations/components/__tests__/list_header_component.test.tsx +1 -0
- package/src/screens/conversations/components/filter_dropdown_list_header_component.tsx +21 -5
- package/src/screens/conversations/components/list_header_component.tsx +14 -4
- package/src/screens/conversations/components/search_list_header_component.tsx +14 -4
- package/src/screens/conversations/conversations_screen.tsx +3 -0
- package/src/screens/get_help_screen.tsx +5 -19
- package/src/screens/index.ts +1 -0
- package/src/types/resources/conversation_membership.ts +1 -0
- package/src/utils/__tests__/open_url.test.ts +67 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/open_url.ts +47 -0
- package/src/utils/request/conversation.ts +6 -0
- package/src/utils/toast_store.ts +45 -0
- package/src/vendor/font_awesome_pro_solid_icons.ts +12 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { render } from '@testing-library/react-native'
|
|
1
|
+
import { fireEvent, render } from '@testing-library/react-native'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
import { Text } from 'react-native'
|
|
4
4
|
import type { ConversationResource } from '../../../types'
|
|
@@ -27,6 +27,29 @@ jest.mock('../../../hooks/use_conversations_actions', () => ({
|
|
|
27
27
|
useConversationsMarkRead: () => ({ read: false, markRead: jest.fn(), isPending: false }),
|
|
28
28
|
}))
|
|
29
29
|
|
|
30
|
+
const mockNavigate = jest.fn()
|
|
31
|
+
jest.mock('@react-navigation/native', () => ({
|
|
32
|
+
...jest.requireActual('@react-navigation/native'),
|
|
33
|
+
useNavigation: () => ({ navigate: mockNavigate }),
|
|
34
|
+
}))
|
|
35
|
+
const mockSetHidden = jest.fn()
|
|
36
|
+
jest.mock('../../../hooks/use_hide_conversation', () => ({
|
|
37
|
+
useHideConversation: () => ({ hidden: false, setHidden: mockSetHidden, isPending: false }),
|
|
38
|
+
}))
|
|
39
|
+
let mockHideEnabled = false
|
|
40
|
+
jest.mock('../../../hooks/use_hide_conversations_enabled', () => ({
|
|
41
|
+
useHideConversationsEnabled: () => mockHideEnabled,
|
|
42
|
+
}))
|
|
43
|
+
let mockHideable = true
|
|
44
|
+
jest.mock('../../../contexts/conversations_context', () => ({
|
|
45
|
+
useConversationsContext: () => ({
|
|
46
|
+
activeConversationId: undefined,
|
|
47
|
+
setActiveConversationId: jest.fn(),
|
|
48
|
+
hideable: mockHideable,
|
|
49
|
+
args: {},
|
|
50
|
+
}),
|
|
51
|
+
}))
|
|
52
|
+
|
|
30
53
|
const createdAt = '2026-10-01T12:00:00Z'
|
|
31
54
|
|
|
32
55
|
const conversation = (overrides: Partial<ConversationResource>): ConversationResource => ({
|
|
@@ -52,11 +75,18 @@ const renderActions = (overrides: Partial<ConversationResource>) =>
|
|
|
52
75
|
)
|
|
53
76
|
|
|
54
77
|
describe('ConversationActions', () => {
|
|
55
|
-
|
|
78
|
+
beforeEach(() => {
|
|
79
|
+
mockHideEnabled = false
|
|
80
|
+
jest.clearAllMocks()
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('offers mark read but not mute or hide on an archived conversation', () => {
|
|
84
|
+
mockHideEnabled = true
|
|
56
85
|
const view = renderActions({ disabled: true, disabledReason: 'archived' })
|
|
57
86
|
|
|
58
87
|
expect(view.getByText('Mark read')).toBeTruthy()
|
|
59
88
|
expect(view.queryByText('Silence')).toBeNull()
|
|
89
|
+
expect(view.queryByText('Hide')).toBeNull()
|
|
60
90
|
})
|
|
61
91
|
|
|
62
92
|
it('offers mute on a conversation disabled for another reason', () => {
|
|
@@ -65,3 +95,48 @@ describe('ConversationActions', () => {
|
|
|
65
95
|
expect(view.getByText('Silence')).toBeTruthy()
|
|
66
96
|
})
|
|
67
97
|
})
|
|
98
|
+
|
|
99
|
+
describe('ConversationActions hide', () => {
|
|
100
|
+
beforeEach(() => {
|
|
101
|
+
mockHideEnabled = true
|
|
102
|
+
mockHideable = true
|
|
103
|
+
jest.clearAllMocks()
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
it('offers no hide action or long press when the list is not hideable', () => {
|
|
107
|
+
mockHideable = false
|
|
108
|
+
const view = renderActions({})
|
|
109
|
+
|
|
110
|
+
fireEvent(view.getByTestId('conversation-7'), 'longPress')
|
|
111
|
+
|
|
112
|
+
expect(view.queryByText('Hide')).toBeNull()
|
|
113
|
+
expect(view.getByText('Silence')).toBeTruthy()
|
|
114
|
+
expect(mockNavigate).not.toHaveBeenCalled()
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('offers no hide action or long press when the flag is off', () => {
|
|
118
|
+
mockHideEnabled = false
|
|
119
|
+
const view = renderActions({})
|
|
120
|
+
|
|
121
|
+
fireEvent(view.getByTestId('conversation-7'), 'longPress')
|
|
122
|
+
|
|
123
|
+
expect(view.queryByText('Hide')).toBeNull()
|
|
124
|
+
expect(mockNavigate).not.toHaveBeenCalled()
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
it('hides from the swipe action', () => {
|
|
128
|
+
const view = renderActions({})
|
|
129
|
+
|
|
130
|
+
fireEvent.press(view.getByText('Hide'))
|
|
131
|
+
|
|
132
|
+
expect(mockSetHidden).toHaveBeenCalledWith(true)
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
it('opens the conversation actions sheet on long press', () => {
|
|
136
|
+
const view = renderActions({})
|
|
137
|
+
|
|
138
|
+
fireEvent(view.getByTestId('conversation-7'), 'longPress')
|
|
139
|
+
|
|
140
|
+
expect(mockNavigate).toHaveBeenCalledWith('ConversationActions', { conversation_id: 7 })
|
|
141
|
+
})
|
|
142
|
+
})
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { renderWithQueryClient } from '../../../__utils__/render_with_query_client'
|
|
3
|
+
import { ConversationFiltersParams } from '../../../screens/conversation_filters/screen_props'
|
|
3
4
|
import type { ConversationPreviewData, ConversationResource } from '../../../types'
|
|
4
5
|
import { formatDatePreview } from '../../../utils/date'
|
|
5
6
|
import { ConversationPreview } from '../conversation_preview'
|
|
6
7
|
|
|
8
|
+
let mockArgs: ConversationFiltersParams = {}
|
|
9
|
+
jest.mock('../../../contexts/conversations_context', () => ({
|
|
10
|
+
useConversationsContext: () => ({ args: mockArgs }),
|
|
11
|
+
}))
|
|
7
12
|
jest.mock('../conversation_actions', () => ({
|
|
8
13
|
ConversationActions: ({
|
|
9
14
|
children,
|
|
@@ -102,4 +107,28 @@ describe('ConversationPreview', () => {
|
|
|
102
107
|
).toBeNull()
|
|
103
108
|
expect(view.getByLabelText(/^Select Worship Team, Disabled,/)).toBeTruthy()
|
|
104
109
|
})
|
|
110
|
+
|
|
111
|
+
describe('hidden indicator', () => {
|
|
112
|
+
afterEach(() => {
|
|
113
|
+
mockArgs = {}
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it('marks rows in the hidden list as hidden', () => {
|
|
117
|
+
mockArgs = { show_hidden: true }
|
|
118
|
+
const view = renderPreview(messagePreview)
|
|
119
|
+
|
|
120
|
+
expect(
|
|
121
|
+
view.getByTestId('conversation-hidden-icon', { includeHiddenElements: true })
|
|
122
|
+
).toBeTruthy()
|
|
123
|
+
expect(view.getByLabelText(/^Select Worship Team, Hidden,/)).toBeTruthy()
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
it('leaves rows outside the hidden list unmarked', () => {
|
|
127
|
+
const view = renderPreview(messagePreview)
|
|
128
|
+
|
|
129
|
+
expect(
|
|
130
|
+
view.queryByTestId('conversation-hidden-icon', { includeHiddenElements: true })
|
|
131
|
+
).toBeNull()
|
|
132
|
+
})
|
|
133
|
+
})
|
|
105
134
|
})
|
|
@@ -91,3 +91,29 @@ describe('Conversations archived footer', () => {
|
|
|
91
91
|
expect(view.queryByLabelText('View active conversations')).toBeNull()
|
|
92
92
|
})
|
|
93
93
|
})
|
|
94
|
+
|
|
95
|
+
describe('Conversations hidden footer', () => {
|
|
96
|
+
beforeEach(() => {
|
|
97
|
+
mockFilterDropdownEnabled = true
|
|
98
|
+
mockHasNextPage = false
|
|
99
|
+
mockArgs = { show_hidden: true }
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('ends the hidden list with a note on how conversations come back', () => {
|
|
103
|
+
const view = render(<Conversations />)
|
|
104
|
+
|
|
105
|
+
expect(
|
|
106
|
+
view.getByText(
|
|
107
|
+
'Hidden just for you. A conversation comes back to your list when someone sends a new message, unless it’s also silenced.'
|
|
108
|
+
)
|
|
109
|
+
).toBeTruthy()
|
|
110
|
+
expect(view.queryByText('You’re viewing filtered results')).toBeNull()
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
it('waits for the last page before showing the hidden note', () => {
|
|
114
|
+
mockHasNextPage = true
|
|
115
|
+
const view = render(<Conversations />)
|
|
116
|
+
|
|
117
|
+
expect(view.queryByText(/Hidden just for you/)).toBeNull()
|
|
118
|
+
})
|
|
119
|
+
})
|
|
@@ -41,6 +41,7 @@ describe('ConversationsBlankState', () => {
|
|
|
41
41
|
group_source_app_name: undefined,
|
|
42
42
|
show_direct_messages: undefined,
|
|
43
43
|
show_archived: undefined,
|
|
44
|
+
show_hidden: undefined,
|
|
44
45
|
show_unread: undefined,
|
|
45
46
|
})
|
|
46
47
|
})
|
|
@@ -71,4 +72,20 @@ describe('ConversationsBlankState', () => {
|
|
|
71
72
|
expect(view.queryByText('View all conversations')).toBeNull()
|
|
72
73
|
})
|
|
73
74
|
})
|
|
75
|
+
|
|
76
|
+
it('explains how to hide a conversation when the hidden list is empty', () => {
|
|
77
|
+
mockUseFilterDropdownEnabled.mockReturnValue(true)
|
|
78
|
+
|
|
79
|
+
const view = render(
|
|
80
|
+
<ConversationsBlankState
|
|
81
|
+
isFilterApplied={true}
|
|
82
|
+
isHiddenFilterApplied={true}
|
|
83
|
+
canCreateConversations={true}
|
|
84
|
+
/>
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
expect(view.getByText('No hidden conversations')).toBeTruthy()
|
|
88
|
+
expect(view.getByText('Swipe left on a conversation to hide it from your list.')).toBeTruthy()
|
|
89
|
+
expect(view.queryByText('View all conversations')).toBeNull()
|
|
90
|
+
})
|
|
74
91
|
})
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useNavigation } from '@react-navigation/native'
|
|
1
2
|
import React, { ReactNode, useCallback, useEffect, useRef, useState } from 'react'
|
|
2
3
|
import {
|
|
3
4
|
AccessibilityActionEvent,
|
|
@@ -17,8 +18,11 @@ import {
|
|
|
17
18
|
useConversationsMarkRead,
|
|
18
19
|
useConversationsMute,
|
|
19
20
|
} from '../../hooks/use_conversations_actions'
|
|
21
|
+
import { useHideConversation } from '../../hooks/use_hide_conversation'
|
|
22
|
+
import { useHideConversationsEnabled } from '../../hooks/use_hide_conversations_enabled'
|
|
20
23
|
import { ConversationResource } from '../../types'
|
|
21
24
|
import { isArchivedConversation, platformPressedOpacityStyle } from '../../utils'
|
|
25
|
+
import { Haptic } from '../../utils/native_adapters'
|
|
22
26
|
import { tokens } from '../../vendor/tapestry/tokens'
|
|
23
27
|
import { SwipeableToggleButton } from './swipeable_toggle_button'
|
|
24
28
|
|
|
@@ -36,8 +40,10 @@ export function ConversationActions({
|
|
|
36
40
|
accessibilityLabel?: string
|
|
37
41
|
}) {
|
|
38
42
|
const swipeableRef = useRef<SwipeableMethods>(null)
|
|
43
|
+
const navigation = useNavigation()
|
|
39
44
|
const styles = useStyles()
|
|
40
|
-
const { activeConversationId, setActiveConversationId } =
|
|
45
|
+
const { activeConversationId, setActiveConversationId, hideable, args } =
|
|
46
|
+
useConversationsContext()
|
|
41
47
|
const [disabled, setDisabled] = useState(false)
|
|
42
48
|
const overshootLeft = Platform.OS === 'ios'
|
|
43
49
|
const androidRippleColor = useCreateAndroidRippleColor({
|
|
@@ -51,9 +57,16 @@ export function ConversationActions({
|
|
|
51
57
|
} = useConversationsMarkRead({
|
|
52
58
|
conversation,
|
|
53
59
|
})
|
|
60
|
+
const {
|
|
61
|
+
hidden,
|
|
62
|
+
setHidden,
|
|
63
|
+
isPending: isHiddenPending,
|
|
64
|
+
} = useHideConversation({ conversation, hidden: args.show_hidden || undefined })
|
|
65
|
+
const hideConversationsEnabled = useHideConversationsEnabled()
|
|
54
66
|
|
|
55
67
|
const isConversationEmpty = conversation.lastMessageCreatedAt === null
|
|
56
68
|
const canMute = !isArchivedConversation(conversation)
|
|
69
|
+
const canHide = hideable && hideConversationsEnabled && !isArchivedConversation(conversation)
|
|
57
70
|
|
|
58
71
|
const handleSwipeableClose = useCallback(() => {
|
|
59
72
|
setDisabled(false)
|
|
@@ -75,6 +88,18 @@ export function ConversationActions({
|
|
|
75
88
|
handleSwipeableClose()
|
|
76
89
|
}, [muted, handleSwipeableClose, setMuted])
|
|
77
90
|
|
|
91
|
+
const handleHide = useCallback(() => {
|
|
92
|
+
setHidden(!hidden)
|
|
93
|
+
handleSwipeableClose()
|
|
94
|
+
}, [hidden, handleSwipeableClose, setHidden])
|
|
95
|
+
|
|
96
|
+
const handleLongPress = useCallback(() => {
|
|
97
|
+
if (disabled) return
|
|
98
|
+
|
|
99
|
+
Haptic.impactLight()
|
|
100
|
+
navigation.navigate('ConversationActions', { conversation_id: conversation.id })
|
|
101
|
+
}, [disabled, navigation, conversation.id])
|
|
102
|
+
|
|
78
103
|
const handleLatestMessageUnread = useCallback(() => {
|
|
79
104
|
markRead(!read)
|
|
80
105
|
handleSwipeableClose()
|
|
@@ -98,7 +123,20 @@ export function ConversationActions({
|
|
|
98
123
|
]
|
|
99
124
|
: []
|
|
100
125
|
|
|
101
|
-
const
|
|
126
|
+
const hideAccessibilityAction = canHide
|
|
127
|
+
? [
|
|
128
|
+
{
|
|
129
|
+
name: hidden ? 'unhide' : 'hide',
|
|
130
|
+
label: hidden ? 'Unhide' : 'Hide',
|
|
131
|
+
},
|
|
132
|
+
]
|
|
133
|
+
: []
|
|
134
|
+
|
|
135
|
+
const accessibilityActions = [
|
|
136
|
+
...muteAccessibilityAction,
|
|
137
|
+
...hideAccessibilityAction,
|
|
138
|
+
...readAccessibilityAction,
|
|
139
|
+
]
|
|
102
140
|
|
|
103
141
|
const handleAccessibilityAction = useCallback(
|
|
104
142
|
(event: AccessibilityActionEvent) => {
|
|
@@ -115,9 +153,13 @@ export function ConversationActions({
|
|
|
115
153
|
case 'unmute':
|
|
116
154
|
handleMute()
|
|
117
155
|
break
|
|
156
|
+
case 'hide':
|
|
157
|
+
case 'unhide':
|
|
158
|
+
handleHide()
|
|
159
|
+
break
|
|
118
160
|
}
|
|
119
161
|
},
|
|
120
|
-
[handleLatestMessageUnread, handleMute]
|
|
162
|
+
[handleLatestMessageUnread, handleMute, handleHide]
|
|
121
163
|
)
|
|
122
164
|
|
|
123
165
|
useEffect(() => {
|
|
@@ -141,11 +183,15 @@ export function ConversationActions({
|
|
|
141
183
|
<LeftActions
|
|
142
184
|
isConversationEmpty={isConversationEmpty}
|
|
143
185
|
canMute={canMute}
|
|
186
|
+
canHide={canHide}
|
|
144
187
|
handleMute={handleMute}
|
|
188
|
+
handleHide={handleHide}
|
|
145
189
|
handleLatestMessageUnread={handleLatestMessageUnread}
|
|
146
190
|
muted={muted}
|
|
191
|
+
hidden={hidden}
|
|
147
192
|
read={read}
|
|
148
193
|
isMutedPending={isMutedPending}
|
|
194
|
+
isHiddenPending={isHiddenPending}
|
|
149
195
|
isMarkReadPending={isMarkReadPending}
|
|
150
196
|
/>
|
|
151
197
|
)}
|
|
@@ -153,6 +199,7 @@ export function ConversationActions({
|
|
|
153
199
|
<Pressable
|
|
154
200
|
testID={`conversation-${conversation.id}`}
|
|
155
201
|
onPress={handlePress}
|
|
202
|
+
onLongPress={canHide ? handleLongPress : undefined}
|
|
156
203
|
style={({ pressed }) => [style, pressed && platformPressedOpacityStyle]}
|
|
157
204
|
android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}
|
|
158
205
|
accessibilityLabel={accessibilityLabel}
|
|
@@ -169,31 +216,44 @@ export function ConversationActions({
|
|
|
169
216
|
interface LeftActionsProps {
|
|
170
217
|
isConversationEmpty: boolean
|
|
171
218
|
canMute: boolean
|
|
219
|
+
canHide: boolean
|
|
172
220
|
handleMute: () => void
|
|
221
|
+
handleHide: () => void
|
|
173
222
|
handleLatestMessageUnread: () => void
|
|
174
223
|
muted: boolean
|
|
224
|
+
hidden: boolean
|
|
175
225
|
read: boolean
|
|
176
226
|
isMutedPending: boolean
|
|
227
|
+
isHiddenPending: boolean
|
|
177
228
|
isMarkReadPending: boolean
|
|
178
229
|
}
|
|
179
230
|
|
|
180
231
|
function LeftActions({
|
|
181
232
|
isConversationEmpty,
|
|
182
233
|
canMute,
|
|
234
|
+
canHide,
|
|
183
235
|
handleMute,
|
|
236
|
+
handleHide,
|
|
184
237
|
handleLatestMessageUnread,
|
|
185
238
|
muted,
|
|
239
|
+
hidden,
|
|
186
240
|
read,
|
|
187
241
|
isMutedPending,
|
|
242
|
+
isHiddenPending,
|
|
188
243
|
isMarkReadPending,
|
|
189
244
|
}: LeftActionsProps) {
|
|
190
|
-
const styles = useStyles({ actionButtonCount:
|
|
245
|
+
const styles = useStyles({ actionButtonCount: 1 + Number(canMute) + Number(canHide) })
|
|
191
246
|
|
|
192
247
|
const muteToggleContent = {
|
|
193
248
|
true: { iconName: 'general.bell', label: 'Enable' },
|
|
194
249
|
false: { iconName: 'general.bellMuted', label: 'Silence' },
|
|
195
250
|
} as const
|
|
196
251
|
|
|
252
|
+
const hideToggleContent = {
|
|
253
|
+
true: { iconName: 'general.showEye', label: 'Unhide' },
|
|
254
|
+
false: { iconName: 'general.hideEye', label: 'Hide' },
|
|
255
|
+
} as const
|
|
256
|
+
|
|
197
257
|
const latestMessageUnreadToggleContent = {
|
|
198
258
|
true: { iconName: 'general.outlinedTextMessage', label: 'Mark read' },
|
|
199
259
|
false: { iconName: 'general.textMessageNotifications', label: 'Mark unread' },
|
|
@@ -218,6 +278,15 @@ function LeftActions({
|
|
|
218
278
|
backgroundColor={tokens.fillColorInteractionSwipeSecondary}
|
|
219
279
|
/>
|
|
220
280
|
)}
|
|
281
|
+
{canHide && (
|
|
282
|
+
<SwipeableToggleButton
|
|
283
|
+
loading={isHiddenPending}
|
|
284
|
+
toggled={hidden}
|
|
285
|
+
onPress={handleHide}
|
|
286
|
+
toggleContent={hideToggleContent}
|
|
287
|
+
backgroundColor={tokens.colorNeutral45}
|
|
288
|
+
/>
|
|
289
|
+
)}
|
|
221
290
|
</View>
|
|
222
291
|
)
|
|
223
292
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { StyleSheet, View, ViewStyle } from 'react-native'
|
|
3
|
+
import { useConversationsContext } from '../../contexts/conversations_context'
|
|
3
4
|
import {
|
|
4
5
|
useTheme,
|
|
5
6
|
useAtFontScaleBreakpoint,
|
|
@@ -21,6 +22,7 @@ import {
|
|
|
21
22
|
type BadgeProps,
|
|
22
23
|
} from '../display'
|
|
23
24
|
import { ConversationActions } from './conversation_actions'
|
|
25
|
+
import { HiddenIndicator } from './hidden_indicator'
|
|
24
26
|
import { MuteIndicator } from './mute_indicator'
|
|
25
27
|
import { UnreadCountBadge } from './unread_count_badge'
|
|
26
28
|
|
|
@@ -40,6 +42,9 @@ export const ConversationPreview = ({
|
|
|
40
42
|
style,
|
|
41
43
|
}: ConversationPreviewProps) => {
|
|
42
44
|
const styles = useStyles()
|
|
45
|
+
const {
|
|
46
|
+
args: { show_hidden: hidden = false },
|
|
47
|
+
} = useConversationsContext()
|
|
43
48
|
const {
|
|
44
49
|
conversationPreview,
|
|
45
50
|
lastMessageCreatedAt,
|
|
@@ -54,7 +59,7 @@ export const ConversationPreview = ({
|
|
|
54
59
|
const archived = isArchivedConversation(conversation)
|
|
55
60
|
const emptyConversation = !lastMessageCreatedAt
|
|
56
61
|
const fallbackIconName = emptyConversation ? 'people.noTextMessage' : 'general.person'
|
|
57
|
-
const hasMetaContent = lastMessageCreatedAt || unreadCount > 0 || muted
|
|
62
|
+
const hasMetaContent = lastMessageCreatedAt || unreadCount > 0 || muted || hidden
|
|
58
63
|
const isUnread = unreadCount > 0 || unreadReaction
|
|
59
64
|
|
|
60
65
|
const numberOfLinesScaledTitle = useScalableNumberOfLines(1)
|
|
@@ -68,6 +73,7 @@ export const ConversationPreview = ({
|
|
|
68
73
|
conversation,
|
|
69
74
|
showBadges,
|
|
70
75
|
archived,
|
|
76
|
+
hidden,
|
|
71
77
|
})
|
|
72
78
|
|
|
73
79
|
return (
|
|
@@ -117,6 +123,7 @@ export const ConversationPreview = ({
|
|
|
117
123
|
<View style={styles.statusContainer}>
|
|
118
124
|
<UnreadCountBadge count={unreadCount} unreadReaction={unreadReaction} showDot={muted} />
|
|
119
125
|
<MuteIndicator muted={muted} />
|
|
126
|
+
<HiddenIndicator hidden={hidden} />
|
|
120
127
|
</View>
|
|
121
128
|
</View>
|
|
122
129
|
)}
|
|
@@ -214,11 +221,13 @@ interface GetConversationAccessibilityLabelProps {
|
|
|
214
221
|
conversation: ConversationResource
|
|
215
222
|
showBadges: boolean
|
|
216
223
|
archived: boolean
|
|
224
|
+
hidden: boolean
|
|
217
225
|
}
|
|
218
226
|
const getConversationAccessibilityLabel = ({
|
|
219
227
|
conversation,
|
|
220
228
|
showBadges,
|
|
221
229
|
archived,
|
|
230
|
+
hidden,
|
|
222
231
|
}: GetConversationAccessibilityLabelProps) => {
|
|
223
232
|
const { badges, title, conversationPreview, muted, disabled, unreadCount, unreadReaction } =
|
|
224
233
|
conversation
|
|
@@ -231,6 +240,7 @@ const getConversationAccessibilityLabel = ({
|
|
|
231
240
|
badge: hasBadges ? `for ${badges[0]?.pcoResourceType} ${badges[0]?.text || ''}` : '',
|
|
232
241
|
disabled: archived ? 'Archived' : disabled ? 'Disabled' : '',
|
|
233
242
|
muted: muted ? 'Muted' : '',
|
|
243
|
+
hidden: hidden ? 'Hidden' : '',
|
|
234
244
|
readStatus: hasUnreadMessages
|
|
235
245
|
? `${unreadCount} unread messages`
|
|
236
246
|
: unreadReaction
|
|
@@ -246,6 +256,7 @@ const getConversationAccessibilityLabel = ({
|
|
|
246
256
|
label.badge,
|
|
247
257
|
label.disabled,
|
|
248
258
|
label.muted,
|
|
259
|
+
label.hidden,
|
|
249
260
|
label.readStatus,
|
|
250
261
|
label.lastMessage,
|
|
251
262
|
]
|
|
@@ -12,6 +12,7 @@ import { ArchivedResultsFooter } from './archived_results_footer'
|
|
|
12
12
|
import { ConversationPreview, ConversationPreviewSkeleton } from './conversation_preview'
|
|
13
13
|
import { ConversationsBlankState } from './conversations_blank_state'
|
|
14
14
|
import { FilteredResultsFooter } from './filtered_results_footer'
|
|
15
|
+
import { HiddenResultsFooter } from './hidden_results_footer'
|
|
15
16
|
|
|
16
17
|
interface ConversationsProps {
|
|
17
18
|
ListHeaderComponent?:
|
|
@@ -36,6 +37,7 @@ export const Conversations = ({ ListHeaderComponent }: ConversationsProps) => {
|
|
|
36
37
|
group_source_app_name,
|
|
37
38
|
show_direct_messages,
|
|
38
39
|
show_archived,
|
|
40
|
+
show_hidden,
|
|
39
41
|
show_unread,
|
|
40
42
|
},
|
|
41
43
|
} = useConversationsContext()
|
|
@@ -48,12 +50,16 @@ export const Conversations = ({ ListHeaderComponent }: ConversationsProps) => {
|
|
|
48
50
|
!!group_source_app_name ||
|
|
49
51
|
!!show_direct_messages ||
|
|
50
52
|
!!show_archived ||
|
|
53
|
+
!!show_hidden ||
|
|
51
54
|
!!show_unread
|
|
52
55
|
const showArchivedResultsFooter = !!show_archived && !isLoading && !hasNextPage
|
|
56
|
+
const showHiddenResultsFooter =
|
|
57
|
+
!!show_hidden && !isLoading && !hasNextPage && conversations.length > 0
|
|
53
58
|
const showFilteredResultsFooter =
|
|
54
59
|
filterDropdownEnabled &&
|
|
55
60
|
isFilterApplied &&
|
|
56
61
|
!show_archived &&
|
|
62
|
+
!show_hidden &&
|
|
57
63
|
!hasNextPage &&
|
|
58
64
|
!isLoading &&
|
|
59
65
|
conversations.length > 0
|
|
@@ -86,12 +92,15 @@ export const Conversations = ({ ListHeaderComponent }: ConversationsProps) => {
|
|
|
86
92
|
ListEmptyComponent={
|
|
87
93
|
<ConversationsBlankState
|
|
88
94
|
isFilterApplied={isFilterApplied}
|
|
95
|
+
isHiddenFilterApplied={!!show_hidden}
|
|
89
96
|
canCreateConversations={canCreateConversations}
|
|
90
97
|
/>
|
|
91
98
|
}
|
|
92
99
|
ListFooterComponent={
|
|
93
100
|
showArchivedResultsFooter ? (
|
|
94
101
|
<ArchivedResultsFooter onViewActiveConversations={clearFilters} />
|
|
102
|
+
) : showHiddenResultsFooter ? (
|
|
103
|
+
<HiddenResultsFooter />
|
|
95
104
|
) : showFilteredResultsFooter ? (
|
|
96
105
|
<FilteredResultsFooter />
|
|
97
106
|
) : null
|
|
@@ -6,16 +6,34 @@ import BlankState from '../primitive/blank_state_primitive'
|
|
|
6
6
|
|
|
7
7
|
interface ConversationsBlankStateProps {
|
|
8
8
|
isFilterApplied: boolean
|
|
9
|
+
isHiddenFilterApplied?: boolean
|
|
9
10
|
canCreateConversations: boolean
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export function ConversationsBlankState({
|
|
13
14
|
isFilterApplied,
|
|
15
|
+
isHiddenFilterApplied = false,
|
|
14
16
|
canCreateConversations,
|
|
15
17
|
}: ConversationsBlankStateProps) {
|
|
16
18
|
const filterDropdownEnabled = useFilterDropdownEnabled()
|
|
17
19
|
const clearFilters = useClearConversationFilters()
|
|
18
20
|
|
|
21
|
+
if (isHiddenFilterApplied) {
|
|
22
|
+
return (
|
|
23
|
+
<View style={styles.container}>
|
|
24
|
+
<BlankState.Root>
|
|
25
|
+
<BlankState.Imagery name="general.hideEye" />
|
|
26
|
+
<BlankState.Content>
|
|
27
|
+
<BlankState.Heading>No hidden conversations</BlankState.Heading>
|
|
28
|
+
<BlankState.Text>
|
|
29
|
+
Swipe left on a conversation to hide it from your list.
|
|
30
|
+
</BlankState.Text>
|
|
31
|
+
</BlankState.Content>
|
|
32
|
+
</BlankState.Root>
|
|
33
|
+
</View>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
19
37
|
if (filterDropdownEnabled && isFilterApplied) {
|
|
20
38
|
return (
|
|
21
39
|
<View style={styles.container}>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { StyleSheet } from 'react-native'
|
|
3
|
+
import { useTheme } from '../../hooks'
|
|
4
|
+
import { MAX_FONT_SIZE_MULTIPLIER } from '../../utils'
|
|
5
|
+
import { Icon } from '../display'
|
|
6
|
+
|
|
7
|
+
export const HiddenIndicator = ({ hidden }: { hidden: boolean }) => {
|
|
8
|
+
const styles = useStyles()
|
|
9
|
+
|
|
10
|
+
if (!hidden) return null
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<Icon
|
|
14
|
+
name="general.hideEye"
|
|
15
|
+
style={styles.hiddenIcon}
|
|
16
|
+
testID="conversation-hidden-icon"
|
|
17
|
+
maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER}
|
|
18
|
+
/>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const useStyles = () => {
|
|
23
|
+
const { colors } = useTheme()
|
|
24
|
+
return StyleSheet.create({
|
|
25
|
+
hiddenIcon: {
|
|
26
|
+
color: colors.iconColorDefaultDim,
|
|
27
|
+
fontSize: 16,
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { StyleSheet, View } from 'react-native'
|
|
3
|
+
import { Text } from '../display'
|
|
4
|
+
|
|
5
|
+
export function HiddenResultsFooter() {
|
|
6
|
+
return (
|
|
7
|
+
<View style={styles.container}>
|
|
8
|
+
<Text variant="tertiary" style={styles.text}>
|
|
9
|
+
Hidden just for you. A conversation comes back to your list when someone sends a new
|
|
10
|
+
message, unless it’s also silenced.
|
|
11
|
+
</Text>
|
|
12
|
+
</View>
|
|
13
|
+
)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const styles = StyleSheet.create({
|
|
17
|
+
container: {
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
paddingVertical: 24,
|
|
20
|
+
paddingHorizontal: 16,
|
|
21
|
+
},
|
|
22
|
+
text: {
|
|
23
|
+
textAlign: 'center',
|
|
24
|
+
},
|
|
25
|
+
})
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { act, fireEvent, render } from '@testing-library/react-native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { SafeAreaProvider } from 'react-native-safe-area-context'
|
|
4
|
+
import { dismissToast, showToast } from '../../../utils/toast_store'
|
|
5
|
+
import { Toast, TOAST_DURATION_MS } from '../toast'
|
|
6
|
+
|
|
7
|
+
const safeAreaMetrics = {
|
|
8
|
+
frame: { x: 0, y: 0, width: 390, height: 844 },
|
|
9
|
+
insets: { top: 0, right: 0, bottom: 0, left: 0 },
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const renderToast = () =>
|
|
13
|
+
render(
|
|
14
|
+
<SafeAreaProvider initialMetrics={safeAreaMetrics}>
|
|
15
|
+
<Toast />
|
|
16
|
+
</SafeAreaProvider>
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
describe('Toast', () => {
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
jest.useFakeTimers()
|
|
22
|
+
dismissToast()
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
afterEach(() => {
|
|
26
|
+
jest.useRealTimers()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('runs the action and dismisses when the action is pressed', () => {
|
|
30
|
+
const onUndo = jest.fn()
|
|
31
|
+
const view = renderToast()
|
|
32
|
+
act(() =>
|
|
33
|
+
showToast({
|
|
34
|
+
title: 'Conversation hidden',
|
|
35
|
+
subtitle: 'Subtitle',
|
|
36
|
+
action: { label: 'Undo', onPress: onUndo },
|
|
37
|
+
})
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
expect(view.getByText('Subtitle')).toBeTruthy()
|
|
41
|
+
fireEvent.press(view.getByText('Undo'))
|
|
42
|
+
|
|
43
|
+
expect(onUndo).toHaveBeenCalledTimes(1)
|
|
44
|
+
expect(view.queryByText('Conversation hidden')).toBeNull()
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('dismisses itself after a delay', () => {
|
|
48
|
+
const view = renderToast()
|
|
49
|
+
act(() => showToast({ title: 'Conversation hidden' }))
|
|
50
|
+
|
|
51
|
+
act(() => jest.advanceTimersByTime(TOAST_DURATION_MS))
|
|
52
|
+
|
|
53
|
+
expect(view.queryByText('Conversation hidden')).toBeNull()
|
|
54
|
+
})
|
|
55
|
+
})
|