@openpeepshq/rn-components 0.13.1 → 0.14.0

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.
Files changed (30) hide show
  1. package/README.md +2 -0
  2. package/package.json +3 -3
  3. package/src/components/icons/index.ts +2 -0
  4. package/src/components/jams/JamDeviceSelectors.tsx +2 -2
  5. package/src/components/jams/JamLobby.tsx +5 -3
  6. package/src/components/jams/JamParticipantConference.tsx +6 -1
  7. package/src/components/jams/JamRoomIndicators.test.tsx +80 -4
  8. package/src/components/jams/JamRoomIndicators.tsx +34 -1
  9. package/src/components/jams/JamVideoCall.tsx +5 -5
  10. package/src/components/layout/ContentHeader.tsx +6 -2
  11. package/src/components/layout/HeaderMobile.tsx +48 -22
  12. package/src/components/layout/PlusButton.tsx +1 -7
  13. package/src/components/layout/pageChrome.test.tsx +213 -0
  14. package/src/components/post/pieces/FeedPostStats.tsx +15 -11
  15. package/src/components/post/pieces/PollContent.tsx +1 -1
  16. package/src/components/post/pieces/PostMenu.test.tsx +333 -0
  17. package/src/components/post/pieces/PostMenu.tsx +19 -15
  18. package/src/components/post/post-form/ReplyModal.tsx +1 -1
  19. package/src/components/profile/ProfileCard.test.tsx +16 -1
  20. package/src/components/profile/ProfileCard.tsx +14 -3
  21. package/src/components/resources/ResourceLibrary.tsx +0 -1
  22. package/src/hooks/use-controlled-sheet.test.tsx +140 -0
  23. package/src/hooks/use-controlled-sheet.ts +25 -2
  24. package/src/pages/Explore.tsx +1 -3
  25. package/src/pages/conversations/Info.tsx +1 -1
  26. package/src/pages/conversations/New.tsx +1 -1
  27. package/src/pages/conversations/Show.tsx +21 -29
  28. package/src/pages/posts/Edit.tsx +1 -1
  29. package/src/pages/posts/New.tsx +1 -1
  30. package/src/pages/posts/Reply.tsx +2 -2
@@ -19,6 +19,124 @@ import {
19
19
  useSetPlusButtonActions,
20
20
  } from './pageChrome';
21
21
 
