@openpeepshq/rn-components 0.16.0 → 0.18.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/conversations/ConversationPreviewCard.tsx +2 -6
- package/src/components/custom/navigation/side-menu.test.tsx +212 -0
- package/src/components/custom/navigation/side-menu.tsx +3 -8
- package/src/components/groups/GroupCard.tsx +3 -6
- package/src/components/jams/JamChatDrawer.test.tsx +113 -41
- package/src/components/jams/JamChatDrawer.tsx +23 -20
- package/src/components/jams/JamFooter.toast.test.tsx +253 -0
- package/src/components/jams/JamFooter.tsx +66 -2
- package/src/components/jams/JamParticipantConference.tsx +4 -0
- package/src/components/jams/JamVideoLayout.tsx +2 -2
- package/src/components/jams/useLateTrackMediaStream.test.ts +113 -24
- package/src/components/jams/useLateTrackMediaStream.ts +86 -24
- package/src/components/post/post-form/ResourceForm.tsx +1 -1
- package/src/components/profile/EditProfileForm.test.tsx +316 -0
- package/src/components/profile/EditProfileForm.tsx +33 -4
- package/src/components/ui/dropdown-menu.test.ts +332 -0
- package/src/components/ui/dropdown-menu.tsx +108 -19
- package/src/components/ui/index.ts +1 -0
- package/src/components/ui/unread-badge.test.tsx +111 -0
- package/src/components/ui/unread-badge.tsx +43 -0
- package/src/pages/Members.test.tsx +117 -0
- package/src/pages/Members.tsx +1 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consumer-pin for the RN Members (directory) screen (issue #211 round-6
|
|
3
|
+
* review S1, native side).
|
|
4
|
+
*
|
|
5
|
+
* The behavioral contract is "the directory list is filtered, pickers are
|
|
6
|
+
* not". The server/SQL layer and the shared hook (`useProfiles(directory)` →
|
|
7
|
+
* `queryParams: { directory: 'true' }`) are already pinned; this pins the
|
|
8
|
+
* consumer wiring: if `platform/rn-components/src/pages/Members.tsx` ever
|
|
9
|
+
* reverts `useProfiles(true)` to plain `useProfiles()`, the directory screen
|
|
10
|
+
* silently falls back to the unfiltered picker list and this test fails.
|
|
11
|
+
*
|
|
12
|
+
* The component's only directory-facing surface is its `useProfiles` call, so
|
|
13
|
+
* the module boundary (`@openpeepshq/react`) is mocked with a `useProfiles`
|
|
14
|
+
* spy that records its argument; the rest of the screen renders for real
|
|
15
|
+
* under `react-test-renderer`.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const React = require('react');
|
|
19
|
+
const ReactTestRenderer = require('react-test-renderer');
|
|
20
|
+
|
|
21
|
+
jest.mock('react-native', () => ({
|
|
22
|
+
View: (props: Record<string, unknown>) =>
|
|
23
|
+
React.createElement('View', props, props.children),
|
|
24
|
+
Pressable: (props: Record<string, unknown>) =>
|
|
25
|
+
React.createElement('Pressable', props, props.children),
|
|
26
|
+
ActivityIndicator: () => null,
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
jest.mock('react-i18next', () => ({
|
|
30
|
+
useTranslation: () => ({ t: (key: string) => key }),
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
jest.mock('react-native-keyboard-aware-scroll-view', () => ({
|
|
34
|
+
KeyboardAwareScrollView: (props: { children?: unknown }) =>
|
|
35
|
+
React.createElement('KeyboardAwareScrollView', null, props.children),
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
jest.mock('../components/ui/themed-view', () => ({
|
|
39
|
+
ThemedView: (props: { children?: unknown }) =>
|
|
40
|
+
React.createElement('ThemedView', null, props.children),
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
jest.mock('../components/layout', () => ({
|
|
44
|
+
useSetPageHeader: () => undefined,
|
|
45
|
+
}));
|
|
46
|
+
|
|
47
|
+
jest.mock('../components/icons/index', () => ({
|
|
48
|
+
XIcon: () => null,
|
|
49
|
+
SearchIcon: () => null,
|
|
50
|
+
MessageSquareTextIcon: () => null,
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
jest.mock('../components/ui/input', () => ({
|
|
54
|
+
Input: () => null,
|
|
55
|
+
}));
|
|
56
|
+
|
|
57
|
+
jest.mock('../components/custom/index', () => ({
|
|
58
|
+
EmptyStateContainer: () => null,
|
|
59
|
+
}));
|
|
60
|
+
|
|
61
|
+
jest.mock('../components/profile/index', () => ({
|
|
62
|
+
FollowUnfollowButton: () => null,
|
|
63
|
+
ProfileCard: () => null,
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
jest.mock('../stores/useNewConversationStore', () => ({
|
|
67
|
+
useNewConversationStore: () => ({
|
|
68
|
+
clearMembers: () => {},
|
|
69
|
+
setContt: () => {},
|
|
70
|
+
setMember: () => {},
|
|
71
|
+
}),
|
|
72
|
+
}));
|
|
73
|
+
|
|
74
|
+
// `../lib/utils` transitively imports `react-native-config` (ESM) via
|
|
75
|
+
// `lib/constants`, which jest's CJS runtime cannot parse; the screen only
|
|
76
|
+
// uses `profileMatchesQuery` for its (empty) search filter, so a no-op is
|
|
77
|
+
// enough for this wiring pin.
|
|
78
|
+
jest.mock('../lib/utils', () => ({
|
|
79
|
+
profileMatchesQuery: () => true,
|
|
80
|
+
}));
|
|
81
|
+
|
|
82
|
+
const useProfilesMock = jest.fn(() => ({ data: undefined, isLoading: false }));
|
|
83
|
+
|
|
84
|
+
jest.mock('@openpeepshq/react', () => ({
|
|
85
|
+
useOpenpeeps: () => ({
|
|
86
|
+
openpeepsApi: { useProfiles: useProfilesMock },
|
|
87
|
+
currentProfile: undefined,
|
|
88
|
+
}),
|
|
89
|
+
}));
|
|
90
|
+
|
|
91
|
+
import { Members } from './Members';
|
|
92
|
+
|
|
93
|
+
describe('RN Members directory view consumer wiring (issue #211 S1)', () => {
|
|
94
|
+
beforeEach(() => {
|
|
95
|
+
(
|
|
96
|
+
globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
|
|
97
|
+
).IS_REACT_ACT_ENVIRONMENT = true;
|
|
98
|
+
useProfilesMock.mockClear();
|
|
99
|
+
useProfilesMock.mockReturnValue({ data: undefined, isLoading: false });
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('requests the profiles list as the directory view (useProfiles(true))', () => {
|
|
103
|
+
ReactTestRenderer.act(() => {
|
|
104
|
+
ReactTestRenderer.create(
|
|
105
|
+
React.createElement(Members, {
|
|
106
|
+
navigation: { navigate: () => {} },
|
|
107
|
+
} as unknown as never)
|
|
108
|
+
);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
expect(useProfilesMock).toHaveBeenCalled();
|
|
112
|
+
// The directory screen must opt into the filtered directory list. A
|
|
113
|
+
// revert to plain `useProfiles()` drops the argument (false) and fails
|
|
114
|
+
// here — the screen would then render the unfiltered picker list.
|
|
115
|
+
expect(useProfilesMock.mock.calls[0]![0]).toBe(true);
|
|
116
|
+
});
|
|
117
|
+
});
|
package/src/pages/Members.tsx
CHANGED
|
@@ -30,7 +30,7 @@ type DirectoryProps = CompositeScreenProps<
|
|
|
30
30
|
export const Members: React.FC<DirectoryProps> = ({ navigation }) => {
|
|
31
31
|
const { t } = useTranslation();
|
|
32
32
|
const { openpeepsApi, currentProfile } = useOpenpeeps();
|
|
33
|
-
const { data: profiles, isLoading } = openpeepsApi.useProfiles();
|
|
33
|
+
const { data: profiles, isLoading } = openpeepsApi.useProfiles(true);
|
|
34
34
|
const [filteredProfiles, setFilteredProfiles] = React.useState(profiles);
|
|
35
35
|
const [searchQuery, setSearchQuery] = React.useState('');
|
|
36
36
|
const [isSearchButtonClicked, setIsSearchButtonClicked] =
|