@openpeepshq/rn-components 0.14.1 → 0.15.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/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/jams/JamChatDrawer.test.tsx +263 -0
  5. package/src/components/jams/JamChatDrawer.tsx +117 -52
  6. package/src/components/jams/JamConference.tsx +5 -0
  7. package/src/components/jams/JamParticipantConference.tsx +7 -4
  8. package/src/components/jams/JamPeopleDrawer.test.tsx +216 -0
  9. package/src/components/jams/JamPeopleDrawer.tsx +32 -2
  10. package/src/components/jams/JamRoomIndicators.test.tsx +190 -38
  11. package/src/components/jams/JamRoomIndicators.tsx +62 -20
  12. package/src/components/jams/useTrackSubscriptionBump.test.ts +294 -0
  13. package/src/components/jams/useTrackSubscriptionBump.ts +44 -0
  14. package/src/components/post/feed/events/EventsCalendar.test.tsx +33 -18
  15. package/src/components/post/pieces/ShareMenu.test.tsx +217 -0
  16. package/src/components/post/pieces/ShareMenu.tsx +107 -61
  17. package/src/components/post/post-form/VisibilitySheet.test.tsx +153 -0
  18. package/src/components/post/post-form/VisibilitySheet.tsx +6 -5
  19. package/src/components/profile/Avatar.test.tsx +147 -0
  20. package/src/components/profile/Avatar.tsx +26 -0
  21. package/src/components/profile/ProfileCard.test.tsx +165 -8
  22. package/src/components/profile/ProfileCard.tsx +63 -10
  23. package/src/components/profile/ProfileSelector.test.tsx +147 -5
  24. package/src/components/profile/ProfileSelector.tsx +64 -18
  25. package/src/pages/conversations/New.test.tsx +340 -0
  26. package/src/pages/conversations/New.tsx +35 -30
  27. package/src/pages/events/Index.tsx +4 -1
  28. package/src/pages/events/My.tsx +1 -1
  29. package/src/pages/groups/Show.tsx +1 -1
  30. package/src/theme/useThemeOpacity.test.ts +70 -0
