@openpeepshq/rn-components 0.23.0 → 0.28.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 (38) hide show
  1. package/package.json +4 -4
  2. package/src/components/conversations/ConversationPreviewCard.test.tsx +345 -0
  3. package/src/components/conversations/ConversationPreviewCard.tsx +29 -24
  4. package/src/components/custom/navigation/side-menu.test.tsx +9 -0
  5. package/src/components/custom/navigation/side-menu.tsx +19 -3
  6. package/src/components/groups/GroupAvatar.test.tsx +20 -2
  7. package/src/components/groups/GroupAvatar.tsx +7 -1
  8. package/src/components/jams/JamCallParticipant.test.tsx +303 -0
  9. package/src/components/jams/JamCallParticipant.tsx +7 -1
  10. package/src/components/jams/JamPeopleDrawer.test.tsx +104 -9
  11. package/src/components/jams/JamPeopleDrawer.tsx +48 -11
  12. package/src/components/jams/JamRequestJoin.test.tsx +163 -0
  13. package/src/components/jams/JamRequestJoin.tsx +31 -15
  14. package/src/components/jams/useLateTrackMediaStream.test.ts +139 -25
  15. package/src/components/jams/useLateTrackMediaStream.ts +62 -19
  16. package/src/components/navigation/main-navigator.tsx +5 -0
  17. package/src/components/navigation/nativeRouter.tsx +1 -0
  18. package/src/components/navigation/parent-back.ts +1 -0
  19. package/src/components/navigation/types/main.ts +1 -0
  20. package/src/components/post/pieces/ShareMenu.test.tsx +105 -11
  21. package/src/components/post/pieces/ShareMenu.tsx +55 -10
  22. package/src/components/post/pieces/modals/SendToConversationModal.tsx +140 -0
  23. package/src/components/post/pieces/modals/ShareIntoGroupModal.tsx +121 -0
  24. package/src/components/post/pieces/modals/index.ts +2 -0
  25. package/src/components/post/pieces/sharePickers.test.tsx +819 -0
  26. package/src/components/profile/Avatar.test.tsx +19 -0
  27. package/src/components/profile/Avatar.tsx +9 -1
  28. package/src/lib/push-notifications.test.ts +244 -0
  29. package/src/lib/push-notifications.ts +65 -0
  30. package/src/pages/auth/Login.tsx +16 -2
  31. package/src/pages/conversations/Index.test.tsx +235 -0
  32. package/src/pages/conversations/Index.tsx +15 -16
  33. package/src/pages/index.ts +1 -0
  34. package/src/pages/settings/Account.test.tsx +4 -0
  35. package/src/pages/settings/Account.tsx +14 -0
  36. package/src/pages/settings/CalendarFeed.test.tsx +269 -0
  37. package/src/pages/settings/CalendarFeed.tsx +77 -0
  38. package/src/pages/settings/Index.tsx +4 -0