22
+ // The two rebuilt layout components (HeaderMobile, ContentHeader) pull in
23
+ // navigation, i18n, drawer, window and theme hooks plus a few UI primitives.
24
+ // Mock that whole dependency surface so the real components can be rendered in
25
+ // the node test environment; the real pageChrome scaffolding above is reused
26
+ // (the provider is what ContentHeader reads its title / onBack from).
27
+ const React = require('react');
28
+
29
+ let mockServerInfo: unknown;
30
+ let mockTheme: unknown;
31
+ let mockCurrentProfile: unknown;
32
+ const mockNavigate = jest.fn();
33
+ const mockOpenDrawer = jest.fn();
34
+ const mockGoToParentOrBack = jest.fn();
35
+ const mockOnBack = jest.fn();
36
+
37
+ jest.mock('react-native', () => ({
38
+ Platform: { OS: 'ios' },
39
+ StatusBar: { currentHeight: 0 },
40
+ StyleSheet: { create: (s: Record<string, unknown>) => s },
41
+ View: (props: { children?: unknown }) =>
42
+ React.createElement('View', props, props.children),
43
+ Pressable: (props: { children?: unknown }) =>
44
+ React.createElement('Pressable', props, props.children),
45
+ useColorScheme: () => 'light',
46
+ }));
47
+
48
+ jest.mock('react-native-safe-area-context', () => ({
49
+ SafeAreaView: (props: { children?: unknown }) =>
50
+ React.createElement('SafeAreaView', props, props.children),
51
+ }));
52
+
53
+ jest.mock('@react-navigation/native', () => ({
54
+ useNavigation: () => ({ navigate: mockNavigate }),
55
+ useRoute: () => ({ name: 'Test', params: undefined }),
56
+ }));
57
+
58
+ jest.mock('@openpeepshq/react', () => ({
59
+ useOpenpeeps: () => ({
60
+ currentProfile: mockCurrentProfile,
61
+ openpeepsApi: {
62
+ useServerInfo: () => ({ data: mockServerInfo }),
63
+ useCurrentProfileSettings: () => ({ data: undefined }),
64
+ },
65
+ }),
66
+ useCurrentProfile: () => mockCurrentProfile,
67
+ }));
68
+
69
+ jest.mock('@openpeepshq/common', () => ({
70
+ getTheme: () => mockTheme,
71
+ }));
72
+
73
+ jest.mock('react-i18next', () => ({
74
+ useTranslation: () => ({ t: (key: string) => key }),
75
+ }));
76
+
77
+ jest.mock('../../contexts/drawer-context', () => ({
78
+ useDrawer: () => ({ openDrawer: mockOpenDrawer }),
79
+ }));
80
+
81
+ jest.mock('../../hooks/index', () => ({
82
+ useWindowSize: () => ({
83
+ windowWidth: 390,
84
+ windowHeight: 844,
85
+ isMediumScreenOrLarger: false,
86
+ }),
87
+ }));
88
+
89
+ jest.mock('../../lib/constants', () => ({
90
+ BASE_URL: 'https://example.test',
91
+ isProduction: true,
92
+ }));
93
+
94
+ jest.mock('../../lib/media-url', () => ({
95
+ toAbsoluteMediaUrl: (url?: string) => url,
96
+ }));
97
+
98
+ jest.mock('../navigation/parent-back', () => ({
99
+ goToParentOrBack: mockGoToParentOrBack,
100
+ }));
101
+
102
+ jest.mock('../ui/avatar', () => ({
103
+ Avatar: (props: { children?: unknown }) =>
104
+ React.createElement('Avatar', props, props.children),
105
+ AvatarFallback: (props: { children?: unknown }) =>
106
+ React.createElement('AvatarFallback', props, props.children),
107
+ AvatarImage: (props: { children?: unknown }) =>
108
+ React.createElement('AvatarImage', props, props.children),
109
+ }));
110
+
111
+ jest.mock('../ui/button', () => ({
112
+ Button: (props: { children?: unknown }) =>
113
+ React.createElement('Button', props, props.children),
114
+ }));
115
+
116
+ jest.mock('../ui/themed-text', () => ({
117
+ ThemedText: (props: { children?: unknown }) =>
118
+ React.createElement('ThemedText', props, props.children),
119
+ }));
120
+
121
+ jest.mock('../ui/svg-image', () => ({
122
+ SvgImage: (props: { children?: unknown }) =>
123
+ React.createElement('SvgImage', props, props.children),
124
+ }));
125
+
126
+ jest.mock('../icons/index', () => ({
127
+ MenuIcon: (props: Record<string, unknown>) =>
128
+ React.createElement('MenuIcon', props),
129
+ MessageSquareTextIcon: (props: Record<string, unknown>) =>
130
+ React.createElement('MessageSquareTextIcon', props),
131
+ UserIcon: (props: Record<string, unknown>) =>
132
+ React.createElement('UserIcon', props),
133
+ ChevronLeftIcon: (props: Record<string, unknown>) =>
134
+ React.createElement('ChevronLeftIcon', props),
135
+ }));
136
+
137
+ import { ContentHeader } from './ContentHeader';
138
+ import { HeaderMobile } from './HeaderMobile';
139
+
22
140
  const MAX_RENDER_GUARD = 20;
23
141
 
24
142
  const Text = ({ children }: { children?: ReactNode }) => (
@@ -145,3 +263,98 @@ test('page chrome hooks throw outside RootLayout', () => {
145
263
  });
146
264
  }).toThrow('Page chrome hooks must be used within RootLayout');
147
265
  });
