@openpeepshq/rn-components 0.14.1 → 0.16.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 (46) hide show
  1. package/package.json +3 -3
  2. package/src/components/buttonOverflow.test.tsx +8 -0
  3. package/src/components/conversations/ConversationParticipantsModal.tsx +1 -6
  4. package/src/components/icons/index.ts +2 -0
  5. package/src/components/jams/JamChatDrawer.test.tsx +263 -0
  6. package/src/components/jams/JamChatDrawer.tsx +117 -52
  7. package/src/components/jams/JamConference.tsx +5 -0
  8. package/src/components/jams/JamParticipantConference.tsx +7 -4
  9. package/src/components/jams/JamPeopleDrawer.test.tsx +216 -0
  10. package/src/components/jams/JamPeopleDrawer.tsx +32 -2
  11. package/src/components/jams/JamRoomIndicators.test.tsx +190 -38
  12. package/src/components/jams/JamRoomIndicators.tsx +62 -20
  13. package/src/components/jams/useTrackSubscriptionBump.test.ts +294 -0
  14. package/src/components/jams/useTrackSubscriptionBump.ts +44 -0
  15. package/src/components/navigation/nativeRouter.tsx +13 -3
  16. package/src/components/notifications/NotificationHeaderActions.test.tsx +285 -0
  17. package/src/components/notifications/NotificationHeaderActions.tsx +91 -4
  18. package/src/components/notifications/NotificationsList.test.tsx +109 -0
  19. package/src/components/notifications/NotificationsList.tsx +13 -3
  20. package/src/components/notifications/types/Reaction.tsx +6 -2
  21. package/src/components/post/feed/events/EventsCalendar.test.tsx +33 -18
  22. package/src/components/post/pieces/PostActions.test.tsx +244 -0
  23. package/src/components/post/pieces/PostActions.tsx +74 -49
  24. package/src/components/post/pieces/ReactionPicker.test.tsx +184 -0
  25. package/src/components/post/pieces/ReactionPicker.tsx +58 -0
  26. package/src/components/post/pieces/ShareMenu.test.tsx +217 -0
  27. package/src/components/post/pieces/ShareMenu.tsx +107 -61
  28. package/src/components/post/pieces/index.ts +1 -0
  29. package/src/components/post/pieces/modals/ReactionsModal.tsx +1 -1
  30. package/src/components/post/post-form/VisibilitySheet.test.tsx +153 -0
  31. package/src/components/post/post-form/VisibilitySheet.tsx +6 -5
  32. package/src/components/profile/Avatar.test.tsx +147 -0
  33. package/src/components/profile/Avatar.tsx +26 -0
  34. package/src/components/profile/ProfileCard.test.tsx +165 -8
  35. package/src/components/profile/ProfileCard.tsx +63 -10
  36. package/src/components/profile/ProfileSelector.test.tsx +147 -5
  37. package/src/components/profile/ProfileSelector.tsx +64 -18
  38. package/src/pages/Notifications.tsx +3 -1
  39. package/src/pages/Welcome.test.tsx +166 -0
  40. package/src/pages/Welcome.tsx +50 -4
  41. package/src/pages/conversations/New.test.tsx +340 -0
  42. package/src/pages/conversations/New.tsx +35 -30
  43. package/src/pages/events/Index.tsx +4 -1
  44. package/src/pages/events/My.tsx +1 -1
  45. package/src/pages/groups/Show.tsx +1 -1
  46. package/src/theme/useThemeOpacity.test.ts +70 -0
