@openpeepshq/rn-components 0.22.0 → 0.24.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.
- package/package.json +3 -3
- package/src/components/custom/modals/media/audio-picker-sheet.test.tsx +913 -0
- package/src/components/custom/modals/media/audio-picker-sheet.tsx +181 -49
- package/src/components/custom/modals/media/record-audio-sheet.test.tsx +626 -0
- package/src/components/custom/modals/media/record-audio-sheet.tsx +335 -111
- package/src/components/jams/JamPeopleDrawer.test.tsx +104 -9
- package/src/components/jams/JamPeopleDrawer.tsx +48 -11
- package/src/components/jams/JamRequestJoin.test.tsx +163 -0
- package/src/components/jams/JamRequestJoin.tsx +31 -15
- package/src/components/navigation/main-navigator.tsx +5 -0
- package/src/components/navigation/nativeRouter.tsx +1 -0
- package/src/components/navigation/parent-back.ts +1 -0
- package/src/components/navigation/types/main.ts +1 -0
- package/src/lib/uploadMedia.test.ts +190 -0
- package/src/lib/uploadMedia.ts +55 -0
- package/src/pages/index.ts +1 -0
- package/src/pages/settings/CalendarFeed.test.tsx +269 -0
- package/src/pages/settings/CalendarFeed.tsx +77 -0
- package/src/pages/settings/Index.tsx +4 -0
|
@@ -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
|
-
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
<
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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>
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web/native parity pin for the request-to-join phase machine (issue #1781).
|
|
3
|
+
*
|
|
4
|
+
* The web twin is pinned in `platform/react/src/components/jams/
|
|
5
|
+
* JamRequestJoin.test.tsx` (same idle → waiting → denied → re-request
|
|
6
|
+
* flow). The RN component gained the identical phase machine in this PR;
|
|
7
|
+
* this file pins it on native: the waiting copy renders only while the
|
|
8
|
+
* join stream is open, the denial copy renders after the stream reports a
|
|
9
|
+
* denial, and the request affordance returns so the guest can try again.
|
|
10
|
+
*
|
|
11
|
+
* Only RN, i18n, and the shared join hook are stubbed. `ThemedText` is the
|
|
12
|
+
* single text primitive the component renders through, so the mock records
|
|
13
|
+
* every rendered label in document order (`mockRenderedTexts`) — the
|
|
14
|
+
* assertions read that ordered log instead of walking the rendered tree.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const React = require('react');
|
|
18
|
+
const ReactTestRenderer = require('react-test-renderer');
|
|
19
|
+
|
|
20
|
+
let mockOnJoin: ((params: unknown) => void) | undefined;
|
|
21
|
+
let mockOnDenied: (() => void) | undefined;
|
|
22
|
+
let mockButtonOnPress: (() => void) | undefined;
|
|
23
|
+
let mockButtonComponent: unknown;
|
|
24
|
+
const mockRenderedTexts: string[] = [];
|
|
25
|
+
|
|
26
|
+
jest.mock('react-native', () => ({
|
|
27
|
+
View: (props: { children?: unknown; className?: string }) =>
|
|
28
|
+
React.createElement('View', null, props.children),
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
jest.mock('react-i18next', () => ({
|
|
32
|
+
useTranslation: () => ({
|
|
33
|
+
// Values mirror `platform/i18n/src/locales/en.json` so the rendered
|
|
34
|
+
// copy pins the key usage.
|
|
35
|
+
t: (key: string) => {
|
|
36
|
+
if (key === 'jams.join.requestToJoin') return 'Request to join';
|
|
37
|
+
if (key === 'jams.join.waitingForModerator')
|
|
38
|
+
return 'Waiting for a moderator to let you in';
|
|
39
|
+
if (key === 'jams.join.rejected')
|
|
40
|
+
return 'The moderator declined your request to join';
|
|
41
|
+
return key;
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
}));
|
|
45
|
+
|
|
46
|
+
// The hook is the only thing that talks to the join stream; capturing its
|
|
47
|
+
// callbacks lets the test drive the denied transition directly (a real
|
|
48
|
+
// stream would emit `{ denied: true }`).
|
|
49
|
+
jest.mock('@openpeepshq/react', () => ({
|
|
50
|
+
apiErrorMessage: () => '',
|
|
51
|
+
useJoinWaitingRoomToken: (
|
|
52
|
+
onJoin: (params: unknown) => void,
|
|
53
|
+
_onError: unknown,
|
|
54
|
+
onDenied?: () => void
|
|
55
|
+
) => {
|
|
56
|
+
mockOnJoin = onJoin;
|
|
57
|
+
mockOnDenied = onDenied;
|
|
58
|
+
},
|
|
59
|
+
}));
|
|
60
|
+
|
|
61
|
+
jest.mock('../ui/button', () => {
|
|
62
|
+
mockButtonComponent = (props: {
|
|
63
|
+
children?: unknown;
|
|
64
|
+
onPress?: () => void;
|
|
65
|
+
}) => {
|
|
66
|
+
mockButtonOnPress = props.onPress;
|
|
67
|
+
return React.createElement('Button', null, props.children);
|
|
68
|
+
};
|
|
69
|
+
return { Button: mockButtonComponent };
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
jest.mock('../ui/themed-text', () => ({
|
|
73
|
+
ThemedText: (props: { children?: unknown; className?: string }) => {
|
|
74
|
+
const c = props.children;
|
|
75
|
+
if (typeof c === 'string' && c) mockRenderedTexts.push(c);
|
|
76
|
+
return React.createElement('ThemedText', { className: props.className }, c);
|
|
77
|
+
},
|
|
78
|
+
}));
|
|
79
|
+
|
|
80
|
+
const { JamRequestJoin } = require('./JamRequestJoin');
|
|
81
|
+
|
|
82
|
+
const pressButton = () => {
|
|
83
|
+
ReactTestRenderer.act(() => {
|
|
84
|
+
mockButtonOnPress?.();
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
describe('JamRequestJoin denied phase (RN)', () => {
|
|
89
|
+
let tree: ReactTestRenderer.ReactTestRenderer | undefined;
|
|
90
|
+
|
|
91
|
+
beforeEach(() => {
|
|
92
|
+
mockOnJoin = undefined;
|
|
93
|
+
mockOnDenied = undefined;
|
|
94
|
+
mockButtonOnPress = undefined;
|
|
95
|
+
mockRenderedTexts.length = 0;
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
afterEach(() => {
|
|
99
|
+
ReactTestRenderer.act(() => {
|
|
100
|
+
tree?.unmount();
|
|
101
|
+
});
|
|
102
|
+
tree = undefined;
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('shows the rejection message and offers the request again after a denial', () => {
|
|
106
|
+
ReactTestRenderer.act(() => {
|
|
107
|
+
tree = ReactTestRenderer.create(
|
|
108
|
+
React.createElement(JamRequestJoin, { onJoin: () => {} })
|
|
109
|
+
);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Idle: only the request button, no waiting or rejection copy.
|
|
113
|
+
expect(mockButtonOnPress).toBeDefined();
|
|
114
|
+
expect(mockRenderedTexts).toEqual(['Request to join']);
|
|
115
|
+
expect(mockOnJoin).toBeUndefined();
|
|
116
|
+
expect(mockOnDenied).toBeUndefined();
|
|
117
|
+
|
|
118
|
+
// Requesting starts the waiting phase (the join stream is opened).
|
|
119
|
+
pressButton();
|
|
120
|
+
expect(mockOnJoin).toBeDefined();
|
|
121
|
+
expect(mockOnDenied).toBeDefined();
|
|
122
|
+
expect(mockRenderedTexts).toContain(
|
|
123
|
+
'Waiting for a moderator to let you in'
|
|
124
|
+
);
|
|
125
|
+
expect(mockRenderedTexts).not.toContain('The moderator declined');
|
|
126
|
+
// The request button is replaced by the waiting copy.
|
|
127
|
+
expect(
|
|
128
|
+
(tree as ReactTestRenderer.ReactTestRenderer).root.findAllByType(
|
|
129
|
+
mockButtonComponent as never
|
|
130
|
+
)
|
|
131
|
+
).toHaveLength(0);
|
|
132
|
+
|
|
133
|
+
// The stream reports a denial: the phase switches to denied.
|
|
134
|
+
mockRenderedTexts.length = 0;
|
|
135
|
+
ReactTestRenderer.act(() => {
|
|
136
|
+
mockOnDenied?.();
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// The rejection copy is shown and the request is offered again; the
|
|
140
|
+
// waiting copy is gone (asserted on the phase's own render, since the
|
|
141
|
+
// log accumulates across renders).
|
|
142
|
+
expect(mockRenderedTexts).toEqual([
|
|
143
|
+
'The moderator declined your request to join',
|
|
144
|
+
'Request to join',
|
|
145
|
+
]);
|
|
146
|
+
expect(mockButtonOnPress).toBeDefined();
|
|
147
|
+
|
|
148
|
+
// Requesting again goes back to the waiting phase.
|
|
149
|
+
mockRenderedTexts.length = 0;
|
|
150
|
+
pressButton();
|
|
151
|
+
expect(mockRenderedTexts).toContain(
|
|
152
|
+
'Waiting for a moderator to let you in'
|
|
153
|
+
);
|
|
154
|
+
expect(mockRenderedTexts).not.toContain(
|
|
155
|
+
'The moderator declined your request to join'
|
|
156
|
+
);
|
|
157
|
+
expect(
|
|
158
|
+
(tree as ReactTestRenderer.ReactTestRenderer).root.findAllByType(
|
|
159
|
+
mockButtonComponent as never
|
|
160
|
+
)
|
|
161
|
+
).toHaveLength(0);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
@@ -16,8 +16,10 @@ export interface JamRequestJoinProps {
|
|
|
16
16
|
|
|
17
17
|
const JamWaitingRoomListener = ({
|
|
18
18
|
onJoin,
|
|
19
|
+
onDenied,
|
|
19
20
|
}: {
|
|
20
21
|
onJoin: JamRequestJoinProps['onJoin'];
|
|
22
|
+
onDenied: () => void;
|
|
21
23
|
}) => {
|
|
22
24
|
const { t } = useTranslation();
|
|
23
25
|
const [error, setError] = useState<string | null>(null);
|
|
@@ -33,13 +35,17 @@ const JamWaitingRoomListener = ({
|
|
|
33
35
|
[onJoin]
|
|
34
36
|
);
|
|
35
37
|
|
|
36
|
-
useJoinWaitingRoomToken(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
useJoinWaitingRoomToken(
|
|
39
|
+
joinAndClearError,
|
|
40
|
+
(e?: SseError) => {
|
|
41
|
+
// Reuse the shared key→message mapping (`errorKey ?? key`, translate
|
|
42
|
+
// `error.*` keys). The SSE path passes an empty fallback so a keyless,
|
|
43
|
+
// message-less error renders nothing rather than a generic "Error".
|
|
44
|
+
const message = apiErrorMessage(e, t, '');
|
|
45
|
+
setError(message.length > 0 ? message : null);
|
|
46
|
+
},
|
|
47
|
+
onDenied
|
|
48
|
+
);
|
|
43
49
|
|
|
44
50
|
return error ? (
|
|
45
51
|
<ThemedText className="text-center text-sm text-destructive">
|
|
@@ -50,23 +56,33 @@ const JamWaitingRoomListener = ({
|
|
|
50
56
|
|
|
51
57
|
export const JamRequestJoin = ({ onJoin }: JamRequestJoinProps) => {
|
|
52
58
|
const { t } = useTranslation();
|
|
53
|
-
const [
|
|
59
|
+
const [phase, setPhase] = useState<'idle' | 'waiting' | 'denied'>('idle');
|
|
54
60
|
|
|
55
61
|
return (
|
|
56
62
|
<View className="w-full flex-1 items-center justify-center gap-4 p-4">
|
|
57
|
-
{
|
|
63
|
+
{phase === 'waiting' ? (
|
|
58
64
|
<>
|
|
59
|
-
<JamWaitingRoomListener
|
|
65
|
+
<JamWaitingRoomListener
|
|
66
|
+
onJoin={onJoin}
|
|
67
|
+
onDenied={() => setPhase('denied')}
|
|
68
|
+
/>
|
|
60
69
|
<ThemedText className="text-center text-sm text-muted-foreground">
|
|
61
70
|
{t('jams.join.waitingForModerator')}
|
|
62
71
|
</ThemedText>
|
|
63
72
|
</>
|
|
64
73
|
) : (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
<>
|
|
75
|
+
{phase === 'denied' ? (
|
|
76
|
+
<ThemedText className="text-center text-sm text-muted-foreground">
|
|
77
|
+
{t('jams.join.rejected')}
|
|
78
|
+
</ThemedText>
|
|
79
|
+
) : null}
|
|
80
|
+
<Button onPress={() => setPhase('waiting')}>
|
|
81
|
+
<ThemedText className="text-primary-foreground">
|
|
82
|
+
{t('jams.join.requestToJoin')}
|
|
83
|
+
</ThemedText>
|
|
84
|
+
</Button>
|
|
85
|
+
</>
|
|
70
86
|
)}
|
|
71
87
|
</View>
|
|
72
88
|
);
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
AccountSettings,
|
|
28
28
|
ThemeSettings,
|
|
29
29
|
AccessTokensSettings,
|
|
30
|
+
CalendarFeedSettings,
|
|
30
31
|
FeedSettings,
|
|
31
32
|
BlockedSettings,
|
|
32
33
|
VideoPlayer,
|
|
@@ -153,6 +154,10 @@ export const MainNavigator = () => {
|
|
|
153
154
|
name="AccessTokensSettings"
|
|
154
155
|
component={AccessTokensSettings}
|
|
155
156
|
/>
|
|
157
|
+
<Stack.Screen
|
|
158
|
+
name="CalendarFeedSettings"
|
|
159
|
+
component={CalendarFeedSettings}
|
|
160
|
+
/>
|
|
156
161
|
<Stack.Screen name="BlockedSettings" component={BlockedSettings} />
|
|
157
162
|
<Stack.Screen name="LanguageSettings" component={LanguageSettings} />
|
|
158
163
|
<Stack.Screen name="TimezoneSettings" component={TimezoneSettings} />
|
|
@@ -21,6 +21,7 @@ const SETTINGS_SCREENS: Record<string, keyof MainStackParamList | undefined> = {
|
|
|
21
21
|
'language': 'LanguageSettings',
|
|
22
22
|
'timezone': 'TimezoneSettings',
|
|
23
23
|
'feed': 'FeedSettings',
|
|
24
|
+
'calendar-feed': 'CalendarFeedSettings',
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
const go = (name: string, params?: object) => {
|