266
+
267
+ // The two rebuilt layout components (issue #1971). The existing tests above
268
+ // exercise the pageChrome context but never the components that render it;
269
+ // these pin their structure and navigation wiring so a regression in the
270
+ // consolidated chrome fails CI instead of only typechecking clean.
271
+ describe('rebuilt layout components (issue #1971)', () => {
272
+ beforeEach(() => {
273
+ mockNavigate.mockReset();
274
+ mockOpenDrawer.mockReset();
275
+ mockGoToParentOrBack.mockReset();
276
+ mockServerInfo = undefined;
277
+ mockTheme = undefined;
278
+ mockCurrentProfile = undefined;
279
+ });
280
+
281
+ const renderHeader = () => {
282
+ let tree!: ReactTestRenderer.ReactTestRenderer;
283
+ ReactTestRenderer.act(() => {
284
+ tree = ReactTestRenderer.create(<HeaderMobile />);
285
+ });
286
+ return tree;
287
+ };
288
+
289
+ const RegisterHeader = () => {
290
+ useSetPageHeader('Conversations', undefined, mockOnBack);
291
+ return null;
292
+ };
293
+
294
+ test('HeaderMobile: a guest (no current profile) renders the menu-icon trigger', () => {
295
+ const tree = renderHeader();
296
+ // currentProfile is undefined → the guest fallback MenuIcon is the drawer
297
+ // trigger (web renders an avatar for signed-in users, a menu icon for
298
+ // guests); no logo (server info / theme absent) so no navigation logo.
299
+ expect(tree.root.findAllByType('MenuIcon')).toHaveLength(1);
300
+ expect(tree.root.findAllByType('Avatar')).toHaveLength(0);
301
+ expect(tree.root.findAllByType('SvgImage')).toHaveLength(0);
302
+ // The menu trigger button carries the (mocked to its key) label.
303
+ const menuButtons = tree.root
304
+ .findAllByType('Button')
305
+ .filter(
306
+ (node: { props: Record<string, unknown> }) =>
307
+ node.props.accessibilityLabel === 'navigation.openMenu'
308
+ );
309
+ expect(menuButtons).toHaveLength(1);
310
+ tree.unmount();
311
+ });
312
+
313
+ test('HeaderMobile: the logo button navigates to Home (guest branch)', () => {
314
+ // A configured theme with a small logo renders the logo button.
315
+ mockServerInfo = { communityConfig: {} };
316
+ mockTheme = { logoSmall: '/logo.svg' };
317
+ const tree = renderHeader();
318
+ const logoButton = tree.root.find(
319
+ (node: { props?: Record<string, unknown> }) =>
320
+ node.props && node.props.accessibilityLabel === 'navigation.home'
321
+ );
322
+ expect(logoButton).toBeDefined();
323
+ ReactTestRenderer.act(() => {
324
+ logoButton.props.onPress();
325
+ });
326
+ expect(mockNavigate).toHaveBeenCalledWith('TabNavigator', {
327
+ screen: 'Home',
328
+ });
329
+ tree.unmount();
330
+ });
331
+
332
+ test('ContentHeader: renders the fixed h-16 bg-background row and the back button', () => {
333
+ let tree!: ReactTestRenderer.ReactTestRenderer;
334
+ ReactTestRenderer.act(() => {
335
+ tree = ReactTestRenderer.create(
336
+ <PageChromeProvider>
337
+ <ContentHeader />
338
+ <RegisterHeader />
339
+ </PageChromeProvider>
340
+ );
341
+ });
342
+ // The fixed-height background row renders.
343
+ const rows = tree.root.findAll(
344
+ (node: { type?: unknown; props: Record<string, unknown> }) =>
345
+ node.type === 'View' &&
346
+ node.props.className ===
347
+ 'bg-background border-border h-16 flex-row items-center justify-between border-b px-4'
348
+ );
349
+ expect(rows).toHaveLength(1);
350
+ // The back button exposes the (mocked to its key) common.actions.back label.
351
+ const backButtons = tree.root
352
+ .findAllByType('Pressable')
353
+ .filter(
354
+ (node: { props: Record<string, unknown> }) =>
355
+ node.props.accessibilityLabel === 'common.actions.back'
356
+ );
357
+ expect(backButtons).toHaveLength(1);
358
+ tree.unmount();
359
+ });
360
+ });
@@ -59,17 +59,21 @@ export const FeedPostStats = ({ post }: FeedPostStatsProps) => {
59
59
  </View>
60
60
  </View>
61
61
 
62
- <ReactionsModal
63
- reactions={post.reactions ?? []}
64
- open={modal === 'reactions'}
65
- onClose={() => setModal(null)}
66
- />
67
- <RepostModal
68
- reposts={post.reposts ?? []}
69
- repostCount={post.repostCount ?? 0}
70
- open={modal === 'reposts'}
71
- onClose={() => setModal(null)}
72
- />
62
+ {modal === 'reactions' && (
63
+ <ReactionsModal
64
+ open
65
+ reactions={post.reactions ?? []}
66
+ onClose={() => setModal(null)}
67
+ />
68
+ )}
69
+ {modal === 'reposts' && (
70
+ <RepostModal
71
+ open
72
+ reposts={post.reposts ?? []}
73
+ repostCount={post.repostCount ?? 0}
74
+ onClose={() => setModal(null)}
75
+ />
76
+ )}
73
77
  </>
74
78
  );
