@openpeepshq/rn-components 0.19.0 → 0.21.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 +4 -5
  2. package/src/components/conversations/ConversationMessageBubble.test.tsx +158 -0
  3. package/src/components/conversations/ConversationMessageBubble.tsx +43 -25
  4. package/src/components/jams/JamCallParticipant.tsx +84 -16
  5. package/src/components/jams/JamChatMessage.test.tsx +139 -0
  6. package/src/components/jams/JamChatMessage.tsx +13 -0
  7. package/src/components/jams/JamPeopleDrawer.test.tsx +77 -3
  8. package/src/components/jams/JamPeopleDrawer.tsx +94 -3
  9. package/src/components/jams/JamReactionMenu.tsx +10 -31
  10. package/src/components/jams/JamRoom.tsx +15 -0
  11. package/src/components/markdown/OpenpeepsMarkdown.tsx +10 -3
  12. package/src/components/markdown/theme.test.ts +78 -0
  13. package/src/components/markdown/theme.ts +30 -12
  14. package/src/components/post/CompactReplyParent.test.tsx +337 -0
  15. package/src/components/post/CompactReplyParent.tsx +21 -5
  16. package/src/components/post/TruncatedMarkdown.test.tsx +201 -0
  17. package/src/components/post/TruncatedMarkdown.tsx +98 -10
  18. package/src/components/post/pieces/PostActions.test.tsx +27 -19
  19. package/src/components/post/pieces/PostActions.tsx +7 -11
  20. package/src/components/post/pieces/ReactionButton.tsx +41 -0
  21. package/src/components/post/pieces/ReactionPicker.test.tsx +80 -161
  22. package/src/components/post/pieces/ReactionPicker.tsx +32 -33
  23. package/src/components/post/pieces/index.ts +1 -0
  24. package/src/components/preview-link/local/WelcomePreview.tsx +1 -0
  25. package/src/components/resources/CategoryPathPicker.tsx +8 -2
  26. package/src/components/resources/ResourceCard.test.tsx +48 -4
  27. package/src/components/resources/ResourceCard.tsx +8 -2
  28. package/src/components/resources/ResourceLibrary.test.tsx +40 -2
  29. package/src/components/resources/ResourceLibrary.tsx +11 -6
  30. package/src/lib/moduleResolverRootGuard.test.ts +281 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/rn-components",
3
- "version": "0.19.0",
3
+ "version": "0.21.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",
@@ -142,9 +142,9 @@
142
142
  "timezones-list": "^3.1.0",
143
143
  "validator": "^13.15.23",
144
144
  "zustand": "^5.0.3",
145
- "@openpeepshq/fetch-client": "^0.2.1",
146
- "@openpeepshq/common": "^0.13.0",
147
- "@openpeepshq/react": "^0.20.0"
145
+ "@openpeepshq/common": "^0.14.0",
146
+ "@openpeepshq/react": "^0.22.0",
147
+ "@openpeepshq/fetch-client": "^0.2.1"
148
148
  },