@@ -0,0 +1,217 @@
1
+ /**
2
+ * ShareMenu external-share gating (issue #306 review round).
3
+ *
4
+ * Pins the decision tree from the ShareMenu contract: external items
5
+ * ("Share via…", "Copy link") render only for publicly shareable posts,
6
+ * while repost / send-in-message stay available for any post the viewer can
7
+ * see, and the "Other options" header only renders when something follows it.
8
+ *
9
+ * Mirrors the inline-mock pattern of FullEvent.test.tsx on main: node jest
10
+ * env, every external import mocked; the built common package ships ESM, so
11
+ * the predicate is mirrored inline (its real semantics are exhaustively
12
+ * unit-tested in platform/common).
13
+ */
14
+ import { type ReactNode } from 'react';
15
+ import ReactTestRenderer from 'react-test-renderer';
16
+ import { Share } from 'react-native';
17
+ import Clipboard from '@react-native-clipboard/clipboard';
18
+ import Toast from 'react-native-toast-message';
19
+
20
+ let mockSignedIn = true;
21
+
22
+ jest.mock('react-native', () => ({
23
+ Share: { share: jest.fn() },
24
+ }));
25
+
26
+ jest.mock('react-native-fs', () => ({
27
+ CachesDirectoryPath: '/cache',
28
+ writeFile: jest.fn(),
29
+ }));
30
+
31
+ jest.mock('@react-native-clipboard/clipboard', () => ({
32
+ __esModule: true,
33
+ default: { setString: jest.fn() },
34
+ }));
35
+
36
+ jest.mock('react-native-toast-message', () => ({
37
+ __esModule: true,
38
+ default: { show: jest.fn() },
39
+ }));
40
+
41
+ jest.mock('react-i18next', () => ({
42
+ useTranslation: () => ({
43
+ t: (key: string, opts?: { defaultValue?: string }) =>
44
+ opts?.defaultValue ?? key,
45
+ }),
46
+ }));
47
+
48
+ jest.mock('@react-navigation/native', () => ({
49
+ useNavigation: () => ({ navigate: jest.fn() }),
50
+ }));
51
+
52
+ jest.mock('@react-navigation/native-stack', () => ({}));
53
+
54
+ jest.mock('@openpeepshq/common/lib', () => ({
55
+ isPubliclyShareable: (post: { visibility: string }) =>
56
+ post.visibility === 'public',
57
+ }));
58
+
59
+ jest.mock('@openpeepshq/react', () => ({
60
+ postPublicPath: (post: { id: string }) => `/posts/${post.id}`,
61
+ useShareMenu: () => ({
62
+ signedIn: mockSignedIn,
63
+ isEvent: false,
64
+ repost: jest.fn(),
65
+ eventIcsFile: () => null,
66
+ }),
67
+ }));
68
+
69
+ jest.mock('../../icons/index', () => ({
70
+ CalendarIcon: () => null,
71
+ CopyIcon: () => null,
72
+ Repeat2Icon: () => null,
73
+ SendIcon: () => null,
74
+ ShareIcon: () => null,
75
+ }));
76
+
77
+ jest.mock('../../ui', () => {
78
+ const React = require('react');
79
+ return {
80
+ PopupMenu: (props: { children?: ReactNode }) =>
81
+ React.createElement('View', null, props.children),
82
+ PopupMenuButton: (props: { text?: string; action?: unknown }) =>
83
+ React.createElement('View', {
84
+ testID: `menu-${props.text}`,
85
+ onPress: typeof props.action === 'function' ? props.action : undefined,
86
+ }),
87
+ PopupSection: (props: { title: string }) =>
88
+ React.createElement('Text', null, props.title),
89
+ PopupSeparator: () => null,
90
+ };
91
+ });
92
+
93
+ jest.mock('../../../lib/constants', () => ({
94
+ BASE_URL: 'https://community.example',
95
+ }));
96
+
97
+ jest.mock('../../../stores/useNewConversationStore', () => ({
98
+ useNewConversationStore: (selector: (s: unknown) => unknown) =>
99
+ selector({ setContt: jest.fn() }),
100
+ }));
101
+
102
+ import { ShareMenu } from './ShareMenu';
103
+
104
+ type TreeNode = {
105
+ type?: string;
106
+ props?: Record<string, unknown> | null;
107
+ children?: (TreeNode | string | null)[];
108
+ };
109
+
110
+ function collectText(node: unknown, out: string[] = []): string[] {
111
+ if (node === null || typeof node !== 'object') return out;
112
+ const n = node as TreeNode;
113
+ for (const c of n.children || []) {
114
+ if (typeof c === 'string') out.push(c);
115
+ else if (c) collectText(c, out);
116
+ }
117
+ return out;
118
+ }
119
+
120
+ function findByTestID(json: unknown, testID: string): TreeNode | undefined {
121
+ if (json === null || typeof json !== 'object') return undefined;
122
+ const node = json as TreeNode;
123
+ if (node.props?.testID === testID) return node;
124
+ for (const c of node.children || []) {
125
+ if (typeof c !== 'string' && c !== null) {
126
+ const found = findByTestID(c, testID);
127
+ if (found) return found;
128
+ }
129
+ }
130
+ return undefined;
131
+ }
132
+
133
+ const render = (post: unknown) => {
134
+ let tree!: ReactTestRenderer.ReactTestRenderer;
135
+ ReactTestRenderer.act(() => {
136
+ tree = ReactTestRenderer.create(<ShareMenu post={post as never} />);
137
+ });
138
+ return tree;
139
+ };
140
+
141
+ beforeEach(() => {
142
+ mockSignedIn = true;
143
+ (Toast.show as jest.Mock).mockClear();
144
+ (Clipboard.setString as jest.Mock).mockClear();
145
+ });
146
+
147
+ test('public post: external items, in-community items, and the section header render', () => {
148
+ const tree = render({ id: 'post-1', visibility: 'public' });
149
+ const json = tree.toJSON();
150
+ expect(findByTestID(json, 'menu-Copy link')).toBeTruthy();
151
+ expect(findByTestID(json, 'menu-Share via…')).toBeTruthy();
152
+ expect(findByTestID(json, 'menu-Repost')).toBeTruthy();
153
+ expect(findByTestID(json, 'menu-Send in message')).toBeTruthy();
154
+ expect(collectText(json)).toContain('Other options');
155
+ tree.unmount();
156
+ });
157
+
158
+ test('private post: external items and the orphaned section header are gone, repost/DM stay', () => {
159
+ const tree = render({ id: 'post-2', visibility: 'private' });
160
+ const json = tree.toJSON();
161
+ expect(findByTestID(json, 'menu-Copy link')).toBeUndefined();
162
+ expect(findByTestID(json, 'menu-Share via…')).toBeUndefined();
163
+ expect(findByTestID(json, 'menu-Repost')).toBeTruthy();
164
+ expect(findByTestID(json, 'menu-Send in message')).toBeTruthy();
165
+ expect(collectText(json)).not.toContain('Other options');
166
+ tree.unmount();
167
+ });
168
+
169
+ test('copy link copies the public URL and toasts the shared shareMenu key (#306 round 2)', () => {
170
+ const tree = render({ id: 'post-1', visibility: 'public' });
171
+ const item = findByTestID(tree.toJSON(), 'menu-Copy link');
172
+ ReactTestRenderer.act(() => {
173
+ (item?.props?.onPress as () => void)();
174
+ });
175
+ expect(Clipboard.setString).toHaveBeenCalledWith(
176
+ 'https://community.example/posts/post-1'
177
+ );
178
+ expect(Toast.show).toHaveBeenCalledWith(
179
+ expect.objectContaining({ text1: 'Link copied' })
180
+ );
181
+ tree.unmount();
182
+ });
183
+
184
+ test('system share sends the post URL to the share sheet on both payload shapes (#306 round 2 S4)', async () => {
185
+ const tree = render({ id: 'post-1', visibility: 'public' });
186
+ const item = findByTestID(tree.toJSON(), 'menu-Share via…');
187
+ await ReactTestRenderer.act(async () => {
188
+ await (item?.props?.onPress as () => Promise<void>)();
189
+ });
190
+ const arg = (Share.share as jest.Mock).mock.calls[0][0];
191
+ // iOS consumes `url`; Android builds the sheet from `message` only.
192
+ expect(arg.url).toBe('https://community.example/posts/post-1');
193
+ expect(arg.message).toBe('https://community.example/posts/post-1');
194
+ tree.unmount();
195
+ });
196
+
197
+ test('signed-out viewer of a public post sees only external items, no in-community (#306 round 5 S4)', () => {
198
+ mockSignedIn = false;
199
+ const tree = render({ id: 'post-1', visibility: 'public' });
200
+ const json = tree.toJSON();
201
+ expect(findByTestID(json, 'menu-Copy link')).toBeTruthy();
202
+ expect(findByTestID(json, 'menu-Share via…')).toBeTruthy();
203
+ expect(findByTestID(json, 'menu-Repost')).toBeUndefined();
204
+ expect(findByTestID(json, 'menu-Send in message')).toBeUndefined();
205
+ // No orphaned "Other options" header with nothing above it.
206
+ expect(collectText(json)).not.toContain('Other options');
207
+ tree.unmount();
208
+ });
209
+
210
+ test('signed-out viewer of a non-public post gets no Share menu at all (#306 round 5 S1)', () => {
211
+ mockSignedIn = false;
212
+ const tree = render({ id: 'post-2', visibility: 'private' });
213
+ // The whole affordance (button + menu) is removed instead of opening an
214
+ // empty dropdown.
215
+ expect(tree.toJSON()).toBeNull();
216
+ tree.unmount();
217
+ });
@@ -7,6 +7,7 @@ import { useTranslation } from 'react-i18next';
7
7
  import { useNavigation } from '@react-navigation/native';