75
79
  };
@@ -72,7 +72,7 @@ export const PollContent = ({ post }: Props) => {
72
72
  } else {
73
73
  Toast.show({
74
74
  type: 'error',
75
- text1: t('posts.poll.selectOption'),
75
+ text1: t('posts.vote.selectOption'),
76
76
  });
77
77
  }
78
78
  };
@@ -0,0 +1,333 @@
1
+ /**
2
+ * PostMenu mount-gated reaction/repost sheets (issue #2109 round 2).
3
+ *
4
+ * These pin the call-site contract after the mount-gating rework: both sheet
5
+ * call sites (Reactions, Reposts) render their modal only while their `open`
6
+ * prop is true, and `open` is a required prop on the modal components. This
7
+ * file's regression guard is that PostMenu never mounts a sheet while its
8
+ * state is closed, so a closed modal can never race its own `present()` on
9
+ * mount.
10
+ *
11
+ * Mirrors FullEvent.test.tsx: every external import is mocked (node jest env,
12
+ * no native modules); the decision tree under test is the modal mount logic.
13
+ */
14
+ import { type ReactNode } from 'react';
15
+ import ReactTestRenderer from 'react-test-renderer';
16
+ import Toast from 'react-native-toast-message';
17
+
18
+ // --- shared mutable state read by the module mocks (mock* = hoisting-safe) --
19
+ let mockProfile: { id: string; displayName?: string; handle?: string } | null =
20
+ { id: 'u-1', displayName: 'Me', handle: 'me', following: [] };
21
+ const mockClient = {
22
+ posts: { deletePost: jest.fn(), pinPost: jest.fn() },
23
+ profiles: { followProfile: jest.fn() },
24
+ };
25
+ // ReactionsModal/RepostModal record their mount + open props for assertions.
26
+ const mountedReactions: { open: boolean | undefined; onClose?: () => void }[] =
27
+ [];
28
+ const mountedReposts: { open: boolean | undefined; onClose?: () => void }[] =
29
+ [];
30
+
31
+ // --- react-native: host elements render as plain host tags ----------------
32
+ // Each factory uses `require('react')` (not a top-level `import React`) because
33
+ // jest.mock factories run during hoisted import resolution, before top-level
34
+ // bindings exist — the same convention FullEvent.test.tsx documents.
35
+ jest.mock('react-native', () => {
36
+ const React = require('react');
37
+ const make = (tag: string) => (props: { children?: ReactNode }) =>
38
+ React.createElement(tag, props, props.children);
39
+ return {
40
+ View: make('View'),
41
+ Pressable: make('Pressable'),
42
+ TouchableOpacity: make('TouchableOpacity'),
43
+ ActivityIndicator: () => null,
44
+ Share: { share: jest.fn() },
45
+ };
46
+ });
47
+
48
+ // --- i18n: resolve keys to their defaultValue -----------------------------
49
+ jest.mock('react-i18next', () => ({
50
+ useTranslation: () => ({
51
+ t: (_key: string, opts?: { defaultValue?: string }) =>
52
+ opts?.defaultValue ?? _key,
53
+ }),
54
+ }));
55
+
56
+ // --- openpeeps context -----------------------------------------------------
57
+ jest.mock('@openpeepshq/react', () => ({
58
+ useOpenpeeps: () => ({
59
+ currentProfile: mockProfile,
60
+ openpeepsApi: {
61
+ useCurrentProfile: () => ({ data: mockProfile, refetch: jest.fn() }),
62
+ useServerInfo: () => ({
63
+ data: { feature_flags: { groups: true, events: true } },
64
+ }),
65
+ useCurrentProfileBookmarkedIds: () => ({ data: [], refetch: jest.fn() }),
66
+ bookmarkPostAction: () => jest.fn(),
67
+ unbookmarkPostAction: () => jest.fn(),
68
+ deletePostAction: () => jest.fn(),
69
+ updateGroupAction: () => jest.fn(),
70
+ pinPostOnProfileAction: () => jest.fn(),
71
+ followProfileAction: () => jest.fn().mockResolvedValue({ success: true }),
72
+ unfollowProfileAction: () =>
73
+ jest.fn().mockResolvedValue({ success: true }),
74
+ admin: { pinPostGloballyAction: () => jest.fn() },
75
+ },
76
+ client: mockClient,
77
+ }),
78
+ }));
79
+
80
+ // --- local modules ---------------------------------------------------------
81
+ jest.mock('../../../hooks/use-controlled-sheet', () => ({
82
+ useControlledSheet: () => ({ current: {} }),
83
+ }));
84
+ jest.mock('../../../lib/utils', () => ({
85
+ profileName: (p?: { displayName?: string; handle?: string }) =>
86
+ p?.displayName ?? p?.handle ?? '',
87
+ handleInternalURLNavigation: jest.fn(),
88
+ }));
89
+ jest.mock('../../../components/navigation/helpers', () => ({
90
+ buildGoto: () => jest.fn(),
91
+ }));
92
+ jest.mock('@react-navigation/native', () => ({
93
+ useNavigation: () => ({ navigate: jest.fn() }),
94
+ }));
95
+ jest.mock('@react-navigation/native-stack', () => ({}));
96
+ jest.mock('react-native-toast-message', () => ({
97
+ __esModule: true,
98
+ default: { show: jest.fn() },
99
+ }));
100
+ jest.mock('@gorhom/bottom-sheet', () => ({
101
+ BottomSheetModal: () => null,
102
+ }));
103
+
104
+ // --- ui primitives ---------------------------------------------------------
105
+ // PostMenu imports its UI primitives from the `../../ui` barrel (mocked
106
+ // below); direct-path mocks for the individual modules are unreachable
107
+ // because jest resolves `jest.mock` by exact module path, so they are not
108
+ // kept here.
109
+
110
+ // Delete/confirm flow renders nothing under test.
111
+ jest.mock('./modals/DeletePostModal', () => ({
112
+ DeletePostModal: () => null,
113
+ }));
114
+
115
+ // Current main's PostMenu also mounts the edit-history sheet; it is out of
116
+ // scope here, and its real module graph reaches ESM-only react-native-config,
117
+ // which Jest's CommonJS runtime cannot parse. Stub it out for the test.
118
+ jest.mock('./modals/PostEditHistoryModal', () => ({
119
+ PostEditHistoryModal: () => null,
120
+ }));
121
+
122
+ // The two modals under test: record mount + open prop.
123
+ jest.mock('./modals/ReactionsModal', () => ({
124
+ ReactionsModal: (props: { open?: boolean; onClose?: () => void }) => {
125
+ mountedReactions.push({ open: props.open, onClose: props.onClose });
126
+ return null;
127
+ },
128
+ }));
129
+ jest.mock('./modals/RepostModal', () => ({
130
+ RepostModal: (props: { open?: boolean; onClose?: () => void }) => {
131
+ mountedReposts.push({ open: props.open, onClose: props.onClose });
132
+ return null;
133
+ },
134
+ }));
135
+
136
+ jest.mock('../../icons/index', () => ({
137
+ PencilIcon: () => null,
138
+ Trash2Icon: () => null,
139
+ FlagIcon: () => null,
140
+ UserXIcon: () => null,
141
+ UsersPlusIcon: () => null,
142
+ PinIcon: () => null,
143
+ BookmarkPlusIcon: () => null,
144
+ BookmarkMinusIcon: () => null,
145
+ Repeat2Icon: () => null,
146
+ HeartIcon: () => null,
147
+ MessageCircleIcon: () => null,
148
+ MoreVerticalIcon: () => null,
149
+ LogOutIcon: () => null,
150
+ MessageSquareReplyIcon: () => null,
151
+ SaveIcon: () => null,
152
+ RadioIcon: () => null,
153
+ TriangleAlertIcon: () => null,
154
+ FileTextIcon: () => null,
155
+ BellOffIcon: () => null,
156
+ BellPlusIcon: () => null,
157
+ BadgeCheckIcon: () => null,
158
+ ShareIcon: () => null,
159
+ DownloadIcon: () => null,
160
+ MapPinIcon: () => null,
161
+ LinkIcon: () => null,
162
+ Link2Icon: () => null,
163
+ PhoneCallIcon: () => null,
164
+ SendIcon: () => null,
165
+ MessageSquareLockIcon: () => null,
166
+ MessageSquarePlusIcon: () => null,
167
+ }));
168
+
169
+ jest.mock('../../ui/index', () => {
170
+ const React = require('react');
171
+ return {
172
+ // The full barrel drags in avatar/dropdown natives; expose only the menu
173
+ // surface PostMenu uses, backed by the same mock fakes as the direct mocks.
174
+ PopupMenu: (props: { children?: ReactNode }) =>
175
+ React.createElement('View', props, props.children),
176
+ PopupMenuButton: (props: {
177
+ text?: string;
178
+ action?: unknown;
179
+ onPress?: () => void;
180
+ }) =>
181
+ React.createElement('View', {
182
+ testID: `menu-${props.text}`,
183
+ onPress: typeof props.action === 'function' ? props.action : undefined,
184
+ }),
185
+ PopupSeparator: () => null,
186
+ Avatar: () => null,
187
+ Badge: () => null,
188
+ Button: () => null,
189
+ };
190
+ });
191
+
192
+ jest.mock('@openpeepshq/common', () => ({
193
+ checkGroupCapabilities: () => ({}),
194
+ checkRoleCapabilities: () => ({}),
195
+ }));
196
+ jest.mock('@openpeepshq/common/lib', () => ({
197
+ checkRoleCapabilities: () => ({}),
198
+ // Current main's PostMenu gates the edit-history action on this; the edit
199
+ // history is out of scope for these tests, so it stays hidden.
200
+ postHasEditHistory: () => false,
201
+ }));
202
+ jest.mock('@openpeepshq/common/types', () => ({}), { virtual: true });
203
+
204
+ jest.mock('../../profile/ReportProfileOrPostModal', () => ({
205
+ ReportProfileOrPostModal: () => null,
206
+ }));
207
+
208
+ jest.mock('../post-form/EditPostModalContext', () => ({
209
+ useEditPostModal: () => ({ openEditPost: jest.fn() }),
210
+ }));
211
+
212
+ import { PostMenu } from './PostMenu';
213
+
214
+ // A "Join Jam" button is the host View that carries the label AND forwards
215
+ // onPress (only Button does). Search deepest-first so the button itself — not
216
+ // an ancestor container that merely contains the label — is returned.
217
+ type TreeNode = {
218
+ type?: string;
219
+ props?: Record<string, unknown> | null;
220
+ children?: (TreeNode | string | null)[];
221
+ };
222
+
223
+ function findByTestID(json: unknown, testID: string): TreeNode | undefined {
224
+ if (json === null || typeof json !== 'object') return undefined;
225
+ const node = json as TreeNode;
226
+ if (node.props?.testID === testID) return node;
227
+ for (const c of node.children || []) {
228
+ if (typeof c !== 'string' && c !== null) {
229
+ const found = findByTestID(c, testID);
230
+ if (found) return found;
231
+ }
232
+ }
233
+ return undefined;
234
+ }
235
+
236
+ const BASE_POST = {
237
+ id: 'post-1',
238
+ profile: { id: 'owner-1', displayName: 'Owner' },
239
+ visibility: 'public',
240
+ repostCount: 2,
241
+ reactionCount: 3,
242
+ data: { type: 'note', content: 'hello' },
243
+ };
244
+
245
+ function render(): ReactTestRenderer.ReactTestRenderer {
246
+ let tree!: ReactTestRenderer.ReactTestRenderer;
247
+ ReactTestRenderer.act(() => {
248
+ tree = ReactTestRenderer.create(
249
+ <PostMenu post={BASE_POST as never} deleteCallback={jest.fn()} />
250
+ );
251
+ });
252
+ return tree;
253
+ }
254
+
255
+ beforeEach(() => {
256
+ mockProfile = { id: 'u-1', displayName: 'Me', handle: 'me', following: [] };
257
+ mountedReactions.length = 0;
258
+ mountedReposts.length = 0;
259
+ (Toast.show as jest.Mock).mockClear();
260
+ });
261
+
262
+ test('1. closed state: no modal mounted, sheet does not present on mount', () => {
263
+ const tree = render();
264
+ expect(mountedReactions).toHaveLength(0);
265
+ expect(mountedReposts).toHaveLength(0);
266
+ tree.unmount();
267
+ });
268
+
269
+ test('2. reposts menu action mounts RepostModal with open=true', () => {
270
+ const tree = render();
271
+ const repostsItem = findByTestID(tree.toJSON(), 'menu-Reposts');
272
+ expect(typeof repostsItem?.props?.onPress).toBe('function');
273
+ ReactTestRenderer.act(() => {
274
+ (repostsItem?.props?.onPress as () => void)();
275
+ });
276
+ expect(mountedReposts).toHaveLength(1);
277
+ expect(mountedReposts[0].open).toBe(true);
278
+ tree.unmount();
279
+ });
280
+
281
+ test('3. reactions menu action mounts ReactionsModal with open=true', () => {
282
+ const tree = render();
283
+ const reactionsItem = findByTestID(tree.toJSON(), 'menu-Reactions');
284
+ expect(typeof reactionsItem?.props?.onPress).toBe('function');
285
+ ReactTestRenderer.act(() => {
286
+ (reactionsItem?.props?.onPress as () => void)();
287
+ });
288
+ expect(mountedReactions).toHaveLength(1);
289
+ expect(mountedReactions[0].open).toBe(true);
290
+ tree.unmount();
291
+ });
292
+
293
+ test('4. closing the modal via onClose fully unmounts it (no remount with open=false)', () => {
294
+ const tree = render();
295
+ const repostsItem = findByTestID(tree.toJSON(), 'menu-Reposts');
296
+ ReactTestRenderer.act(() => {
297
+ (repostsItem?.props?.onPress as () => void)();
298
+ });
299
+ expect(mountedReposts).toHaveLength(1);
300
+ // onClose flips state closed -> conditional unmount
301
+ // (no {open:false} remount).
302
+ ReactTestRenderer.act(() => {
303
+ mountedReposts[0].onClose?.();
304
+ });
305
+ expect(mountedReposts).toHaveLength(1); // no remount with open=false
306
+ tree.unmount();
307
+ });
308
+
309
+ test('5. follow/unfollow toasts render the shared profile.follow.* keys (#2110)', async () => {
310
+ const tree = render();
311
+ const followItem = findByTestID(tree.toJSON(), 'menu-Follow');
312
+ expect(typeof followItem?.props?.onPress).toBe('function');
313
+ await ReactTestRenderer.act(async () => {
314
+ await (followItem?.props?.onPress as () => Promise<void>)();
315
+ });
316
+ expect(Toast.show).toHaveBeenCalledWith(
317
+ expect.objectContaining({ text1: 'profile.follow.followedSuccess' })
318
+ );
319
+
320
+ // Flip to following so the menu exposes Unfollow, then assert its toast.
321
+ mockProfile = { ...mockProfile, following: [{ id: BASE_POST.profile.id }] };
322
+ const tree2 = render();
323
+ const unfollowItem = findByTestID(tree2.toJSON(), 'menu-Unfollow');
324
+ expect(typeof unfollowItem?.props?.onPress).toBe('function');
325
+ await ReactTestRenderer.act(async () => {
326
+ await (unfollowItem?.props?.onPress as () => Promise<void>)();
327
+ });
328
+ expect(Toast.show).toHaveBeenCalledWith(
329
+ expect.objectContaining({ text1: 'profile.follow.unfollowedSuccess' })
330
+ );
331
+ tree.unmount();
332
+ tree2.unmount();
333
+ });
@@ -54,7 +54,7 @@ export const PostMenu = ({ post, deleteCallback }: PostMenuProps) => {
54
54
  const [isBookmarkActionPending, setIsBookmarkActionPending] =
55
55
  React.useState(false);
56
56
  const [isFollowing, setIsFollowing] = React.useState(false);
57
- const [repostsModalOpen, setRepostsModalOpen] = React.useState(false);
57
+ const [repostModalOpen, setRepostModalOpen] = React.useState(false);
58
58
  const [reactionsModalOpen, setReactionsModalOpen] = React.useState(false);
59
59
  const [historyModalOpen, setHistoryModalOpen] = React.useState(false);
60
60
 
@@ -139,7 +139,7 @@ export const PostMenu = ({ post, deleteCallback }: PostMenuProps) => {
139
139
  setIsFollowing(true);
140
140
  Toast.show({
141
141
  type: 'success',
142
- text1: t('profile.actions.followedSuccess'),
142
+ text1: t('profile.follow.followedSuccess'),
143
143
  });
144
144
  } else {
145
145
  Toast.show({ type: 'error', text1: t('profile.follow.error') });
@@ -152,7 +152,7 @@ export const PostMenu = ({ post, deleteCallback }: PostMenuProps) => {
152
152
  setIsFollowing(false);
153
153
  Toast.show({
154
154
  type: 'success',
155
- text1: t('profile.actions.unfollowedSuccess'),
155
+ text1: t('profile.follow.unfollowedSuccess'),
156
156
  });
157
157
  } else {
158
158
  Toast.show({ type: 'error', text1: t('profile.follow.error') });
@@ -296,7 +296,7 @@ export const PostMenu = ({ post, deleteCallback }: PostMenuProps) => {
296
296
  title={t('posts.menu.reposts', { defaultValue: 'Reposts' })}
297
297
  text={t('posts.menu.reposts', { defaultValue: 'Reposts' })}
298
298
  icon={Repeat2Icon}
299
- action={() => setRepostsModalOpen(true)}
299
+ action={() => setRepostModalOpen(true)}
300
300
  />
301
301
  <PopupMenuButton
302
302
  title={t('posts.menu.reactions', { defaultValue: 'Reactions' })}
@@ -467,17 +467,21 @@ export const PostMenu = ({ post, deleteCallback }: PostMenuProps) => {
467
467
  ) : null}
468
468
  </PopupMenu>
469
469
 
470
- <RepostModal
471
- reposts={post.reposts ?? []}
472
- repostCount={post.repostCount ?? 0}
473
- open={repostsModalOpen}
474
- onClose={() => setRepostsModalOpen(false)}
475
- />
476
- <ReactionsModal
477
- reactions={post.reactions ?? []}
478
- open={reactionsModalOpen}
479
- onClose={() => setReactionsModalOpen(false)}
480
- />
470
+ {repostModalOpen && (
471
+ <RepostModal
472
+ open
473
+ reposts={post.reposts ?? []}
474
+ repostCount={post.repostCount ?? 0}
475
+ onClose={() => setRepostModalOpen(false)}
476
+ />
477
+ )}
478
+ {reactionsModalOpen && (
479
+ <ReactionsModal
480
+ open
481
+ reactions={post.reactions ?? []}
482
+ onClose={() => setReactionsModalOpen(false)}
483
+ />
484
+ )}
481
485
  {showEditHistory ? (
482
486
  <PostEditHistoryModal
483
487
  post={post}
@@ -22,7 +22,7 @@ export const ReplyModal = forwardRef<BottomSheetModal, ReplySheetProps>(
22
22
  <BaseSheet ref={ref} enableOverDrag={false}>
23
23
  <View className="flex-1 px-4 pt-2 pb-8">
24
24
  <ThemedText className="text-center text-xl tracking-wider font-semibold">
25
- {t('posts.replies.title')}
25
+ {t('posts.replyModal.title')}
26
26
  </ThemedText>
27
27
  {post && (
28
28
  <ThreadPost