@planningcenter/chat-react-native 4.8.0-rc.0 → 4.8.0-rc.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/components/conversations/bulk_conversation_actions_bar.d.ts +2 -0
- package/build/components/conversations/bulk_conversation_actions_bar.d.ts.map +1 -0
- package/build/components/conversations/bulk_conversation_actions_bar.js +215 -0
- package/build/components/conversations/bulk_conversation_actions_bar.js.map +1 -0
- package/build/components/conversations/conversation_actions.d.ts +2 -1
- package/build/components/conversations/conversation_actions.d.ts.map +1 -1
- package/build/components/conversations/conversation_actions.js +173 -130
- 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 +168 -110
- 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 +50 -48
- package/build/components/conversations/conversations.js.map +1 -1
- package/build/components/display/checkbox.d.ts +8 -0
- package/build/components/display/checkbox.d.ts.map +1 -0
- package/build/components/display/checkbox.js +87 -0
- package/build/components/display/checkbox.js.map +1 -0
- package/build/components/display/icon.d.ts +3 -1
- package/build/components/display/icon.d.ts.map +1 -1
- package/build/components/display/icon.js +2 -0
- package/build/components/display/icon.js.map +1 -1
- package/build/components/display/index.d.ts +1 -0
- package/build/components/display/index.d.ts.map +1 -1
- package/build/components/display/index.js +1 -0
- package/build/components/display/index.js.map +1 -1
- package/build/contexts/api_provider.d.ts.map +1 -1
- package/build/contexts/api_provider.js +2 -0
- package/build/contexts/api_provider.js.map +1 -1
- package/build/contexts/chat_context.d.ts +0 -2
- package/build/contexts/chat_context.d.ts.map +1 -1
- package/build/contexts/chat_context.js +16 -93
- package/build/contexts/chat_context.js.map +1 -1
- package/build/contexts/conversations_context.d.ts +5 -0
- package/build/contexts/conversations_context.d.ts.map +1 -1
- package/build/contexts/conversations_context.js +121 -32
- package/build/contexts/conversations_context.js.map +1 -1
- 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 +3 -0
- package/build/contexts/session_context.js.map +1 -1
- package/build/hooks/groups/use_group_chat_conversation_payload.d.ts +11 -1
- package/build/hooks/groups/use_group_chat_conversation_payload.d.ts.map +1 -1
- package/build/hooks/groups/use_group_chat_conversation_payload.js +92 -47
- package/build/hooks/groups/use_group_chat_conversation_payload.js.map +1 -1
- package/build/hooks/groups/use_group_members_for_new_conversation.d.ts +27 -25
- package/build/hooks/groups/use_group_members_for_new_conversation.d.ts.map +1 -1
- package/build/hooks/groups/use_group_members_for_new_conversation.js +125 -110
- package/build/hooks/groups/use_group_members_for_new_conversation.js.map +1 -1
- package/build/hooks/groups/use_groups_conversation_create.d.ts.map +1 -1
- package/build/hooks/groups/use_groups_conversation_create.js +39 -31
- package/build/hooks/groups/use_groups_conversation_create.js.map +1 -1
- package/build/hooks/groups/use_groups_proxy.d.ts +2 -0
- package/build/hooks/groups/use_groups_proxy.d.ts.map +1 -0
- package/build/hooks/groups/use_groups_proxy.js +18 -0
- package/build/hooks/groups/use_groups_proxy.js.map +1 -0
- package/build/hooks/use_bulk_conversation_actions.d.ts +8 -0
- package/build/hooks/use_bulk_conversation_actions.d.ts.map +1 -0
- package/build/hooks/use_bulk_conversation_actions.js +309 -0
- package/build/hooks/use_bulk_conversation_actions.js.map +1 -0
- package/build/hooks/use_conversation_jolt_events.d.ts.map +1 -1
- package/build/hooks/use_conversation_jolt_events.js +3 -2
- package/build/hooks/use_conversation_jolt_events.js.map +1 -1
- package/build/hooks/use_conversations_actions.d.ts +9 -9
- package/build/hooks/use_conversations_actions.d.ts.map +1 -1
- package/build/hooks/use_conversations_actions.js +12 -7
- package/build/hooks/use_conversations_actions.js.map +1 -1
- package/build/hooks/use_conversations_cache.d.ts +15 -5
- package/build/hooks/use_conversations_cache.d.ts.map +1 -1
- package/build/hooks/use_conversations_cache.js +170 -122
- package/build/hooks/use_conversations_cache.js.map +1 -1
- package/build/hooks/use_conversations_jolt_events.d.ts.map +1 -1
- package/build/hooks/use_conversations_jolt_events.js +47 -20
- package/build/hooks/use_conversations_jolt_events.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 +1 -0
- package/build/hooks/use_features.js.map +1 -1
- package/build/hooks/use_groups_groups.d.ts.map +1 -1
- package/build/hooks/use_groups_groups.js +25 -9
- package/build/hooks/use_groups_groups.js.map +1 -1
- package/build/hooks/use_mark_latest_message_read.d.ts.map +1 -1
- package/build/hooks/use_mark_latest_message_read.js +5 -4
- package/build/hooks/use_mark_latest_message_read.js.map +1 -1
- package/build/hooks/use_new_conversation_from_filter.d.ts.map +1 -1
- package/build/hooks/use_new_conversation_from_filter.js +11 -1
- package/build/hooks/use_new_conversation_from_filter.js.map +1 -1
- package/build/hooks/use_product_analytics.d.ts.map +1 -1
- package/build/hooks/use_product_analytics.js +93 -75
- package/build/hooks/use_product_analytics.js.map +1 -1
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +5 -7
- package/build/navigation/index.js.map +1 -1
- package/build/screens/conversation_actions_screen.d.ts +2 -0
- package/build/screens/conversation_actions_screen.d.ts.map +1 -1
- package/build/screens/conversation_actions_screen.js +380 -46
- package/build/screens/conversation_actions_screen.js.map +1 -1
- package/build/screens/conversation_filter_recipients/components/checkbox_row.d.ts.map +1 -1
- package/build/screens/conversation_filter_recipients/components/checkbox_row.js +9 -64
- package/build/screens/conversation_filter_recipients/components/checkbox_row.js.map +1 -1
- package/build/screens/conversation_new/components/groups_form.d.ts.map +1 -1
- package/build/screens/conversation_new/components/groups_form.js +96 -93
- package/build/screens/conversation_new/components/groups_form.js.map +1 -1
- package/build/screens/conversations/conversations_screen.d.ts +5 -0
- package/build/screens/conversations/conversations_screen.d.ts.map +1 -1
- package/build/screens/conversations/conversations_screen.js +156 -31
- 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 +4 -20
- package/build/screens/get_help_screen.js.map +1 -1
- package/build/types/jolt_events/index.d.ts +2 -0
- package/build/types/jolt_events/index.d.ts.map +1 -1
- package/build/types/jolt_events/index.js.map +1 -1
- package/build/types/jolt_events/person_events.d.ts +9 -0
- package/build/types/jolt_events/person_events.d.ts.map +1 -0
- package/build/types/jolt_events/person_events.js +2 -0
- package/build/types/jolt_events/person_events.js.map +1 -0
- package/build/types/resources/groups/groups_group_resource.d.ts +1 -1
- package/build/types/resources/groups/groups_group_resource.d.ts.map +1 -1
- package/build/types/resources/groups/groups_group_resource.js.map +1 -1
- package/build/types/resources/groups/groups_membership_resource.d.ts +11 -0
- package/build/types/resources/groups/groups_membership_resource.d.ts.map +1 -0
- package/build/types/resources/groups/groups_membership_resource.js +2 -0
- package/build/types/resources/groups/groups_membership_resource.js.map +1 -0
- package/build/types/resources/groups/index.d.ts +1 -0
- package/build/types/resources/groups/index.d.ts.map +1 -1
- package/build/types/resources/groups/index.js +1 -0
- package/build/types/resources/groups/index.js.map +1 -1
- package/build/utils/jolt/parse_stream_user_event_type.d.ts +3 -0
- package/build/utils/jolt/parse_stream_user_event_type.d.ts.map +1 -0
- package/build/utils/jolt/parse_stream_user_event_type.js +9 -0
- package/build/utils/jolt/parse_stream_user_event_type.js.map +1 -0
- package/build/utils/native_adapters/configuration.d.ts +3 -0
- package/build/utils/native_adapters/configuration.d.ts.map +1 -1
- package/build/utils/native_adapters/configuration.js +3 -0
- package/build/utils/native_adapters/configuration.js.map +1 -1
- package/build/utils/native_adapters/index.d.ts +1 -0
- package/build/utils/native_adapters/index.d.ts.map +1 -1
- package/build/utils/native_adapters/index.js +1 -0
- package/build/utils/native_adapters/index.js.map +1 -1
- package/build/utils/native_adapters/linking.d.ts.map +1 -1
- package/build/utils/native_adapters/linking.js +48 -2
- package/build/utils/native_adapters/linking.js.map +1 -1
- package/build/utils/native_adapters/updates.d.ts +11 -0
- package/build/utils/native_adapters/updates.d.ts.map +1 -0
- package/build/utils/native_adapters/updates.js +8 -0
- package/build/utils/native_adapters/updates.js.map +1 -0
- package/build/utils/product_analytics_token.d.ts +12 -0
- package/build/utils/product_analytics_token.d.ts.map +1 -0
- package/build/utils/product_analytics_token.js +84 -0
- package/build/utils/product_analytics_token.js.map +1 -0
- package/build/utils/throttled_refresh.d.ts +7 -0
- package/build/utils/throttled_refresh.d.ts.map +1 -0
- package/build/utils/throttled_refresh.js +42 -0
- package/build/utils/throttled_refresh.js.map +1 -0
- package/package.json +2 -2
- 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__/hooks/use_group_chat_conversation_payload.test.tsx +31 -0
- 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__/bulk_conversation_actions_bar.test.tsx +95 -0
- package/src/components/conversations/__tests__/conversation_actions.test.tsx +35 -3
- package/src/components/conversations/__tests__/conversation_preview.test.tsx +69 -3
- package/src/components/conversations/__tests__/conversations.test.tsx +4 -1
- package/src/components/conversations/bulk_conversation_actions_bar.tsx +140 -0
- package/src/components/conversations/conversation_actions.tsx +17 -9
- package/src/components/conversations/conversation_preview.tsx +20 -2
- package/src/components/conversations/conversations.tsx +2 -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/display/checkbox.tsx +47 -0
- package/src/components/display/icon.tsx +3 -0
- package/src/components/display/index.ts +1 -0
- package/src/components/page/__tests__/component_error_boundary.test.tsx +0 -12
- package/src/contexts/__tests__/conversations_context.test.tsx +86 -0
- package/src/contexts/api_provider.tsx +2 -0
- package/src/contexts/chat_context.tsx +2 -58
- package/src/contexts/conversations_context.tsx +69 -2
- package/src/contexts/session_context.tsx +3 -1
- package/src/hooks/__tests__/jolt_refresh_throttling.test.tsx +194 -0
- package/src/hooks/__tests__/use_bulk_conversation_actions.test.tsx +119 -0
- package/src/hooks/__tests__/use_conversations_jolt_events.test.tsx +1 -0
- package/src/hooks/__tests__/use_conversations_mark_read.test.tsx +38 -12
- package/src/hooks/__tests__/use_hide_conversation.test.tsx +15 -3
- package/src/hooks/__tests__/use_mark_latest_message_read.test.tsx +23 -2
- package/src/hooks/__tests__/use_product_analytics.test.tsx +304 -0
- package/src/hooks/groups/use_group_chat_conversation_payload.ts +30 -12
- package/src/hooks/groups/use_group_members_for_new_conversation.ts +49 -18
- package/src/hooks/groups/use_groups_conversation_create.ts +10 -14
- package/src/hooks/groups/use_groups_proxy.ts +6 -0
- package/src/hooks/use_bulk_conversation_actions.ts +173 -0
- package/src/hooks/use_conversation_jolt_events.ts +2 -1
- package/src/hooks/use_conversations_actions.ts +7 -4
- package/src/hooks/use_conversations_cache.ts +33 -26
- package/src/hooks/use_conversations_jolt_events.ts +24 -10
- package/src/hooks/use_features.ts +1 -0
- package/src/hooks/use_groups_groups.ts +21 -16
- package/src/hooks/use_mark_latest_message_read.ts +6 -5
- package/src/hooks/use_new_conversation_from_filter.ts +13 -5
- package/src/hooks/use_product_analytics.ts +74 -41
- package/src/navigation/index.tsx +8 -8
- package/src/screens/__tests__/conversation_actions_screen.test.tsx +48 -6
- 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/conversation_actions_screen.tsx +145 -12
- package/src/screens/conversation_filter_recipients/components/checkbox_row.tsx +3 -35
- package/src/screens/conversation_new/components/groups_form.tsx +11 -9
- package/src/screens/conversations/__tests__/conversations_screen.test.tsx +35 -9
- 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/conversations/conversations_screen.tsx +67 -3
- package/src/screens/get_help_screen.tsx +4 -18
- package/src/screens/search/components/__tests__/search_results_list.test.tsx +1 -0
- package/src/types/jolt_events/index.ts +2 -0
- package/src/types/jolt_events/person_events.ts +16 -0
- package/src/types/resources/groups/groups_group_resource.ts +1 -1
- package/src/types/resources/groups/groups_membership_resource.ts +10 -0
- package/src/types/resources/groups/index.ts +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__/throttled_refresh.test.ts +101 -0
- package/src/utils/__tests__/uri.test.ts +51 -0
- package/src/utils/jolt/__tests__/parse_stream_user_event_type.test.ts +27 -0
- package/src/utils/jolt/parse_stream_user_event_type.ts +16 -0
- package/src/utils/native_adapters/__tests__/linking.test.ts +60 -4
- package/src/utils/native_adapters/configuration.ts +5 -0
- package/src/utils/native_adapters/index.ts +1 -0
- package/src/utils/native_adapters/linking.ts +50 -2
- package/src/utils/native_adapters/updates.ts +16 -0
- package/src/utils/product_analytics_token.ts +120 -0
- package/src/utils/throttled_refresh.ts +62 -0
- 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
|
@@ -0,0 +1,95 @@
|
|
|
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 type { ConversationResource } from '../../../types'
|
|
5
|
+
import { BulkConversationActionsBar } from '../bulk_conversation_actions_bar'
|
|
6
|
+
|
|
7
|
+
jest.mock('react-native-reanimated', () => ({
|
|
8
|
+
...jest.requireActual('react-native-reanimated/mock'),
|
|
9
|
+
LayoutAnimationConfig: ({ children }: { children: React.ReactNode }) => children,
|
|
10
|
+
useReducedMotion: () => false,
|
|
11
|
+
}))
|
|
12
|
+
|
|
13
|
+
const mockHide = jest.fn(async () => {})
|
|
14
|
+
const mockSilence = jest.fn(async () => {})
|
|
15
|
+
jest.mock('../../../hooks/use_bulk_conversation_actions', () => ({
|
|
16
|
+
useBulkConversationActions: () => ({
|
|
17
|
+
hide: mockHide,
|
|
18
|
+
unhide: jest.fn(),
|
|
19
|
+
silence: mockSilence,
|
|
20
|
+
markRead: jest.fn(),
|
|
21
|
+
}),
|
|
22
|
+
}))
|
|
23
|
+
|
|
24
|
+
const createdAt = '2026-10-01T12:00:00Z'
|
|
25
|
+
|
|
26
|
+
const conversation = (overrides: Partial<ConversationResource>): ConversationResource => ({
|
|
27
|
+
type: 'Conversation',
|
|
28
|
+
id: 1,
|
|
29
|
+
title: 'Youth Group',
|
|
30
|
+
conversationPreview: null,
|
|
31
|
+
createdAt,
|
|
32
|
+
lastMessageCreatedAt: createdAt,
|
|
33
|
+
muted: false,
|
|
34
|
+
repliesDisabled: false,
|
|
35
|
+
unreadCount: 1,
|
|
36
|
+
unreadReaction: false,
|
|
37
|
+
updatedAt: createdAt,
|
|
38
|
+
...overrides,
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const first = conversation({ id: 1 })
|
|
42
|
+
const second = conversation({ id: 2 })
|
|
43
|
+
const archived = conversation({ id: 3, disabled: true, disabledReason: 'archived' })
|
|
44
|
+
const mockConversations = [first, second, archived]
|
|
45
|
+
|
|
46
|
+
const mockClearSelection = jest.fn()
|
|
47
|
+
let mockSelectedIds: number[] = []
|
|
48
|
+
jest.mock('../../../contexts/conversations_context', () => ({
|
|
49
|
+
useConversationsContext: () => ({
|
|
50
|
+
selectMode: true,
|
|
51
|
+
selectedIds: mockSelectedIds,
|
|
52
|
+
conversations: mockConversations,
|
|
53
|
+
hideable: true,
|
|
54
|
+
clearSelection: mockClearSelection,
|
|
55
|
+
args: {},
|
|
56
|
+
}),
|
|
57
|
+
}))
|
|
58
|
+
|
|
59
|
+
const safeAreaMetrics = {
|
|
60
|
+
frame: { x: 0, y: 0, width: 390, height: 844 },
|
|
61
|
+
insets: { top: 0, right: 0, bottom: 0, left: 0 },
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const renderBar = () =>
|
|
65
|
+
render(
|
|
66
|
+
<SafeAreaProvider initialMetrics={safeAreaMetrics}>
|
|
67
|
+
<BulkConversationActionsBar />
|
|
68
|
+
</SafeAreaProvider>
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
describe('BulkConversationActionsBar', () => {
|
|
72
|
+
beforeEach(() => jest.clearAllMocks())
|
|
73
|
+
|
|
74
|
+
it('hides every selected conversation and then clears the selection', async () => {
|
|
75
|
+
mockSelectedIds = [1, 2]
|
|
76
|
+
const view = renderBar()
|
|
77
|
+
|
|
78
|
+
await act(async () => fireEvent.press(view.getByText('Hide')))
|
|
79
|
+
|
|
80
|
+
expect(mockHide).toHaveBeenCalledWith([first, second])
|
|
81
|
+
expect(mockClearSelection).toHaveBeenCalled()
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('disables hide and silence when an archived conversation is selected', () => {
|
|
85
|
+
mockSelectedIds = [1, 3]
|
|
86
|
+
const view = renderBar()
|
|
87
|
+
|
|
88
|
+
fireEvent.press(view.getByText('Hide'))
|
|
89
|
+
fireEvent.press(view.getByText('Silence'))
|
|
90
|
+
|
|
91
|
+
expect(mockHide).not.toHaveBeenCalled()
|
|
92
|
+
expect(mockSilence).not.toHaveBeenCalled()
|
|
93
|
+
expect(mockClearSelection).not.toHaveBeenCalled()
|
|
94
|
+
})
|
|
95
|
+
})
|
|
@@ -67,9 +67,13 @@ const conversation = (overrides: Partial<ConversationResource>): ConversationRes
|
|
|
67
67
|
...overrides,
|
|
68
68
|
})
|
|
69
69
|
|
|
70
|
-
const renderActions = (overrides: Partial<ConversationResource
|
|
70
|
+
const renderActions = (overrides: Partial<ConversationResource>, selected?: boolean) =>
|
|
71
71
|
render(
|
|
72
|
-
<ConversationActions
|
|
72
|
+
<ConversationActions
|
|
73
|
+
conversation={conversation(overrides)}
|
|
74
|
+
onPress={jest.fn()}
|
|
75
|
+
selected={selected}
|
|
76
|
+
>
|
|
73
77
|
<Text>Youth Group</Text>
|
|
74
78
|
</ConversationActions>
|
|
75
79
|
)
|
|
@@ -137,6 +141,34 @@ describe('ConversationActions hide', () => {
|
|
|
137
141
|
|
|
138
142
|
fireEvent(view.getByTestId('conversation-7'), 'longPress')
|
|
139
143
|
|
|
140
|
-
expect(mockNavigate).toHaveBeenCalledWith('ConversationActions', {
|
|
144
|
+
expect(mockNavigate).toHaveBeenCalledWith('ConversationActions', {
|
|
145
|
+
conversation_id: 7,
|
|
146
|
+
read: false,
|
|
147
|
+
muted: false,
|
|
148
|
+
})
|
|
149
|
+
})
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
describe('ConversationActions select mode', () => {
|
|
153
|
+
beforeEach(() => {
|
|
154
|
+
mockHideEnabled = true
|
|
155
|
+
mockHideable = true
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
it('presents the row as a checked checkbox without row actions', () => {
|
|
159
|
+
const view = renderActions({}, true)
|
|
160
|
+
const row = view.getByTestId('conversation-7')
|
|
161
|
+
|
|
162
|
+
expect(row.props.accessibilityRole).toBe('checkbox')
|
|
163
|
+
expect(row.props.accessibilityState).toEqual({ checked: true })
|
|
164
|
+
expect(row.props.accessibilityActions).toEqual([])
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
it('keeps the button role and row actions outside select mode', () => {
|
|
168
|
+
const view = renderActions({})
|
|
169
|
+
const row = view.getByTestId('conversation-7')
|
|
170
|
+
|
|
171
|
+
expect(row.props.accessibilityRole).toBe('button')
|
|
172
|
+
expect(row.props.accessibilityActions.length).toBeGreaterThan(0)
|
|
141
173
|
})
|
|
142
174
|
})
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fireEvent } from '@testing-library/react-native'
|
|
1
2
|
import React from 'react'
|
|
2
3
|
import { renderWithQueryClient } from '../../../__utils__/render_with_query_client'
|
|
3
4
|
import { ConversationFiltersParams } from '../../../screens/conversation_filters/screen_props'
|
|
@@ -6,19 +7,40 @@ import { formatDatePreview } from '../../../utils/date'
|
|
|
6
7
|
import { ConversationPreview } from '../conversation_preview'
|
|
7
8
|
|
|
8
9
|
let mockArgs: ConversationFiltersParams = {}
|
|
10
|
+
let mockSelectMode = false
|
|
11
|
+
let mockSelectedIds: number[] = []
|
|
12
|
+
const mockToggleSelected = jest.fn()
|
|
9
13
|
jest.mock('../../../contexts/conversations_context', () => ({
|
|
10
|
-
useConversationsContext: () => ({
|
|
14
|
+
useConversationsContext: () => ({
|
|
15
|
+
args: mockArgs,
|
|
16
|
+
selectMode: mockSelectMode,
|
|
17
|
+
selectedIds: mockSelectedIds,
|
|
18
|
+
toggleSelected: mockToggleSelected,
|
|
19
|
+
}),
|
|
11
20
|
}))
|
|
12
21
|
jest.mock('../conversation_actions', () => ({
|
|
13
22
|
ConversationActions: ({
|
|
14
23
|
children,
|
|
15
24
|
accessibilityLabel,
|
|
25
|
+
onPress,
|
|
26
|
+
selected,
|
|
16
27
|
}: {
|
|
17
28
|
children: React.ReactNode
|
|
18
29
|
accessibilityLabel?: string
|
|
30
|
+
onPress: () => void
|
|
31
|
+
selected?: boolean
|
|
19
32
|
}) => {
|
|
20
|
-
const {
|
|
21
|
-
return
|
|
33
|
+
const { Pressable: MockPressable } = jest.requireActual('react-native')
|
|
34
|
+
return (
|
|
35
|
+
<MockPressable
|
|
36
|
+
accessibilityLabel={accessibilityLabel}
|
|
37
|
+
accessibilityRole="checkbox"
|
|
38
|
+
accessibilityState={{ checked: selected }}
|
|
39
|
+
onPress={onPress}
|
|
40
|
+
>
|
|
41
|
+
{children}
|
|
42
|
+
</MockPressable>
|
|
43
|
+
)
|
|
22
44
|
},
|
|
23
45
|
}))
|
|
24
46
|
|
|
@@ -131,4 +153,48 @@ describe('ConversationPreview', () => {
|
|
|
131
153
|
).toBeNull()
|
|
132
154
|
})
|
|
133
155
|
})
|
|
156
|
+
|
|
157
|
+
describe('select mode', () => {
|
|
158
|
+
const onPress = jest.fn()
|
|
159
|
+
const renderSelectable = () =>
|
|
160
|
+
renderWithQueryClient(
|
|
161
|
+
<ConversationPreview conversation={conversation(messagePreview)} onPress={onPress} />
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
beforeEach(() => {
|
|
165
|
+
mockSelectMode = true
|
|
166
|
+
mockSelectedIds = []
|
|
167
|
+
jest.clearAllMocks()
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
afterAll(() => {
|
|
171
|
+
mockSelectMode = false
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
it('toggles the conversation instead of opening it', () => {
|
|
175
|
+
const view = renderSelectable()
|
|
176
|
+
|
|
177
|
+
fireEvent.press(view.getByText('Worship Team'))
|
|
178
|
+
|
|
179
|
+
expect(mockToggleSelected).toHaveBeenCalledWith(7)
|
|
180
|
+
expect(onPress).not.toHaveBeenCalled()
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
it('marks a selected conversation as checked', () => {
|
|
184
|
+
mockSelectedIds = [7]
|
|
185
|
+
const view = renderSelectable()
|
|
186
|
+
|
|
187
|
+
expect(view.getByRole('checkbox', { checked: true })).toBeTruthy()
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
it('opens the conversation outside select mode', () => {
|
|
191
|
+
mockSelectMode = false
|
|
192
|
+
const view = renderSelectable()
|
|
193
|
+
|
|
194
|
+
fireEvent.press(view.getByText('Worship Team'))
|
|
195
|
+
|
|
196
|
+
expect(onPress).toHaveBeenCalled()
|
|
197
|
+
expect(mockToggleSelected).not.toHaveBeenCalled()
|
|
198
|
+
})
|
|
199
|
+
})
|
|
134
200
|
})
|
|
@@ -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
|
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import { Pressable, StyleSheet } from 'react-native'
|
|
3
|
+
import Animated, { FadeIn, LayoutAnimationConfig, ReduceMotion } from 'react-native-reanimated'
|
|
4
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
5
|
+
import { useConversationsContext } from '../../contexts/conversations_context'
|
|
6
|
+
import { useReduceMotion, useTheme } from '../../hooks'
|
|
7
|
+
import { useBulkConversationActions } from '../../hooks/use_bulk_conversation_actions'
|
|
8
|
+
import { ConversationResource } from '../../types'
|
|
9
|
+
import {
|
|
10
|
+
MAX_FONT_SIZE_MULTIPLIER_LANDMARK,
|
|
11
|
+
isArchivedConversation,
|
|
12
|
+
platformPressedOpacityStyle,
|
|
13
|
+
} from '../../utils'
|
|
14
|
+
import { dismissToast } from '../../utils/toast_store'
|
|
15
|
+
import { Icon, IconString, Text } from '../display'
|
|
16
|
+
|
|
17
|
+
export function BulkConversationActionsBar() {
|
|
18
|
+
const styles = useStyles()
|
|
19
|
+
const reduceMotion = useReduceMotion() ? ReduceMotion.Always : ReduceMotion.Never
|
|
20
|
+
const {
|
|
21
|
+
selectMode,
|
|
22
|
+
selectedIds,
|
|
23
|
+
conversations,
|
|
24
|
+
hideable,
|
|
25
|
+
clearSelection,
|
|
26
|
+
args: { show_hidden: hiddenView = false },
|
|
27
|
+
} = useConversationsContext()
|
|
28
|
+
const { hide, unhide, silence, markRead } = useBulkConversationActions()
|
|
29
|
+
const [pending, setPending] = useState(false)
|
|
30
|
+
|
|
31
|
+
const selected = conversations.filter(({ id }) => selectedIds.includes(id))
|
|
32
|
+
const disabled = pending || selected.length === 0
|
|
33
|
+
const canSilence = !disabled && !selected.some(isArchivedConversation)
|
|
34
|
+
const canHide = canSilence && hideable
|
|
35
|
+
|
|
36
|
+
const run = (action: (_conversations: ConversationResource[]) => Promise<void>) => async () => {
|
|
37
|
+
setPending(true)
|
|
38
|
+
try {
|
|
39
|
+
await action(selected)
|
|
40
|
+
} finally {
|
|
41
|
+
setPending(false)
|
|
42
|
+
clearSelection()
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (selectMode) dismissToast()
|
|
48
|
+
}, [selectMode])
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<LayoutAnimationConfig skipEntering>
|
|
52
|
+
{selectMode && (
|
|
53
|
+
<Animated.View
|
|
54
|
+
entering={FadeIn.duration(300).reduceMotion(reduceMotion)}
|
|
55
|
+
style={styles.container}
|
|
56
|
+
testID="bulk-conversation-actions-bar"
|
|
57
|
+
>
|
|
58
|
+
<BulkAction
|
|
59
|
+
title="Mark read"
|
|
60
|
+
iconName="general.check"
|
|
61
|
+
disabled={disabled}
|
|
62
|
+
onPress={run(markRead)}
|
|
63
|
+
/>
|
|
64
|
+
<BulkAction
|
|
65
|
+
title="Silence"
|
|
66
|
+
iconName="general.bellMuted"
|
|
67
|
+
disabled={!canSilence}
|
|
68
|
+
onPress={run(silence)}
|
|
69
|
+
/>
|
|
70
|
+
<BulkAction
|
|
71
|
+
title={hiddenView ? 'Unhide' : 'Hide'}
|
|
72
|
+
iconName={hiddenView ? 'general.showEye' : 'general.hideEye'}
|
|
73
|
+
disabled={!canHide}
|
|
74
|
+
onPress={run(hiddenView ? unhide : hide)}
|
|
75
|
+
/>
|
|
76
|
+
</Animated.View>
|
|
77
|
+
)}
|
|
78
|
+
</LayoutAnimationConfig>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function BulkAction({
|
|
83
|
+
title,
|
|
84
|
+
iconName,
|
|
85
|
+
disabled,
|
|
86
|
+
onPress,
|
|
87
|
+
}: {
|
|
88
|
+
title: string
|
|
89
|
+
iconName: IconString
|
|
90
|
+
disabled: boolean
|
|
91
|
+
onPress: () => void
|
|
92
|
+
}) {
|
|
93
|
+
const styles = useStyles({ disabled })
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<Pressable
|
|
97
|
+
onPress={onPress}
|
|
98
|
+
disabled={disabled}
|
|
99
|
+
accessibilityRole="button"
|
|
100
|
+
accessibilityState={{ disabled }}
|
|
101
|
+
style={({ pressed }) => [styles.action, pressed && platformPressedOpacityStyle]}
|
|
102
|
+
>
|
|
103
|
+
<Icon name={iconName} size={20} style={styles.actionIcon} accessibilityElementsHidden />
|
|
104
|
+
<Text style={styles.actionTitle} maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}>
|
|
105
|
+
{title}
|
|
106
|
+
</Text>
|
|
107
|
+
</Pressable>
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const useStyles = ({ disabled = false }: { disabled?: boolean } = {}) => {
|
|
112
|
+
const { bottom } = useSafeAreaInsets()
|
|
113
|
+
const { colors } = useTheme()
|
|
114
|
+
const containerVerticalPadding = 12
|
|
115
|
+
const actionColor = disabled ? colors.textColorDefaultDisabled : colors.textColorDefaultPrimary
|
|
116
|
+
|
|
117
|
+
return StyleSheet.create({
|
|
118
|
+
container: {
|
|
119
|
+
flexDirection: 'row',
|
|
120
|
+
backgroundColor: colors.surfaceColor090,
|
|
121
|
+
paddingHorizontal: 16,
|
|
122
|
+
paddingTop: containerVerticalPadding,
|
|
123
|
+
paddingBottom: bottom + containerVerticalPadding,
|
|
124
|
+
borderTopWidth: 1,
|
|
125
|
+
borderTopColor: colors.borderColorDefaultDim,
|
|
126
|
+
},
|
|
127
|
+
action: {
|
|
128
|
+
flex: 1,
|
|
129
|
+
alignItems: 'center',
|
|
130
|
+
gap: 4,
|
|
131
|
+
},
|
|
132
|
+
actionIcon: {
|
|
133
|
+
color: actionColor,
|
|
134
|
+
},
|
|
135
|
+
actionTitle: {
|
|
136
|
+
color: actionColor,
|
|
137
|
+
fontWeight: '600',
|
|
138
|
+
},
|
|
139
|
+
})
|
|
140
|
+
}
|
|
@@ -32,12 +32,14 @@ export function ConversationActions({
|
|
|
32
32
|
style,
|
|
33
33
|
onPress,
|
|
34
34
|
accessibilityLabel,
|
|
35
|
+
selected,
|
|
35
36
|
}: {
|
|
36
37
|
children: ReactNode
|
|
37
38
|
conversation: ConversationResource
|
|
38
39
|
onPress: () => void
|
|
39
40
|
style?: StyleProp<ViewStyle>
|
|
40
41
|
accessibilityLabel?: string
|
|
42
|
+
selected?: boolean
|
|
41
43
|
}) {
|
|
42
44
|
const swipeableRef = useRef<SwipeableMethods>(null)
|
|
43
45
|
const navigation = useNavigation()
|
|
@@ -67,6 +69,8 @@ export function ConversationActions({
|
|
|
67
69
|
const isConversationEmpty = conversation.lastMessageCreatedAt === null
|
|
68
70
|
const canMute = !isArchivedConversation(conversation)
|
|
69
71
|
const canHide = hideable && hideConversationsEnabled && !isArchivedConversation(conversation)
|
|
72
|
+
const selectMode = selected !== undefined
|
|
73
|
+
const canOpenActions = hideable && hideConversationsEnabled && !selectMode
|
|
70
74
|
|
|
71
75
|
const handleSwipeableClose = useCallback(() => {
|
|
72
76
|
setDisabled(false)
|
|
@@ -97,8 +101,8 @@ export function ConversationActions({
|
|
|
97
101
|
if (disabled) return
|
|
98
102
|
|
|
99
103
|
Haptic.impactLight()
|
|
100
|
-
navigation.navigate('ConversationActions', { conversation_id: conversation.id })
|
|
101
|
-
}, [disabled, navigation, conversation.id])
|
|
104
|
+
navigation.navigate('ConversationActions', { conversation_id: conversation.id, read, muted })
|
|
105
|
+
}, [disabled, navigation, conversation.id, read, muted])
|
|
102
106
|
|
|
103
107
|
const handleLatestMessageUnread = useCallback(() => {
|
|
104
108
|
markRead(!read)
|
|
@@ -132,11 +136,9 @@ export function ConversationActions({
|
|
|
132
136
|
]
|
|
133
137
|
: []
|
|
134
138
|
|
|
135
|
-
const accessibilityActions =
|
|
136
|
-
|
|
137
|
-
...hideAccessibilityAction,
|
|
138
|
-
...readAccessibilityAction,
|
|
139
|
-
]
|
|
139
|
+
const accessibilityActions = selectMode
|
|
140
|
+
? []
|
|
141
|
+
: [...muteAccessibilityAction, ...hideAccessibilityAction, ...readAccessibilityAction]
|
|
140
142
|
|
|
141
143
|
const handleAccessibilityAction = useCallback(
|
|
142
144
|
(event: AccessibilityActionEvent) => {
|
|
@@ -162,6 +164,10 @@ export function ConversationActions({
|
|
|
162
164
|
[handleLatestMessageUnread, handleMute, handleHide]
|
|
163
165
|
)
|
|
164
166
|
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
if (selectMode) handleSwipeableClose()
|
|
169
|
+
}, [selectMode, handleSwipeableClose])
|
|
170
|
+
|
|
165
171
|
useEffect(() => {
|
|
166
172
|
if (activeConversationId === conversation.id) return
|
|
167
173
|
|
|
@@ -171,6 +177,7 @@ export function ConversationActions({
|
|
|
171
177
|
return (
|
|
172
178
|
<ReanimatedSwipeable
|
|
173
179
|
ref={swipeableRef}
|
|
180
|
+
enabled={!selectMode}
|
|
174
181
|
childrenContainerStyle={styles.swipeableChildContainer}
|
|
175
182
|
containerStyle={styles.swipeableContainer}
|
|
176
183
|
overshootFriction={8}
|
|
@@ -199,11 +206,12 @@ export function ConversationActions({
|
|
|
199
206
|
<Pressable
|
|
200
207
|
testID={`conversation-${conversation.id}`}
|
|
201
208
|
onPress={handlePress}
|
|
202
|
-
onLongPress={
|
|
209
|
+
onLongPress={canOpenActions ? handleLongPress : undefined}
|
|
203
210
|
style={({ pressed }) => [style, pressed && platformPressedOpacityStyle]}
|
|
204
211
|
android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}
|
|
205
212
|
accessibilityLabel={accessibilityLabel}
|
|
206
|
-
accessibilityRole=
|
|
213
|
+
accessibilityRole={selectMode ? 'checkbox' : 'button'}
|
|
214
|
+
accessibilityState={selectMode ? { checked: selected } : undefined}
|
|
207
215
|
accessibilityActions={accessibilityActions}
|
|
208
216
|
onAccessibilityAction={handleAccessibilityAction}
|
|
209
217
|
>
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
useFontScale,
|
|
8
8
|
useScalableNumberOfLines,
|
|
9
9
|
} from '../../hooks'
|
|
10
|
+
import { useSelectedChipBackgroundColor } from '../../hooks/use_selected_chip_background_color'
|
|
10
11
|
import { ConversationPreviewData, ConversationResource } from '../../types'
|
|
11
12
|
import { REACTION_EMOJIS, isArchivedConversation, platformFontWeightBold } from '../../utils'
|
|
12
13
|
import { formatDatePreview } from '../../utils/date'
|
|
@@ -19,6 +20,7 @@ import {
|
|
|
19
20
|
IconTile,
|
|
20
21
|
Text,
|
|
21
22
|
Badge,
|
|
23
|
+
Checkbox,
|
|
22
24
|
type BadgeProps,
|
|
23
25
|
} from '../display'
|
|
24
26
|
import { ConversationActions } from './conversation_actions'
|
|
@@ -44,8 +46,12 @@ export const ConversationPreview = ({
|
|
|
44
46
|
const styles = useStyles()
|
|
45
47
|
const {
|
|
46
48
|
args: { show_hidden: hidden = false },
|
|
49
|
+
selectMode,
|
|
50
|
+
selectedIds,
|
|
51
|
+
toggleSelected,
|
|
47
52
|
} = useConversationsContext()
|
|
48
53
|
const {
|
|
54
|
+
id,
|
|
49
55
|
conversationPreview,
|
|
50
56
|
lastMessageCreatedAt,
|
|
51
57
|
title,
|
|
@@ -61,6 +67,8 @@ export const ConversationPreview = ({
|
|
|
61
67
|
const fallbackIconName = emptyConversation ? 'people.noTextMessage' : 'general.person'
|
|
62
68
|
const hasMetaContent = lastMessageCreatedAt || unreadCount > 0 || muted || hidden
|
|
63
69
|
const isUnread = unreadCount > 0 || unreadReaction
|
|
70
|
+
const selected = selectMode ? selectedIds.includes(id) : undefined
|
|
71
|
+
const selectedBackgroundColor = useSelectedChipBackgroundColor()
|
|
64
72
|
|
|
65
73
|
const numberOfLinesScaledTitle = useScalableNumberOfLines(1)
|
|
66
74
|
const numberOfLinesScaledPreviewText = useScalableNumberOfLines(2)
|
|
@@ -79,10 +87,17 @@ export const ConversationPreview = ({
|
|
|
79
87
|
return (
|
|
80
88
|
<ConversationActions
|
|
81
89
|
conversation={conversation}
|
|
82
|
-
style={[
|
|
83
|
-
|
|
90
|
+
style={[
|
|
91
|
+
styles.previewRow,
|
|
92
|
+
disabled && !archived && styles.disabled,
|
|
93
|
+
selected && { backgroundColor: selectedBackgroundColor },
|
|
94
|
+
style,
|
|
95
|
+
]}
|
|
96
|
+
onPress={selectMode ? () => toggleSelected(id) : onPress}
|
|
84
97
|
accessibilityLabel={conversationAccessibilityLabel}
|
|
98
|
+
selected={selected}
|
|
85
99
|
>
|
|
100
|
+
{selected !== undefined && <Checkbox checked={selected} style={styles.checkbox} />}
|
|
86
101
|
{archived ? (
|
|
87
102
|
<IconTile
|
|
88
103
|
icon={faBoxArchive}
|
|
@@ -284,6 +299,9 @@ const useStyles = () => {
|
|
|
284
299
|
disabled: {
|
|
285
300
|
opacity: 0.4,
|
|
286
301
|
},
|
|
302
|
+
checkbox: {
|
|
303
|
+
alignSelf: 'center',
|
|
304
|
+
},
|
|
287
305
|
title: {
|
|
288
306
|
fontSize: 16,
|
|
289
307
|
color: colors.textColorDefaultPrimary,
|
|
@@ -32,6 +32,7 @@ export const Conversations = ({ ListHeaderComponent }: ConversationsProps) => {
|
|
|
32
32
|
isRefetching,
|
|
33
33
|
isFetched,
|
|
34
34
|
hasNextPage,
|
|
35
|
+
selectMode,
|
|
35
36
|
args: {
|
|
36
37
|
chat_group_graph_id,
|
|
37
38
|
group_source_app_name,
|
|
@@ -88,7 +89,7 @@ export const Conversations = ({ ListHeaderComponent }: ConversationsProps) => {
|
|
|
88
89
|
contentInsetAdjustmentBehavior="automatic"
|
|
89
90
|
onRefresh={refetch}
|
|
90
91
|
refreshing={!isFetched && isRefetching}
|
|
91
|
-
ListHeaderComponent={ListHeaderComponent}
|
|
92
|
+
ListHeaderComponent={selectMode ? null : ListHeaderComponent}
|
|
92
93
|
ListEmptyComponent={
|
|
93
94
|
<ConversationsBlankState
|
|
94
95
|
isFilterApplied={isFilterApplied}
|
|
@@ -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
|
})
|