@openpeepshq/rn-components 0.10.2 → 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",
|
|
@@ -31,10 +31,13 @@ jest.mock('react-native', () => {
|
|
|
31
31
|
const React = require('react');
|
|
32
32
|
const make = (tag: string) => (props: { children?: ReactNode }) =>
|
|
33
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);
|
|
34
37
|
return {
|
|
35
38
|
View: make('View'),
|
|
36
39
|
Pressable: make('Pressable'),
|
|
37
|
-
TouchableOpacity:
|
|
40
|
+
TouchableOpacity: makeTouchable('TouchableOpacity'),
|
|
38
41
|
Image: make('Image'),
|
|
39
42
|
Share: { share: jest.fn() },
|
|
40
43
|
};
|
|
@@ -93,9 +96,11 @@ jest.mock('@react-navigation/native-stack', () => ({}));
|
|
|
93
96
|
// --- native third-party modules (no native impl in node) ------------------
|
|
94
97
|
jest.mock('react-native-fs', () => ({ default: { CachesDirectoryPath: '' } }));
|
|
95
98
|
jest.mock('@react-native-clipboard/clipboard', () => ({
|
|
99
|
+
__esModule: true,
|
|
96
100
|
default: { setString: jest.fn(), getString: jest.fn() },
|
|
97
101
|
}));
|
|
98
102
|
jest.mock('react-native-toast-message', () => ({
|
|
103
|
+
__esModule: true,
|
|
99
104
|
default: { show: jest.fn() },
|
|
100
105
|
}));
|
|
101
106
|
jest.mock('@gorhom/bottom-sheet', () => ({
|
|
@@ -229,6 +234,8 @@ jest.mock('../../index', () => ({
|
|
|
229
234
|
useNewPostModal: () => ({ openNewPost: jest.fn() }),
|
|
230
235
|
}));
|
|
231
236
|
|
|
237
|
+
import Clipboard from '@react-native-clipboard/clipboard';
|
|
238
|
+
import Toast from 'react-native-toast-message';
|
|
232
239
|
import { FullEvent } from './FullEvent';
|
|
233
240
|
|
|
234
241
|
type TreeNode = {
|
|
@@ -255,6 +262,20 @@ function joinButton(node: TreeNode): TreeNode | undefined {
|
|
|
255
262
|
: undefined;
|
|
256
263
|
}
|
|
257
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
|
+
|
|
258
279
|
const BASE_POST = {
|
|
259
280
|
id: 'post-1',
|
|
260
281
|
profile: { id: 'owner-1', displayName: 'Owner' },
|
|
@@ -381,3 +402,66 @@ test('7. button is a pure navigation trigger — capacity gated in JamSession, n
|
|
|
381
402
|
});
|
|
382
403
|
tree.unmount();
|
|
383
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}`,
|
|
@@ -251,13 +256,7 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
|
|
|
251
256
|
</DropdownMenuItem>
|
|
252
257
|
<DropdownMenuItem
|
|
253
258
|
className="flex-row gap-x-2 items-center"
|
|
254
|
-
onPress={
|
|
255
|
-
Clipboard.setString(jamLink);
|
|
256
|
-
Toast.show({
|
|
257
|
-
type: 'success',
|
|
258
|
-
text1: 'Link copied to clipboard',
|
|
259
|
-
});
|
|
260
|
-
}}
|
|
259
|
+
onPress={copyJamLink}
|
|
261
260
|
>
|
|
262
261
|
<Link2Icon className="text-muted-foreground" size={18} />
|
|
263
262
|
<ThemedText>Copy link</ThemedText>
|
|
@@ -345,9 +344,25 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
|
|
|
345
344
|
<ThemedText className="text-xl">
|
|
346
345
|
{t('events.location.jam', { defaultValue: 'Jam Event' })}
|
|
347
346
|
</ThemedText>
|
|
348
|
-
<
|
|
349
|
-
|
|
350
|
-
|
|
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>
|
|
351
366
|
</>
|
|
352
367
|
) : event?.url ? (
|
|
353
368
|
<>
|