@openpeepshq/rn-components 0.10.1 → 0.11.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/rn-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "React Native community screens and shared UI (extracted from the Black Ambition app) for the OpenPeeps stack.",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Join-Jam affordance for signed-in attendees on the single event page
|
|
3
|
+
* (issue #1815). The RN `FullEvent` previously rendered a Join/Start button
|
|
4
|
+
* only for the host or a jam moderator, so an attendee on a *live* jam had no
|
|
5
|
+
* way to join from this screen. This locks in the attendee button: it appears
|
|
6
|
+
* only when the user is signed in, LiveKit is enabled, and the jam is active;
|
|
7
|
+
* it is mutually exclusive with the host/moderator button; and pressing it
|
|
8
|
+
* navigates to the JamSession (the same route CardEvent uses), leaving all
|
|
9
|
+
* auth/capacity/moderation gating to JamSession -> JamRoom.
|
|
10
|
+
*
|
|
11
|
+
* FullEvent is a large composite, so every external import is mocked (node
|
|
12
|
+
* jest env, no native modules) — mirroring MessageInThread.test.tsx. Only the
|
|
13
|
+
* jam-section decision tree under test is exercised; the surrounding feed /
|
|
14
|
+
* tabs / share UI render inert mocks.
|
|
15
|
+
*/
|
|
16
|
+
import { type ReactNode } from 'react';
|
|
17
|
+
import ReactTestRenderer from 'react-test-renderer';
|
|
18
|
+
|
|
19
|
+
// --- shared mutable state read by the module mocks (mock* = hoisting-safe) --
|
|
20
|
+
let mockJamState: { active: boolean } | undefined;
|
|
21
|
+
let mockProfile: { id: string; displayName?: string; handle?: string } | null =
|
|
22
|
+
{ id: 'u-1', displayName: 'Att', handle: 'att' };
|
|
23
|
+
const mockNavigate = jest.fn();
|
|
24
|
+
const mockClient = { posts: { exportRsvps: jest.fn() } };
|
|
25
|
+
const mockUseServerInfo = jest.fn(() => ({
|
|
26
|
+
jams: { livekit: { enabled: true } },
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
// --- react-native: host elements render as plain host tags ----------------
|
|
30
|
+
jest.mock('react-native', () => {
|
|
31
|
+
const React = require('react');
|
|
32
|
+
const make = (tag: string) => (props: { children?: ReactNode }) =>
|
|
33
|
+
React.createElement(tag, null, props.children);
|
|
34
|
+
// forwards props so the tappable Jam URL's a11y/press handlers are testable
|
|
35
|
+
const makeTouchable = (tag: string) => (props: { children?: ReactNode }) =>
|
|
36
|
+
React.createElement(tag, props, props.children);
|
|
37
|
+
return {
|
|
38
|
+
View: make('View'),
|
|
39
|
+
Pressable: make('Pressable'),
|
|
40
|
+
TouchableOpacity: makeTouchable('TouchableOpacity'),
|
|
41
|
+
Image: make('Image'),
|
|
42
|
+
Share: { share: jest.fn() },
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// --- i18n: resolve keys to their defaultValue -----------------------------
|
|
47
|
+
jest.mock('react-i18next', () => ({
|
|
48
|
+
useTranslation: () => ({
|
|
49
|
+
t: (_key: string, opts?: { defaultValue?: string }) =>
|
|
50
|
+
opts?.defaultValue ?? _key,
|
|
51
|
+
}),
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
// --- openpeeps context + server info --------------------------------------
|
|
55
|
+
jest.mock('@openpeepshq/react', () => ({
|
|
56
|
+
useOpenpeeps: () => ({
|
|
57
|
+
currentProfile: mockProfile,
|
|
58
|
+
openpeepsApi: {
|
|
59
|
+
rsvpManageAction: () => ({}),
|
|
60
|
+
useJamAttendance: () => ({ isSuccess: false, data: [] }),
|
|
61
|
+
useJamState: () => ({ data: mockJamState }),
|
|
62
|
+
usePostRecordings: () => ({ data: [] }),
|
|
63
|
+
usePostContext: () => ({ data: undefined }),
|
|
64
|
+
},
|
|
65
|
+
client: mockClient,
|
|
66
|
+
}),
|
|
67
|
+
useServerInfo: mockUseServerInfo,
|
|
68
|
+
}));
|
|
69
|
+
|
|
70
|
+
// --- shared (pure) helpers -------------------------------------------------
|
|
71
|
+
jest.mock('@openpeepshq/common', () => ({
|
|
72
|
+
buildThreads: (posts: unknown[]) => (Array.isArray(posts) ? posts : []),
|
|
73
|
+
}));
|
|
74
|
+
jest.mock('@openpeepshq/common/lib', () => ({
|
|
75
|
+
availableSpots: () => null,
|
|
76
|
+
canAccessJamRecordings: () => false,
|
|
77
|
+
canModerateJam: () => false,
|
|
78
|
+
canViewJamAttendees: () => false,
|
|
79
|
+
effectiveEventTimes: () => ({}),
|
|
80
|
+
eventTimeZoneOptions: () => ({ label: 'UTC' }),
|
|
81
|
+
formatEventClockTime: () => '',
|
|
82
|
+
formatEventRecurrence: () => '',
|
|
83
|
+
listRsvpOccurrences: () => [],
|
|
84
|
+
parseOccurrenceQuery: () => null,
|
|
85
|
+
rsvpExportFilename: () => 'rsvp.csv',
|
|
86
|
+
}));
|
|
87
|
+
|
|
88
|
+
// --- navigation ------------------------------------------------------------
|
|
89
|
+
jest.mock('@react-navigation/native', () => ({
|
|
90
|
+
useNavigation: () => ({
|
|
91
|
+
navigate: (...args: unknown[]) => mockNavigate(...args),
|
|
92
|
+
}),
|
|
93
|
+
}));
|
|
94
|
+
jest.mock('@react-navigation/native-stack', () => ({}));
|
|
95
|
+
|
|
96
|
+
// --- native third-party modules (no native impl in node) ------------------
|
|
97
|
+
jest.mock('react-native-fs', () => ({ default: { CachesDirectoryPath: '' } }));
|
|
98
|
+
jest.mock('@react-native-clipboard/clipboard', () => ({
|
|
99
|
+
__esModule: true,
|
|
100
|
+
default: { setString: jest.fn(), getString: jest.fn() },
|
|
101
|
+
}));
|
|
102
|
+
jest.mock('react-native-toast-message', () => ({
|
|
103
|
+
__esModule: true,
|
|
104
|
+
default: { show: jest.fn() },
|
|
105
|
+
}));
|
|
106
|
+
jest.mock('@gorhom/bottom-sheet', () => ({
|
|
107
|
+
BottomSheetModal: () => null,
|
|
108
|
+
}));
|
|
109
|
+
|
|
110
|
+
// --- local modules (state stores, sheets, utils, constants) ---------------
|
|
111
|
+
jest.mock('../../../../stores/useNewConversationStore', () => ({
|
|
112
|
+
useNewConversationStore: () => ({ setContt: jest.fn() }),
|
|
113
|
+
}));
|
|
114
|
+
jest.mock('../../../../hooks/use-controlled-sheet', () => ({
|
|
115
|
+
useControlledSheet: () => ({ current: {} }),
|
|
116
|
+
}));
|
|
117
|
+
jest.mock('../../../../lib/utils', () => ({
|
|
118
|
+
profileName: (p?: { displayName?: string; handle?: string }) =>
|
|
119
|
+
p?.displayName ?? p?.handle ?? '',
|
|
120
|
+
groupName: (g?: { name?: string }) => g?.name ?? '',
|
|
121
|
+
truncateText: (s: string, n: number) => (s ? s.slice(0, n) : ''),
|
|
122
|
+
canManageEventRsvps: () => false,
|
|
123
|
+
}));
|
|
124
|
+
jest.mock('../../../../lib/constants', () => ({
|
|
125
|
+
BASE_URL: 'https://openpeeps.org',
|
|
126
|
+
}));
|
|
127
|
+
jest.mock('../../../../lib/downloadFile', () => ({
|
|
128
|
+
downloadDocument: jest.fn(),
|
|
129
|
+
}));
|
|
130
|
+
|
|
131
|
+
// --- ui primitives ---------------------------------------------------------
|
|
132
|
+
// Each factory is self-contained (React.createElement) because jest.mock
|
|
133
|
+
// factories run during hoisted import resolution, before top-level consts.
|
|
134
|
+
jest.mock('../../../ui/themed-text', () => {
|
|
135
|
+
const React = require('react');
|
|
136
|
+
return {
|
|
137
|
+
ThemedText: (props: { children?: ReactNode }) =>
|
|
138
|
+
React.createElement('Text', null, props.children),
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
jest.mock('../../../ui/themed-view', () => {
|
|
142
|
+
const React = require('react');
|
|
143
|
+
return {
|
|
144
|
+
ThemedView: (props: { children?: ReactNode }) =>
|
|
145
|
+
React.createElement('View', null, props.children),
|
|
146
|
+
};
|
|
147
|
+
});
|
|
148
|
+
jest.mock('../../../ui/button', () => {
|
|
149
|
+
const React = require('react');
|
|
150
|
+
// forwards props (incl. onPress/className) to a host View so the button is
|
|
151
|
+
// findable, pressable, and carries the styling under test.
|
|
152
|
+
return {
|
|
153
|
+
Button: (props: {
|
|
154
|
+
children?: ReactNode;
|
|
155
|
+
className?: string;
|
|
156
|
+
size?: string;
|
|
157
|
+
onPress?: () => void;
|
|
158
|
+
}) =>
|
|
159
|
+
React.createElement(
|
|
160
|
+
'View',
|
|
161
|
+
{
|
|
162
|
+
className: props.className,
|
|
163
|
+
size: props.size,
|
|
164
|
+
onPress: props.onPress,
|
|
165
|
+
},
|
|
166
|
+
props.children
|
|
167
|
+
),
|
|
168
|
+
};
|
|
169
|
+
});
|
|
170
|
+
jest.mock('../../../ui/dropdown-menu', () => {
|
|
171
|
+
const React = require('react');
|
|
172
|
+
const V = (p: { children?: ReactNode }) =>
|
|
173
|
+
React.createElement('View', null, p.children);
|
|
174
|
+
return {
|
|
175
|
+
DropdownMenu: V,
|
|
176
|
+
DropdownMenuContent: V,
|
|
177
|
+
DropdownMenuGroup: V,
|
|
178
|
+
DropdownMenuTrigger: V,
|
|
179
|
+
DropdownMenuItem: () => null,
|
|
180
|
+
};
|
|
181
|
+
});
|
|
182
|
+
jest.mock('../../../ui/tabs', () => {
|
|
183
|
+
const React = require('react');
|
|
184
|
+
const V = (p: { children?: ReactNode }) =>
|
|
185
|
+
React.createElement('View', null, p.children);
|
|
186
|
+
return { Tabs: V, TabsList: V, TabsTrigger: V, TabsContent: V };
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// --- sibling components (render inert) ------------------------------------
|
|
190
|
+
jest.mock('../../../profile/Avatar', () => ({ ProfileAvatar: () => null }));
|
|
191
|
+
jest.mock('../../../profile/ProfileFromId', () => ({
|
|
192
|
+
ProfileFromId: () => null,
|
|
193
|
+
}));
|
|
194
|
+
jest.mock('../../../profile/index', () => ({
|
|
195
|
+
ReportProfileOrPostModal: () => null,
|
|
196
|
+
}));
|
|
197
|
+
jest.mock('../../../custom/date/updating-date', () => ({
|
|
198
|
+
UpdatingDate: () => null,
|
|
199
|
+
}));
|
|
200
|
+
jest.mock('../../../custom/modals/common', () => ({
|
|
201
|
+
BaseSheet: () => null,
|
|
202
|
+
SheetFooter: () => null,
|
|
203
|
+
}));
|
|
204
|
+
jest.mock('../../pieces/VideoPlayer', () => ({ VideoPlayer: () => null }));
|
|
205
|
+
jest.mock('../../pieces/EventOccurrenceList', () => ({
|
|
206
|
+
EventOccurrenceList: () => null,
|
|
207
|
+
}));
|
|
208
|
+
jest.mock('../../pieces/EventRsvpList', () => ({
|
|
209
|
+
EventRsvpList: () => null,
|
|
210
|
+
}));
|
|
211
|
+
jest.mock('../../../markdown/index', () => ({
|
|
212
|
+
OpenpeepsMarkdown: () => null,
|
|
213
|
+
}));
|
|
214
|
+
jest.mock('../../../icons/index', () => ({
|
|
215
|
+
MoreVerticalIcon: () => null,
|
|
216
|
+
ShareIcon: () => null,
|
|
217
|
+
DownloadIcon: () => null,
|
|
218
|
+
Trash2Icon: () => null,
|
|
219
|
+
MapPinIcon: () => null,
|
|
220
|
+
LinkIcon: () => null,
|
|
221
|
+
PhoneCallIcon: () => null,
|
|
222
|
+
Link2Icon: () => null,
|
|
223
|
+
SendIcon: () => null,
|
|
224
|
+
PencilIcon: () => null,
|
|
225
|
+
FlagIcon: () => null,
|
|
226
|
+
}));
|
|
227
|
+
// The components barrel (EventRsvpButton, ReplyBox, ShareMenu, useNewPostModal, ...)
|
|
228
|
+
jest.mock('../../index', () => ({
|
|
229
|
+
EventMenu: () => null,
|
|
230
|
+
EventRsvpButton: () => null,
|
|
231
|
+
ReplyBox: () => null,
|
|
232
|
+
ShareMenu: () => null,
|
|
233
|
+
ThreadedFeed: () => null,
|
|
234
|
+
useNewPostModal: () => ({ openNewPost: jest.fn() }),
|
|
235
|
+
}));
|
|
236
|
+
|
|
237
|
+
import Clipboard from '@react-native-clipboard/clipboard';
|
|
238
|
+
import Toast from 'react-native-toast-message';
|
|
239
|
+
import { FullEvent } from './FullEvent';
|
|
240
|
+
|
|
241
|
+
type TreeNode = {
|
|
242
|
+
type: string;
|
|
243
|
+
props?: Record<string, unknown>;
|
|
244
|
+
children?: (string | TreeNode)[];
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
// A "Join Jam" button is the host View that carries the label AND forwards
|
|
248
|
+
// onPress (only Button does). Search deepest-first so the button itself — not
|
|
249
|
+
// an ancestor container that merely contains the label — is returned.
|
|
250
|
+
function joinButton(node: TreeNode): TreeNode | undefined {
|
|
251
|
+
if (node.type !== 'View') return undefined;
|
|
252
|
+
const kids = (node.children || []).filter(
|
|
253
|
+
(c): c is TreeNode => typeof c !== 'string'
|
|
254
|
+
);
|
|
255
|
+
for (const c of kids) {
|
|
256
|
+
const found = joinButton(c);
|
|
257
|
+
if (found) return found;
|
|
258
|
+
}
|
|
259
|
+
if (typeof node.props?.onPress !== 'function') return undefined;
|
|
260
|
+
return JSON.stringify(node.children || []).includes('Join Jam')
|
|
261
|
+
? node
|
|
262
|
+
: undefined;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// The tappable Jam URL: the only TouchableOpacity exposed as a link.
|
|
266
|
+
function jamUrlLink(node: TreeNode): TreeNode | undefined {
|
|
267
|
+
if (
|
|
268
|
+
node.type === 'TouchableOpacity' &&
|
|
269
|
+
node.props?.accessibilityRole === 'link'
|
|
270
|
+
)
|
|
271
|
+
return node;
|
|
272
|
+
for (const c of node.children || []) {
|
|
273
|
+
const found = typeof c === 'string' ? undefined : jamUrlLink(c);
|
|
274
|
+
if (found) return found;
|
|
275
|
+
}
|
|
276
|
+
return undefined;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const BASE_POST = {
|
|
280
|
+
id: 'post-1',
|
|
281
|
+
profile: { id: 'owner-1', displayName: 'Owner' },
|
|
282
|
+
visibility: 'public',
|
|
283
|
+
// `image` set so the header uses a remote URI instead of require()ing a
|
|
284
|
+
// local placeholder PNG (jest's node env cannot parse binary assets).
|
|
285
|
+
data: {
|
|
286
|
+
type: 'event',
|
|
287
|
+
name: 'Meetup',
|
|
288
|
+
jam: true,
|
|
289
|
+
image: 'https://openpeeps.org/img/pic.svg',
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
function render(
|
|
294
|
+
post: unknown,
|
|
295
|
+
occurrence?: string
|
|
296
|
+
): ReactTestRenderer.ReactTestRenderer {
|
|
297
|
+
mockNavigate.mockClear();
|
|
298
|
+
let tree!: ReactTestRenderer.ReactTestRenderer;
|
|
299
|
+
ReactTestRenderer.act(() => {
|
|
300
|
+
tree = ReactTestRenderer.create(
|
|
301
|
+
<FullEvent post={post as never} occurrence={occurrence} />
|
|
302
|
+
);
|
|
303
|
+
});
|
|
304
|
+
return tree;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
beforeEach(() => {
|
|
308
|
+
mockJamState = undefined;
|
|
309
|
+
mockProfile = { id: 'u-1', displayName: 'Att', handle: 'att' };
|
|
310
|
+
mockUseServerInfo.mockReset();
|
|
311
|
+
mockUseServerInfo.mockReturnValue({ jams: { livekit: { enabled: true } } });
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
test('1. signed-in attendee, live jam, livekit on -> Join Jam button navigates to JamSession', () => {
|
|
315
|
+
mockJamState = { active: true };
|
|
316
|
+
const tree = render(BASE_POST, 'occ-1');
|
|
317
|
+
const json = JSON.stringify(tree.toJSON());
|
|
318
|
+
expect(json).toContain('Join Jam');
|
|
319
|
+
expect(json).not.toContain('Start jam'); // attendee never sees the host block
|
|
320
|
+
const button = joinButton(tree.toJSON() as unknown as TreeNode);
|
|
321
|
+
expect(button).toBeDefined();
|
|
322
|
+
// Pressing it navigates to the jam session with the occurrence (CardEvent parity).
|
|
323
|
+
ReactTestRenderer.act(() => {
|
|
324
|
+
(button!.props?.onPress as () => void)();
|
|
325
|
+
});
|
|
326
|
+
expect(mockNavigate).toHaveBeenCalledWith('JamSession', {
|
|
327
|
+
jamId: 'post-1',
|
|
328
|
+
occurrence: 'occ-1',
|
|
329
|
+
});
|
|
330
|
+
// Button styling matches the host button on this screen (review suggestion #2):
|
|
331
|
+
// full width, default size — not the inline `size="sm"` of CardEvent.
|
|
332
|
+
expect(button!.props?.className).toBe('mt-2 w-full');
|
|
333
|
+
expect(button!.props?.size).toBeUndefined();
|
|
334
|
+
tree.unmount();
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
test('2. signed out (no profile) -> no Join Jam button', () => {
|
|
338
|
+
mockJamState = { active: true };
|
|
339
|
+
mockProfile = null;
|
|
340
|
+
const tree = render(BASE_POST);
|
|
341
|
+
const json = JSON.stringify(tree.toJSON());
|
|
342
|
+
expect(json).not.toContain('Join Jam');
|
|
343
|
+
tree.unmount();
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
test('3. jam not started (jamState inactive) -> no Join Jam button for attendee', () => {
|
|
347
|
+
mockJamState = { active: false };
|
|
348
|
+
const tree = render(BASE_POST);
|
|
349
|
+
const json = JSON.stringify(tree.toJSON());
|
|
350
|
+
expect(json).not.toContain('Join Jam');
|
|
351
|
+
expect(json).not.toContain('Start jam'); // attendee, not host
|
|
352
|
+
tree.unmount();
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
test('4. jam ended -> no Join Jam button (ended jam reports inactive state)', () => {
|
|
356
|
+
mockJamState = { active: false };
|
|
357
|
+
const tree = render(BASE_POST);
|
|
358
|
+
const json = JSON.stringify(tree.toJSON());
|
|
359
|
+
expect(json).not.toContain('Join Jam');
|
|
360
|
+
tree.unmount();
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
test('5. livekit disabled on server -> no Join Jam button', () => {
|
|
364
|
+
mockJamState = { active: true };
|
|
365
|
+
mockUseServerInfo.mockReturnValue({ jams: { livekit: { enabled: false } } });
|
|
366
|
+
const tree = render(BASE_POST);
|
|
367
|
+
const json = JSON.stringify(tree.toJSON());
|
|
368
|
+
expect(json).not.toContain('Join Jam');
|
|
369
|
+
tree.unmount();
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
test('6. host, live jam -> host Join Jam shown (single; attendee block gated off)', () => {
|
|
373
|
+
mockJamState = { active: true };
|
|
374
|
+
// Host: currentProfile.id === post.profile.id
|
|
375
|
+
const hostPost = { ...BASE_POST, profile: { id: 'u-1', displayName: 'Me' } };
|
|
376
|
+
const tree = render(hostPost);
|
|
377
|
+
const json = JSON.stringify(tree.toJSON());
|
|
378
|
+
expect(json).toContain('Join Jam');
|
|
379
|
+
const button = joinButton(tree.toJSON() as unknown as TreeNode);
|
|
380
|
+
expect(button).toBeDefined();
|
|
381
|
+
// Only the host button renders; the attendee block is mutually exclusive.
|
|
382
|
+
expect(json.match(/Join Jam/g)).toHaveLength(1);
|
|
383
|
+
expect(button!.props?.className).toBe('mt-2 w-full');
|
|
384
|
+
tree.unmount();
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
test('7. button is a pure navigation trigger — capacity gated in JamSession, not here', () => {
|
|
388
|
+
mockJamState = { active: true };
|
|
389
|
+
// FullEvent has no capacity/attendee model; JamSession → JamRoom owns that gate.
|
|
390
|
+
// The button simply navigates regardless of room capacity.
|
|
391
|
+
const tree = render(BASE_POST);
|
|
392
|
+
const json = JSON.stringify(tree.toJSON());
|
|
393
|
+
expect(json).toContain('Join Jam');
|
|
394
|
+
const button = joinButton(tree.toJSON() as unknown as TreeNode);
|
|
395
|
+
expect(button).toBeDefined();
|
|
396
|
+
ReactTestRenderer.act(() => {
|
|
397
|
+
(button!.props?.onPress as () => void)();
|
|
398
|
+
});
|
|
399
|
+
expect(mockNavigate).toHaveBeenCalledWith('JamSession', {
|
|
400
|
+
jamId: 'post-1',
|
|
401
|
+
occurrence: undefined,
|
|
402
|
+
});
|
|
403
|
+
tree.unmount();
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
// Tappable Jam URL (issue #2063): the URL text on a jam event opens the
|
|
407
|
+
// in-app JamSession instead of being inert text.
|
|
408
|
+
describe('tappable Jam URL', () => {
|
|
409
|
+
const link = (tree: ReactTestRenderer.ReactTestRenderer) =>
|
|
410
|
+
jamUrlLink(tree.toJSON() as unknown as TreeNode);
|
|
411
|
+
|
|
412
|
+
test('8. jam event -> URL renders as an accessible link with a tap target', () => {
|
|
413
|
+
const tree = render(BASE_POST);
|
|
414
|
+
const row = link(tree);
|
|
415
|
+
expect(row).toBeDefined();
|
|
416
|
+
expect(row!.props?.accessibilityLabel).toBe("Open this event's jam");
|
|
417
|
+
expect(row!.props?.activeOpacity).toBe(0.7);
|
|
418
|
+
expect(JSON.stringify(row!.children)).toContain('openpeeps.org/events');
|
|
419
|
+
tree.unmount();
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
test('9. press forwards the occurrence, and omits it at the base view', () => {
|
|
423
|
+
const occTree = render(BASE_POST, 'occ-1');
|
|
424
|
+
ReactTestRenderer.act(() => {
|
|
425
|
+
(link(occTree)!.props?.onPress as () => void)();
|
|
426
|
+
});
|
|
427
|
+
expect(mockNavigate).toHaveBeenCalledWith('JamSession', {
|
|
428
|
+
jamId: 'post-1',
|
|
429
|
+
occurrence: 'occ-1',
|
|
430
|
+
});
|
|
431
|
+
occTree.unmount();
|
|
432
|
+
|
|
433
|
+
const baseTree = render(BASE_POST);
|
|
434
|
+
ReactTestRenderer.act(() => {
|
|
435
|
+
(link(baseTree)!.props?.onPress as () => void)();
|
|
436
|
+
});
|
|
437
|
+
expect(mockNavigate).toHaveBeenCalledWith('JamSession', {
|
|
438
|
+
jamId: 'post-1',
|
|
439
|
+
occurrence: undefined,
|
|
440
|
+
});
|
|
441
|
+
baseTree.unmount();
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
test('10. long-press copies the full web URL and confirms with a toast', () => {
|
|
445
|
+
const tree = render(BASE_POST, 'occ-1');
|
|
446
|
+
ReactTestRenderer.act(() => {
|
|
447
|
+
(link(tree)!.props?.onLongPress as () => void)();
|
|
448
|
+
});
|
|
449
|
+
expect(Clipboard.setString).toHaveBeenCalledWith(
|
|
450
|
+
'https://openpeeps.org/events/post-1/jam?occurrence=occ-1'
|
|
451
|
+
);
|
|
452
|
+
expect(Toast.show).toHaveBeenCalledWith({
|
|
453
|
+
type: 'success',
|
|
454
|
+
text1: 'Link copied to clipboard',
|
|
455
|
+
});
|
|
456
|
+
tree.unmount();
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
test('11. non-jam event -> no tappable Jam URL', () => {
|
|
460
|
+
const tree = render({
|
|
461
|
+
...BASE_POST,
|
|
462
|
+
data: { ...BASE_POST.data, jam: false },
|
|
463
|
+
});
|
|
464
|
+
expect(link(tree)).toBeUndefined();
|
|
465
|
+
tree.unmount();
|
|
466
|
+
});
|
|
467
|
+
});
|
|
@@ -138,6 +138,11 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
|
|
|
138
138
|
? `${BASE_URL}/events/${post?.id}/jam?occurrence=${encodeURIComponent(occurrence)}`
|
|
139
139
|
: `${BASE_URL}/events/${post?.id}/jam`;
|
|
140
140
|
|
|
141
|
+
const copyJamLink = () => {
|
|
142
|
+
Clipboard.setString(jamLink);
|
|
143
|
+
Toast.show({ type: 'success', text1: 'Link copied to clipboard' });
|
|
144
|
+
};
|
|
145
|
+
|
|
141
146
|
const onRepostToFeed = () =>
|
|
142
147
|
openNewPost({
|
|
143
148
|
initialContent: `Join our event happening at ${BASE_URL}/post/${post?.id}`,
|
|
@@ -156,6 +161,10 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
|
|
|
156
161
|
const jamAttendeesQuery = openpeepsApi.useJamAttendance(post.id);
|
|
157
162
|
const jamStateQuery = openpeepsApi.useJamState(post.id, occurrence);
|
|
158
163
|
const jamState = event.jam ? jamStateQuery.data : undefined;
|
|
164
|
+
// Signed-in attendees (not just the host/moderator) can join a live jam,
|
|
165
|
+
// mirroring CardEvent. jamState is only populated when the event has a jam.
|
|
166
|
+
const canJoinLiveJam =
|
|
167
|
+
!!currentProfile && livekitEnabled && !!jamState?.active;
|
|
159
168
|
const recordingsQuery = openpeepsApi.usePostRecordings(
|
|
160
169
|
post.id,
|
|
161
170
|
!!event.jam && canViewRecordings
|
|
@@ -247,13 +256,7 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
|
|
|
247
256
|
</DropdownMenuItem>
|
|
248
257
|
<DropdownMenuItem
|
|
249
258
|
className="flex-row gap-x-2 items-center"
|
|
250
|
-
onPress={
|
|
251
|
-
Clipboard.setString(jamLink);
|
|
252
|
-
Toast.show({
|
|
253
|
-
type: 'success',
|
|
254
|
-
text1: 'Link copied to clipboard',
|
|
255
|
-
});
|
|
256
|
-
}}
|
|
259
|
+
onPress={copyJamLink}
|
|
257
260
|
>
|
|
258
261
|
<Link2Icon className="text-muted-foreground" size={18} />
|
|
259
262
|
<ThemedText>Copy link</ThemedText>
|
|
@@ -341,9 +344,25 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
|
|
|
341
344
|
<ThemedText className="text-xl">
|
|
342
345
|
{t('events.location.jam', { defaultValue: 'Jam Event' })}
|
|
343
346
|
</ThemedText>
|
|
344
|
-
<
|
|
345
|
-
|
|
346
|
-
|
|
347
|
+
<TouchableOpacity
|
|
348
|
+
accessibilityRole="link"
|
|
349
|
+
accessibilityLabel={t('events.location.openJam', {
|
|
350
|
+
defaultValue: "Open this event's jam",
|
|
351
|
+
})}
|
|
352
|
+
activeOpacity={0.7}
|
|
353
|
+
className="mt-2 -my-1 px-2 py-1"
|
|
354
|
+
onPress={() =>
|
|
355
|
+
navigation.navigate('JamSession', {
|
|
356
|
+
jamId: post.id,
|
|
357
|
+
occurrence,
|
|
358
|
+
})
|
|
359
|
+
}
|
|
360
|
+
onLongPress={copyJamLink}
|
|
361
|
+
>
|
|
362
|
+
<ThemedText className="text-muted-foreground underline">
|
|
363
|
+
{truncateText(jamLink, 30)}
|
|
364
|
+
</ThemedText>
|
|
365
|
+
</TouchableOpacity>
|
|
347
366
|
</>
|
|
348
367
|
) : event?.url ? (
|
|
349
368
|
<>
|
|
@@ -409,6 +428,21 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
|
|
|
409
428
|
</ThemedText>
|
|
410
429
|
)
|
|
411
430
|
) : null}
|
|
431
|
+
{!myEvent && !iAmModerator && canJoinLiveJam ? (
|
|
432
|
+
<Button
|
|
433
|
+
className="mt-2 w-full"
|
|
434
|
+
onPress={() =>
|
|
435
|
+
navigation.navigate('JamSession', {
|
|
436
|
+
jamId: post.id,
|
|
437
|
+
occurrence: occurrence,
|
|
438
|
+
})
|
|
439
|
+
}
|
|
440
|
+
>
|
|
441
|
+
<ThemedText numberOfLines={1}>
|
|
442
|
+
{t('jam.join.submit', { defaultValue: 'Join Jam' })}
|
|
443
|
+
</ThemedText>
|
|
444
|
+
</Button>
|
|
445
|
+
) : null}
|
|
412
446
|
<Tabs
|
|
413
447
|
onValueChange={setTabValue}
|
|
414
448
|
value={tabValue}
|