@@ -1,20 +1,33 @@
1
1
  /**
2
- * Regression tests for the ProfileSelector sheet title (issue #1666).
2
+ * Regression tests for the ProfileSelector sheet title, picker-row tint,
3
+ * selection a11y and id-based selection (issue #1666).
3
4
  *
4
5
  * The sheet used to hard-code the English string "Add members", so every
5
6
  * caller that omitted `title` (jam moderators, group members, event
6
7
  * moderators) rendered untranslated copy, and the audience picker could be
7
8
  * re-titled to a non-matching string. Web defaults to
8
9
  * `profile.selector.title` ("Select profiles"); RN must match.
10
+ *
11
+ * The picker rows also carried no visual selection state, so testers could
12
+ * not see which profiles were picked. NativeWind v4 cannot apply the `/N`
13
+ * opacity modifier to a CSS-variable color, so the tint is built inline via
14
+ * `useThemeOpacity` (`rgba` style) — asserted here as the resolved style
15
+ * value. The tint must use a token that actually contrasts on the sheet:
16
+ * `secondary` is a near-white neutral in the RN palette (web's is the brand
17
+ * teal), so a `secondary` wash is invisible; the selected row uses `primary`
18
+ * at low opacity. The mocked hook is keyed by token so a regression back to
19
+ * `secondary` fails here.
9
20
  */
10
21
 
11
22
  const React = require('react');
12
23
  const ReactTestRenderer = require('react-test-renderer');
13
24
 