@@ -0,0 +1,303 @@
1
+ /**
2
+ * Wiring test for the camera tile: the `VideoTrack` in `JamCallParticipant`
3
+ * is keyed by the late-track `remountKey`, so when a first mid-Jam remote
4
+ * camera publish delivers its video track late, the native view remounts and
5
+ * re-runs its one-shot `streamURL` attach (one transition remount plus the
6
+ * hook's retry schedule — tight burst first, then the sparse tail).
7
+ *
8
+ * The real `JamCallParticipant` and the real `useLateTrackMediaStream` run;
9
+ * only the module surfaces the test cannot load under jest are stubbed
10
+ * (react-native, `@livekit/react-native` with a mount-counting `VideoTrack`,
11
+ * `@openpeepshq/react`, i18n, toast, `react-native-sound`, icons, dropdown/
12
+ * button UI, connection and theme hooks, avatar). The `.wav` asset in the
13
+ * overlay needs an explicit mock because jest cannot require audio files.
14
+ */
15
+
16
+ const React = require('react');
17
+ const ReactTestRenderer = require('react-test-renderer');
18
+
19
+ // Counts how many times the stub VideoTrack actually mounts. A key change
20
+ // unmounts the old instance and mounts a new one, so this is a direct count
21
+ // of the tile's VideoTrack remounts (the `key` prop is consumed by the
22
+ // reconciler and is not visible to the stub).
23
+ let videoTrackMountCount = 0;
24
+
25
+ jest.mock('react-native-sound', () => ({
26
+ __esModule: true,
27
+ default: jest.fn().mockImplementation(() => ({
28
+ setVolume: jest.fn(),
29
+ play: jest.fn(),
30
+ release: jest.fn(),
31
+ })),
32
+ }));
33
+
34
+ jest.mock(
35
+ '../../assets/audio/click-notification.wav',
36
+ () => 'click-notification.wav',
37
+ { virtual: true }
38
+ );
39
+
40
+ jest.mock('react-native', () => ({
41
+ Alert: { alert: jest.fn() },
42
+ Pressable: (props: {
43
+ accessibilityLabel?: string;
44
+ onPress?: () => void;
45
+ children?: unknown;
46
+ }) =>
47
+ React.createElement(
48
+ 'Pressable',
49
+ {
50
+ accessibilityLabel: props.accessibilityLabel,
51
+ onPress: props.onPress,
52
+ },
53
+ props.children
54
+ ),
55
+ StyleSheet: {
56
+ absoluteFill: { position: 'absolute', inset: 0 },
57
+ create: (o: Record<string, unknown>) => o,
58
+ },
59
+ View: (props: { style?: unknown; className?: string; children?: unknown }) =>
60
+ React.createElement('View', null, props.children),
61
+ }));
62
+
63
+ jest.mock('@livekit/react-native', () => ({
64
+ VideoTrack: ({
65
+ trackRef,
66
+ mirror,
67
+ }: {
68
+ trackRef: { publication: { trackSid: string } };
69
+ mirror: boolean;
70
+ }) => {
71
+ const { useEffect } = require('react');
72
+ useEffect(() => {
73
+ videoTrackMountCount++;
74
+ }, []);
75
+ return React.createElement('VideoTrack', {
76
+ mirror,
77
+ trackSid: trackRef.publication.trackSid,
78
+ });
79
+ },
80
+ isTrackReference: (ref: { publication?: unknown }) => !!ref.publication,
81
+ useIsSpeaking: () => false,
82
+ useRoomContext: () => ({ localParticipant: {} }),
83
+ }));
84
+
85
+ jest.mock('@openpeepshq/react', () => ({
86
+ useCurrentProfile: () => null,
87
+ participantTileProfile: () => null,
88
+ useJamContext: () => ({ jam: { moderators: [] } }),
89
+ useJamEventsContext: () => ({
90
+ ownReactions: [],
91
+ reactionsForParticipant: () => [],
92
+ }),
93
+ useJamParticipantMute: () => jest.fn(),
94
+ useJamParticipantRemove: () => jest.fn(),
95
+ useRaisedHands: () => new Set(),
96
+ }));
97
+
98
+ jest.mock('react-i18next', () => ({
99
+ useTranslation: () => ({
100
+ t: (key: string, opts?: Record<string, unknown>) =>
101
+ String(key).replace(/\{\{(\w+)\}\}/g, (_m: string, n: string) =>
102
+ String(opts?.[n] ?? '')
103
+ ),
104
+ }),
105
+ }));
106
+
107
+ jest.mock('react-native-toast-message', () => ({
108
+ __esModule: true,
109
+ default: { show: jest.fn() },
110
+ }));
111
+
112
+ jest.mock('../icons/index', () => {
113
+ const icon = (name: string) => () => React.createElement(name);
114
+ return {
115
+ AudioLinesIcon: icon('AudioLinesIcon'),
116
+ BanIcon: icon('BanIcon'),
117
+ EllipsisIcon: icon('EllipsisIcon'),
118
+ HandIcon: icon('HandIcon'),
119
+ MicIcon: icon('MicIcon'),
120
+ MicOffIcon: icon('MicOffIcon'),
121
+ PinIcon: icon('PinIcon'),
122
+ WifiOffIcon: icon('WifiOffIcon'),
123
+ };
124
+ });
125
+
126
+ jest.mock('../ui/dropdown-menu', () => ({
127
+ DropdownMenu: (props: { children?: unknown }) =>
128
+ React.createElement('DropdownMenu', null, props.children),
129
+ DropdownMenuContent: (props: { children?: unknown }) =>
130
+ React.createElement('DropdownMenuContent', null, props.children),
131
+ DropdownMenuGroup: (props: { children?: unknown }) =>
132
+ React.createElement('DropdownMenuGroup', null, props.children),
133
+ DropdownMenuItem: (props: { children?: unknown }) =>
134
+ React.createElement('DropdownMenuItem', null, props.children),
135
+ DropdownMenuTrigger: (props: { children?: unknown }) =>
136
+ React.createElement('DropdownMenuTrigger', null, props.children),
137
+ }));
138
+
139
+ jest.mock('../ui/themed-text', () => ({
140
+ ThemedText: (props: { children?: unknown; className?: string }) =>
141
+ React.createElement(
142
+ 'ThemedText',
143
+ { className: props.className },
144
+ props.children
145
+ ),
146
+ }));
147
+
148
+ jest.mock('../ui/button', () => ({
149
+ Button: (props: { children?: unknown; accessibilityLabel?: string }) =>
150
+ React.createElement(
151
+ 'Button',
152
+ { accessibilityLabel: props.accessibilityLabel },
153
+ props.children
154
+ ),
155
+ }));
156
+
157
+ jest.mock('../../lib/utils', () => ({
158
+ cn: (...classes: Array<string | false | undefined>) =>
159
+ classes.filter(Boolean).join(' '),
160
+ }));
161
+
162
+ jest.mock('../profile/Avatar', () => ({
163
+ ProfileAvatar: () => React.createElement('ProfileAvatar'),
164
+ }));
165
+
166
+ jest.mock('./useParticipantConnection', () => ({
167
+ useConnectionLost: () => false,
168
+ }));
169
+
170
+ jest.mock('../../theme/useThemeOpacity', () => ({
171
+ useThemeOpacity: () => ({
172
+ background: () => ({ backgroundColor: 'rgba(0, 0, 0, 0.7)' }),
173
+ }),
174
+ }));
175
+
176
+ const { JamCallParticipant } = require('./JamCallParticipant');
177
+
178
+ // Minimal stand-in for the webrtc MediaStream surface the hook touches.
179
+ const makeMediaStream = (initialVideoTracks = 0) => {
180
+ const videoTracks: unknown[] = Array.from({ length: initialVideoTracks });
181
+ const listeners: Array<() => void> = [];
182
+ return {
183
+ getVideoTracks: () => videoTracks,
184
+ addEventListener: (_type: string, listener: () => void) =>
185
+ listeners.push(listener),
186
+ removeEventListener: (_type: string, listener: () => void) => {
187
+ const index = listeners.indexOf(listener);
188
+ if (index !== -1) listeners.splice(index, 1);
189
+ },
190
+ // Test helper, not part of the real MediaStream API.
191
+ addVideoTrack() {
192
+ videoTracks.push({});
193
+ listeners.forEach((listener) => listener());
194
+ },
195
+ };
196
+ };
197
+
198
+ type Stream = ReturnType<typeof makeMediaStream>;
199
+
200
+ const renderTile = (track: { mediaStream?: Stream }) => {
201
+ videoTrackMountCount = 0;
202
+ const publication = {
203
+ trackSid: 'track-1',
204
+ isMuted: false,
205
+ track: track as never,
206
+ };
207
+ const trackRef = {
208
+ participant: {
209
+ identity: 'remote',
210
+ isLocal: false,
211
+ isMicrophoneEnabled: true,
212
+ connectionQuality: 1, // ConnectionQuality.Good
213
+ },
214
+ publication,
215
+ } as never;
216
+ let tree!: ReactTestRenderer.ReactTestRenderer;
217
+ ReactTestRenderer.act(() => {
218
+ tree = ReactTestRenderer.create(
219
+ React.createElement(JamCallParticipant, {
220
+ trackRef,
221
+ size: 'size-full',
222
+ })
223
+ );
224
+ });
225
+ return {
226
+ tree,
227
+ mounts: () => videoTrackMountCount,
228
+ unmount() {
229
+ ReactTestRenderer.act(() => {
230
+ tree.unmount();
231
+ });
232
+ },
233
+ };
234
+ };
235
+
236
+ describe('JamCallParticipant camera tile wiring', () => {
237
+ it('remounts the VideoTrack when the stream gains its first video track, plus a bounded burst, then stops', () => {
238
+ jest.useFakeTimers();
239
+ try {
240
+ const stream = makeMediaStream(0);
241
+ const tile = renderTile({ mediaStream: stream });
242
+
243
+ // Two mounts at initial render: the tile renders once, then the #1903
244
+ // trackEpoch effect bumps once on mount, re-keying the VideoTrack.
245
+ expect(tile.mounts()).toBe(2);
246
+
247
+ // First-track transition: one remount (remountKey 0 → 1)...
248
+ ReactTestRenderer.act(() => {
249
+ stream.addVideoTrack();
250
+ });
251
+ expect(tile.mounts()).toBe(3);
252
+
253
+ // ...then the hook's bounded burst: one remount per 300 ms tick, so
254
+ // keep the commits separate by advancing one tick per act().
255
+ ReactTestRenderer.act(() => {
256
+ jest.advanceTimersByTime(300);
257
+ });
258
+ expect(tile.mounts()).toBe(4);
259
+ ReactTestRenderer.act(() => {
260
+ jest.advanceTimersByTime(300);
261
+ });
262
+ expect(tile.mounts()).toBe(5);
263
+ ReactTestRenderer.act(() => {
264
+ jest.advanceTimersByTime(300);
265
+ });
266
+ expect(tile.mounts()).toBe(6);
267
+
268
+ // The tight burst is bounded: the fourth tick (1200 ms) clears the
269
+ // interval, and nothing further remounts up to the tail's first tick
270
+ // (3200 ms) — advance just before it. The tail's remounts at 2 s
271
+ // intervals are covered by the hook's own suite
272
+ // (`useLateTrackMediaStream.test.ts`, "sparse backoff tail"); a camera
273
+ // publish mid-Jam does not renegotiate, so it stays within the burst
274
+ // window.
275
+ ReactTestRenderer.act(() => {
276
+ jest.advanceTimersByTime(1900);
277
+ });
278
+ expect(tile.mounts()).toBe(6);
279
+ tile.unmount();
280
+ } finally {
281
+ jest.useRealTimers();
282
+ }
283
+ });
284
+
285
+ it('does not burst when the stream already has its track at mount', () => {
286
+ jest.useFakeTimers();
287
+ try {
288
+ const tile = renderTile({ mediaStream: makeMediaStream(1) });
289
+
290
+ // The two initial mounts come from the trackEpoch mount bump only.
291
+ expect(tile.mounts()).toBe(2);
292
+
293
+ // No 0 → 1 transition ever happens: no late remounts at all.
294
+ ReactTestRenderer.act(() => {
295
+ jest.advanceTimersByTime(300 * 20);
296
+ });
297
+ expect(tile.mounts()).toBe(2);
298
+ tile.unmount();
299
+ } finally {
300
+ jest.useRealTimers();
301
+ }
302
+ });
303
+ });
@@ -42,6 +42,7 @@ import { cn } from '../../lib/utils';
42
42
  import { ProfileAvatar } from '../profile/Avatar';
