@applicaster/zapp-react-native-ui-components 14.0.0-alpha.5114565431 → 14.0.0-alpha.5203410334
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/Components/BaseFocusable/index.tsx +23 -12
- package/Components/Cell/__tests__/CellWIthFocusable.test.js +3 -2
- package/Components/Cell/index.js +1 -1
- package/Components/ComponentResolver/index.ts +1 -1
- package/Components/FeedLoader/FeedLoader.tsx +6 -15
- package/Components/FeedLoader/FeedLoaderHOC.tsx +21 -0
- package/Components/FeedLoader/index.js +2 -8
- package/Components/FreezeWithCallback/__tests__/index.test.tsx +67 -43
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +42 -59
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +13 -10
- package/Components/Layout/TV/LayoutBackground.tsx +1 -1
- package/Components/Layout/TV/__tests__/index.test.tsx +0 -1
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -0
- package/Components/MasterCell/DefaultComponents/Button.tsx +1 -1
- package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +1 -1
- package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +10 -10
- package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +18 -18
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/index.test.tsx +10 -10
- package/Components/MasterCell/utils/behaviorProvider.ts +82 -14
- package/Components/MasterCell/utils/index.ts +11 -5
- package/Components/OfflineHandler/__tests__/index.test.tsx +26 -35
- package/Components/PlayerContainer/ErrorDisplay/index.ts +1 -1
- package/Components/PlayerContainer/ProgramInfo/index.tsx +1 -1
- package/Components/PlayerContainer/index.ts +1 -1
- package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +378 -0
- package/Components/River/ComponentsMap/hooks/useLoadingState.ts +2 -2
- package/Components/River/RefreshControl.tsx +11 -17
- package/Components/River/__tests__/river.test.js +12 -26
- package/Components/River/index.tsx +1 -1
- package/Components/Screen/__tests__/Screen.test.tsx +28 -29
- package/Components/Tabs/Tabs.tsx +2 -3
- package/Components/Touchable/__tests__/touchable.test.tsx +12 -17
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +3 -9
- package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +5 -5
- package/Contexts/ConfigutaionContext/__tests__/ConfigurationProvider.test.tsx +3 -3
- package/Contexts/ScreenContext/index.tsx +46 -6
- package/Decorators/ConfigurationWrapper/__tests__/withConfigurationProvider.test.tsx +3 -3
- package/Decorators/RiverFeedLoader/__tests__/__snapshots__/riverFeedLoader.test.tsx.snap +221 -209
- package/Decorators/RiverFeedLoader/__tests__/riverFeedLoader.test.tsx +14 -16
- package/Decorators/RiverFeedLoader/__tests__/utils.test.ts +0 -20
- package/Decorators/RiverFeedLoader/index.tsx +22 -4
- package/Decorators/RiverFeedLoader/utils/index.ts +0 -18
- package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +3 -6
- package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +27 -27
- package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +35 -10
- package/Decorators/ZappPipesDataConnector/utils/mongoFilter.ts +738 -0
- package/Decorators/ZappPipesDataConnector/utils/useFilter.tsx +157 -0
- package/events/index.ts +1 -0
- package/package.json +5 -6
- package/Components/River/__tests__/__snapshots__/river.test.js.snap +0 -27
|
@@ -146,10 +146,14 @@ export class BaseFocusable<
|
|
|
146
146
|
* @param {Object} scrollDirection
|
|
147
147
|
* @returns {Promise}
|
|
148
148
|
*/
|
|
149
|
-
onFocus: FocusManager.FocusEventCB = (
|
|
149
|
+
onFocus: FocusManager.FocusEventCB = (
|
|
150
|
+
focusable,
|
|
151
|
+
scrollDirection,
|
|
152
|
+
context
|
|
153
|
+
) => {
|
|
150
154
|
const { onFocus = noop } = this.props;
|
|
151
155
|
this.setFocusedState(true);
|
|
152
|
-
onFocus(focusable, scrollDirection);
|
|
156
|
+
onFocus(focusable, scrollDirection, context);
|
|
153
157
|
};
|
|
154
158
|
|
|
155
159
|
/**
|
|
@@ -247,8 +251,8 @@ export class BaseFocusable<
|
|
|
247
251
|
* @param {Object} scrollDirection
|
|
248
252
|
* @returns {Promise}
|
|
249
253
|
*/
|
|
250
|
-
focus(_, scrollDirection) {
|
|
251
|
-
return this.onFocus(this, scrollDirection); // invokeComponentMethod(this, "onFocus", scrollDirection);
|
|
254
|
+
focus(_, scrollDirection, context?: FocusManager.FocusContext) {
|
|
255
|
+
return this.onFocus(this, scrollDirection, context); // invokeComponentMethod(this, "onFocus", scrollDirection, context);
|
|
252
256
|
}
|
|
253
257
|
|
|
254
258
|
/**
|
|
@@ -258,9 +262,10 @@ export class BaseFocusable<
|
|
|
258
262
|
*/
|
|
259
263
|
blur(
|
|
260
264
|
_,
|
|
261
|
-
scrollDirection?: FocusManager.Web.Direction | FocusManager.IOS.Direction
|
|
265
|
+
scrollDirection?: FocusManager.Web.Direction | FocusManager.IOS.Direction,
|
|
266
|
+
context?: FocusManager.FocusContext
|
|
262
267
|
) {
|
|
263
|
-
return this.onBlur(this, scrollDirection);
|
|
268
|
+
return this.onBlur(this, scrollDirection, context);
|
|
264
269
|
}
|
|
265
270
|
|
|
266
271
|
/**
|
|
@@ -272,7 +277,7 @@ export class BaseFocusable<
|
|
|
272
277
|
* @param {string} scrollDirection string representation of the direction of the navigation which landed
|
|
273
278
|
* to this item being focused
|
|
274
279
|
*/
|
|
275
|
-
_executeFocusSequence(methodNames, scrollDirection) {
|
|
280
|
+
_executeFocusSequence(methodNames, scrollDirection, context) {
|
|
276
281
|
return R.reduce(
|
|
277
282
|
(sequence, methodName) => {
|
|
278
283
|
const method = this[methodName]; // Access the method by name
|
|
@@ -284,7 +289,7 @@ export class BaseFocusable<
|
|
|
284
289
|
}
|
|
285
290
|
|
|
286
291
|
return sequence
|
|
287
|
-
.then(() => method.call(this, scrollDirection))
|
|
292
|
+
.then(() => method.call(this, this, scrollDirection, context))
|
|
288
293
|
.catch((e) => {
|
|
289
294
|
throw e; // Re-throw for consistent error handling
|
|
290
295
|
});
|
|
@@ -294,15 +299,21 @@ export class BaseFocusable<
|
|
|
294
299
|
);
|
|
295
300
|
}
|
|
296
301
|
|
|
297
|
-
setFocus(
|
|
302
|
+
setFocus(
|
|
303
|
+
scrollDirection?: ScrollDirection,
|
|
304
|
+
context?: FocusManager.FocusContext
|
|
305
|
+
) {
|
|
298
306
|
const focusMethods = ["willReceiveFocus", "focus", "hasReceivedFocus"];
|
|
299
307
|
|
|
300
|
-
return this._executeFocusSequence(focusMethods, scrollDirection);
|
|
308
|
+
return this._executeFocusSequence(focusMethods, scrollDirection, context);
|
|
301
309
|
}
|
|
302
310
|
|
|
303
|
-
setBlur(
|
|
311
|
+
setBlur(
|
|
312
|
+
scrollDirection?: ScrollDirection,
|
|
313
|
+
context?: FocusManager.FocusContext
|
|
314
|
+
) {
|
|
304
315
|
const blurMethods = ["willLoseFocus", "blur", "hasLostFocus"];
|
|
305
316
|
|
|
306
|
-
return this._executeFocusSequence(blurMethods, scrollDirection);
|
|
317
|
+
return this._executeFocusSequence(blurMethods, scrollDirection, context);
|
|
307
318
|
}
|
|
308
319
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { View } from "react-native";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { act
|
|
3
|
+
import { act } from "@testing-library/react-native";
|
|
4
4
|
import { CellWithFocusable } from "../CellWithFocusable.tsx";
|
|
5
5
|
|
|
6
6
|
import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
|
|
7
|
+
import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils/index.tsx";
|
|
7
8
|
|
|
8
9
|
const renderWith = (props) => {
|
|
9
|
-
return
|
|
10
|
+
return renderWithProviders(<CellWithFocusable {...props} />);
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
describe("CellWithFocusable", () => {
|
package/Components/Cell/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
2
|
|
|
3
|
-
import { connectToStore } from "@applicaster/zapp-react-native-redux";
|
|
3
|
+
import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
|
|
4
4
|
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
5
5
|
|
|
6
6
|
import {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
2
|
|
|
3
|
-
import { connectToStore } from "@applicaster/zapp-react-native-redux";
|
|
3
|
+
import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
|
|
4
4
|
|
|
5
5
|
import { ComponentResolverComponent } from "./ComponentResolver";
|
|
6
6
|
|
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import * as R from "ramda";
|
|
3
|
+
import { selectZappPipes } from "@applicaster/zapp-react-native-redux";
|
|
3
4
|
|
|
4
5
|
type Props = {
|
|
5
|
-
zappPipes:
|
|
6
|
-
loadPipesData:
|
|
7
|
-
feed
|
|
8
|
-
|
|
9
|
-
clearCache: boolean;
|
|
10
|
-
meta: any;
|
|
11
|
-
loadLocalFavorites: boolean;
|
|
12
|
-
silentRefresh: boolean;
|
|
13
|
-
parentFeed: ZappFeed;
|
|
14
|
-
callback: () => void;
|
|
15
|
-
bodyParams: any;
|
|
16
|
-
riverId: string;
|
|
17
|
-
}>
|
|
18
|
-
) => void;
|
|
6
|
+
zappPipes: ReturnType<typeof selectZappPipes>;
|
|
7
|
+
loadPipesData: ReturnType<
|
|
8
|
+
typeof import("@applicaster/zapp-react-native-utils/reactHooks/feed").useLoadPipesDataDispatch
|
|
9
|
+
>;
|
|
19
10
|
feedUrl: string;
|
|
20
11
|
children: (feed: ZappFeed) => React.ComponentType<any>;
|
|
21
12
|
onFeedLoaded: (feed: ZappFeed) => {};
|
|
22
|
-
onError: (
|
|
13
|
+
onError: (error: ZappPipesData["error"]) => {};
|
|
23
14
|
refreshing: boolean;
|
|
24
15
|
refreshCallback: () => void;
|
|
25
16
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
selectZappPipes,
|
|
4
|
+
useAppSelector,
|
|
5
|
+
} from "@applicaster/zapp-react-native-redux";
|
|
6
|
+
import { useLoadPipesDataDispatch } from "@applicaster/zapp-react-native-utils/reactHooks/feed";
|
|
7
|
+
|
|
8
|
+
export const FeedLoaderHOC = (_Component: any) => {
|
|
9
|
+
return function FeedLoaderHOC(props: any) {
|
|
10
|
+
const zappPipes = useAppSelector(selectZappPipes);
|
|
11
|
+
const loadPipesData = useLoadPipesDataDispatch();
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<_Component
|
|
15
|
+
{...props}
|
|
16
|
+
zappPipes={zappPipes}
|
|
17
|
+
loadPipesData={loadPipesData}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import * as R from "ramda";
|
|
2
|
-
|
|
3
|
-
import { connectToStore } from "@applicaster/zapp-react-native-redux";
|
|
4
|
-
import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
|
|
5
|
-
|
|
6
1
|
import { FeedLoaderComponent } from "./FeedLoader";
|
|
2
|
+
import { FeedLoaderHOC } from "./FeedLoaderHOC";
|
|
7
3
|
|
|
8
|
-
export const FeedLoader =
|
|
9
|
-
loadPipesData,
|
|
10
|
-
})(FeedLoaderComponent);
|
|
4
|
+
export const FeedLoader = FeedLoaderHOC(FeedLoaderComponent);
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import React, { Dispatch, useEffect, useState } from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
create,
|
|
5
|
-
ReactTestRenderer,
|
|
6
|
-
ReactTestRendererJSON,
|
|
7
|
-
} from "react-test-renderer";
|
|
2
|
+
import { act, render } from "@testing-library/react-native";
|
|
3
|
+
import { View } from "react-native";
|
|
8
4
|
import { FreezeWithCallback } from "../index";
|
|
9
5
|
|
|
10
|
-
const SimpleContent = () => <
|
|
6
|
+
const SimpleContent = () => <View testID="simple-content" />;
|
|
11
7
|
|
|
12
8
|
interface InnerProps {
|
|
13
9
|
value: number;
|
|
14
10
|
}
|
|
11
|
+
|
|
15
12
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
16
|
-
const Inner = ({ value }: InnerProps) =>
|
|
13
|
+
const Inner = ({ value }: InnerProps) => (
|
|
14
|
+
<View testID="inner-component" data-value={value} />
|
|
15
|
+
);
|
|
17
16
|
|
|
18
17
|
interface TestSubscriber {
|
|
19
18
|
renderCount: number;
|
|
@@ -51,24 +50,20 @@ const Container = ({ freeze, children }: ContainerProps) => (
|
|
|
51
50
|
);
|
|
52
51
|
|
|
53
52
|
function setupTest(initialFreeze: boolean = false) {
|
|
54
|
-
let testRenderer: ReactTestRenderer | undefined;
|
|
55
53
|
const [Subscriber, subscriberState] = createSubscriberComponent();
|
|
56
54
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
<
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
);
|
|
63
|
-
});
|
|
55
|
+
const renderResult = render(
|
|
56
|
+
<Container freeze={initialFreeze}>
|
|
57
|
+
<Subscriber />
|
|
58
|
+
</Container>
|
|
59
|
+
);
|
|
64
60
|
|
|
65
61
|
return {
|
|
66
|
-
|
|
67
|
-
testInstance: testRenderer?.root,
|
|
62
|
+
renderResult,
|
|
68
63
|
subscriberState,
|
|
69
64
|
updateFreeze: (freeze: boolean) => {
|
|
70
65
|
act(() =>
|
|
71
|
-
|
|
66
|
+
renderResult.rerender(
|
|
72
67
|
<Container freeze={freeze}>
|
|
73
68
|
<Subscriber />
|
|
74
69
|
</Container>
|
|
@@ -80,91 +75,120 @@ function setupTest(initialFreeze: boolean = false) {
|
|
|
80
75
|
|
|
81
76
|
describe("FreezeWithCallback", () => {
|
|
82
77
|
test("Renders stuff not frozen", () => {
|
|
83
|
-
const
|
|
78
|
+
const { getByTestId } = render(
|
|
84
79
|
<Container freeze={false}>
|
|
85
80
|
<SimpleContent />
|
|
86
81
|
</Container>
|
|
87
82
|
);
|
|
88
83
|
|
|
89
|
-
expect(
|
|
84
|
+
expect(getByTestId("simple-content")).toBeTruthy();
|
|
90
85
|
});
|
|
91
86
|
|
|
92
87
|
test("Does not render stuff when frozen", () => {
|
|
93
|
-
const
|
|
88
|
+
const { queryByTestId } = render(
|
|
94
89
|
<Container freeze>
|
|
95
90
|
<SimpleContent />
|
|
96
91
|
</Container>
|
|
97
92
|
);
|
|
98
93
|
|
|
99
|
-
expect(
|
|
94
|
+
expect(queryByTestId("simple-content")).toBe(null);
|
|
100
95
|
});
|
|
101
96
|
|
|
102
97
|
test("Stuff is gone after freeze", () => {
|
|
103
|
-
const
|
|
98
|
+
const { toJSON, getByTestId, rerender } = render(
|
|
104
99
|
<Container freeze={false}>
|
|
105
100
|
<SimpleContent />
|
|
106
101
|
</Container>
|
|
107
102
|
);
|
|
108
103
|
|
|
109
|
-
expect(
|
|
104
|
+
expect(getByTestId("simple-content")).toBeTruthy();
|
|
110
105
|
|
|
111
106
|
act(() =>
|
|
112
|
-
|
|
107
|
+
rerender(
|
|
113
108
|
<Container freeze>
|
|
114
109
|
<SimpleContent />
|
|
115
110
|
</Container>
|
|
116
111
|
)
|
|
117
112
|
);
|
|
118
113
|
|
|
119
|
-
expect(
|
|
114
|
+
expect(toJSON()).toBe(null);
|
|
120
115
|
});
|
|
121
116
|
|
|
122
117
|
test("Updates work when not frozen", () => {
|
|
123
|
-
const {
|
|
118
|
+
const { renderResult, subscriberState } = setupTest();
|
|
119
|
+
|
|
120
|
+
expect(
|
|
121
|
+
renderResult.getByTestId("inner-component").props["data-value"]
|
|
122
|
+
).toEqual(0);
|
|
124
123
|
|
|
125
|
-
expect(testInstance?.findByType(Inner).props.value).toEqual(0);
|
|
126
124
|
act(() => subscriberState.subscription(1));
|
|
127
|
-
|
|
125
|
+
|
|
126
|
+
expect(
|
|
127
|
+
renderResult.getByTestId("inner-component").props["data-value"]
|
|
128
|
+
).toEqual(1);
|
|
129
|
+
|
|
128
130
|
expect(subscriberState.renderCount).toBe(2);
|
|
129
131
|
});
|
|
130
132
|
|
|
131
133
|
test("Updates does not propagate when frozen", () => {
|
|
132
|
-
const {
|
|
134
|
+
const { renderResult, subscriberState, updateFreeze } = setupTest();
|
|
135
|
+
|
|
136
|
+
expect(
|
|
137
|
+
renderResult.getByTestId("inner-component").props["data-value"]
|
|
138
|
+
).toEqual(0);
|
|
133
139
|
|
|
134
|
-
expect(testInstance?.findByType(Inner).props.value).toEqual(0);
|
|
135
140
|
updateFreeze(true);
|
|
136
141
|
act(() => subscriberState.subscription(1));
|
|
137
|
-
|
|
142
|
+
|
|
143
|
+
expect(
|
|
144
|
+
renderResult.getByTestId("inner-component").props["data-value"]
|
|
145
|
+
).toEqual(0);
|
|
146
|
+
|
|
138
147
|
expect(subscriberState.renderCount).toBe(1);
|
|
139
148
|
});
|
|
140
149
|
|
|
141
150
|
test("State persists after defrost", () => {
|
|
142
|
-
const {
|
|
143
|
-
|
|
151
|
+
const { renderResult, subscriberState, updateFreeze } = setupTest();
|
|
152
|
+
|
|
153
|
+
expect(
|
|
154
|
+
renderResult.getByTestId("inner-component").props["data-value"]
|
|
155
|
+
).toEqual(0);
|
|
144
156
|
|
|
145
|
-
expect(testInstance?.findByType(Inner).props.value).toEqual(0);
|
|
146
157
|
act(() => subscriberState.subscription(1));
|
|
147
|
-
|
|
158
|
+
|
|
159
|
+
expect(
|
|
160
|
+
renderResult.getByTestId("inner-component").props["data-value"]
|
|
161
|
+
).toEqual(1);
|
|
148
162
|
|
|
149
163
|
updateFreeze(true);
|
|
150
|
-
expect(
|
|
164
|
+
expect(renderResult.toJSON()).toBe(null);
|
|
151
165
|
|
|
152
166
|
updateFreeze(false);
|
|
153
|
-
expect((
|
|
154
|
-
|
|
167
|
+
expect(renderResult.getByTestId("inner-component")).toBeTruthy();
|
|
168
|
+
|
|
169
|
+
expect(
|
|
170
|
+
renderResult.getByTestId("inner-component").props["data-value"]
|
|
171
|
+
).toEqual(1);
|
|
155
172
|
});
|
|
156
173
|
|
|
157
174
|
test("Update propagate after defrost", () => {
|
|
158
|
-
const {
|
|
175
|
+
const { renderResult, subscriberState, updateFreeze } = setupTest();
|
|
159
176
|
|
|
160
177
|
updateFreeze(true);
|
|
161
178
|
act(() => subscriberState.subscription(1));
|
|
162
179
|
act(() => subscriberState.subscription(2));
|
|
163
180
|
act(() => subscriberState.subscription(3));
|
|
164
|
-
|
|
181
|
+
|
|
182
|
+
expect(
|
|
183
|
+
renderResult.getByTestId("inner-component").props["data-value"]
|
|
184
|
+
).toEqual(0);
|
|
165
185
|
|
|
166
186
|
updateFreeze(false);
|
|
167
|
-
|
|
187
|
+
|
|
188
|
+
expect(
|
|
189
|
+
renderResult.getByTestId("inner-component").props["data-value"]
|
|
190
|
+
).toEqual(3);
|
|
191
|
+
|
|
168
192
|
expect(subscriberState.renderCount).toBe(2);
|
|
169
193
|
});
|
|
170
194
|
});
|
|
@@ -8,13 +8,10 @@ import {
|
|
|
8
8
|
useCurationAPI,
|
|
9
9
|
} from "../useCurationAPI";
|
|
10
10
|
import * as redux from "react-redux";
|
|
11
|
-
import * as layoutPresets from "@applicaster/zapp-react-native-redux/hooks/useLayoutPresets";
|
|
12
|
-
import * as pipesFeeds from "@applicaster/zapp-react-native-redux/hooks/useZappPipesFeeds";
|
|
13
11
|
import { NavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NavigationContext";
|
|
14
12
|
import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Contexts/PathnameContext";
|
|
15
13
|
|
|
16
|
-
import {
|
|
17
|
-
import configureStore from "redux-mock-store";
|
|
14
|
+
import { WrappedWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
18
15
|
|
|
19
16
|
jest.mock(
|
|
20
17
|
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute",
|
|
@@ -42,19 +39,20 @@ const mainStackNavigator = {
|
|
|
42
39
|
},
|
|
43
40
|
};
|
|
44
41
|
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
{
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
42
|
+
const getWrapper =
|
|
43
|
+
(store) =>
|
|
44
|
+
// eslint-disable-next-line react/display-name, react/prop-types
|
|
45
|
+
({ children }) => (
|
|
46
|
+
<WrappedWithProviders store={store}>
|
|
47
|
+
<NavigationContext.Provider
|
|
48
|
+
value={{ ...mainStackNavigator, currentRoute: homeStack.route }}
|
|
49
|
+
>
|
|
50
|
+
<PathnameContext.Provider value={homeStack.route}>
|
|
51
|
+
{children}
|
|
52
|
+
</PathnameContext.Provider>
|
|
53
|
+
</NavigationContext.Provider>
|
|
54
|
+
</WrappedWithProviders>
|
|
55
|
+
);
|
|
58
56
|
|
|
59
57
|
describe("getTransformedPreset should return the passed components if smartComponents is empty", () => {
|
|
60
58
|
describe("getTransformedPreset function", () => {
|
|
@@ -312,19 +310,10 @@ describe("getTransformedPreset should return the passed components if smartCompo
|
|
|
312
310
|
{ id: "02", component_type: "not_smart_another" },
|
|
313
311
|
];
|
|
314
312
|
|
|
315
|
-
// mock the hooks
|
|
316
|
-
const mockUseZappPipesFeeds = jest.spyOn(pipesFeeds, "useZappPipesFeeds");
|
|
317
|
-
mockUseZappPipesFeeds.mockReturnValue({});
|
|
318
|
-
|
|
319
|
-
const mockUseLayoutPresets = jest.spyOn(
|
|
320
|
-
layoutPresets,
|
|
321
|
-
"useLayoutPresets"
|
|
322
|
-
);
|
|
323
|
-
|
|
324
|
-
mockUseLayoutPresets.mockReturnValue({});
|
|
325
|
-
|
|
326
313
|
const { result } = renderHook(() => useCurationAPI(mockComponents), {
|
|
327
|
-
wrapper
|
|
314
|
+
wrapper: getWrapper({
|
|
315
|
+
zappPipes: {},
|
|
316
|
+
}),
|
|
328
317
|
});
|
|
329
318
|
|
|
330
319
|
// if there are no smart components, it should return the original array
|
|
@@ -366,18 +355,15 @@ describe("getTransformedPreset should return the passed components if smartCompo
|
|
|
366
355
|
"http://curation": { loading: false, data: { entry: mockPresetEntry } },
|
|
367
356
|
};
|
|
368
357
|
|
|
369
|
-
const mockUseZappPipesFeeds = jest.spyOn(pipesFeeds, "useZappPipesFeeds");
|
|
370
|
-
mockUseZappPipesFeeds.mockReturnValue(mockFeeds);
|
|
371
|
-
|
|
372
|
-
const mockUseLayoutPresets = jest.spyOn(
|
|
373
|
-
layoutPresets,
|
|
374
|
-
"useLayoutPresets"
|
|
375
|
-
);
|
|
376
|
-
|
|
377
|
-
mockUseLayoutPresets.mockReturnValue(mockLayoutPresets);
|
|
378
|
-
|
|
379
358
|
const { result } = renderHook(() => useCurationAPI(mockComponents), {
|
|
380
|
-
wrapper
|
|
359
|
+
wrapper: getWrapper({
|
|
360
|
+
zappPipes: mockFeeds,
|
|
361
|
+
presetsMapping: {
|
|
362
|
+
presets_mappings: {
|
|
363
|
+
...mockLayoutPresets,
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
}),
|
|
381
367
|
});
|
|
382
368
|
|
|
383
369
|
expect(result.current).toEqual(mockTransformedComponents);
|
|
@@ -437,19 +423,15 @@ describe("getTransformedPreset should return the passed components if smartCompo
|
|
|
437
423
|
},
|
|
438
424
|
};
|
|
439
425
|
|
|
440
|
-
// mock the hooks
|
|
441
|
-
const mockUseZappPipesFeeds = jest.spyOn(pipesFeeds, "useZappPipesFeeds");
|
|
442
|
-
mockUseZappPipesFeeds.mockReturnValue(mockFeeds);
|
|
443
|
-
|
|
444
|
-
const mockUseLayoutPresets = jest.spyOn(
|
|
445
|
-
layoutPresets,
|
|
446
|
-
"useLayoutPresets"
|
|
447
|
-
);
|
|
448
|
-
|
|
449
|
-
mockUseLayoutPresets.mockReturnValue(mockLayoutPresets);
|
|
450
|
-
|
|
451
426
|
const { result } = renderHook(() => useCurationAPI(mockComponents), {
|
|
452
|
-
wrapper
|
|
427
|
+
wrapper: getWrapper({
|
|
428
|
+
zappPipes: mockFeeds,
|
|
429
|
+
presetsMapping: {
|
|
430
|
+
presets_mappings: {
|
|
431
|
+
...mockLayoutPresets,
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
}),
|
|
453
435
|
});
|
|
454
436
|
|
|
455
437
|
expect(result.current).toEqual(mockTransformedComponents);
|
|
@@ -495,14 +477,15 @@ describe("getTransformedPreset should return the passed components if smartCompo
|
|
|
495
477
|
"http://curation": { loading: false, data: { entry: mockPresetEntry } },
|
|
496
478
|
};
|
|
497
479
|
|
|
498
|
-
// mock the hooks
|
|
499
|
-
const mockUseZappPipesFeeds = jest.spyOn(pipesFeeds, "useZappPipesFeeds");
|
|
500
|
-
mockUseZappPipesFeeds.mockReturnValue(mockFeeds);
|
|
501
|
-
const mockUseLayoutPresets = jest.spyOn(layoutPresets, "useLayoutPresets");
|
|
502
|
-
mockUseLayoutPresets.mockReturnValue(mockLayoutPresets);
|
|
503
|
-
|
|
504
480
|
const { result } = renderHook(() => useCurationAPI(mockComponents), {
|
|
505
|
-
wrapper
|
|
481
|
+
wrapper: getWrapper({
|
|
482
|
+
zappPipes: mockFeeds,
|
|
483
|
+
presetsMapping: {
|
|
484
|
+
presets_mappings: {
|
|
485
|
+
...mockLayoutPresets,
|
|
486
|
+
},
|
|
487
|
+
},
|
|
488
|
+
}),
|
|
506
489
|
});
|
|
507
490
|
|
|
508
491
|
expect(result.current).toEqual(mockTransformedComponents);
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { all, equals, path, prop, isEmpty, pluck, values } from "ramda";
|
|
2
2
|
|
|
3
3
|
import { useEffect, useMemo } from "react";
|
|
4
|
-
import { useDispatch } from "react-redux";
|
|
5
4
|
|
|
6
5
|
import {
|
|
7
6
|
useLayoutPresets,
|
|
8
|
-
|
|
9
|
-
} from "@applicaster/zapp-react-native-redux
|
|
10
|
-
import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
|
|
7
|
+
useZappPipesFeed,
|
|
8
|
+
} from "@applicaster/zapp-react-native-redux";
|
|
11
9
|
import { isEmptyOrNil } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
12
10
|
import { Categories } from "./logger";
|
|
13
11
|
import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
14
12
|
import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute";
|
|
13
|
+
|
|
15
14
|
import {
|
|
16
15
|
ZappPipesEntryContext,
|
|
17
16
|
ZappPipesScreenContext,
|
|
@@ -24,9 +23,13 @@ import {
|
|
|
24
23
|
} from "@applicaster/zapp-react-native-utils/reactHooks/feed/useInflatedUrl";
|
|
25
24
|
|
|
26
25
|
import { produce } from "immer";
|
|
26
|
+
import { useLoadPipesDataDispatch } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
27
27
|
// types reference
|
|
28
28
|
|
|
29
|
-
declare
|
|
29
|
+
declare interface CurationEntry {
|
|
30
|
+
preset_name: string;
|
|
31
|
+
feed_url: string;
|
|
32
|
+
}
|
|
30
33
|
|
|
31
34
|
type Feeds = Record<string, ZappPipesData>;
|
|
32
35
|
|
|
@@ -122,8 +125,6 @@ export const getFinalComponents = (
|
|
|
122
125
|
export const useCurationAPI = (
|
|
123
126
|
components: Array<ZappUIComponent>
|
|
124
127
|
): ZappUIComponent[] => {
|
|
125
|
-
const dispatch = useDispatch();
|
|
126
|
-
|
|
127
128
|
const smartComponents = useMemo(
|
|
128
129
|
() => components?.filter?.(isSmartComponent) ?? [],
|
|
129
130
|
[components]
|
|
@@ -159,19 +160,21 @@ export const useCurationAPI = (
|
|
|
159
160
|
|
|
160
161
|
const urls = useMemo<string[]>(() => Object.values(urlsMap), [urlsMap]);
|
|
161
162
|
|
|
163
|
+
const loadPipesDataDispatcher = useLoadPipesDataDispatch();
|
|
164
|
+
|
|
162
165
|
useEffect(() => {
|
|
163
166
|
urls.forEach((url, index) => {
|
|
164
167
|
if (url) {
|
|
165
|
-
|
|
168
|
+
loadPipesDataDispatcher(url, { clearCache: false });
|
|
166
169
|
} else {
|
|
167
170
|
logger.log_error("Curation url is empty", {
|
|
168
171
|
componentId: smartComponents?.[index]?.id,
|
|
169
172
|
});
|
|
170
173
|
}
|
|
171
174
|
});
|
|
172
|
-
}, [urls]);
|
|
175
|
+
}, [urls, loadPipesDataDispatcher]);
|
|
173
176
|
|
|
174
|
-
const feeds =
|
|
177
|
+
const feeds = useZappPipesFeed(urls);
|
|
175
178
|
const layoutPresets = useLayoutPresets();
|
|
176
179
|
|
|
177
180
|
const enrichedComponents = useMemo(() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks
|
|
2
|
+
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
3
3
|
import { getBackgroundImageUrl } from "../utils";
|
|
4
4
|
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
5
5
|
|
|
@@ -7,7 +7,6 @@ import { NavigationContext } from "@applicaster/zapp-react-native-ui-components/
|
|
|
7
7
|
import configureStore from "redux-mock-store";
|
|
8
8
|
import Layout from "../index.web";
|
|
9
9
|
|
|
10
|
-
// mock useTheme to provide app_background_color
|
|
11
10
|
jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
|
|
12
11
|
useTheme: () => ({
|
|
13
12
|
app_background_color: "#000000",
|
|
@@ -23,6 +23,7 @@ type Props = {
|
|
|
23
23
|
style: ViewStyle;
|
|
24
24
|
testID?: string;
|
|
25
25
|
accessibilityLabel?: string;
|
|
26
|
+
accessibilityHint?: string;
|
|
26
27
|
cellUUID?: string;
|
|
27
28
|
extraProps?: Record<string, any>;
|
|
28
29
|
};
|
|
@@ -98,6 +99,7 @@ export function ActionButton(props: Props) {
|
|
|
98
99
|
onPress={onPress}
|
|
99
100
|
testID={props?.testID || `${item?.id}`}
|
|
100
101
|
accessibilityLabel={props?.accessibilityLabel || `${item?.id}`}
|
|
102
|
+
accessibilityHint={props?.accessibilityHint}
|
|
101
103
|
accessible={!!(props?.testID || props?.accessibilityLabel)}
|
|
102
104
|
style={props?.style}
|
|
103
105
|
>
|
|
@@ -4,7 +4,7 @@ import * as R from "ramda";
|
|
|
4
4
|
import { TouchableOpacity } from "react-native";
|
|
5
5
|
// import { SvgUri } from "react-native-svg";
|
|
6
6
|
|
|
7
|
-
import { connectToStore } from "@applicaster/zapp-react-native-redux";
|
|
7
|
+
import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
|
|
8
8
|
import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
|
|
9
9
|
|
|
10
10
|
import Image from "./Image";
|