14
- const mockT = (key: string) => MESSAGES[key] ?? key;
15
-
16
25
  const MESSAGES: Record<string, string> = {
17
26
  'profile.selector.title': 'Select profiles',
27
+ // Deliberately NOT the literal ', selected' the old code hard-coded, so
28
+ // this suite fails if the label regresses to a hard-coded English
29
+ // fragment instead of resolving the locale key (issue #1666 review S1).
30
+ 'profile.selector.rowSelected': '{{name}} (selected)',
18
31
  'profile.search.placeholder': 'Search profiles',
19
32
  'profile.search.noResults': 'No results found',
20
33
  'common.members.addSuccess': 'Added',
@@ -23,11 +36,19 @@ const MESSAGES: Record<string, string> = {
23
36
  'common.actions.add': 'Add',
24
37
  };
25
38
 
39
+ // Mirrors i18next's default interpolation so the row-label regression test
40
+ // can assert the composed, localized screen-reader string (issue #1666
41
+ // review S1).
42
+ const mockT = (key: string, opts?: { name?: string }) =>
43
+ (MESSAGES[key] ?? key).replace('{{name}}', opts?.name ?? '');
44
+
26
45
  jest.mock('react-native', () => ({
27
46
  View: (props: { children?: unknown }) =>
28
47
  React.createElement('View', null, props.children),
29
48
  ScrollView: (props: { children?: unknown }) =>
30
49
  React.createElement('ScrollView', null, props.children),
50
+ Pressable: (props: Record<string, unknown>) =>
51
+ React.createElement('Pressable', props, props.children),
31
52
  ActivityIndicator: () => null,
32
53
  }));
33
54
 
@@ -48,6 +69,12 @@ jest.mock('@openpeepshq/react', () => ({
48
69
 
49
70
  const PROFILES: unknown[] = [];
50
71
 
72
+ // Two profile objects; PROFILES[0] is passed as the sheet's initial selection
73
+ // so the tint test can compare a selected row against an unselected one.
74
+ const ada = { id: 'p1', handle: 'ada', displayName: 'Ada' };
75
+ const alan = { id: 'p2', handle: 'alan', displayName: 'Alan' };
76
+ PROFILES.push(ada, alan);
77
+
51
78
  jest.mock('../../lib/utils', () => ({
52
79
  profileMatchesQuery: () => true,
53
80
  }));
@@ -74,13 +101,29 @@ jest.mock('../custom/modals/common', () => ({
74
101
 
75
102
  jest.mock('react-native-toast-message', () => ({ show: jest.fn() }));
76
103
 
104
+ jest.mock('../../theme/useThemeOpacity', () => ({
105
+ // Mirrors the real hook's shape. Values come from theme/defaults.ts so the
106
+ // tint style is asserted deterministically; keyed by token so a regression
107
+ // back to the invisible `secondary` wash fails (issue #1666 review S1).
108
+ useThemeOpacity: () => ({
109
+ background: (name: string, opacity: number) => ({
110
+ backgroundColor:
111
+ name === 'primary'
112
+ ? `rgba(22, 22, 26, ${opacity})`
113
+ : `rgba(244, 244, 245, ${opacity})`,
114
+ }),
115
+ }),
116
+ }));
117
+
77
118
  jest.mock('../../lib/bottom-sheet-ref', () => ({
78
119
  bottomSheetClose: jest.fn(),
79
120
  }));
80
121
 
81
122
  jest.mock('./ProfileCard', () => ({
82
- MiniProfileCard: () => null,
83
- ProfileCard: () => null,
123
+ MiniProfileCard: (props: Record<string, unknown>) =>
124
+ React.createElement('MiniProfileCard', props),
125
+ ProfileCard: (props: Record<string, unknown>) =>
126
+ React.createElement('ProfileCard', props),
84
127
  }));
85
128
 
86
129
  import type { ProfilePickerSheetProps } from './ProfileSelector';
@@ -113,3 +156,102 @@ describe('ProfileSelector sheet title (issue #1666)', () => {
113
156
  expect(titleText(tree)).toBe('Add members to Test Group');
114
157
  });
115
158
  });
159
+
160
+ describe('ProfileSelector selected-row tint (issue #1666)', () => {
161
+ it('tints the selected row with primary at low opacity and leaves the unselected ones clear', () => {
162
+ const tree = renderSelector({
163
+ initialProfiles: [PROFILES[0]] as never,
164
+ });
165
+
166
+ const rows = tree.root.findAllByType('Pressable');
167
+ expect(rows.length).toBeGreaterThanOrEqual(2);
168
+ const selected = rows.find(
169
+ (node: { props: { accessibilityState?: { selected?: boolean } } }) =>
170
+ node.props.accessibilityState?.selected === true
171
+ );
172
+ expect(selected).toBeDefined();
173
+ expect(selected.props.style).toEqual({
174
+ backgroundColor: 'rgba(22, 22, 26, 0.15)',
175
+ });
176
+ const unselected = rows.find(
177
+ (node: { props: { accessibilityState?: { selected?: boolean } } }) =>
178
+ node.props.accessibilityState?.selected === false
179
+ );
180
+ expect(unselected).toBeDefined();
181
+ expect(unselected.props.style).toBeUndefined();
182
+ });
183
+
184
+ it('marks the rows as accessible buttons with a selected state (web parity)', () => {
185
+ const tree = renderSelector({
186
+ initialProfiles: [PROFILES[0]] as never,
187
+ });
188
+
189
+ // Only the selectable rows carry `accessibilityState`; the selected-chip
190
+ // remove buttons (also Pressable) do not, so scope to the rows.
191
+ const rows = tree.root
192
+ .findAllByType('Pressable')
193
+ .filter(
194
+ (node: { props: { accessibilityState?: unknown } }) =>
195
+ node.props.accessibilityState !== undefined
196
+ );
197
+ const selected = rows.filter(
198
+ (node: { props: { accessibilityState?: { selected?: boolean } } }) =>
199
+ node.props.accessibilityState?.selected === true
200
+ );
201
+ const unselected = rows.filter(
202
+ (node: { props: { accessibilityState?: { selected?: boolean } } }) =>
203
+ node.props.accessibilityState?.selected === false
204
+ );
205
+ expect(selected.length).toBe(1);
206
+ expect(unselected.length).toBeGreaterThan(0);
207
+ for (const row of rows) {
208
+ expect(row.props.accessibilityRole).toBe('button');
209
+ expect(typeof row.props.accessibilityLabel).toBe('string');
210
+ expect(row.props.accessibilityLabel.length).toBeGreaterThan(0);
211
+ }
212
+ expect(selected[0].props.accessibilityLabel).toContain('selected');
213
+ });
214
+
215
+ it('builds the selected-row label from the profile.selector.rowSelected locale key (issue #1666 review S1)', () => {
216
+ // The label must come from a t() key, not a hard-coded English fragment:
217
+ // the mock t() resolves the key and interpolates {{name}}, so a
218
+ // regression to a literal ", selected" concatenation would skip the key
219
+ // entirely and leave the label with no interpolation.
220
+ const tree = renderSelector({
221
+ initialProfiles: [PROFILES[0]] as never,
222
+ });
223
+ const rows = tree.root
224
+ .findAllByType('Pressable')
225
+ .filter(
226
+ (node: { props: { accessibilityState?: unknown } }) =>
227
+ node.props.accessibilityState !== undefined
228
+ );
229
+ const selected = rows.find(
230
+ (node: { props: { accessibilityState?: { selected?: boolean } } }) =>
231
+ node.props.accessibilityState?.selected === true
232
+ );
233
+ const unselected = rows.find(
234
+ (node: { props: { accessibilityState?: { selected?: boolean } } }) =>
235
+ node.props.accessibilityState?.selected === false
236
+ );
237
+ expect(selected.props.accessibilityLabel).toBe('Ada (selected)');
238
+ expect(unselected.props.accessibilityLabel).toBe('Alan');
239
+ });
240
+ });
241
+
242
+ describe('ProfileSelector id-based selection (issue #1666 review S3)', () => {
243
+ it('keeps the selection when the caller re-seeds with a fresh object of the same id', () => {
244
+ // A re-mounted sheet (or upstream object churn) seeds `initialProfiles`
245
+ // with a new object; reference equality would drop the selection, so the
246
+ // row must still render selected for the matching id.
247
+ const freshAda = { id: 'p1', handle: 'ada', displayName: 'Ada' };
248
+ const tree = renderSelector({ initialProfiles: [freshAda] as never });
249
+
250
+ const rows = tree.root.findAllByType('Pressable');
251
+ const selected = rows.filter(
252
+ (node: { props: { accessibilityState?: { selected?: boolean } } }) =>
253
+ node.props.accessibilityState?.selected === true
254
+ );
255
+ expect(selected.length).toBe(1);
256
+ });
257
+ });
@@ -1,5 +1,5 @@
1
1
  import React, { forwardRef, useEffect, useState } from 'react';
2
- import { View, ScrollView, ActivityIndicator } from 'react-native';
2
+ import { View, ScrollView, ActivityIndicator, Pressable } from 'react-native';
3
3
  import { BottomSheetModal } from '@gorhom/bottom-sheet';
4
4
  import { ThemedText } from '../ui/themed-text';
5
5
  import { PublicProfile } from '@openpeepshq/common';
@@ -11,6 +11,7 @@ import { BaseSheet, SheetFooter } from '../custom/modals/common';
11
11
  import Toast from 'react-native-toast-message';
12
12
  import { MiniProfileCard, ProfileCard } from './ProfileCard';
13
13
  import { useTranslation } from 'react-i18next';
14
+ import { useThemeOpacity } from '../../theme/useThemeOpacity';
14
15
  import { bottomSheetClose } from '../../lib/bottom-sheet-ref';
15
16
 
16
17
  interface ProfilePickerSheetProps {
@@ -87,10 +88,23 @@ export const ProfileSelector = forwardRef<
87
88
  }
88
89
  }, [searchQuery, profiles, currentProfile, profilesToExclude]);
89
90
 
91
+ // NativeWind v4 can't apply `/N` opacity to CSS-variable colors, so the
92
+ // selected-row tint is built inline from the theme color (issue #1666).
93
+ // `secondary` is a near-white neutral in the RN palette (unlike web's
94
+ // teal), so a `secondary` wash is invisible on a white sheet; the tint
95
+ // uses `primary` at low opacity, matching web's brand-accent selection.
96
+ const { background: tintBackground } = useThemeOpacity();
97
+
98
+ // Compare by id, not object reference: callers re-seed `initialProfiles`
99
+ // with fresh objects on every present, so reference equality would drop
100
+ // the selection (issue #1666 review).
101
+ const isSelected = (profile: PublicProfile) =>
102
+ selectedProfiles.some((p) => p.id === profile.id);
103
+
90
104
  const handleSelectProfile = (profile: PublicProfile) => {
91
105
  setSelectedProfiles((prev) =>
92
- prev.includes(profile)
93
- ? prev.filter((p) => p !== profile)
106
+ prev.some((p) => p.id === profile.id)
107
+ ? prev.filter((p) => p.id !== profile.id)
94
108
  : [...prev, profile]
95
109
  );
96
110
  if (single) {
@@ -164,21 +178,53 @@ export const ProfileSelector = forwardRef<
164
178
  </View>
165
179
  )}
166
180
 
167
- {filteredProfiles?.map((profile) => (
168
- <ProfileCard
169
- key={profile.id}
170
- profile={profile}
171
- actionType="select"
172
- handleSelectProfile={() => handleSelectProfile(profile)}
173
- rightComponent={
174
- selectedProfiles.includes(profile) ? (
175
- <View className="items-center justify-center">
176
- <CheckIcon className="text-foreground" />
177
- </View>
178
- ) : null
179
- }
180
- />
181
- ))}
181
+ {filteredProfiles?.map((profile) => {
182
+ const selected = isSelected(profile);
183
+ // Screen-reader copy is user-facing copy: compose the label
184
+ // from a locale key instead of a hard-coded English fragment
185
+ // (issue #1666 review S1).
186
+ const rowLabel = selected
187
+ ? t('profile.selector.rowSelected', {
188
+ name: profile.displayName || `@${profile.handle}`,
189
+ })
190
+ : profile.displayName || `@${profile.handle}`;
191
+ // Two overlapping press surfaces, on purpose: the full row is a
192
+ // `Pressable` (the a11y element), but the left avatar+name column
193
+ // is also `ProfileCard`'s inner `TouchableWithoutFeedback`. RN
194
+ // hands a tap to the first responder that claims it, so a tap on
195
+ // the left column hits the inner touchable and a tap on the right
196
+ // (check-icon) region hits this Pressable — both call
197
+ // `handleSelectProfile`, so exactly one toggle per tap. Do not
198
+ // "simplify" away the inner touchable: it is the only tap target
199
+ // over the card itself, and dropping it would strand the right
200
+ // half of the row (issue #1666 review S3).
201
+ return (
202
+ <Pressable
203
+ key={profile.id}
204
+ className="rounded-md"
205
+ style={
206
+ selected ? tintBackground('primary', 0.15) : undefined
207
+ }
208
+ accessibilityRole="button"
209
+ accessibilityLabel={rowLabel}
210
+ accessibilityState={{ selected }}
211
+ onPress={() => handleSelectProfile(profile)}
212
+ >
213
+ <ProfileCard
214
+ profile={profile}
215
+ actionType="select"
216
+ handleSelectProfile={() => handleSelectProfile(profile)}
217
+ rightComponent={
218
+ selected ? (
219
+ <View className="items-center justify-center pr-1">
220
+ <CheckIcon size={16} className="text-primary" />
221
+ </View>
222
+ ) : null
223
+ }
224
+ />
225
+ </Pressable>
226
+ );
227
+ })}
182
228
 
183
229
  {filteredProfiles?.length === 0 && (
184
230
  <ThemedText className="text-center text-muted-foreground">
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ThemedView } from '../components/ui/themed-view';
3
- import { useOpenpeeps } from '@openpeepshq/react';
3
+ import { useNotificationFeedFilter, useOpenpeeps } from '@openpeepshq/react';
4
4
  import { useSetPageHeader } from '../components/layout';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import {
@@ -12,8 +12,10 @@ import { useNotificationBadgeReset } from '../hooks/use-notification-badge-reset
12
12
  export const Notifications = () => {
13
13
  const { openpeepsApi } = useOpenpeeps();
14
14
  const { t } = useTranslation();
15
+ const { excludeTypes } = useNotificationFeedFilter();
15
16
  const query = openpeepsApi.useCurrentProfileNotifications({
16
17
  limit: 15,
18
+ excludeTypes,
17
19
  });
18
20
  const notificationStats = openpeepsApi.useCurrentProfileNotificationStats();
19
21
 
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Regression coverage for #1600 (RN parity) — the native Onboarding screen
3
+ * (the RN mirror of the web Welcome page) is guest-reachable, so a signed-out
4
+ * visitor must see the markdown welcome plus a Sign In CTA, NOT the signed-in
5
+ * setup checklist. The checklist is the only consumer of the disabled
6
+ * `usePostsByProfile('')` query, which never leaves `isPending` for a guest —
7
+ * rendering it would leave the checklist in a permanent loading spin (the bug
8
+ * fixed on the web side). Nothing else asserted that a guest opening this
9
+ * screen avoided that path.
10
+ *
11
+ * The node jest env has no native modules, so every external import is
12
+ * mocked (mirroring New.carryover.test.tsx); only the real `Welcome` under
13
+ * test renders, with its guest / signed-in branches driven by the mocked
14
+ * `useOpenpeeps`.
15
+ */
16
+ import { type ReactNode } from 'react';
17
+ import ReactTestRenderer from 'react-test-renderer';
18
+
19
+ const React = require('react');
20
+
21
+ let mockCurrentProfile: {
22
+ id: string;
23
+ displayName?: string;
24
+ handle?: string;
25
+ } | null = null;
26
+ const mockNavigate = jest.fn();
27
+
28
+ // --- react-native: host elements render as plain host tags, props kept ----
29
+ jest.mock('react-native', () => {
30
+ const make = (tag: string) => (props: { children?: ReactNode }) =>
31
+ React.createElement(tag, props);
32
+ return {
33
+ View: make('View'),
34
+ Text: make('Text'),
35
+ ScrollView: make('ScrollView'),
36
+ TouchableOpacity: make('TouchableOpacity'),
37
+ Pressable: make('Pressable'),
38
+ ActivityIndicator: make('ActivityIndicator'),
39
+ };
40
+ });
41
+
42
+ // --- shared @openpeepshq/react: drive the branch, capture navigation ------
43
+ jest.mock('@openpeepshq/react', () => ({
44
+ useOpenpeeps: () => ({
45
+ currentProfile: mockCurrentProfile,
46
+ currentAccount: { emailValidated: true },
47
+ openpeepsApi: {
48
+ useServerInfo: () => ({
49
+ data: {
50
+ communityConfig: {
51
+ info: { name: 'TestCo' },
52
+ content: { welcomePage: 'Welcome to TestCo' },
53
+ },
54
+ },
55
+ isLoading: false,
56
+ }),
57
+ // Disabled for guests (empty profile id) — mirrors the production
58
+ // wiring; only the render gate under test decides whether it is used.
59
+ usePostsByProfile: () => ({ data: { pages: [] }, isLoading: false }),
60
+ validationEmailAction: () => () => Promise.resolve({ success: true }),
61
+ },
62
+ }),
63
+ useRouter: () => ({ navigate: mockNavigate }),
64
+ }));
65
+
66
+ // --- i18n: resolve keys to their defaultValue, or a few known values ------
67
+ // (the guest row calls t(key) without a defaultValue, unlike the web page) --
68
+ jest.mock('react-i18next', () => ({
69
+ useTranslation: () => ({
70
+ t: (_key: string, opts?: { defaultValue?: string }) => {
71
+ const known: Record<string, string> = {
72
+ 'welcome.guestSignIn':
73
+ 'Sign in to complete your account setup and see the checklist.',
74
+ 'auth.register.signIn': 'Sign In',
75
+ };
76
+ return opts?.defaultValue ?? known[_key] ?? _key;
77
+ },
78
+ }),
79
+ }));
80
+
81
+ // --- lucide icons: inert ---------------------------------------------------
82
+ jest.mock('lucide-react-native', () => {
83
+ const icon = (name: string) => () => React.createElement(name, null);
84
+ return {
85
+ UserCheckIcon: icon('UserCheckIcon'),
86
+ MailCheckIcon: icon('MailCheckIcon'),
87
+ SquareUserRoundIcon: icon('SquareUserRoundIcon'),
88
+ PencilIcon: icon('PencilIcon'),
89
+ ChevronRightIcon: icon('ChevronRightIcon'),
90
+ CheckIcon: icon('CheckIcon'),
91
+ };
92
+ });
93
+
94
+ // --- local component deps: inert -------------------------------------------
95
+ jest.mock('react-native-toast-message', () => {
96
+ const Toast = { show: jest.fn() };
97
+ return { __esModule: true, default: Toast };
98
+ });
99
+ jest.mock('@react-navigation/native', () => ({
100
+ useNavigation: () => ({ navigate: jest.fn() }),
101
+ }));
102
+ jest.mock('@react-navigation/native-stack', () => ({}));
103
+ jest.mock('../components/layout', () => ({
104
+ useSetPageHeader: jest.fn(),
105
+ }));
106
+ jest.mock('../components/ui/themed-view', () => ({
107
+ ThemedView: ({ children }: { children?: ReactNode }) =>
108
+ React.createElement('View', null, children),
109
+ }));
110
+ jest.mock('../components/ui/themed-text', () => ({
111
+ ThemedText: ({ children }: { children?: ReactNode }) =>
112
+ React.createElement('Text', null, children),
113
+ }));
114
+ jest.mock('../components/markdown/index', () => ({
115
+ OpenpeepsMarkdown: ({ source }: { source: string }) =>
116
+ React.createElement('Markdown', null, source),
117
+ }));
118
+ jest.mock('../theme/useThemeOpacity', () => ({
119
+ useThemeOpacity: () => ({ background: () => 'rgba(0,0,0,0.1)' }),
120
+ }));
121
+
122
+ import { Welcome } from './Welcome';
123
+
124
+ describe('RN Welcome (Onboarding) guest parity', () => {
125
+ beforeEach(() => {
126
+ mockCurrentProfile = null;
127
+ mockNavigate.mockClear();
128
+ });
129
+
130
+ it('shows a Sign In CTA (and no checklist) for a signed-out visitor', () => {
131
+ let tree: ReturnType<typeof ReactTestRenderer.create>;
132
+ ReactTestRenderer.act(() => {
133
+ tree = ReactTestRenderer.create(React.createElement(Welcome));
134
+ });
135
+
136
+ // The guest CTA is rendered …
137
+ const [cta] = tree.root.findAllByProps({
138
+ testID: 'welcome-guest-sign-in',
139
+ });
140
+ // … and pressing it routes to the auth screen.
141
+ cta.props.onPress();
142
+ expect(mockNavigate).toHaveBeenCalledWith({ type: 'auth', mode: 'login' });
143
+
144
+ const json = JSON.stringify(tree.toJSON());
145
+ // The signed-in checklist must be absent — it is the only consumer of
146
+ // the disabled posts query, so rendering it is exactly the spin
147
+ // regression this test guards.
148
+ expect(json).not.toContain('Complete account setup');
149
+ // … while the guest copy and the CTA label are present.
150
+ expect(json).toContain('Sign in to complete your account setup');
151
+ expect(json).toContain('Sign In');
152
+ });
153
+
154
+ it('shows the setup checklist (and no guest CTA) when signed in', () => {
155
+ mockCurrentProfile = { id: 'me', displayName: 'Me', handle: 'me' };
156
+ let tree: ReturnType<typeof ReactTestRenderer.create>;
157
+ ReactTestRenderer.act(() => {
158
+ tree = ReactTestRenderer.create(React.createElement(Welcome));
159
+ });
160
+
161
+ expect(
162
+ tree.root.findAllByProps({ testID: 'welcome-guest-sign-in' })
163
+ ).toHaveLength(0);
164
+ expect(JSON.stringify(tree.toJSON())).toContain('Complete account setup');
165
+ });
166
+ });
@@ -1,7 +1,13 @@
1
1
  import React, { useCallback, useMemo } from 'react';
2
2
  import { ThemedView } from '../components/ui/themed-view';
3
- import { ActivityIndicator, ScrollView, TouchableOpacity } from 'react-native';
4
- import { useOpenpeeps } from '@openpeepshq/react';
3
+ import {
4
+ ActivityIndicator,
5
+ Pressable,
6
+ ScrollView,
7
+ TouchableOpacity,
8
+ View,
9
+ } from 'react-native';
10
+ import { useOpenpeeps, useRouter } from '@openpeepshq/react';
5
11
  import { useSetPageHeader } from '../components/layout';
6
12
  import {
7
13
  UserCheckIcon,
@@ -42,6 +48,7 @@ type AccountSetupChecklistItem = {
42
48
 
43
49
  export const Welcome = () => {
44
50
  const { openpeepsApi, currentProfile, currentAccount } = useOpenpeeps();
51
+ const router = useRouter();
45
52
  const { t } = useTranslation();
46
53
  const { data: serverInfo, isLoading } = openpeepsApi.useServerInfo();
47
54
  const { data: posts, isLoading: isPostLoading } =
@@ -125,16 +132,55 @@ export const Welcome = () => {
125
132
 
126
133
  useSetPageHeader(t('navigation.welcome'));
127
134
 
135
+ // Guest mirror of web Welcome.tsx: a signed-out visitor on the guest-reachable
136
+ // Onboarding screen sees the markdown welcome plus a Sign In CTA instead of
137
+ // the signed-in checklist — the checklist's posts query is disabled without a
138
+ // profile id and would leave the checklist in a permanent loading spin.
139
+ if (!currentProfile) {
140
+ return (
141
+ <ThemedView className="flex-1">
142
+ <ScrollView className="p-4 w-full">
143
+ {isLoading && <ActivityIndicator size={'small'} />}
144
+ <ThemedView className="w-full mt-2">
145
+ <ThemedText className="text-3xl font-bold mb-2">
146
+ {t('welcome.heading', {
147
+ name: serverInfo?.communityConfig?.info?.name,
148
+ })}
149
+ </ThemedText>
150
+ <OpenpeepsMarkdown
151
+ source={serverInfo?.communityConfig?.content?.welcomePage || ''}
152
+ />
153
+ </ThemedView>
154
+ <View className="mt-4">
155
+ <ThemedText className="text-base text-muted-foreground">
156
+ {t('welcome.guestSignIn')}
157
+ </ThemedText>
158
+ <Pressable
159
+ testID="welcome-guest-sign-in"
160
+ onPress={() => router.navigate({ type: 'auth', mode: 'login' })}
161
+ >
162
+ <ThemedText className="text-base font-medium text-primary">
163
+ {t('auth.register.signIn')}
164
+ </ThemedText>
165
+ </Pressable>
166
+ </View>
167
+ </ScrollView>
168
+ </ThemedView>
169
+ );
170
+ }
171
+
128
172
  return (
129
173
  <ThemedView className="flex-1">
130
174
  <ScrollView className="p-4 w-full">
131
175
  {isLoading && <ActivityIndicator size={'small'} />}
132
176
  <ThemedView className="w-full mt-2">
133
177
  <ThemedText className="text-3xl font-bold mb-2">
134
- Welcome to {serverInfo?.communityConfig.info.name}
178
+ {t('welcome.heading', {
179
+ name: serverInfo?.communityConfig?.info?.name,
180
+ })}
135
181
  </ThemedText>
136
182
  <OpenpeepsMarkdown
137
- source={serverInfo?.communityConfig.content.welcomePage || ''}
183
+ source={serverInfo?.communityConfig?.content?.welcomePage || ''}
138
184
  />
139
185
  </ThemedView>
140
186
  <ThemedText className="text-3xl font-bold my-4">