43
43
  import { JamAnimatedEmoji } from './JamAnimatedEmoji';
44
44
  import { useConnectionLost } from './useParticipantConnection';
45
+ import { useLateTrackMediaStream } from './useLateTrackMediaStream';
45
46
  import { useThemeOpacity } from '../../theme/useThemeOpacity';
46
47
 
47
48
  export interface JamCallParticipantProps {
@@ -377,6 +378,11 @@ export const JamCallParticipant = ({
377
378
  useEffect(() => {
378
379
  bumpTrackEpoch();
379
380
  }, [cameraTrack]);
381
+ // A first mid-Jam camera publish has the same late-attach race as screen
382
+ // share: the one-shot `streamURL` attach can run before the stream carries
383
+ // its video track and the native view never retries — so the hook's
384
+ // remountKey re-runs it once the track arrives.
385
+ const { remountKey } = useLateTrackMediaStream(cameraTrack);
380
386
  const cameraOn =
381
387
  isTrackReference(trackRef) &&
382
388
  !!cameraTrack &&
@@ -401,7 +407,7 @@ export const JamCallParticipant = ({
401
407
  >
402
408
  {cameraOn ? (
403
409
  <VideoTrack
404
- key={`${trackRef.publication.trackSid}-${trackEpoch}`}
410
+ key={`${trackRef.publication.trackSid}-${trackEpoch}-${remountKey}`}
405
411
  trackRef={trackRef}
406
412
  style={StyleSheet.absoluteFill}
407
413
  objectFit="cover"
@@ -26,10 +26,21 @@ let mockHasWaitingRoom = false;
26
26
  let mockWaitingProfiles: unknown[] = [];
27
27
  let mockBannedIds: string[] = [];
28
28
  const mockPressHandlers: Array<() => void> = [];
29
+ // Busy state for the waiting-room action row (mirrors `useJamPeople`).
30
+ let mockAdmittingId: string | null = null;
31
+ let mockRejectingId: string | null = null;
32
+ // Every rendered action-button and its props, in document order.
33
+ const mockButtonProps: Array<Record<string, unknown>> = [];
34
+ // Every rendered View className (pins the action group's layout classes).
35
+ const mockViewClasses: string[] = [];
36
+ // Every rendered icon, in document order (recorded by the icon stub).
37
+ const mockIconNames: string[] = [];
29
38
 
30
39
  jest.mock('react-native', () => ({
31
- View: (props: { children?: unknown }) =>
32
- React.createElement('View', null, props.children),
40
+ View: (props: { children?: unknown; className?: string }) => {
41
+ if (props.className) mockViewClasses.push(props.className);
42
+ return React.createElement('View', null, props.children);
43
+ },
33
44
  ScrollView: (props: { children?: unknown }) =>
34
45
  React.createElement('ScrollView', null, props.children),
35
46
  // Records every press handler in render order so a test can fire the
@@ -58,6 +69,10 @@ jest.mock('react-i18next', () => ({
58
69
  if (key === 'jams.people.observers') return 'Observers';
59
70
  if (key === 'jams.people.inWaitingRoom') return 'Waiting room';
60
71
  if (key === 'jams.people.noParticipants') return 'No participants found';
72
+ if (key === 'jams.waitingRoom.admitParticipant') return 'Admit';
73
+ if (key === 'jams.waitingRoom.admitting') return 'Admitting\u2026';
74
+ if (key === 'jams.waitingRoom.rejectParticipant') return 'Reject';
75
+ if (key === 'jams.waitingRoom.rejecting') return 'Rejecting\u2026';
61
76
  if (key === 'jams.drawer.peopleTitle') return 'People';
62
77
  if (key === 'jams.drawer.close') return 'Close';
63
78
  if (key === 'jams.drawer.searchPeoplePlaceholder') return 'Search';
@@ -84,8 +99,10 @@ jest.mock('@openpeepshq/react', () => ({
84
99
  setQuery: () => {},
85
100
  listedParticipants: mockParticipants,
86
101
  waitingProfiles: mockWaitingProfiles,
87
- admittingId: null,
102
+ admittingId: mockAdmittingId,
103
+ rejectingId: mockRejectingId,
88
104
  admit: () => {},
105
+ reject: () => {},
89
106
  // Mirror the real hook's banned-sublist contract (the drawer reads
90
107
  // bannedIds/liftingId/liftBan when isModerator is true); empty keeps the
91
108
  // "Removed" section hidden so these assertions stay on the Observers pin.
@@ -109,8 +126,10 @@ jest.mock('@openpeepshq/common/lib', () => ({
109
126
  }));
110
127
 
111
128
  jest.mock('../icons/index', () => {
112
- const make = (name: string) => (props: Record<string, unknown>) =>
113
- React.createElement(name, props);
129
+ const make = (name: string) => (props: Record<string, unknown>) => {
130
+ mockIconNames.push(name);
131
+ return React.createElement(name, props);
132
+ };
114
133
  return {
115
134
  AudioLinesIcon: make('AudioLinesIcon'),
116
135
  ChevronDownIcon: make('ChevronDownIcon'),
@@ -121,13 +140,16 @@ jest.mock('../icons/index', () => {
121
140
  MicOffIcon: make('MicOffIcon'),
122
141
  SearchIcon: make('SearchIcon'),
123
142
  UserRoundCheckIcon: make('UserRoundCheckIcon'),
143
+ UserRoundXIcon: make('UserRoundXIcon'),
124
144
  WifiOffIcon: make('WifiOffIcon'),
125
145
  };
126
146
  });
127
147
 
128
148
  jest.mock('../ui/button', () => ({
129
- Button: (props: { children?: unknown }) =>
130
- React.createElement('Button', null, props.children),
149
+ Button: (props: { children?: unknown }) => {
150
+ mockButtonProps.push(props as unknown as Record<string, unknown>);
151
+ return React.createElement('Button', null, props.children);
152
+ },
131
153
  }));
132
154
 
133
155
  jest.mock('../ui/input', () => ({
@@ -170,8 +192,8 @@ jest.mock('../ui/themed-text', () => ({
170
192
  }));
171
193
 
172
194
  // The package ships ESM-only source (see the jest.config.cjs notes); the
173
- // drawer only calls Toast.show for lift-ban errors, which these cases never
174
- // reach, so an inert mock keeps the suite parseable.
195
+ // drawer only calls Toast.show for waiting-room action feedback, which these
196
+ // cases never reach, so an inert mock keeps the suite parseable.
175
197
  jest.mock('react-native-toast-message', () => {
176
198
  const Toast = { show: jest.fn() };
177
199
  return { __esModule: true, default: Toast };
@@ -182,6 +204,7 @@ const { JamPeopleDrawer } = require('./JamPeopleDrawer');
182
204
  const renderDrawer = (
183
205
  sessions: number,
184
206
  waitingRoom: boolean = false,
207
+ busy: { admittingId?: string | null; rejectingId?: string | null } = {},
185
208
  bannedIds: string[] = []
186
209
  ) => {
187
210
  mockSessions = sessions;
@@ -189,7 +212,12 @@ const renderDrawer = (
189
212
  mockHasWaitingRoom = waitingRoom;
190
213
  mockWaitingProfiles = waitingRoom ? [{ id: 'w1' }] : [];
191
214
  mockBannedIds = bannedIds;
215
+ mockAdmittingId = busy.admittingId ?? null;
216
+ mockRejectingId = busy.rejectingId ?? null;
192
217
  mockRenderedTexts.length = 0;
218
+ mockButtonProps.length = 0;
219
+ mockViewClasses.length = 0;
220
+ mockIconNames.length = 0;
193
221
  mockPressHandlers.length = 0;
194
222
  let tree!: ReactTestRenderer.ReactTestRenderer;
195
223
  ReactTestRenderer.act(() => {
@@ -252,6 +280,68 @@ describe('JamPeopleDrawer observers section (RN)', () => {
252
280
  });
253
281
  });
254
282
 
283
+ describe('JamPeopleDrawer waiting-room action row (RN)', () => {
284
+ it('pins the admit/reject row: labels, order, group layout, and icons', () => {
285
+ renderDrawer(0, true);
286
+ const texts = mockRenderedTexts;
287
+
288
+ expect(texts).toContain('Waiting room');
289
+ expect(texts).toContain('waiting');
290
+ expect(texts).toContain('Admit');
291
+ expect(texts).toContain('Reject');
292
+ // The action row follows the queued profile name…
293
+ expect(texts.indexOf('waiting')).toBeLessThan(texts.indexOf('Admit'));
294
+ // …and Admit precedes Reject within the row.
295
+ expect(texts.indexOf('Admit')).toBeLessThan(texts.indexOf('Reject'));
296
+
297
+ // Exactly the two action buttons render, in order, both enabled.
298
+ expect(mockButtonProps).toHaveLength(2);
299
+ expect(mockButtonProps[0].accessibilityLabel).toBe('Admit');
300
+ expect(mockButtonProps[1].accessibilityLabel).toBe('Reject');
301
+ expect(mockButtonProps[0].disabled).toBe(false);
302
+ expect(mockButtonProps[1].disabled).toBe(false);
303
+
304
+ // The button group carries the non-wrapping layout class (round-2
305
+ // finding), so it survives narrow-width Yoga shrinking.
306
+ expect(mockViewClasses).toContain('flex-row shrink-0 items-center gap-1');
307
+
308
+ // Both action icons render, check (admit) before x (reject).
309
+ expect(mockIconNames).toContain('UserRoundCheckIcon');
310
+ expect(mockIconNames).toContain('UserRoundXIcon');
311
+ expect(mockIconNames.indexOf('UserRoundCheckIcon')).toBeLessThan(
312
+ mockIconNames.indexOf('UserRoundXIcon')
313
+ );
314
+ });
315
+
316
+ it('swaps the busy accessibilityLabel and disables both buttons while admitting', () => {
317
+ renderDrawer(0, true, { admittingId: 'w1' });
318
+
319
+ expect(mockButtonProps[0].accessibilityLabel).toBe('Admitting\u2026');
320
+ expect(mockButtonProps[1].accessibilityLabel).toBe('Reject');
321
+ expect(mockButtonProps[0].disabled).toBe(true);
322
+ expect(mockButtonProps[1].disabled).toBe(true);
323
+ });
324
+
325
+ it('swaps the busy accessibilityLabel and disables both buttons while rejecting', () => {
326
+ renderDrawer(0, true, { rejectingId: 'w1' });
327
+
328
+ expect(mockButtonProps[0].accessibilityLabel).toBe('Admit');
329
+ expect(mockButtonProps[1].accessibilityLabel).toBe('Rejecting\u2026');
330
+ expect(mockButtonProps[0].disabled).toBe(true);
331
+ expect(mockButtonProps[1].disabled).toBe(true);
332
+ });
333
+
334
+ it('hides the action row for non-moderators and without a waiting room', () => {
335
+ renderDrawer(0);
336
+
337
+ expect(mockButtonProps).toHaveLength(0);
338
+ expect(mockRenderedTexts).not.toContain('Waiting room');
339
+ expect(mockViewClasses).not.toContain(
340
+ 'flex-row shrink-0 items-center gap-1'
341
+ );
342
+ });
343
+ });
344
+
255
345
  describe('JamPeopleDrawer "Removed" sublist fallback (RN, issue #303 round-15 suggestion 2)', () => {
256
346
  // Independent of the observers renderDrawer: the fallback case needs a
257
347
  // moderator with a non-empty banned list but no waiting room / participants,
@@ -261,7 +351,12 @@ describe('JamPeopleDrawer "Removed" sublist fallback (RN, issue #303 round-15 su
261
351
  mockHasWaitingRoom = false;
262
352
  mockWaitingProfiles = [];
263
353
  mockBannedIds = bannedIds;
354
+ mockAdmittingId = null;
355
+ mockRejectingId = null;
264
356
  mockRenderedTexts.length = 0;
357
+ mockButtonProps.length = 0;
358
+ mockViewClasses.length = 0;
359
+ mockIconNames.length = 0;
265
360
  mockPressHandlers.length = 0;
266
361
  let tree!: ReactTestRenderer.ReactTestRenderer;
267
362
  ReactTestRenderer.act(() => {
@@ -22,6 +22,7 @@ import {
22
22
  MicOffIcon,
23
23
  SearchIcon,
24
24
  UserRoundCheckIcon,
25
+ UserRoundXIcon,
25
26
  WifiOffIcon,
26
27
  } from '../icons/index';
27
28
  import { Button } from '../ui/button';
@@ -118,8 +119,8 @@ const JamObserversSection = ({ count }: { count: number }) => {
118
119
 
119
120
  /**
120
121
  * In-room participants list with mic / raised-hand / moderator indicators,
121
- * plus a moderator-only waiting-room admit section and the hidden
122
- * external-session count.
122
+ * plus a moderator-only waiting-room section with admit and reject and the
123
+ * hidden external-session count.
123
124
  */
124
125
  export const JamPeopleDrawer = ({ open, onClose }: JamPeopleDrawerProps) => {
125
126
  const { t } = useTranslation();
@@ -137,7 +138,9 @@ export const JamPeopleDrawer = ({ open, onClose }: JamPeopleDrawerProps) => {
137
138
  listedParticipants,
138
139
  waitingProfiles,
139
140
  admittingId,
141
+ rejectingId,
140
142
  admit,
143
+ reject,
141
144
  bannedIds,
142
145
  liftingId,
143
146
  liftBan,
@@ -145,6 +148,8 @@ export const JamPeopleDrawer = ({ open, onClose }: JamPeopleDrawerProps) => {
145
148
  room,
146
149
  participants,
147
150
  onLiftError: (text1) => Toast.show({ type: 'error', text1 }),
151
+ onActionSuccess: (text1) => Toast.show({ type: 'success', text1 }),
152
+ onActionError: (text1) => Toast.show({ type: 'error', text1 }),
148
153
  });
149
154
 
150
155
  if (!open) return null;
@@ -206,15 +211,47 @@ export const JamPeopleDrawer = ({ open, onClose }: JamPeopleDrawerProps) => {
206
211
  {waitingRoomEntryName(profile)}
207
212
  </ThemedText>
208
213
  </View>
209
- <Button
210
- variant="outline"
211
- size="icon"
212
- onPress={() => admit(profile)}
213
- disabled={admittingId === profile.id}
214
- accessibilityLabel={t('jams.waitingRoom.admitParticipant')}
215
- >
216
- <UserRoundCheckIcon size={16} className="text-foreground" />
217
- </Button>
214
+ <View className="flex-row shrink-0 items-center gap-1">
215
+ <Button
216
+ variant="outline"
217
+ size="sm"
218
+ onPress={() => admit(profile)}
219
+ disabled={
220
+ admittingId === profile.id || rejectingId === profile.id
221
+ }
222
+ accessibilityLabel={
223
+ admittingId === profile.id
224
+ ? t('jams.waitingRoom.admitting')
225
+ : t('jams.waitingRoom.admitParticipant')
226
+ }
227
+ >
228
+ <UserRoundCheckIcon
229
+ size={16}
230
+ className="text-foreground"
231
+ />
232
+ <ThemedText className="text-xs">
233
+ {t('jams.waitingRoom.admitParticipant')}
234
+ </ThemedText>
235
+ </Button>
236
+ <Button
237
+ variant="destructive"
238
+ size="sm"
239
+ onPress={() => reject(profile)}
240
+ disabled={
241
+ admittingId === profile.id || rejectingId === profile.id
242
+ }
243
+ accessibilityLabel={
244
+ rejectingId === profile.id
245
+ ? t('jams.waitingRoom.rejecting')
246
+ : t('jams.waitingRoom.rejectParticipant')
247
+ }
248
+ >
249
+ <UserRoundXIcon size={16} className="text-foreground" />
250
+ <ThemedText className="text-xs">
251
+ {t('jams.waitingRoom.rejectParticipant')}
252
+ </ThemedText>
253
+ </Button>
254
+ </View>
218
255
  </View>
219
256
  ))}
220
257
  </View>