8
8
  import { NativeStackNavigationProp } from '@react-navigation/native-stack';
9
9
  import type { PublicPost } from '@openpeepshq/common';
10
+ import { isPubliclyShareable } from '@openpeepshq/common/lib';
10
11
  import { postPublicPath, useShareMenu } from '@openpeepshq/react';
11
12
  import {
12
13
  CalendarIcon,
@@ -40,6 +41,12 @@ export const ShareMenu = ({ post, menuButton }: ShareMenuProps) => {
40
41
  post,
41
42
  postUrl
42
43
  );
44
+ // Repost/DM are valid for any post the viewer can see; handing the link to
45
+ // the outside world only makes sense for publicly readable posts.
46
+ const externallyShareable = isPubliclyShareable(post);
47
+ // A signed-out viewer of a non-public, non-event post would get an empty
48
+ // menu — hide the whole affordance instead (review round 5, S1).
49
+ const menuAvailable = isEvent || externallyShareable || signedIn;
43
50
 
44
51
  // No download folder on mobile: write the .ics to cache and hand it to the share sheet.
45
52
  const shareEventIcs = async () => {
@@ -54,74 +61,113 @@ export const ShareMenu = ({ post, menuButton }: ShareMenuProps) => {
54
61
  Clipboard.setString(postUrl);
55
62
  Toast.show({
56
63
  type: 'success',
57
- text1: t('posts.copyPostLink.success'),
58
- text2: t('posts.copyPostLink.successMessage'),
64
+ text1: t('posts.shareMenu.linkCopied', { defaultValue: 'Link copied' }),
59
65
  });
60
66
  };
61
67
 
68
+ const systemShare = async () => {
69
+ try {
70
+ // Android drops `url` from the payload (react-native >=0.85 builds the
71
+ // sheet from title+message only), so ship the link as the message.
72
+ await Share.share({
73
+ url: postUrl,
74
+ message: postUrl,
75
+ title: t('posts.shareMenu.title', { defaultValue: 'Share' }),
76
+ });
77
+ } catch {
78
+ // User dismissed the sheet; nothing to do.
79
+ }
80
+ };
81
+
82
+ if (!menuAvailable) return null;
83
+
62
84
  return (
63
- <PopupMenu
64
- menuButton={
65
- menuButton ?? <ShareIcon size={18} className="text-foreground" />
66
- }
67
- title={t('posts.shareMenu.title', { defaultValue: 'Share' })}
68
- >
69
- {signedIn ? (
70
- <>
71
- <PopupSection
72
- title={t('posts.shareMenu.shareOnCommunity', {
73
- defaultValue: 'Share on community',
74
- })}
75
- />
85
+ <>
86
+ <PopupMenu
87
+ menuButton={
88
+ menuButton ?? <ShareIcon size={18} className="text-foreground" />
89
+ }
90
+ title={t('posts.shareMenu.title', { defaultValue: 'Share' })}
91
+ >
92
+ {signedIn ? (
93
+ <>
94
+ <PopupSection
95
+ title={t('posts.shareMenu.shareOnCommunity', {
96
+ defaultValue: 'Share on community',
97
+ })}
98
+ />
99
+ <PopupMenuButton
100
+ title={t('posts.shareMenu.repostToFeed', {
101
+ defaultValue: 'Repost',
102
+ })}
103
+ text={t('posts.shareMenu.repostToFeed', {
104
+ defaultValue: 'Repost',
105
+ })}
106
+ icon={Repeat2Icon as any}
107
+ action={repost}
108
+ />
109
+ <PopupMenuButton
110
+ title={t('posts.shareMenu.sendInMessage', {
111
+ defaultValue: 'Send in message',
112
+ })}
113
+ text={t('posts.shareMenu.sendInMessage', {
114
+ defaultValue: 'Send in message',
115
+ })}
116
+ icon={SendIcon as any}
117
+ action={() => {
118
+ setDraftMessage(postUrl);
119
+ navigation.navigate('SelectPrivateMessageMembers');
120
+ }}
121
+ />
122
+ </>
123
+ ) : null}
124
+ {signedIn && (isEvent || externallyShareable) ? (
125
+ <>
126
+ <PopupSeparator />
127
+ <PopupSection
128
+ title={t('posts.shareMenu.otherOptions', {
129
+ defaultValue: 'Other options',
130
+ })}
131
+ />
132
+ </>
133
+ ) : null}
134
+ {isEvent ? (
76
135
  <PopupMenuButton
77
- title={t('posts.shareMenu.repostToFeed', {
78
- defaultValue: 'Repost',
79
- })}
80
- text={t('posts.shareMenu.repostToFeed', {
81
- defaultValue: 'Repost',
136
+ title={t('posts.shareMenu.downloadCalendarIcsTitle', {
137
+ defaultValue: 'Download calendar file',
82
138
  })}
83
- icon={Repeat2Icon as any}
84
- action={repost}
85
- />
86
- <PopupMenuButton
87
- title={t('posts.shareMenu.sendInMessage', {
88
- defaultValue: 'Send in message',
89
- })}
90
- text={t('posts.shareMenu.sendInMessage', {
91
- defaultValue: 'Send in message',
92
- })}
93
- icon={SendIcon as any}
94
- action={() => {
95
- setDraftMessage(postUrl);
96
- navigation.navigate('SelectPrivateMessageMembers');
97
- }}
98
- />
99
- <PopupSeparator />
100
- <PopupSection
101
- title={t('posts.shareMenu.otherOptions', {
102
- defaultValue: 'Other options',
139
+ text={t('posts.shareMenu.downloadCalendarIcs', {
140
+ defaultValue: 'Add to calendar (.ics)',
103
141
  })}
142
+ icon={CalendarIcon as any}
143
+ action={shareEventIcs}
104
144
  />
105
- </>
106
- ) : null}
107
- {isEvent ? (
108
- <PopupMenuButton
109
- title={t('posts.shareMenu.downloadCalendarIcsTitle', {
110
- defaultValue: 'Download calendar file',
111
- })}
112
- text={t('posts.shareMenu.downloadCalendarIcs', {
113
- defaultValue: 'Add to calendar (.ics)',
114
- })}
115
- icon={CalendarIcon as any}
116
- action={shareEventIcs}
117
- />
118
- ) : null}
119
- <PopupMenuButton
120
- title={t('posts.shareMenu.copyLink', { defaultValue: 'Copy link' })}
121
- text={t('posts.shareMenu.copyLink', { defaultValue: 'Copy link' })}
122
- icon={CopyIcon as any}
123
- action={copyLink}
124
- />
125
- </PopupMenu>
145
+ ) : null}
146
+ {externallyShareable ? (
147
+ <>
148
+ <PopupMenuButton
149
+ title={t('posts.shareMenu.systemShare', {
150
+ defaultValue: 'Share via…',
151
+ })}
152
+ text={t('posts.shareMenu.systemShare', {
153
+ defaultValue: 'Share via…',
154
+ })}
155
+ icon={ShareIcon as any}
156
+ action={() => void systemShare()}
157
+ />
158
+ <PopupMenuButton
159
+ title={t('posts.shareMenu.copyLink', {
160
+ defaultValue: 'Copy link',
161
+ })}
162
+ text={t('posts.shareMenu.copyLink', {
163
+ defaultValue: 'Copy link',
164
+ })}
165
+ icon={CopyIcon as any}
166
+ action={copyLink}
167
+ />
168
+ </>
169
+ ) : null}
170
+ </PopupMenu>
171
+ </>
126
172
  );
127
173
  };
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Regression tests for the VisibilitySheet direct-message audience chips
3
+ * (issue #1666 round-11 S1).
4
+ *
5
+ * The "direct" option reuses the shared `MiniProfileCard` chip (with
6
+ * `showAction={false}`) instead of the old overlapping `ProfileAvatar` stack,
7
+ * and the chips block is only rendered once an audience is actually selected
8
+ * (`selectedAudience.audience.length > 0`). Both behaviors are unpinned
9
+ * elsewhere: a regression that re-renders the chips for an empty audience, or
10
+ * that drops `showAction={false}` (re-adding a remove button to a read-only
11
+ * chip), would not be caught.
12
+ */
13
+
14
+ const React = require('react');
15
+ const ReactTestRenderer = require('react-test-renderer');
16
+
17
+ // Stub for the lucide icon slot; only the `value` matters to the sheet.
18
+ const Icon = () => React.createElement('Icon');
19
+
20
+ jest.mock('react-native', () => ({
21
+ View: (props: Record<string, unknown>) =>
22
+ React.createElement('View', props, props.children),
23
+ Text: (props: { children?: unknown }) =>
24
+ React.createElement('Text', null, props.children),
25
+ Image: () => null,
26
+ ScrollView: (props: { children?: unknown }) =>
27
+ React.createElement('ScrollView', null, props.children),
28
+ Dimensions: { get: () => ({ height: 800, width: 400 }) },
29
+ }));
30
+
31
+ jest.mock('react-i18next', () => ({
32
+ useTranslation: () => ({ t: (key: string) => key }),
33
+ }));
34
+
35
+ // The sheet filters the public/direct options on these flags; keep the list
36
+ // stable and include the 'direct' option under test.
37
+ jest.mock('./constants', () => ({
38
+ useAudienceChoices: () => [
39
+ { title: 'Local', description: '', value: 'local', icon: Icon },
40
+ { title: 'Group', description: '', value: 'group', icon: Icon },
41
+ { title: 'Direct', description: '', value: 'direct', icon: Icon },
42
+ ],
43
+ }));
44
+
45
+ jest.mock('@openpeepshq/react', () => ({
46
+ useOpenpeeps: () => ({
47
+ openpeepsApi: { useServerInfo: () => ({ data: { publicContent: false } }) },
48
+ currentProfile: null,
49
+ }),
50
+ }));
51
+
52
+ jest.mock('@gorhom/bottom-sheet', () => ({
53
+ BottomSheetModal: (props: { children?: unknown }) =>
54
+ React.createElement('BottomSheetModal', null, props.children),
55
+ TouchableWithoutFeedback: (props: { children?: unknown }) =>
56
+ React.createElement('TWF', null, props.children),
57
+ TouchableOpacity: (props: { children?: unknown }) =>
58
+ React.createElement('TS', null, props.children),
59
+ }));
60
+
61
+ jest.mock('../../icons/index', () => ({
62
+ ChevronRightIcon: () => React.createElement('ChevronRightIcon'),
63
+ }));
64
+
65
+ jest.mock('../../ui/themed-text', () => ({
66
+ ThemedText: (props: { children?: unknown }) =>
67
+ React.createElement('ThemedText', null, props.children),
68
+ }));
69
+
70
+ jest.mock('../../custom/modals/common', () => ({
71
+ BaseSheet: (props: { children?: unknown }) =>
72
+ React.createElement('BaseSheet', null, props.children),
73
+ SheetFooter: () => null,
74
+ }));
75
+
76
+ jest.mock('../../groups/GroupNameFromId', () => ({
77
+ GroupNameFromId: () => React.createElement('GroupNameFromId'),
78
+ }));
79
+
80
+ // The component under test imports the real chip; mock only its leaves so the
81
+ // MiniProfileCard's actual `showAction`/geometry behavior stays in scope.
82
+ jest.mock('../../profile/ProfileCard', () => ({
83
+ MiniProfileCard: (props: Record<string, unknown>) =>
84
+ React.createElement('MiniProfileCard', props),
85
+ }));
86
+
87
+ jest.mock('../../profile/ProfileSelector', () => ({
88
+ ProfileSelector: () => null,
89
+ }));
90
+
91
+ jest.mock('../../../lib/bottom-sheet-ref', () => ({
92
+ bottomSheetClose: jest.fn(),
93
+ }));
94
+
95
+ import { VisibilitySheet } from './VisibilitySheet';
96
+
97
+ const renderSheet = (audienceSetting: {
98
+ visibility: string;
99
+ audience?: unknown[];
100
+ }) => {
101
+ let tree: ReturnType<typeof ReactTestRenderer.create>;
102
+ ReactTestRenderer.act(() => {
103
+ tree = ReactTestRenderer.create(
104
+ React.createElement(VisibilitySheet, {
105
+ type: 'post',
106
+ onSubmit: jest.fn(),
107
+ audienceSetting,
108
+ showDirect: true,
109
+ } as never)
110
+ );
111
+ });
112
+ return tree;
113
+ };
114
+
115
+ // The chips share a container View the rest of the sheet never uses, so it is
116
+ // a stable handle for the "chips block" the guard toggles.
117
+ const CHIP_CONTAINER = 'flex-row flex-wrap gap-2 py-2';
118
+ const chipContainer = (tree: ReturnType<typeof ReactTestRenderer.create>) =>
119
+ tree.root
120
+ .findAllByType('View')
121
+ .filter(
122
+ (v: { props: { className?: string } }) =>
123
+ v.props.className === CHIP_CONTAINER
124
+ );
125
+
126
+ describe('VisibilitySheet direct-message audience chips (issue #1666 round-11 S1)', () => {
127
+ it('renders one MiniProfileCard chip per audience member with showAction=false', () => {
128
+ const audience = [
129
+ { id: 'p1', handle: 'ada', displayName: 'Ada' },
130
+ { id: 'p2', handle: 'alan', displayName: 'Alan' },
131
+ ];
132
+ const tree = renderSheet({ visibility: 'direct', audience });
133
+ // The chips block renders once an audience is selected.
134
+ expect(chipContainer(tree)).toHaveLength(1);
135
+ const chips = tree.root.findAllByType('MiniProfileCard');
136
+ // Exactly one chip per selected member — no extra remove-button chip.
137
+ expect(chips).toHaveLength(2);
138
+ // The chips are read-only: the remove action must be suppressed.
139
+ for (const chip of chips) {
140
+ expect(chip.props.showAction).toBe(false);
141
+ }
142
+ });
143
+
144
+ it('renders no chips block when the direct audience is empty', () => {
145
+ // `audience: []` — the `audience.length > 0` guard must suppress the whole
146
+ // container, not just map an empty list. (Mapping an empty list renders no
147
+ // chips but still leaves an empty container behind, so assert the
148
+ // container is gone too.)
149
+ const tree = renderSheet({ visibility: 'direct', audience: [] });
150
+ expect(chipContainer(tree)).toHaveLength(0);
151
+ expect(tree.root.findAllByType('MiniProfileCard')).toHaveLength(0);
152
+ });
153
+ });
@@ -25,7 +25,7 @@ import { BaseSheet, SheetFooter } from '../../custom/modals/common';
25
25
  import { useTranslation } from 'react-i18next';
26
26
  import { useAudienceChoices } from './constants';
27
27
  import { GroupNameFromId } from '../../groups/GroupNameFromId';
28
- import { ProfileAvatar } from '../../profile/Avatar';
28
+ import { MiniProfileCard } from '../../profile/ProfileCard';
29
29
  import { ProfileSelector } from '../../profile/ProfileSelector';
30
30
  import { bottomSheetClose } from '../../../lib/bottom-sheet-ref';
31
31
 
@@ -183,13 +183,14 @@ export const VisibilitySheet = forwardRef<
183
183
  )}
184
184
  {option.value === 'direct' &&
185
185
  selectedAudience.visibility === 'direct' &&
186
- selectedAudience.audience && (
187
- <View className="flex-row items-center gap-2 pl-2">
186
+ selectedAudience.audience &&
187
+ selectedAudience.audience.length > 0 && (
188
+ <View className="flex-row flex-wrap gap-2 py-2">
188
189
  {selectedAudience.audience.map((a) => (
189
- <ProfileAvatar
190
+ <MiniProfileCard
190
191
  key={a.id}
191
192
  profile={a}
192
- className="size-4 -ml-3"
193
+ showAction={false}
193
194
  />
194
195
  ))}
195
196
  </View>