@applicaster/zapp-react-native-ui-components 13.0.0-alpha.3013227535 → 13.0.0-alpha.3044917147
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/AppContainer/__tests__/AppContainer.test.js +4 -6
- package/Components/AudioPlayer/AudioPlayer.tsx +5 -9
- package/Components/AudioPlayer/AudioPlayerLayout.tsx +8 -9
- package/Components/AudioPlayer/__tests__/Runtime.test.js +5 -8
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +54 -111
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +36 -20
- package/Components/AudioPlayer/__tests__/artWork.test.js +3 -5
- package/Components/AudioPlayer/__tests__/audioPlayer.test.js +3 -5
- package/Components/AudioPlayer/__tests__/audioPlayerLayout.test.js +7 -8
- package/Components/AudioPlayer/__tests__/channel.test.js +3 -5
- package/Components/AudioPlayer/__tests__/summary.test.js +3 -5
- package/Components/AudioPlayer/__tests__/title.test.js +3 -5
- package/Components/AudioPlayer/helpers.tsx +1 -2
- package/Components/BaseFocusable/index.tsx +1 -2
- package/Components/Cell/Cell.tsx +4 -13
- package/Components/Cell/CellWithFocusable.tsx +50 -59
- package/Components/Cell/CellWrapper.tsx +18 -0
- package/Components/Cell/TvOSCellComponent.tsx +20 -22
- package/Components/Cell/__tests__/CellWIthFocusable.test.js +13 -6
- package/Components/Cell/index.js +3 -1
- package/Components/Cell/styles.ts +17 -0
- package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +46 -48
- package/Components/CellRendererResolver/index.ts +2 -1
- package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +1 -42
- package/Components/ComponentResolver/__tests__/componentResolver.test.js +16 -22
- package/Components/ContentScreen/__tests__/contentScreen.test.js +3 -3
- package/Components/ErrorScreen/index.tsx +14 -6
- package/Components/Focusable/Focusable.tsx +1 -0
- package/Components/Focusable/FocusableTvOS.tsx +5 -1
- package/Components/Focusable/index.android.tsx +10 -3
- package/Components/FocusableCell/index.tsx +1 -1
- package/Components/FocusableGroup/FocusableTvOS.tsx +34 -86
- package/Components/FocusableGroup/index.tsx +0 -3
- package/Components/FocusableList/index.tsx +26 -9
- package/Components/FocusableScrollView/index.tsx +43 -13
- package/Components/GeneralContentScreen/GeneralContentScreen.tsx +3 -0
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +4 -2
- package/Components/GeneralContentScreen/utils/useEventAlerts.ts +30 -0
- package/Components/HandlePlayable/HandlePlayable.tsx +21 -27
- package/Components/Layout/TV/LayoutBackground.tsx +28 -0
- package/Components/Layout/TV/NavBarContainer.tsx +19 -23
- package/Components/Layout/TV/ScreenContainer.tsx +8 -2
- package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +5 -0
- package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +2 -1
- package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +3 -2
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +3 -2
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +15 -10
- package/Components/Layout/TV/__tests__/index.test.tsx +8 -2
- package/Components/Layout/TV/index.tsx +6 -20
- package/Components/Layout/TV/index.web.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -3
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +4 -3
- package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +11 -7
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +2 -2
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/const.ts +3 -0
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +6 -6
- package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +2 -8
- package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +4 -12
- package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +0 -229
- package/Components/MasterCell/__tests__/elementMapper.test.js +18 -5
- package/Components/MasterCell/__tests__/masterCell.test.js +26 -26
- package/Components/MasterCell/hooks/useAsyncRendering/MasterCellAsyncRenderManager.ts +2 -2
- package/Components/MasterCell/utils/behaviorProvider.ts +136 -0
- package/Components/MasterCell/utils/index.ts +8 -134
- package/Components/ModalComponent/BottomSheetModalContent.tsx +66 -54
- package/Components/ModalComponent/Button/Item.tsx +6 -5
- package/Components/ModalComponent/Button/assets.ts +1 -1
- package/Components/ModalComponent/Button/index.tsx +45 -62
- package/Components/ModalComponent/Header/index.tsx +12 -11
- package/Components/ModalComponent/utils.ts +55 -7
- package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +2 -2
- package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +2 -2
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -5
- package/Components/OfflineHandler/utils/index.ts +1 -1
- package/Components/PlayerContainer/PlayerContainer.tsx +63 -54
- package/Components/PlayerContainer/ProgramInfo/index.tsx +2 -2
- package/Components/PlayerImageBackground/index.tsx +1 -1
- package/Components/River/ComponentsMap/ComponentsMap.tsx +53 -68
- package/Components/River/ComponentsMap/hooks/useLoadingState.ts +78 -51
- package/Components/River/RiverFooter.tsx +39 -9
- package/Components/River/RiverItem.tsx +43 -3
- package/Components/River/TV/index.tsx +6 -1
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +107 -32
- package/Components/River/__tests__/__snapshots__/river.test.js.snap +20 -82
- package/Components/River/__tests__/componentsMap.test.js +3 -4
- package/Components/River/__tests__/river.test.js +75 -40
- package/Components/RouteManager/TestId.tsx +1 -5
- package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +10 -4
- package/Components/RouteManager/__tests__/routeManager.test.js +29 -14
- package/Components/RouteManager/__tests__/testId.test.js +4 -6
- package/Components/Screen/TV/__tests__/index.web.test.tsx +26 -0
- package/Components/Screen/TV/index.web.tsx +5 -6
- package/Components/Screen/__tests__/Screen.test.tsx +22 -14
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +2 -2
- package/Components/Screen/hooks.ts +53 -0
- package/Components/Screen/index.tsx +16 -43
- package/Components/ScreenResolver/__tests__/screenResolver.test.js +91 -70
- package/Components/Tabs/Tab.tsx +5 -3
- package/Components/TextInputTv/index.tsx +2 -1
- package/Components/TopMarginApplicator/TopMarginApplicator.tsx +2 -3
- package/Components/TrackedView/index.tsx +1 -0
- package/Components/Transitioner/AnimationManager.js +15 -15
- package/Components/Transitioner/Scene.tsx +1 -1
- package/Components/Transitioner/Transitioner.tsx +3 -3
- package/Components/Transitioner/__tests__/Scene.test.js +25 -14
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +12 -68
- package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +2 -2
- package/Components/Transitioner/__tests__/transitioner.test.js +13 -4
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +7 -3
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -0
- package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +1 -1
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +46 -30
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +3 -3
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +45 -21
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +13 -6
- package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +108 -0
- package/Components/VideoModal/ModalAnimation/const.ts +5 -0
- package/Components/VideoModal/ModalAnimation/index.ts +2 -0
- package/Components/VideoModal/ModalAnimation/utils.ts +30 -0
- package/Components/VideoModal/PlayerDetails.tsx +18 -10
- package/Components/VideoModal/PlayerWrapper.tsx +37 -24
- package/Components/VideoModal/VideoModal.tsx +19 -4
- package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +2 -40
- package/Components/VideoModal/utils.ts +3 -4
- package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap +24 -36
- package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -18
- package/Components/Viewport/__tests__/utils.test.js +5 -4
- package/Components/ZappUIComponent/Placeholder.tsx +3 -1
- package/Components/ZappUIComponent/__tests__/{ZappUIComponent.test.js → ZappUIComponent.test.tsx} +26 -10
- package/Components/ZappUIComponent/index.tsx +4 -17
- package/Components/default-cell-renderer/__tests__/defaultCellRenderer.test.tsx +20 -17
- package/Components/default-cell-renderer/viewTrees/tv/DefaultCell/__tests__/DefaultCell.test.tsx +15 -11
- package/Contexts/ComponentsMapOffsetContext/index.tsx +49 -0
- package/Contexts/FocusableGroupContext/withFocusableContext.tsx +4 -10
- package/Contexts/HeaderOffsetContext/index.tsx +4 -6
- package/Contexts/ScreenContext/index.tsx +3 -10
- package/Contexts/ScreenLayoutContext/index.tsx +5 -3
- package/Decorators/Navigator/__tests__/navigator.test.js +16 -16
- package/Decorators/Navigator/index.tsx +1 -1
- package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +18 -24
- package/Decorators/RiverResolver/index.tsx +6 -8
- package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +29 -22
- package/Decorators/ZappPipesDataConnector/index.tsx +4 -30
- package/package.json +7 -11
- package/tsconfig.json +2 -3
- package/.babelrc +0 -8
- package/Components/Cell/CellStyles/FallbackCellStyle/index.js +0 -157
- package/Components/Cell/CellStyles/Hero/index.js +0 -111
- package/Components/Cell/CellStyles/ScreenSelector/index.js +0 -68
- package/Components/Cell/CellStyles/cellStylesResolver.ts +0 -19
- package/Components/Cell/CellStyles/colors.js +0 -40
- package/Components/Cell/CellStyles/index.js +0 -15
- package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap +0 -53
- package/Components/RouteManager/__tests__/__snapshots__/testId.test.js.snap +0 -17
- package/Components/ScreenResolver/__tests__/__snapshots__/screenResolver.test.js.snap +0 -17
- package/Components/ZappUIComponent/__tests__/__snapshots__/ZappUIComponent.test.js.snap +0 -91
- package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +0 -338
- package/Decorators/Navigator/__tests__/__snapshots__/navigator.test.js.snap +0 -18
- package/Decorators/RiverResolver/__tests__/__snapshots__/riverResolver.test.tsx.snap +0 -28
|
@@ -1,11 +1,23 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
2
|
import { StyleSheet, View } from "react-native";
|
|
3
3
|
import { Spinner } from "@applicaster/zapp-react-native-ui-components/Components/Spinner";
|
|
4
|
+
import type { Subject } from "rxjs";
|
|
5
|
+
import { useStateFromSubscribe } from "@applicaster/zapp-react-native-utils/reactHooks/state/useStateFromSubscribe";
|
|
6
|
+
|
|
7
|
+
type LoadingState = {
|
|
8
|
+
waitForAllComponents: boolean;
|
|
9
|
+
index: number;
|
|
10
|
+
done: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type State = {
|
|
14
|
+
visible: boolean;
|
|
15
|
+
isAnyLoaded: boolean;
|
|
16
|
+
};
|
|
4
17
|
|
|
5
18
|
type Props = {
|
|
6
|
-
visible?: boolean;
|
|
7
19
|
flatListHeight?: number;
|
|
8
|
-
|
|
20
|
+
loadingState: Subject<LoadingState>;
|
|
9
21
|
};
|
|
10
22
|
|
|
11
23
|
const FOOTER_COMPONENT_HEIGHT = 200;
|
|
@@ -19,17 +31,35 @@ const footerStyles = StyleSheet.create({
|
|
|
19
31
|
});
|
|
20
32
|
|
|
21
33
|
function RiverFooterComponent(props: Props) {
|
|
22
|
-
const {
|
|
34
|
+
const { flatListHeight, loadingState } = props;
|
|
35
|
+
|
|
36
|
+
const { visible, isAnyLoaded } = useStateFromSubscribe<LoadingState, State>(
|
|
37
|
+
loadingState,
|
|
38
|
+
useCallback(
|
|
39
|
+
({ index, done, waitForAllComponents }, setState) =>
|
|
40
|
+
setState(() => ({
|
|
41
|
+
visible: !done,
|
|
42
|
+
isAnyLoaded: index >= 0 || waitForAllComponents,
|
|
43
|
+
})),
|
|
44
|
+
[]
|
|
45
|
+
),
|
|
46
|
+
{
|
|
47
|
+
visible: true,
|
|
48
|
+
isAnyLoaded: false,
|
|
49
|
+
}
|
|
50
|
+
);
|
|
23
51
|
|
|
24
52
|
if (!visible) return null;
|
|
25
53
|
|
|
26
54
|
return (
|
|
27
55
|
<View
|
|
28
|
-
renderToHardwareTextureAndroid
|
|
29
|
-
style={
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
56
|
+
renderToHardwareTextureAndroid
|
|
57
|
+
style={[
|
|
58
|
+
footerStyles.container,
|
|
59
|
+
{
|
|
60
|
+
height: isAnyLoaded ? FOOTER_COMPONENT_HEIGHT : flatListHeight,
|
|
61
|
+
},
|
|
62
|
+
]}
|
|
33
63
|
>
|
|
34
64
|
<Spinner size={isAnyLoaded ? "small" : "large"} />
|
|
35
65
|
</View>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
2
|
import * as R from "ramda";
|
|
3
|
+
import { isGroup } from "@applicaster/zapp-react-native-utils/componentsUtils";
|
|
3
4
|
|
|
4
5
|
import { applyDecorators } from "../../Decorators";
|
|
5
6
|
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
import { riverLogger } from "./logger";
|
|
12
13
|
import { tvPluginsWithCellRenderer } from "../../const";
|
|
13
14
|
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
15
|
+
import type { BehaviorSubject } from "rxjs";
|
|
14
16
|
|
|
15
17
|
export type RiverItemType = {
|
|
16
18
|
item: ZappUIComponent;
|
|
@@ -24,6 +26,7 @@ export type RiverItemType = {
|
|
|
24
26
|
getStaticComponentFeed: GeneralContentScreenProps["getStaticComponentFeed"];
|
|
25
27
|
readyToBeDisplayed?: boolean;
|
|
26
28
|
isLast: boolean;
|
|
29
|
+
loadingState: BehaviorSubject<{ index: number }>;
|
|
27
30
|
};
|
|
28
31
|
|
|
29
32
|
function getFeedUrl(feed: ZappFeed, index: number) {
|
|
@@ -36,6 +39,37 @@ function getFeedUrl(feed: ZappFeed, index: number) {
|
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
41
|
|
|
42
|
+
/**
|
|
43
|
+
* useLoadingState for RiverItemComponent
|
|
44
|
+
* takes currentIndex and loadingState as arguments
|
|
45
|
+
**/
|
|
46
|
+
const useLoadingState = (
|
|
47
|
+
currentIndex: number,
|
|
48
|
+
loadingState: RiverItemType["loadingState"]
|
|
49
|
+
) => {
|
|
50
|
+
const [readyToBeDisplayed, setReadyToBeDisplayed] = React.useState(
|
|
51
|
+
loadingState.getValue().index + 1 >= currentIndex
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const subscription = loadingState.subscribe(({ index }) => {
|
|
56
|
+
if (index + 1 >= currentIndex) {
|
|
57
|
+
setReadyToBeDisplayed(true);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
if (loadingState.getValue().index + 1 >= currentIndex) {
|
|
62
|
+
setReadyToBeDisplayed(true);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return () => {
|
|
66
|
+
subscription.unsubscribe();
|
|
67
|
+
};
|
|
68
|
+
}, [loadingState, currentIndex]);
|
|
69
|
+
|
|
70
|
+
return readyToBeDisplayed;
|
|
71
|
+
};
|
|
72
|
+
|
|
39
73
|
function RiverItemComponent(props: RiverItemType) {
|
|
40
74
|
const {
|
|
41
75
|
item,
|
|
@@ -47,10 +81,12 @@ function RiverItemComponent(props: RiverItemType) {
|
|
|
47
81
|
onLoadFinished,
|
|
48
82
|
onLoadFailed,
|
|
49
83
|
getStaticComponentFeed,
|
|
50
|
-
readyToBeDisplayed,
|
|
51
84
|
isLast,
|
|
85
|
+
loadingState,
|
|
52
86
|
} = props;
|
|
53
87
|
|
|
88
|
+
const readyToBeDisplayed = useLoadingState(index, loadingState);
|
|
89
|
+
|
|
54
90
|
const feedUrl = getFeedUrl(feed, index);
|
|
55
91
|
|
|
56
92
|
const Component = useComponentResolver(
|
|
@@ -81,7 +117,7 @@ function RiverItemComponent(props: RiverItemType) {
|
|
|
81
117
|
jsOnly: true,
|
|
82
118
|
});
|
|
83
119
|
|
|
84
|
-
if (!CellRenderer && item
|
|
120
|
+
if (!CellRenderer && !isGroup(item)) {
|
|
85
121
|
riverLogger.warning({
|
|
86
122
|
message: "Cell Renderer is null - will fallback to default cell",
|
|
87
123
|
data: { item, CellRenderer },
|
|
@@ -90,6 +126,10 @@ function RiverItemComponent(props: RiverItemType) {
|
|
|
90
126
|
}
|
|
91
127
|
}, []);
|
|
92
128
|
|
|
129
|
+
if (!readyToBeDisplayed) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
|
|
93
133
|
if (Component === null || typeof Component === "undefined") {
|
|
94
134
|
riverLogger.warning({
|
|
95
135
|
message: `Component ${item.component_type} is null - skipping rendering`,
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
import { compose } from "ramda";
|
|
1
2
|
import { River as RiverComponent } from "./River";
|
|
2
3
|
import { withTvEventHandler } from "./withTVEventHandler";
|
|
4
|
+
import { withComponentsMapOffsetContext } from "../../../Contexts/ComponentsMapOffsetContext";
|
|
3
5
|
|
|
4
|
-
export const River =
|
|
6
|
+
export const River = compose(
|
|
7
|
+
withTvEventHandler,
|
|
8
|
+
withComponentsMapOffsetContext
|
|
9
|
+
)(RiverComponent);
|
|
@@ -17,7 +17,90 @@ exports[`componentsMap renders renders components map correctly 1`] = `
|
|
|
17
17
|
}
|
|
18
18
|
>
|
|
19
19
|
<RCTScrollView
|
|
20
|
-
ListFooterComponent={
|
|
20
|
+
ListFooterComponent={
|
|
21
|
+
<Memo(RiverFooterComponent)
|
|
22
|
+
flatListHeight={null}
|
|
23
|
+
loadingState={
|
|
24
|
+
BehaviorSubject {
|
|
25
|
+
"_value": {
|
|
26
|
+
"done": false,
|
|
27
|
+
"index": -1,
|
|
28
|
+
"waitForAllComponents": false,
|
|
29
|
+
},
|
|
30
|
+
"closed": false,
|
|
31
|
+
"currentObservers": null,
|
|
32
|
+
"hasError": false,
|
|
33
|
+
"isStopped": false,
|
|
34
|
+
"observers": [
|
|
35
|
+
SafeSubscriber {
|
|
36
|
+
"_finalizers": [
|
|
37
|
+
Subscription {
|
|
38
|
+
"_finalizers": null,
|
|
39
|
+
"_parentage": [Circular],
|
|
40
|
+
"closed": false,
|
|
41
|
+
"initialTeardown": [Function],
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
"_parentage": null,
|
|
45
|
+
"closed": false,
|
|
46
|
+
"destination": ConsumerObserver {
|
|
47
|
+
"partialObserver": {
|
|
48
|
+
"complete": undefined,
|
|
49
|
+
"error": undefined,
|
|
50
|
+
"next": [Function],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
"initialTeardown": undefined,
|
|
54
|
+
"isStopped": false,
|
|
55
|
+
},
|
|
56
|
+
SafeSubscriber {
|
|
57
|
+
"_finalizers": [
|
|
58
|
+
Subscription {
|
|
59
|
+
"_finalizers": null,
|
|
60
|
+
"_parentage": [Circular],
|
|
61
|
+
"closed": false,
|
|
62
|
+
"initialTeardown": [Function],
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
"_parentage": null,
|
|
66
|
+
"closed": false,
|
|
67
|
+
"destination": ConsumerObserver {
|
|
68
|
+
"partialObserver": {
|
|
69
|
+
"complete": undefined,
|
|
70
|
+
"error": undefined,
|
|
71
|
+
"next": [Function],
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
"initialTeardown": undefined,
|
|
75
|
+
"isStopped": false,
|
|
76
|
+
},
|
|
77
|
+
SafeSubscriber {
|
|
78
|
+
"_finalizers": [
|
|
79
|
+
Subscription {
|
|
80
|
+
"_finalizers": null,
|
|
81
|
+
"_parentage": [Circular],
|
|
82
|
+
"closed": false,
|
|
83
|
+
"initialTeardown": [Function],
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
"_parentage": null,
|
|
87
|
+
"closed": false,
|
|
88
|
+
"destination": ConsumerObserver {
|
|
89
|
+
"partialObserver": {
|
|
90
|
+
"complete": undefined,
|
|
91
|
+
"error": undefined,
|
|
92
|
+
"next": [Function],
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
"initialTeardown": undefined,
|
|
96
|
+
"isStopped": false,
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
"thrownError": null,
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/>
|
|
103
|
+
}
|
|
21
104
|
contentContainerStyle={
|
|
22
105
|
{
|
|
23
106
|
"paddingBottom": undefined,
|
|
@@ -52,6 +135,12 @@ exports[`componentsMap renders renders components map correctly 1`] = `
|
|
|
52
135
|
getItemCount={[Function]}
|
|
53
136
|
initialNumToRender={3}
|
|
54
137
|
keyExtractor={[Function]}
|
|
138
|
+
maintainVisibleContentPosition={
|
|
139
|
+
{
|
|
140
|
+
"autoscrollToTopThreshold": 10,
|
|
141
|
+
"minIndexForVisible": 0,
|
|
142
|
+
}
|
|
143
|
+
}
|
|
55
144
|
maxToRenderPerBatch={10}
|
|
56
145
|
onContentSizeChange={[Function]}
|
|
57
146
|
onLayout={[Function]}
|
|
@@ -62,7 +151,7 @@ exports[`componentsMap renders renders components map correctly 1`] = `
|
|
|
62
151
|
onScrollEndDrag={[Function]}
|
|
63
152
|
overScrollMode="auto"
|
|
64
153
|
refreshControl={null}
|
|
65
|
-
removeClippedSubviews={
|
|
154
|
+
removeClippedSubviews={false}
|
|
66
155
|
renderItem={[Function]}
|
|
67
156
|
scrollEventThrottle={16}
|
|
68
157
|
scrollIndicatorInsets={
|
|
@@ -80,22 +169,14 @@ exports[`componentsMap renders renders components map correctly 1`] = `
|
|
|
80
169
|
style={null}
|
|
81
170
|
>
|
|
82
171
|
<View
|
|
172
|
+
onLayout={[Function]}
|
|
83
173
|
style={
|
|
84
174
|
{
|
|
85
|
-
"
|
|
175
|
+
"flex": 1,
|
|
86
176
|
}
|
|
87
177
|
}
|
|
88
178
|
>
|
|
89
|
-
<View
|
|
90
|
-
onLayout={[Function]}
|
|
91
|
-
style={
|
|
92
|
-
{
|
|
93
|
-
"flex": 1,
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
>
|
|
97
|
-
<View />
|
|
98
|
-
</View>
|
|
179
|
+
<View />
|
|
99
180
|
</View>
|
|
100
181
|
</View>
|
|
101
182
|
<View
|
|
@@ -103,23 +184,13 @@ exports[`componentsMap renders renders components map correctly 1`] = `
|
|
|
103
184
|
style={null}
|
|
104
185
|
>
|
|
105
186
|
<View
|
|
187
|
+
onLayout={[Function]}
|
|
106
188
|
style={
|
|
107
189
|
{
|
|
108
|
-
"
|
|
190
|
+
"flex": 1,
|
|
109
191
|
}
|
|
110
192
|
}
|
|
111
|
-
|
|
112
|
-
<View
|
|
113
|
-
onLayout={[Function]}
|
|
114
|
-
style={
|
|
115
|
-
{
|
|
116
|
-
"flex": 1,
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
>
|
|
120
|
-
<View />
|
|
121
|
-
</View>
|
|
122
|
-
</View>
|
|
193
|
+
/>
|
|
123
194
|
</View>
|
|
124
195
|
<View
|
|
125
196
|
onLayout={[Function]}
|
|
@@ -127,12 +198,16 @@ exports[`componentsMap renders renders components map correctly 1`] = `
|
|
|
127
198
|
<View
|
|
128
199
|
renderToHardwareTextureAndroid={true}
|
|
129
200
|
style={
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
201
|
+
[
|
|
202
|
+
{
|
|
203
|
+
"alignItems": "center",
|
|
204
|
+
"justifyContent": "center",
|
|
205
|
+
"width": "100%",
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"height": null,
|
|
209
|
+
},
|
|
210
|
+
]
|
|
136
211
|
}
|
|
137
212
|
>
|
|
138
213
|
<ActivityIndicator
|
|
@@ -1,89 +1,27 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`When River has a general_content type
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<RiverWithData
|
|
8
|
-
appData={
|
|
9
|
-
{
|
|
10
|
-
"layoutVersion": "v1",
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
dispatch={[Function]}
|
|
14
|
-
rivers={
|
|
15
|
-
{
|
|
16
|
-
"A1234": {
|
|
17
|
-
"home": true,
|
|
18
|
-
"id": "A1234",
|
|
19
|
-
"name": "foo",
|
|
20
|
-
"type": "general_content",
|
|
21
|
-
"ui_components": [
|
|
22
|
-
{
|
|
23
|
-
"component_type": "hero",
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"component_type": "grid",
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
},
|
|
30
|
-
"B4567": {
|
|
31
|
-
"id": "B4567",
|
|
32
|
-
},
|
|
33
|
-
"C0987": {
|
|
34
|
-
"home": false,
|
|
35
|
-
"id": "C0987",
|
|
36
|
-
"name": "Some-Screen-Plugin",
|
|
37
|
-
"type": "some-screen-plugin",
|
|
38
|
-
"ui_components": [],
|
|
39
|
-
},
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
screenId="A1234"
|
|
43
|
-
store={
|
|
44
|
-
{
|
|
45
|
-
"clearActions": [Function],
|
|
46
|
-
"dispatch": [Function],
|
|
47
|
-
"getActions": [Function],
|
|
48
|
-
"getState": [Function],
|
|
49
|
-
"replaceReducer": [Function],
|
|
50
|
-
"subscribe": [Function],
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/>
|
|
54
|
-
</ContextProvider>
|
|
55
|
-
`;
|
|
56
|
-
|
|
57
|
-
exports[`When River has a general_content type <RiverComponent /> renders correctly 1`] = `
|
|
58
|
-
<GeneralContentScreen
|
|
59
|
-
groupId="ZF-C4"
|
|
60
|
-
screenId="A1234"
|
|
61
|
-
/>
|
|
62
|
-
`;
|
|
63
|
-
|
|
64
|
-
exports[`When River has any other type other than general_content <RiverComponent /> renders correctly 1`] = `
|
|
65
|
-
<WithProvider
|
|
66
|
-
screenData={
|
|
3
|
+
exports[`When River has a general_content type renders River component correctly 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
onLayout={[Function]}
|
|
6
|
+
style={
|
|
67
7
|
{
|
|
68
|
-
"
|
|
69
|
-
"home": false,
|
|
70
|
-
"id": "C0987",
|
|
71
|
-
"name": "Some-Screen-Plugin",
|
|
72
|
-
"type": "some-screen-plugin",
|
|
73
|
-
"ui_components": [],
|
|
8
|
+
"flex": 1,
|
|
74
9
|
}
|
|
75
10
|
}
|
|
76
|
-
|
|
77
|
-
screenType="some-screen-plugin"
|
|
78
|
-
/>
|
|
79
|
-
`;
|
|
80
|
-
|
|
81
|
-
exports[`When River has feed url <RiverComponent /> renders correctly 1`] = `
|
|
82
|
-
<Connect(FeedLoaderComponent)
|
|
83
|
-
feedUrl="https://some-feed-url.net"
|
|
84
|
-
refreshCallback={[Function]}
|
|
85
|
-
refreshing={false}
|
|
11
|
+
testID="on-layout-view"
|
|
86
12
|
>
|
|
87
|
-
<
|
|
88
|
-
|
|
13
|
+
<View
|
|
14
|
+
style={
|
|
15
|
+
{
|
|
16
|
+
"display": "none",
|
|
17
|
+
"flex": 1,
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
>
|
|
21
|
+
<View
|
|
22
|
+
screenId="A1234"
|
|
23
|
+
testID="general-content-screen"
|
|
24
|
+
/>
|
|
25
|
+
</View>
|
|
26
|
+
</View>
|
|
89
27
|
`;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
-
import { cleanup } from "@testing-library/react-native";
|
|
2
|
+
import { cleanup, render } from "@testing-library/react-native";
|
|
4
3
|
import { Provider } from "react-redux";
|
|
5
4
|
import configureStore from "redux-mock-store";
|
|
6
5
|
|
|
@@ -183,12 +182,12 @@ describe("componentsMap", () => {
|
|
|
183
182
|
.spyOn(themeUtils, "useTheme")
|
|
184
183
|
.mockImplementation(() => () => theme);
|
|
185
184
|
|
|
186
|
-
const
|
|
185
|
+
const { toJSON } = render(
|
|
187
186
|
<Provider store={store}>
|
|
188
187
|
<ComponentsMap {...props} />
|
|
189
188
|
</Provider>
|
|
190
189
|
);
|
|
191
190
|
|
|
192
|
-
expect(
|
|
191
|
+
expect(toJSON()).toMatchSnapshot();
|
|
193
192
|
});
|
|
194
193
|
});
|
|
@@ -1,13 +1,50 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { shallowToJson } from "enzyme-to-json";
|
|
2
|
+
import { render, screen } from "@testing-library/react-native";
|
|
4
3
|
import configureStore from "redux-mock-store";
|
|
4
|
+
import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
5
|
+
import { Provider } from "react-redux";
|
|
5
6
|
|
|
6
|
-
import {
|
|
7
|
-
import { FeedLoader } from "../../FeedLoader";
|
|
8
|
-
import { River } from "../index";
|
|
9
|
-
import { RiverComponent } from "../River";
|
|
7
|
+
import { River } from "../";
|
|
10
8
|
import { ScreenResolver } from "../../ScreenResolver";
|
|
9
|
+
import { RiverComponent } from "../River";
|
|
10
|
+
|
|
11
|
+
jest.mock(
|
|
12
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useIsScreenActive",
|
|
13
|
+
() => ({
|
|
14
|
+
useIsScreenActive: jest.fn(() => true),
|
|
15
|
+
})
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
jest.mock(
|
|
19
|
+
"@applicaster/zapp-react-native-ui-components/Components/GeneralContentScreen",
|
|
20
|
+
() => {
|
|
21
|
+
const { View } = jest.requireActual("react-native");
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
GeneralContentScreen: (props) => (
|
|
25
|
+
<View testID="general-content-screen" {...props} />
|
|
26
|
+
),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
jest.mock(
|
|
32
|
+
"@applicaster/zapp-react-native-utils/analyticsUtils/helpers/hooks",
|
|
33
|
+
() => ({
|
|
34
|
+
useScreenAnalytics: jest.fn(),
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
jest.mock(
|
|
39
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation",
|
|
40
|
+
() => ({
|
|
41
|
+
useNavigation: jest.fn(() => ({
|
|
42
|
+
videoModalState: {
|
|
43
|
+
mode: "test",
|
|
44
|
+
},
|
|
45
|
+
})),
|
|
46
|
+
})
|
|
47
|
+
);
|
|
11
48
|
|
|
12
49
|
const river = {
|
|
13
50
|
home: true,
|
|
@@ -55,24 +92,24 @@ const appData = { layoutVersion: "v1" };
|
|
|
55
92
|
const store = configureStore()({ rivers, appData });
|
|
56
93
|
|
|
57
94
|
describe("When River has a general_content type", () => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
expect(wrapper.find(GeneralContentScreen).length).toBe(1);
|
|
67
|
-
});
|
|
95
|
+
it("renders GeneralContentScreen correctly", () => {
|
|
96
|
+
const { getByTestId } = render(
|
|
97
|
+
<Provider store={store}>
|
|
98
|
+
<RiverComponent {...riverProps} />
|
|
99
|
+
</Provider>
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
expect(getByTestId("general-content-screen")).toBeTruthy();
|
|
68
103
|
});
|
|
69
104
|
|
|
70
|
-
|
|
71
|
-
const wrapper =
|
|
105
|
+
it("renders River component correctly", () => {
|
|
106
|
+
const wrapper = render(
|
|
107
|
+
<Provider store={store}>
|
|
108
|
+
<River screenId="A1234" />
|
|
109
|
+
</Provider>
|
|
110
|
+
);
|
|
72
111
|
|
|
73
|
-
|
|
74
|
-
expect(shallowToJson(wrapper)).toMatchSnapshot();
|
|
75
|
-
});
|
|
112
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
76
113
|
});
|
|
77
114
|
});
|
|
78
115
|
|
|
@@ -83,16 +120,10 @@ describe("When River has any other type other than general_content", () => {
|
|
|
83
120
|
appData,
|
|
84
121
|
};
|
|
85
122
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
describe("<RiverComponent />", () => {
|
|
89
|
-
it("renders correctly", () => {
|
|
90
|
-
expect(shallowToJson(wrapper)).toMatchSnapshot();
|
|
91
|
-
});
|
|
123
|
+
it("renders ScreenResolver correctly", () => {
|
|
124
|
+
renderWithProviders(<RiverComponent {...riverPropsWithScreenPlugin} />);
|
|
92
125
|
|
|
93
|
-
|
|
94
|
-
expect(wrapper.find(ScreenResolver).length).toBe(1);
|
|
95
|
-
});
|
|
126
|
+
expect(screen.UNSAFE_getByType(ScreenResolver)).toBeDefined();
|
|
96
127
|
});
|
|
97
128
|
});
|
|
98
129
|
|
|
@@ -104,15 +135,19 @@ describe("When River has feed url", () => {
|
|
|
104
135
|
appData: { layoutVersion: "v1" },
|
|
105
136
|
};
|
|
106
137
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
138
|
+
it("renders FeedLoader when layout is v1", () => {
|
|
139
|
+
const wrapper = renderWithProviders(
|
|
140
|
+
<RiverComponent {...riverPropsWithFeedUrl} />,
|
|
141
|
+
{
|
|
142
|
+
zappPipes: {
|
|
143
|
+
"https://some-feed-url.net": {
|
|
144
|
+
loading: false,
|
|
145
|
+
data: { entry: [] },
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
expect(wrapper.getByTestId("general-content-screen")).toBeDefined();
|
|
117
152
|
});
|
|
118
153
|
});
|
|
@@ -12,11 +12,7 @@ const styles = StyleSheet.create({
|
|
|
12
12
|
|
|
13
13
|
export function TestId({ screenId, children }: Props) {
|
|
14
14
|
return (
|
|
15
|
-
<View
|
|
16
|
-
testID={screenId}
|
|
17
|
-
accessibilityLabel={screenId}
|
|
18
|
-
style={styles.container}
|
|
19
|
-
>
|
|
15
|
+
<View testID={screenId} style={styles.container}>
|
|
20
16
|
{children}
|
|
21
17
|
</View>
|
|
22
18
|
);
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`<RouteManager /> renders correctly 1`] = `
|
|
4
|
-
<
|
|
5
|
-
|
|
4
|
+
<View
|
|
5
|
+
style={
|
|
6
|
+
{
|
|
7
|
+
"flex": 1,
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
testID="A1234"
|
|
6
11
|
>
|
|
7
|
-
<
|
|
12
|
+
<View
|
|
8
13
|
pathname="/river/A1234"
|
|
9
14
|
screenData={
|
|
10
15
|
{
|
|
@@ -13,6 +18,7 @@ exports[`<RouteManager /> renders correctly 1`] = `
|
|
|
13
18
|
}
|
|
14
19
|
screenId="A1234"
|
|
15
20
|
screenType="river"
|
|
21
|
+
testID="screen-resolver"
|
|
16
22
|
/>
|
|
17
|
-
</
|
|
23
|
+
</View>
|
|
18
24
|
`;
|