@applicaster/zapp-react-native-app 13.0.0-rc.13 → 13.0.0-rc.130

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.
@@ -9,6 +9,7 @@ import {
9
9
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
10
10
  import { useAnalytics } from "@applicaster/zapp-react-native-utils/analyticsUtils";
11
11
  import { useRivers } from "@applicaster/zapp-react-native-utils/reactHooks/state";
12
+ import { useErrorStore } from "@applicaster/quick-brick-core/App/ErrorBoundary/store";
12
13
 
13
14
  const getHome = R.compose(R.find(R.propEq("home", true)), R.values);
14
15
 
@@ -32,6 +33,11 @@ const InteractionManagerComponent = () => {
32
33
 
33
34
  const goToHome = () => {
34
35
  const home = getHome(rivers);
36
+
37
+ if (!home) {
38
+ throw new Error("Could not find home screen");
39
+ }
40
+
35
41
  navigator.replace(home);
36
42
  };
37
43
 
@@ -40,7 +46,16 @@ const InteractionManagerComponent = () => {
40
46
  if (isHomeScreen()) {
41
47
  exitToBackground();
42
48
  } else {
43
- goToHome();
49
+ try {
50
+ goToHome();
51
+ } catch (e) {
52
+ const errorMessage = "Can't find home screen";
53
+ const error = new Error(errorMessage);
54
+
55
+ useErrorStore
56
+ .getState()
57
+ .setError(error, "Failed navigating to home screen", false);
58
+ }
44
59
  }
45
60
  } else {
46
61
  sendHardwareBackButtonClickEvent({ navigator });
@@ -4,8 +4,8 @@ exports[`Layout should match snapshot when appReady is true 1`] = `
4
4
  <RNCSafeAreaProvider
5
5
  onInsetsChange={[Function]}
6
6
  style={
7
- Array [
8
- Object {
7
+ [
8
+ {
9
9
  "flex": 1,
10
10
  },
11
11
  undefined,
@@ -13,85 +13,66 @@ exports[`Layout should match snapshot when appReady is true 1`] = `
13
13
  }
14
14
  >
15
15
  <View
16
- onLayout={[Function]}
17
16
  style={
18
- Object {
19
- "flex": 1,
17
+ {
18
+ "height": "100%",
20
19
  }
21
20
  }
22
- testID="on-layout-view"
23
21
  >
24
22
  <View
25
- style={
26
- Object {
27
- "display": "none",
28
- "flex": 1,
23
+ contentStyle={
24
+ {
25
+ "height": "100%",
26
+ "opacity": 1,
27
+ "paddingBottom": 50,
29
28
  }
30
29
  }
30
+ isRTL={false}
31
+ testID="transitioner"
32
+ transitionConfig={[Function]}
31
33
  >
32
34
  <View
33
- style={
34
- Object {
35
- "height": "100%",
36
- }
37
- }
38
- >
39
- <View
40
- contentStyle={
41
- Object {
42
- "height": "100%",
43
- "opacity": 1,
44
- "paddingBottom": 50,
45
- }
46
- }
47
- isRTL={false}
48
- testID="transitioner"
49
- transitionConfig={[Function]}
50
- >
51
- <View
52
- pathname="home"
53
- screenData={Object {}}
54
- />
55
- </View>
56
- </View>
57
- <View
58
- bottomTabBarHeight={50}
59
- closeMenu={[MockFunction]}
60
- dimensions={
61
- Object {
62
- "window": Object {
63
- "height": 100,
64
- "width": 100,
65
- },
66
- }
67
- }
68
- id="home"
69
- isRTL={false}
70
- navigator={
71
- Object {
72
- "activeRiver": Object {
73
- "navigations": Array [],
74
- },
75
- "currentRoute": "home",
76
- "data": Object {},
77
- "isVideoModalDocked": false,
78
- "videoModalState": Object {
79
- "mode": "MINIMIZED",
80
- "visible": false,
81
- },
82
- }
83
- }
84
- openMenu={[MockFunction]}
85
- setCloseMenu={[MockFunction]}
86
- setOpenMenu={[MockFunction]}
87
- setToggleMenu={[MockFunction]}
88
- testID="menu"
89
- toggleMenu={[MockFunction]}
90
- />
91
- <View
92
- testID="zappHooksModal"
35
+ pathname="home"
36
+ screenData={{}}
93
37
  />
94
38
  </View>
95
39
  </View>
40
+ <View
41
+ bottomTabBarHeight={50}
42
+ closeMenu={[MockFunction]}
43
+ dimensions={
44
+ {
45
+ "window": {
46
+ "height": 100,
47
+ "width": 100,
48
+ },
49
+ }
50
+ }
51
+ id="home"
52
+ isRTL={false}
53
+ navigator={
54
+ {
55
+ "activeRiver": {
56
+ "navigations": [],
57
+ },
58
+ "currentRoute": "home",
59
+ "data": {},
60
+ "isVideoModalDocked": false,
61
+ "videoModalState": {
62
+ "mode": "MINIMIZED",
63
+ "visible": false,
64
+ },
65
+ }
66
+ }
67
+ openMenu={[MockFunction]}
68
+ setCloseMenu={[MockFunction]}
69
+ setOpenMenu={[MockFunction]}
70
+ setToggleMenu={[MockFunction]}
71
+ testID="menu"
72
+ toggleMenu={[MockFunction]}
73
+ />
74
+ <View
75
+ testID="zappHooksModal"
76
+ />
96
77
  </RNCSafeAreaProvider>
97
78
  `;
@@ -1,5 +1,4 @@
1
1
  import React from "react";
2
- import { View } from "react-native";
3
2
  import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
4
3
 
5
4
  const mockUseMenuToggleContext = jest.fn(() => ({
@@ -11,25 +10,39 @@ const mockUseMenuToggleContext = jest.fn(() => ({
11
10
  setCloseMenu: jest.fn(),
12
11
  }));
13
12
 
14
- jest.mock("../layoutHelpers", () => ({
15
- // eslint-disable-next-line react/display-name
16
- getNavigationPluginModule: () => (props) => <View testID="menu" {...props} />,
17
- }));
13
+ jest.mock("../layoutHelpers", () => {
14
+ const { View } = jest.requireActual("react-native");
15
+
16
+ return {
17
+ // eslint-disable-next-line react/display-name
18
+ getNavigationPluginModule: () => (props) => (
19
+ <View testID="menu" {...props} />
20
+ ),
21
+ };
22
+ });
18
23
 
19
24
  jest.mock(
20
25
  "@applicaster/zapp-react-native-ui-components/Components/Transitioner",
21
- () => ({
22
- // eslint-disable-next-line react/display-name
23
- Transitioner: (props) => <View testID="transitioner" {...props} />,
24
- })
26
+ () => {
27
+ const { View } = jest.requireActual("react-native");
28
+
29
+ return {
30
+ // eslint-disable-next-line react/display-name
31
+ Transitioner: (props) => <View testID="transitioner" {...props} />,
32
+ };
33
+ }
25
34
  );
26
35
 
27
36
  jest.mock(
28
37
  "@applicaster/zapp-react-native-ui-components/Components/Screen",
29
- () => ({
30
- // eslint-disable-next-line react/display-name
31
- Screen: (props) => <View {...props} />,
32
- })
38
+ () => {
39
+ const { View } = jest.requireActual("react-native");
40
+
41
+ return {
42
+ // eslint-disable-next-line react/display-name
43
+ Screen: (props) => <View {...props} />,
44
+ };
45
+ }
33
46
  );
34
47
 
35
48
  jest.mock(
@@ -48,12 +61,12 @@ jest.mock(
48
61
  })
49
62
  );
50
63
 
51
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
52
- ...(jest.requireActual(
53
- "@applicaster/zapp-react-native-utils/reactHooks/navigation"
54
- ) as {}),
55
- useGetBottomTabBarHeight: jest.fn(() => 50),
56
- }));
64
+ jest.mock(
65
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useGetBottomTabBarHeight",
66
+ () => ({
67
+ useGetBottomTabBarHeight: jest.fn(() => 50),
68
+ })
69
+ );
57
70
 
58
71
  jest.mock(
59
72
  "@applicaster/zapp-react-native-utils/reactHooks/layout/useDimensions",
@@ -74,17 +87,25 @@ jest.mock("@applicaster/zapp-react-native-utils/localizationUtils", () => ({
74
87
  }));
75
88
 
76
89
  jest.mock(
77
- "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/ModalAnimationContext",
90
+ "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation",
91
+ () => ({
92
+ withModalAnimationProvider: jest.fn((Component) => Component),
93
+ })
94
+ );
95
+
96
+ jest.mock(
97
+ "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/useModalAnimationContext",
78
98
  () => ({
79
- ...(jest.requireActual(
80
- "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/ModalAnimationContext"
81
- ) as {}),
82
99
  useModalAnimationContext: jest.fn(() => ({
83
100
  isActiveGesture: false,
84
101
  })),
85
102
  })
86
103
  );
87
104
 
105
+ jest.mock("@applicaster/zapp-react-native-utils/dimensionsProvider", () => ({
106
+ withDimensionsProvider: jest.fn((Component) => Component),
107
+ }));
108
+
88
109
  jest.mock(
89
110
  "@applicaster/zapp-react-native-ui-components/Components/Screen/navigationHandler",
90
111
  () => ({
@@ -94,18 +115,26 @@ jest.mock(
94
115
 
95
116
  jest.mock(
96
117
  "@applicaster/zapp-react-dom-ui-components/Components/ZappHooksModal",
97
- () => ({
98
- // eslint-disable-next-line react/display-name
99
- ZappHooksModal: (props) => <View testID="zappHooksModal" {...props} />,
100
- })
118
+ () => {
119
+ const { View } = jest.requireActual("react-native");
120
+
121
+ return {
122
+ // eslint-disable-next-line react/display-name
123
+ ZappHooksModal: (props) => <View testID="zappHooksModal" {...props} />,
124
+ };
125
+ }
101
126
  );
102
127
 
103
128
  jest.mock(
104
129
  "@applicaster/zapp-react-native-ui-components/Components/VideoModal",
105
- () => ({
106
- // eslint-disable-next-line react/display-name
107
- VideoModal: (props) => <View testID="videoModal" {...props} />,
108
- })
130
+ () => {
131
+ const { View } = jest.requireActual("react-native");
132
+
133
+ return {
134
+ // eslint-disable-next-line react/display-name
135
+ VideoModal: (props) => <View testID="videoModal" {...props} />,
136
+ };
137
+ }
109
138
  );
110
139
 
111
140
  jest.mock("@applicaster/zapp-react-native-utils/navigationUtils", () => ({
@@ -118,6 +147,16 @@ jest.mock("@applicaster/zapp-react-native-utils/navigationUtils", () => ({
118
147
  const { Layout } = require("../");
119
148
 
120
149
  describe("Layout", () => {
150
+ beforeAll(() => {
151
+ mockUseNavigation.mockImplementation(() => ({
152
+ activeRiver: { navigations: [] },
153
+ videoModalState: { visible: false, mode: "MINIMIZED" },
154
+ isVideoModalDocked: false,
155
+ currentRoute: "home",
156
+ data: {},
157
+ }));
158
+ });
159
+
121
160
  beforeEach(() => {
122
161
  jest.clearAllMocks();
123
162
 
@@ -132,6 +171,7 @@ describe("Layout", () => {
132
171
 
133
172
  it("should match snapshot when appReady is true", () => {
134
173
  const { toJSON } = renderWithProviders(<Layout />);
174
+
135
175
  expect(toJSON()).toMatchSnapshot();
136
176
  });
137
177
 
@@ -147,8 +187,8 @@ describe("Layout", () => {
147
187
  });
148
188
 
149
189
  it("should render menu when showMenu is true", () => {
150
- const { getByTestId } = renderWithProviders(<Layout />);
151
- expect(getByTestId("menu")).toBeTruthy();
190
+ const { queryByTestId } = renderWithProviders(<Layout />);
191
+ expect(queryByTestId("menu")).toBeTruthy();
152
192
  });
153
193
 
154
194
  it("should render VideoModal when visible & VideoModal is true", () => {
@@ -180,9 +220,9 @@ describe("Layout", () => {
180
220
 
181
221
  const { getByTestId } = renderWithProviders(<Layout />);
182
222
 
183
- expect(getByTestId("transitioner").props.contentStyle.paddingBottom).toBe(
184
- 50
185
- );
223
+ return expect(
224
+ getByTestId("transitioner").props.contentStyle.paddingBottom
225
+ ).toBe(50);
186
226
  });
187
227
 
188
228
  it("transitioner should have contentStyle with specific styles", () => {
@@ -24,15 +24,13 @@ import { isMenuVisible } from "@applicaster/zapp-react-native-ui-components/Comp
24
24
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
25
25
 
26
26
  import {
27
- useMenuToggleContext,
28
27
  MenuToggleContextType,
28
+ useMenuToggleContext,
29
29
  } from "@applicaster/zapp-react-native-ui-components/Contexts/MenuToggleContext";
30
30
  import { VideoModal } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal";
31
31
  import { withDimensionsProvider } from "@applicaster/zapp-react-native-utils/dimensionsProvider";
32
- import {
33
- withModalAnimationProvider,
34
- useModalAnimationContext,
35
- } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
32
+ import { withModalAnimationProvider } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
33
+ import { useModalAnimationContext } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/useModalAnimationContext";
36
34
 
37
35
  import { ZappHooksModal } from "@applicaster/zapp-react-dom-ui-components/Components/ZappHooksModal";
38
36
  import { useListenEventBusEvent } from "@applicaster/zapp-react-native-utils/reactHooks/useListenEventBusEvent";
@@ -181,7 +179,7 @@ const LayoutWithMenu = () => {
181
179
  </Transitioner>
182
180
  </View>
183
181
  ) : null}
184
- {showMenu && (
182
+ {showMenu ? (
185
183
  <Menu
186
184
  {...menuProps}
187
185
  setToggleMenu={setToggleMenu}
@@ -191,9 +189,9 @@ const LayoutWithMenu = () => {
191
189
  closeMenu={closeMenu}
192
190
  setCloseMenu={setCloseMenu}
193
191
  />
194
- )}
192
+ ) : null}
195
193
  {/* depends on active river. @TODO move below screen context */}
196
- {VideoModal && videoModalState.visible && <VideoModal />}
194
+ {VideoModal && videoModalState.visible ? <VideoModal /> : null}
197
195
  <ZappHooksModal />
198
196
  </>
199
197
  );
@@ -1,51 +1,3 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`<ZappApp /> renders correctly 1`] = `
4
- <ContextProvider
5
- value={null}
6
- >
7
- <WithContextProviderComponent
8
- appSettings={
9
- Object {
10
- "runtimeConfigurationUrls": Object {
11
- "cell_styles_url": "http://zapp.com/cell_styles.json",
12
- },
13
- }
14
- }
15
- components={
16
- Object {
17
- "AppContainer": [Function],
18
- "Screen": [Function],
19
- }
20
- }
21
- dispatch={[Function]}
22
- rivers={
23
- Array [
24
- Object {
25
- "home": false,
26
- "id": "1",
27
- },
28
- Object {
29
- "home": true,
30
- "id": 2,
31
- },
32
- ]
33
- }
34
- store={
35
- Object {
36
- "clearActions": [Function],
37
- "dispatch": [Function],
38
- "getActions": [Function],
39
- "getState": [Function],
40
- "replaceReducer": [Function],
41
- "subscribe": [Function],
42
- }
43
- }
44
- styles={
45
- Object {
46
- "color": "blue",
47
- }
48
- }
49
- />
50
- </ContextProvider>
51
- `;
3
+ exports[`<ZappApp /> renders correctly 1`] = `null`;
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
- import { shallow } from "enzyme";
3
- import { shallowToJson } from "enzyme-to-json";
2
+ import { render } from "@testing-library/react-native";
4
3
  import configureStore from "redux-mock-store";
5
4
  import * as R from "ramda";
6
5
 
@@ -8,7 +7,7 @@ const MockNetInfo = {
8
7
  connection: { type: "none " },
9
8
  };
10
9
 
11
- class NativeEventEmitter {
10
+ class mockNativeEventEmitter {
12
11
  constructor(eventEmitter) {
13
12
  this.eventEmitter = eventEmitter;
14
13
  this.listeners = [];
@@ -98,7 +97,7 @@ jest.mock("react-native", () => {
98
97
  },
99
98
  UIManager: {},
100
99
  },
101
- NativeEventEmitter: NativeEventEmitter,
100
+ NativeEventEmitter: mockNativeEventEmitter,
102
101
  Easing: {
103
102
  in: jest.fn(),
104
103
  bezier: jest.fn(),
@@ -111,13 +110,9 @@ jest.mock("react-native", () => {
111
110
  };
112
111
  });
113
112
 
114
- jest.mock("react-native-svg", () => {
115
- const SvgXml = (props) => <View {...props} mock="SvgXml" />;
116
-
117
- return { SvgXml };
118
- });
119
-
120
113
  jest.mock("react-native-webview", () => {
114
+ const { View } = jest.requireActual("react-native");
115
+
121
116
  return {
122
117
  WebView: jest.fn(() => <View mock="react-native-webview" />),
123
118
  };
@@ -133,7 +128,8 @@ const store = configureStore()({});
133
128
  const Screen = () => <View />;
134
129
  Screen.displayName = "Screen";
135
130
 
136
- const AppContainer = ({ children }: any) => <View>{children(dimensions)}</View>;
131
+ // eslint-disable-next-line react/prop-types
132
+ const AppContainer = ({ children }) => <View>{children(dimensions)}</View>;
137
133
  AppContainer.displayName = "AppContainer";
138
134
 
139
135
  const runtimeConfigurationUrls = {
@@ -156,10 +152,10 @@ const zappAppProps = {
156
152
  dispatch: jest.fn(),
157
153
  };
158
154
 
159
- describe("<ZappApp />", () => {
155
+ // not clear the purpose of this test
156
+ describe.skip("<ZappApp />", () => {
160
157
  it("renders correctly", () => {
161
- const wrapper = shallow(<ZappApp {...zappAppProps} store={store} />);
162
-
163
- expect(shallowToJson(wrapper)).toMatchSnapshot();
158
+ const { toJSON } = render(<ZappApp {...zappAppProps} store={store} />);
159
+ expect(toJSON()).toMatchSnapshot();
164
160
  });
165
161
  });
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-app",
3
- "version": "13.0.0-rc.13",
3
+ "version": "13.0.0-rc.130",
4
4
  "description": "Zapp App Component for Applicaster's Quick Brick React Native App",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "jest -w=2",
8
7
  "build": "echo 'skipping ts build for core packages'"
9
8
  },
10
9
  "repository": {
@@ -28,11 +27,11 @@
28
27
  },
29
28
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
29
  "dependencies": {
31
- "@applicaster/quick-brick-core": "13.0.0-rc.13",
32
- "@applicaster/zapp-react-native-bridge": "13.0.0-rc.13",
33
- "@applicaster/zapp-react-native-redux": "13.0.0-rc.13",
34
- "@applicaster/zapp-react-native-ui-components": "13.0.0-rc.13",
35
- "@applicaster/zapp-react-native-utils": "13.0.0-rc.13",
30
+ "@applicaster/quick-brick-core": "13.0.0-rc.130",
31
+ "@applicaster/zapp-react-native-bridge": "13.0.0-rc.130",
32
+ "@applicaster/zapp-react-native-redux": "13.0.0-rc.130",
33
+ "@applicaster/zapp-react-native-ui-components": "13.0.0-rc.130",
34
+ "@applicaster/zapp-react-native-utils": "13.0.0-rc.130",
36
35
  "axios": "^0.28.0",
37
36
  "camelize": "^1.0.0",
38
37
  "query-string": "7.1.3",
@@ -40,8 +39,27 @@
40
39
  "url": "^0.11.0"
41
40
  },
42
41
  "peerDependencies": {
43
- "react": "17.0.2",
44
- "react-native": "0.68.6"
42
+ "@applicaster/blur": "*",
43
+ "@applicaster/quick-brick-xray": "*",
44
+ "@applicaster/zapp-pipes-v2-client": "*",
45
+ "@applicaster/zapp-react-dom-ui-components": "*",
46
+ "@applicaster/zapp-react-native-tvos-app": "*",
47
+ "@applicaster/zapp-react-native-tvos-ui-components": "*",
48
+ "@babel/runtime": "*",
49
+ "@react-native-community/netinfo": "*",
50
+ "immer": "*",
51
+ "react": "*",
52
+ "react-native": "*",
53
+ "react-native-fs": "*",
54
+ "react-native-gesture-handler": "*",
55
+ "react-native-linear-gradient": "*",
56
+ "react-native-safe-area-context": "*",
57
+ "react-native-svg": "*",
58
+ "react-native-web": "*",
59
+ "react-native-webview": "*",
60
+ "uglify-js": "*",
61
+ "validate-color": "*",
62
+ "zustand": "*"
45
63
  },
46
64
  "devDependencies": {
47
65
  "nock": "^10.0.0",