149
149
  "devDependencies": {
150
150
  "@babel/core": "^7.26.7",
@@ -171,7 +171,6 @@
171
171
  "@types/validator": "^13.15.10",
172
172
  "@typescript-eslint/eslint-plugin": "^8.72.0",
173
173
  "@typescript-eslint/parser": "^8.72.0",
174
- "babel-plugin-module-resolver": "^5.0.2",
175
174
  "commitlint": "^17.0.2",
176
175
  "del-cli": "^5.1.0",
177
176
  "eslint": "^10.14.0",
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Regression test for the native DM-bubble reaction wiring (issue #276,
3
+ * round-5 review item #2) — the mirror of the web bubble test. The bubble must
4
+ * feed the picker the profile's reactions and the community's allowed set, and
5
+ * route the picker's toggle back through `usePostReactionToggle` (which also
6
+ * closes the picker). Without this, a DM bubble could silently drop the picker
7
+ * or call the toggle with the wrong emoji.
8
+ *
9
+ * Only the RN primitives, i18n, theme, and the `@openpeepshq/react` hooks are
10
+ * stubbed; the real `ConversationMessageBubble` open/close state machine runs.
11
+ * The picker is stubbed to a self-describing host tag so its props are read
12
+ * from the rendered tree.
13
+ */
14
+ const React = require('react');
15
+ const ReactTestRenderer = require('react-test-renderer');
16
+
17
+ const mockToggle = jest.fn();
18
+ const mockCanReact = { value: true };
19
+ const mockMyReactions = { value: ['👍'] };
20
+ const mockAllowed = { value: ['👍', '🎉'] as readonly string[] };
21
+
22
+ jest.mock('react-native', () => ({
23
+ View: (p: { children?: unknown }) =>
24
+ React.createElement('View', null, p.children),
25
+ Text: (p: { children?: unknown }) =>
26
+ React.createElement('Text', null, p.children),
27
+ Pressable: (p: { onPress?: () => void; children?: unknown }) =>
28
+ React.createElement('Pressable', { onPress: p.onPress }, p.children),
29
+ }));
30
+ jest.mock('react-i18next', () => ({
31
+ useTranslation: () => ({ t: (key: string) => key }),
32
+ }));
33
+ jest.mock('../../theme/useThemeOpacity', () => ({
34
+ useThemeOpacity: () => ({ background: () => undefined }),
35
+ }));
36
+ jest.mock('../post/FeedPostContent', () => ({
37
+ FeedPostContent: () => null,
38
+ }));
39
+ jest.mock('../post/pieces/UnreadPostIndicator', () => ({
40
+ UnreadPostIndicator: () => null,
41
+ }));
42
+ jest.mock('../icons/index', () => ({
43
+ ThumbsUpIcon: () => null,
44
+ }));
45
+ // The closed trigger shows the reaction count next to the icon (round-10
46
+ // review item #1/#2). Mock ThemedText to a host tag that carries the count so
47
+ // the display can be asserted without loading @rn-primitives.
48
+ jest.mock('../ui/themed-text', () => ({
49
+ ThemedText: (p: { children?: unknown; className?: string }) =>
50
+ React.createElement(
51
+ 'CountText',
52
+ { 'data-count': String(p.children) },
53
+ p.children
54
+ ),
55
+ }));
56
+ jest.mock('@openpeepshq/react', () => ({
57
+ useCurrentProfile: () => ({ id: 'me-1' }),
58
+ usePostReactionToggle: () => ({
59
+ iLiked: false,
60
+ myReactions: mockMyReactions.value,
61
+ canReact: mockCanReact.value,
62
+ toggleReaction: mockToggle,
63
+ }),
64
+ useAllowedReactions: () => mockAllowed.value,
65
+ }));
66
+ jest.mock('../post/pieces/ReactionPicker', () => ({
67
+ ReactionPicker: (props: {
68
+ myReactions: string[];
69
+ reactions: readonly string[];
70
+ onToggle: (reaction: string) => void;
71
+ }) =>
72
+ React.createElement(
73
+ 'PICKER',
74
+ { onPress: () => props.onToggle('🎉') },
75
+ `MR=${JSON.stringify(props.myReactions)}`,
76
+ `RC=${JSON.stringify(props.reactions)}`
77
+ ),
78
+ }));
79
+
80
+ const { ConversationMessageBubble } = require('./ConversationMessageBubble');
81
+
82
+ const renderBubble = (message: unknown) => {
83
+ let tree!: ReturnType<typeof ReactTestRenderer.create>;
84
+ ReactTestRenderer.act(() => {
85
+ tree = ReactTestRenderer.create(
86
+ React.createElement(ConversationMessageBubble, { message })
87
+ );
88
+ });
89
+ return tree;
90
+ };
91
+
92
+ const message = { id: 'post-1', profile: { id: 'other-1' } };
93
+
94
+ describe('ConversationMessageBubble (native) reaction wiring', () => {
95
+ beforeEach(() => {
96
+ mockToggle.mockClear();
97
+ mockCanReact.value = true;
98
+ mockMyReactions.value = ['👍'];
99
+ mockAllowed.value = ['👍', '🎉'];
100
+ });
101
+
102
+ it('feeds the picker the profile reactions and allowed set on open', () => {
103
+ const tree = renderBubble(message);
104
+ // Closed by default: a thumbs-up trigger, no picker yet.
105
+ expect(tree.root.findAllByType('PICKER').length).toBe(0);
106
+ const trigger = tree.root.findAllByType('Pressable')[0];
107
+ ReactTestRenderer.act(() => {
108
+ trigger.props.onPress();
109
+ });
110
+ // The picker opened and was fed the profile reactions + allowed set.
111
+ const picker = tree.root.findAllByType('PICKER')[0];
112
+ const text = (picker.children ?? []).join(' ');
113
+ expect(text).toContain('MR=["👍"]');
114
+ expect(text).toContain('RC=["👍","🎉"]');
115
+ });
116
+
117
+ it('routes the picker toggle through toggleReaction and closes', () => {
118
+ const tree = renderBubble(message);
119
+ ReactTestRenderer.act(() => {
120
+ tree.root.findAllByType('Pressable')[0].props.onPress();
121
+ });
122
+ const picker = tree.root.findAllByType('PICKER')[0];
123
+ ReactTestRenderer.act(() => {
124
+ picker.props.onPress();
125
+ });
126
+ expect(mockToggle).toHaveBeenCalledWith('🎉');
127
+ // The picker closed back to the trigger.
128
+ expect(tree.root.findAllByType('PICKER').length).toBe(0);
129
+ });
130
+
131
+ it('renders no trigger when the profile cannot react', () => {
132
+ mockCanReact.value = false;
133
+ const tree = renderBubble(message);
134
+ expect(tree.root.findAllByType('Pressable').length).toBe(0);
135
+ expect(tree.root.findAllByType('PICKER').length).toBe(0);
136
+ });
137
+
138
+ it('hides the reaction count on the closed trigger when there are no reactions', () => {
139
+ const tree = renderBubble({ ...message, reactions: [] });
140
+ expect(tree.root.findAllByType('CountText').length).toBe(0);
141
+ });
142
+
143
+ it('shows the reaction count on the closed trigger when reactions exist', () => {
144
+ const withReactions = {
145
+ ...message,
146
+ reactions: [
147
+ { reaction: '👍', profile: { id: 'other-2' } },
148
+ { reaction: '🎉', profile: { id: 'other-3' } },
149
+ ],
150
+ };
151
+ const tree = renderBubble(withReactions);
152
+ const counts = tree.root.findAllByType('CountText');
153
+ expect(counts).toHaveLength(1);
154
+ expect(counts[0].props['data-count']).toBe('2');
155
+ // The picker is still closed: the count is on the trigger, not a picker.
156
+ expect(tree.root.findAllByType('PICKER').length).toBe(0);
157
+ });
158
+ });
@@ -1,14 +1,18 @@
1
- import React from 'react';
2
- import { View } from 'react-native';
1
+ import React, { useState } from 'react';
2
+ import { Pressable, View } from 'react-native';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import type { PublicPost } from '@openpeepshq/common/types';
5
- import { useCurrentProfile, usePostReactionToggle } from '@openpeepshq/react';
5
+ import {
6
+ useCurrentProfile,
7
+ usePostReactionToggle,
8
+ useAllowedReactions,
9
+ } from '@openpeepshq/react';
6
10
  import { useThemeOpacity } from '../../theme/useThemeOpacity';
7
11
  import { FeedPostContent } from '../post/FeedPostContent';
8
12
  import { UnreadPostIndicator } from '../post/pieces/UnreadPostIndicator';
9
- import { Button } from '../ui/button';
10
- import { ThemedText } from '../ui/themed-text';
13
+ import { ReactionPicker } from '../post/pieces/ReactionPicker';
11
14
  import { ThumbsUpIcon } from '../icons/index';
15
+ import { ThemedText } from '../ui/themed-text';
12
16
 
13
17
  export interface ConversationMessageBubbleProps {
14
18
  message: PublicPost;
@@ -23,7 +27,10 @@ export const ConversationMessageBubble = ({
23
27
  const { background } = useThemeOpacity();
24
28
  const { t } = useTranslation();
25
29
  const mine = message.profile.id === me?.id;
26
- const { iReacted, canReact, toggleReaction } = usePostReactionToggle(message);
30
+ const { iLiked, myReactions, canReact, toggleReaction } =
31
+ usePostReactionToggle(message);
32
+ const allowedReactions = useAllowedReactions();
33
+ const [reactionPickerOpen, setReactionPickerOpen] = useState(false);
27
34
  const reactionCount = message.reactions?.length ?? 0;
28
35
 
29
36
  // NativeWind v4 can't apply `/N` opacity to CSS-variable colors (e.g.
@@ -49,26 +56,37 @@ export const ConversationMessageBubble = ({
49
56
  mine ? 'mt-2 flex-row justify-end' : 'mt-2 flex-row justify-start'
50
57
  }
51
58
  >
52
- <Button
53
- variant="ghost"
54
- onPress={() => void toggleReaction()}
55
- accessibilityLabel={t('posts.actions.react')}
56
- className="items-center gap-1 native:px-2 native:py-1"
57
- >
58
- <ThumbsUpIcon
59
- size={16}
60
- className={iReacted ? 'text-primary' : 'text-muted-foreground'}
59
+ {reactionPickerOpen ? (
60
+ <ReactionPicker
61
+ myReactions={myReactions}
62
+ reactions={allowedReactions}
63
+ onToggle={(reaction) => {
64
+ setReactionPickerOpen(false);
65
+ void toggleReaction(reaction);
66
+ }}
61
67
  />
62
- {reactionCount > 0 ? (
63
- <ThemedText
64
- className={`text-xs ${
65
- iReacted ? 'text-primary' : 'text-muted-foreground'
66
- }`}
67
- >
68
- {reactionCount}
69
- </ThemedText>
70
- ) : null}
71
- </Button>
68
+ ) : (
69
+ <Pressable
70
+ className="items-center gap-1"
71
+ accessibilityRole="button"
72
+ accessibilityLabel={t('posts.actions.react')}
73
+ onPress={() => setReactionPickerOpen(true)}
74
+ >
75
+ <ThumbsUpIcon
76
+ size={16}
77
+ className={iLiked ? 'text-primary' : 'text-muted-foreground'}
78
+ />
79
+ {reactionCount > 0 ? (
80
+ <ThemedText
81
+ className={`text-xs ${
82
+ iLiked ? 'text-primary' : 'text-muted-foreground'
83
+ }`}
84
+ >
85
+ {reactionCount}
86
+ </ThemedText>
87
+ ) : null}
88
+ </Pressable>
89
+ )}
72
90
  </View>
73
91
  ) : null}
74
92
  </View>
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useReducer, useRef } from 'react';
2
- import { Pressable, StyleSheet, View } from 'react-native';
2
+ import { Alert, Pressable, StyleSheet, View } from 'react-native';
3
3
  import Sound from 'react-native-sound';
4
4
  import {
5
5
  isTrackReference,
@@ -16,10 +16,12 @@ import {
16
16
  useJamContext,
17
17
  useJamEventsContext,
18
18
  useJamParticipantMute,
19
+ useJamParticipantRemove,
19
20
  useRaisedHands,
20
21
  } from '@openpeepshq/react';
21
22
  import {
22
23
  AudioLinesIcon,
24
+ BanIcon,
23
25
  EllipsisIcon,
24
26
  HandIcon,
25
27
  MicIcon,
@@ -98,17 +100,16 @@ const JamSpotlightMenuItem = ({
98
100
  };
99
101
 
100
102
  /**
101
- * Menu on a remote tile: moderators can mute, and whoever may spotlight
102
- * (creator or moderator) can toggle the room-wide spotlight.
103
+ * Moderator-only menu on a remote tile: mute and remove, plus the
104
+ * room-wide spotlight toggle when the caller may spotlight. Mirrors the
105
+ * web `JamParticipantModeratorMenu` — it is mounted only for moderators.
103
106
  */
104
107
  const JamParticipantMenu = ({
105
108
  trackRef,
106
- canMute,
107
109
  spotlighted,
108
110
  onToggleSpotlight,
109
111
  }: {
110
112
  trackRef: TrackReferenceOrPlaceholder;
111
- canMute: boolean;
112
113
  spotlighted: boolean;
113
114
  onToggleSpotlight?: () => void;
114
115
  }) => {
@@ -118,6 +119,11 @@ const JamParticipantMenu = ({
118
119
  onSuccess: (text1) => Toast.show({ type: 'success', text1 }),
119
120
  onError: (text1) => Toast.show({ type: 'error', text1 }),
120
121
  });
122
+ const handleRemove = useJamParticipantRemove({
123
+ participant: trackRef.participant,
124
+ onSuccess: (text1) => Toast.show({ type: 'success', text1 }),
125
+ onError: (text1) => Toast.show({ type: 'error', text1 }),
126
+ });
121
127
 
122
128
  return (
123
129
  <DropdownMenu>
@@ -133,15 +139,36 @@ const JamParticipantMenu = ({
133
139
  </DropdownMenuTrigger>
134
140
  <DropdownMenuContent align="start">
135
141
  <DropdownMenuGroup>
136
- {canMute ? (
137
- <DropdownMenuItem
138
- className="flex-row items-center gap-x-2"
139
- onPress={() => void handleMute()}
140
- >
141
- <MicOffIcon size={16} className="text-foreground" />
142
- <ThemedText>{t('jams.participants.muteParticipant')}</ThemedText>
143
- </DropdownMenuItem>
144
- ) : null}
142
+ <DropdownMenuItem
143
+ className="flex-row items-center gap-x-2"
144
+ onPress={() => void handleMute()}
145
+ >
146
+ <MicOffIcon size={16} className="text-foreground" />
147
+ <ThemedText>{t('jams.participants.muteParticipant')}</ThemedText>
148
+ </DropdownMenuItem>
149
+ <DropdownMenuItem
150
+ className="flex-row items-center gap-x-2"
151
+ onPress={() =>
152
+ Alert.alert(
153
+ t('jams.participantMenu.removeFromJam'),
154
+ t('jams.participants.removeConfirm'),
155
+ [
156
+ {
157
+ text: t('common.actions.cancel'),
158
+ style: 'cancel',
159
+ },
160
+ {
161
+ text: t('jams.participantMenu.removeFromJam'),
162
+ style: 'destructive',
163
+ onPress: () => void handleRemove(),
164
+ },
165
+ ]
166
+ )
167
+ }
168
+ >
169
+ <BanIcon size={16} className="text-destructive" />
170
+ <ThemedText>{t('jams.participantMenu.removeFromJam')}</ThemedText>
171
+ </DropdownMenuItem>
145
172
  {onToggleSpotlight ? (
146
173
  <JamSpotlightMenuItem
147
174
  spotlighted={spotlighted}
@@ -154,6 +181,43 @@ const JamParticipantMenu = ({
154
181
  );
155
182
  };
156
183
 
184
+ /**
185
+ * Spotlight-only menu on a remote tile for viewers who may spotlight but
186
+ * are not moderators. Mirrors the web spotlight-only `PopupMenu` so a
187
+ * non-moderator host never sees the moderation container.
188
+ */
189
+ const JamParticipantSpotlightMenu = ({
190
+ spotlighted,
191
+ onToggleSpotlight,
192
+ }: {
193
+ spotlighted: boolean;
194
+ onToggleSpotlight: () => void;
195
+ }) => {
196
+ const { t } = useTranslation();
197
+ return (
198
+ <DropdownMenu>
199
+ <DropdownMenuTrigger asChild>
200
+ <Button
201
+ size="icon"
202
+ variant="ghost"
203
+ className="size-8 rounded-full bg-card"
204
+ accessibilityLabel={t('jams.speakerView.spotlight')}
205
+ >
206
+ <EllipsisIcon size={16} className="text-foreground" />
207
+ </Button>
208
+ </DropdownMenuTrigger>
209
+ <DropdownMenuContent align="start">
210
+ <DropdownMenuGroup>
211
+ <JamSpotlightMenuItem
212
+ spotlighted={spotlighted}
213
+ onToggleSpotlight={onToggleSpotlight}
214
+ />
215
+ </DropdownMenuGroup>
216
+ </DropdownMenuContent>
217
+ </DropdownMenu>
218
+ );
219
+ };
220
+
157
221
  /** Raised hand + mic state on top, name (with moderator `*` prefix) at the bottom. */
158
222
  const JamParticipantOverlay = ({
159
223
  trackRef,
@@ -226,10 +290,14 @@ const JamParticipantOverlay = ({
226
290
  <HandIcon size={iconSize} className="text-foreground" />
227
291
  </View>
228
292
  ) : null}
229
- {(viewerIsModerator || onToggleSpotlight) && !participant.isLocal ? (
293
+ {viewerIsModerator && !participant.isLocal ? (
230
294
  <JamParticipantMenu
231
295
  trackRef={trackRef}
232
- canMute={viewerIsModerator}
296
+ spotlighted={spotlighted}
297
+ onToggleSpotlight={onToggleSpotlight}
298
+ />
299
+ ) : onToggleSpotlight && !participant.isLocal ? (
300
+ <JamParticipantSpotlightMenu
233
301
  spotlighted={spotlighted}
234
302
  onToggleSpotlight={onToggleSpotlight}
235
303
  />
@@ -0,0 +1,139 @@
1
+ /**
2
+ * RN pin for the dedicated `kicked` chat-message branch (issue #303
3
+ * round-15 suggestion 1, the RN twin of
4
+ * `platform/react/.../JamChatMessage.test.tsx`).
5
+ *
6
+ * `kicked` is part of the attendance-event union in `jamEventDataSchema`, but
7
+ * `JamChatMessage` deliberately keeps it OUT of the `attendance` array so this
8
+ * branch (profile name + `jams.chat.wasRemoved`) runs instead of the generic
9
+ * attendance renderer. A future edit that adds `kicked` to that array — or
10
+ * reorders the branches — would silently degrade the message to the generic
11
+ * "X kicked the jam" output; these render tests pin the dedicated copy so that
12
+ * regression fails here, on both stacks.
13
+ *
14
+ * Only RN, i18n, the openpeeps context and the leaf primitives are stubbed.
15
+ * `ThemedText` is the single text primitive the message renders through, so
16
+ * the mock records the concatenated string content of every ThemedText it
17
+ * renders — the assertions read that ordered log instead of walking the tree.
18
+ */
19
+
20
+ const React = require('react');
21
+ const ReactTestRenderer = require('react-test-renderer');
22
+
23
+ // The string content of every ThemedText render, in document order.
24
+ const mockRenderedTexts: string[] = [];
25
+ let mockProfile:
26
+ | { id: string; displayName: string; handle: string }
27
+ | undefined;
28
+ let mockLoading = false;
29
+
30
+ jest.mock('react-native', () => ({
31
+ View: (props: { children?: unknown }) =>
32
+ React.createElement('View', null, props.children),
33
+ }));
34
+
35
+ jest.mock('react-i18next', () => ({
36
+ useTranslation: () => ({
37
+ // Value mirrors `platform/i18n/src/locales/en.json` jams.chat.wasRemoved
38
+ // so the rendered copy pins the key the user actually sees.
39
+ t: (key: string) =>
40
+ key === 'jams.chat.wasRemoved' ? 'was removed from the jam' : key,
41
+ }),
42
+ }));
43
+
44
+ jest.mock('@openpeepshq/react', () => ({
45
+ useOpenpeeps: () => ({
46
+ openpeepsApi: {
47
+ useProfile: () => ({ data: mockProfile, isLoading: mockLoading }),
48
+ },
49
+ }),
50
+ }));
51
+
52
+ jest.mock('@openpeepshq/common', () => ({
53
+ // `truncateText` is only used by the message branch, which these cases do
54
+ // not reach; a passthrough keeps the suite parseable.
55
+ truncateText: (text: string | null | undefined) => text ?? '',
56
+ }));
57
+
58
+ jest.mock('../custom/date/updating-date', () => ({
59
+ UpdatingDate: () => React.createElement('UpdatingDate'),
60
+ }));
61
+
62
+ jest.mock('../markdown/index', () => ({
63
+ OpenpeepsMarkdown: () => null,
64
+ }));
65
+
66
+ jest.mock('../ui/themed-text', () => ({
67
+ ThemedText: (props: { children?: unknown }) => {
68
+ const parts: string[] = [];
69
+ const collect = (node: unknown) => {
70
+ if (typeof node === 'string' && node) parts.push(node);
71
+ else if (Array.isArray(node)) for (const p of node) collect(p);
72
+ };
73
+ collect(props.children);
74
+ const text = parts.join('');
75
+ if (text) mockRenderedTexts.push(text);
76
+ return React.createElement('ThemedText', null, props.children);
77
+ },
78
+ }));
79
+
80
+ jest.mock('../profile/Avatar', () => ({
81
+ ProfileAvatar: () => React.createElement('ProfileAvatar'),
82
+ }));
83
+
84
+ const { JamChatMessage } = require('./JamChatMessage');
85
+
86
+ const baseMessage = {
87
+ id: 'evt-1',
88
+ jamId: 'jam-1',
89
+ profileId: 'kicked-1',
90
+ createdAt: '2026-11-22T20:00:00.000Z',
91
+ updatedAt: '2026-11-22T20:00:00.000Z',
92
+ };
93
+
94
+ const renderMessage = (message: Record<string, unknown>) => {
95
+ mockRenderedTexts.length = 0;
96
+ let tree!: ReactTestRenderer.ReactTestRenderer;
97
+ ReactTestRenderer.act(() => {
98
+ tree = ReactTestRenderer.create(
99
+ React.createElement(JamChatMessage, { message })
100
+ );
101
+ });
102
+ return tree;
103
+ };
104
+
105
+ describe('JamChatMessage kicked branch (RN)', () => {
106
+ beforeEach(() => {
107
+ mockProfile = {
108
+ id: 'kicked-1',
109
+ displayName: 'Kicked Person',
110
+ handle: 'kicked',
111
+ };
112
+ mockLoading = false;
113
+ });
114
+
115
+ it('renders the profile name plus the dedicated "was removed" copy', () => {
116
+ renderMessage({ ...baseMessage, type: 'kicked' });
117
+ const rendered = mockRenderedTexts.join('');
118
+ expect(rendered).toContain('Kicked Person');
119
+ expect(rendered).toContain('was removed from the jam');
120
+ });
121
+
122
+ it('does not fall through to the generic attendance rendering for kicked', () => {
123
+ // If `kicked` had been (re)added to the `attendance` array, the generic
124
+ // branch would render the raw type as the label ("… kicked the jam")
125
+ // instead of the dedicated copy — that wrong output must not appear.
126
+ renderMessage({ ...baseMessage, type: 'kicked' });
127
+ expect(mockRenderedTexts.join('')).not.toContain('kicked the jam');
128
+ });
129
+
130
+ it('still routes real attendance events (join) through the generic branch', () => {
131
+ // Guards against the fix overshooting: `join` keeps the generic
132
+ // "X joined the jam" rendering, proving the dedicated branch only
133
+ // special-cases `kicked`.
134
+ renderMessage({ ...baseMessage, type: 'join' });
135
+ const rendered = mockRenderedTexts.join('');
136
+ expect(rendered).toContain('joined');
137
+ expect(rendered).not.toContain('was removed from the jam');
138
+ });
139
+ });
@@ -1,5 +1,6 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import { View } from 'react-native';
3
+ import { useTranslation } from 'react-i18next';
3
4
  import {
4
5
  truncateText,
5
6
  type JamEvent,
@@ -29,6 +30,7 @@ export const JamChatMessage = ({
29
30
  message,
30
31
  mentionProfiles = [],
31
32
  }: JamChatMessageProps) => {
33
+ const { t } = useTranslation();
32
34
  const { openpeepsApi } = useOpenpeeps();
33
35
  const profileQuery = openpeepsApi.useProfile(message.profileId || 'unknown');
34
36
  const profile = profileQuery.data;
@@ -82,5 +84,16 @@ export const JamChatMessage = ({
82
84
  );
83
85
  }
84
86
 
87
+ if (message.type === 'kicked') {
88
+ return (
89
+ <View className="items-center justify-center">
90
+ <ThemedText className="text-center text-sm text-muted-foreground">
91
+ {name} {t('jams.chat.wasRemoved')}{' '}
92
+ <UpdatingDate date={message.createdAt} />
93
+ </ThemedText>
94
+ </View>
95
+ );
96
+ }
97
+
85
98
  return null;
86
99
  };