@applicaster/quick-brick-core 14.0.0-alpha.3259144304 → 14.0.0-alpha.3471443312

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.
@@ -12,18 +12,18 @@ exports[`Actions Provider renders children 1`] = `
12
12
  "$$typeof": Symbol(react.context),
13
13
  "Consumer": {
14
14
  "$$typeof": Symbol(react.context),
15
+ "_calculateChangedBits": null,
15
16
  "_context": [Circular],
16
17
  },
17
18
  "Provider": {
18
19
  "$$typeof": Symbol(react.provider),
19
20
  "_context": [Circular],
20
21
  },
22
+ "_calculateChangedBits": null,
21
23
  "_currentRenderer": null,
22
24
  "_currentRenderer2": {},
23
25
  "_currentValue": null,
24
26
  "_currentValue2": null,
25
- "_defaultValue": null,
26
- "_globalName": null,
27
27
  "_threadCount": 0,
28
28
  },
29
29
  "contextProvider": [Function],
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import * as R from "ramda";
3
3
 
4
- import { connectToStore } from "@applicaster/zapp-react-native-redux";
4
+ import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
5
5
 
6
6
  import { ActionsProvider as ActionsProviderComponent } from "./ActionsProvider";
7
7
 
@@ -2,9 +2,9 @@ import * as React from "react";
2
2
  import { AppState, AppStateStatus } from "react-native";
3
3
  import * as R from "ramda";
4
4
 
5
- import { connectToStore } from "@applicaster/zapp-react-native-redux";
5
+ import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
6
6
  import { setAppState } from "@applicaster/zapp-react-native-redux/appState";
7
- import { Dispatch } from "redux";
7
+ import { Dispatch } from "@reduxjs/toolkit";
8
8
 
9
9
  type Props = {
10
10
  Component: () => React.ComponentType<any>;
@@ -16,7 +16,7 @@ import {
16
16
  } from "../useOpenSchemeHandler/const";
17
17
  import { withInitialPlayerState } from "../useOpenSchemeHandler/utils";
18
18
 
19
- import { log_warning } from "../../../logger";
19
+ const { log_warning } = require("../../../logger");
20
20
 
21
21
  const rivers: Record<string, Partial<ZappRiver>> = {
22
22
  A1234: {
@@ -53,10 +53,13 @@ const navigator = {
53
53
  replace: jest.fn(),
54
54
  push: jest.fn(),
55
55
  goHome: jest.fn(),
56
- } as any;
56
+ };
57
57
 
58
58
  const mockStore = configureStore();
59
- jest.spyOn(useNavigationHooks, "useNavigation").mockReturnValue(navigator);
59
+
60
+ jest
61
+ .spyOn(useNavigationHooks, "useNavigation")
62
+ .mockImplementation(() => navigator);
60
63
 
61
64
  const helperSpy = jest.spyOn(helpers, "handlePresentNavigation");
62
65
  const feedLoaderSpy = jest.spyOn(feedLoader, "useFeedLoader");
@@ -69,7 +72,7 @@ jest.doMock("@applicaster/zapp-react-native-ui-components/Contexts", () => ({
69
72
  },
70
73
  }));
71
74
 
72
- jest.mock("../../../logger", () => ({
75
+ jest.doMock("../../../logger", () => ({
73
76
  log_info: jest.fn(),
74
77
  log_error: jest.fn(),
75
78
  log_warning: jest.fn(),
@@ -77,6 +80,10 @@ jest.mock("../../../logger", () => ({
77
80
  log_debug: jest.fn(),
78
81
  }));
79
82
 
83
+ jest.useFakeTimers({
84
+ legacyFakeTimers: true,
85
+ });
86
+
80
87
  // to use import instead of require it's required to use jest.mock above
81
88
  const { useOpenSchemeHandler } = require("../useOpenSchemeHandler");
82
89
 
@@ -185,6 +192,7 @@ describe("useOpenSchemeHandler", () => {
185
192
  it("doesn't log a warning", async () => {
186
193
  const tests = () => {
187
194
  expect(log_warning).not.toHaveBeenCalled();
195
+ expect.assertions(1);
188
196
  };
189
197
 
190
198
  await testHook({ url, query, tests });
@@ -1,13 +1,13 @@
1
+ import * as React from "react";
1
2
  import * as R from "ramda";
2
3
  import axios from "axios";
3
- import { renderHook } from "@testing-library/react-native";
4
+ import { renderHook } from "@testing-library/react-hooks";
4
5
  import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
6
+
5
7
  import * as helpers from "../../../helpers";
6
8
  import * as feedLoader from "@applicaster/zapp-react-native-utils/reactHooks/feed/useFeedLoader";
7
- import * as useNavigationHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
8
- import { WrappedWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
9
- import { usePresentSchemeHandler } from "../usePresentSchemeHandler";
10
9
 
10
+ import { Provider } from "react-redux";
11
11
  import configureStore from "redux-mock-store";
12
12
 
13
13
  const rivers = {
@@ -16,24 +16,32 @@ const rivers = {
16
16
  },
17
17
  };
18
18
 
19
- const navigator = {
19
+ const mock_navigator = {
20
20
  currentRoute: "/river/A1234",
21
21
  replace: jest.fn(),
22
- goHome: jest.fn(),
23
- } as any;
22
+ };
24
23
 
25
- const mockStore = configureStore();
24
+ jest.mock(
25
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation",
26
+ () => ({
27
+ useNavigation: jest.fn(() => mock_navigator),
28
+ })
29
+ );
26
30
 
27
- jest.spyOn(useNavigationHooks, "useNavigation").mockReturnValue(navigator);
31
+ const mockStore = configureStore();
28
32
 
29
33
  const helperSpy = jest.spyOn(helpers, "handlePresentNavigation");
30
34
  const feedLoaderSpy = jest.spyOn(feedLoader, "useFeedLoader");
35
+ const storageSpy = jest.spyOn(sessionStorage, "getAllItems");
36
+ const axiosGetSpy = jest.spyOn(axios, "get");
37
+
38
+ const { usePresentSchemeHandler } = require("../usePresentSchemeHandler");
31
39
 
32
40
  const onFinish = jest.fn((cb) => {
33
41
  cb();
34
42
  });
35
43
 
36
- jest.useFakeTimers();
44
+ const navigator = mock_navigator;
37
45
 
38
46
  describe("usePresentSchemeHandler", () => {
39
47
  beforeEach(() => {
@@ -42,7 +50,11 @@ describe("usePresentSchemeHandler", () => {
42
50
  navigator.replace.mockClear();
43
51
  });
44
52
 
45
- const store = { test: "test", rivers };
53
+ const store = mockStore({ test: "test", rivers });
54
+
55
+ const wrapper: React.FC<any> = ({ children }) => (
56
+ <Provider store={store}>{children}</Provider>
57
+ );
46
58
 
47
59
  describe("loading link url", () => {
48
60
  const query = { link_url: "http://applicaster.com" };
@@ -53,11 +65,10 @@ describe("usePresentSchemeHandler", () => {
53
65
 
54
66
  it("opens the link entry", () => {
55
67
  renderHook(() => usePresentSchemeHandler({ query, url, onFinish }), {
56
- wrapper: WrappedWithProviders,
57
- initialProps: { store },
68
+ wrapper,
58
69
  });
59
70
 
60
- expect(onFinish).toHaveBeenCalled();
71
+ expect(onFinish).toBeCalled();
61
72
 
62
73
  expect(helperSpy).toBeCalledWith(
63
74
  expect.objectContaining({
@@ -91,8 +102,7 @@ describe("usePresentSchemeHandler", () => {
91
102
  onFinish,
92
103
  }),
93
104
  {
94
- wrapper: WrappedWithProviders,
95
- initialProps: { store },
105
+ wrapper,
96
106
  }
97
107
  );
98
108
 
@@ -119,8 +129,7 @@ describe("usePresentSchemeHandler", () => {
119
129
  )}&show_nav_bar=true`;
120
130
 
121
131
  renderHook(() => usePresentSchemeHandler({ query, url, onFinish }), {
122
- wrapper: WrappedWithProviders,
123
- initialProps: { store },
132
+ wrapper,
124
133
  });
125
134
 
126
135
  expect(onFinish).toBeCalled();
@@ -152,22 +161,22 @@ describe("usePresentSchemeHandler", () => {
152
161
  )}&screen_id=${screen_id}`;
153
162
 
154
163
  renderHook(() => usePresentSchemeHandler({ query, url, onFinish }), {
155
- wrapper: WrappedWithProviders,
156
- initialProps: { store },
164
+ wrapper,
157
165
  });
158
166
 
159
167
  expect(onFinish).toBeCalled();
160
168
 
161
- expect(helperSpy).toHaveBeenCalledWith(
169
+ expect(helperSpy).toBeCalledWith(
162
170
  expect.objectContaining({
163
171
  data: {
164
172
  id: "url_scheme_entry",
165
173
  type: { value: "link" },
174
+ screen_type: screen_id,
166
175
  link: { href: query.link_url, type: "text/html" },
167
176
  extensions: { showNavBar: false },
168
177
  },
169
- navigator: expect.anything(),
170
- pushScreen: "http://applicaster.com",
178
+ navigator,
179
+ pushScreen: expect.anything(),
171
180
  })
172
181
  );
173
182
  });
@@ -177,15 +186,14 @@ describe("usePresentSchemeHandler", () => {
177
186
  it("Re-sets app ready state and calls loadAppContextData with new river and cellStyles data", async () => {
178
187
  const store = mockStore({ test: "test" });
179
188
 
180
- const wrapper = WrappedWithProviders;
189
+ const wrapper: React.FC<any> = ({ children }) => (
190
+ <Provider store={store}>{children}</Provider>
191
+ );
181
192
 
182
193
  const query = {
183
194
  rivers_configuration_id: "test",
184
195
  };
185
196
 
186
- const storageSpy = jest.spyOn(sessionStorage, "getAllItems");
187
- const axiosGetSpy = jest.spyOn(axios, "get");
188
-
189
197
  const getAllItems = jest.fn().mockResolvedValue({
190
198
  accountsAccountId: "accountsAccountId",
191
199
  bundleIdentifier: "bundleIdentifier",
@@ -210,6 +218,8 @@ describe("usePresentSchemeHandler", () => {
210
218
  actions?.find(R.propEq("type", "SET_APP_NOT_READY"))
211
219
  ).toBeDefined();
212
220
 
221
+ expect(actions?.find(R.propEq("type", "SET_APP_READY"))).toBeDefined();
222
+
213
223
  expect(navigator.replace).toBeCalledWith({});
214
224
  };
215
225
  });
@@ -247,7 +257,7 @@ describe("usePresentSchemeHandler", () => {
247
257
  },
248
258
  }),
249
259
  {
250
- wrapper: WrappedWithProviders,
260
+ wrapper,
251
261
  }
252
262
  );
253
263
 
@@ -279,7 +289,7 @@ describe("usePresentSchemeHandler", () => {
279
289
  },
280
290
  }),
281
291
  {
282
- wrapper: WrappedWithProviders,
292
+ wrapper,
283
293
  }
284
294
  );
285
295
 
@@ -311,7 +321,7 @@ describe("usePresentSchemeHandler", () => {
311
321
  },
312
322
  }),
313
323
  {
314
- wrapper: WrappedWithProviders,
324
+ wrapper,
315
325
  }
316
326
  );
317
327
 
@@ -343,7 +353,7 @@ describe("usePresentSchemeHandler", () => {
343
353
  },
344
354
  }),
345
355
  {
346
- wrapper: WrappedWithProviders,
356
+ wrapper,
347
357
  }
348
358
  );
349
359
 
@@ -5,7 +5,7 @@ import * as URLHandlersMap from "..";
5
5
  import { Provider } from "react-redux";
6
6
  import configureStore from "redux-mock-store";
7
7
 
8
- import { log_warning } from "../../../logger";
8
+ const { log_warning } = require("../../../logger");
9
9
 
10
10
  const mockStore = configureStore();
11
11
 
@@ -1,4 +1,8 @@
1
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
1
+ import {
2
+ useAppSelector,
3
+ selectContentTypes,
4
+ selectRivers,
5
+ } from "@applicaster/zapp-react-native-redux";
2
6
  import { ZappPipesEntryContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
3
7
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
4
8
  import { useEffect } from "react";
@@ -97,7 +101,8 @@ async function handleQuery({
97
101
  }
98
102
 
99
103
  export function useOpenSchemeHandler({ query, url, onFinish }) {
100
- const { rivers, contentTypes } = usePickFromState(["rivers", "contentTypes"]);
104
+ const rivers = useAppSelector(selectRivers);
105
+ const contentTypes = useAppSelector(selectContentTypes);
101
106
  const navigator = useNavigation();
102
107
  const homeId = getHomeScreenId(rivers);
103
108
  const homeRoute = `/river/${homeId}`;
@@ -1,15 +1,17 @@
1
- import { useActions } from "@applicaster/zapp-react-native-redux/hooks";
1
+ import {
2
+ loadAppContextData,
3
+ useAppDispatch,
4
+ useActions,
5
+ } from "@applicaster/zapp-react-native-redux";
2
6
  import * as R from "ramda";
3
7
  import * as React from "react";
4
8
  import axios from "axios";
5
- import { useDispatch } from "react-redux";
6
9
 
7
10
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
8
11
 
9
12
  import { useFeedLoader } from "@applicaster/zapp-react-native-utils/reactHooks/feed/useFeedLoader";
10
13
 
11
14
  import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
12
- import { loadAppContextData } from "@applicaster/zapp-react-native-redux";
13
15
  import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
14
16
 
15
17
  import {
@@ -60,7 +62,7 @@ export function usePresentSchemeHandler({
60
62
 
61
63
  const rivers = useRivers();
62
64
  const screenRiver = findRiver({ screen_id, rivers });
63
- const dispatch = useDispatch();
65
+ const dispatch = useAppDispatch();
64
66
 
65
67
  const actions = useActions({
66
68
  setAppReady,
@@ -6,16 +6,16 @@ const theme = {
6
6
  app_background_color: "white",
7
7
  };
8
8
 
9
- const plugins = [];
10
-
11
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation");
9
+ jest.mock(
10
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation"
11
+ );
12
12
 
13
13
  jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
14
14
  useTheme: jest.fn(() => theme),
15
15
  }));
16
16
 
17
17
  jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
18
- usePickFromState: jest.fn(() => plugins),
18
+ usePickFromState: jest.fn(() => ({})),
19
19
  }));
20
20
 
21
21
  const { URLSchemeHandler } = require("../URLSchemeHandler");
@@ -1,5 +1,5 @@
1
1
  import * as R from "ramda";
2
- import { createSelector } from "reselect";
2
+ import { createSelector } from "@reduxjs/toolkit";
3
3
 
4
4
  import { getPathAttributes } from "@applicaster/zapp-react-native-utils/navigationUtils";
5
5
 
@@ -7,6 +7,7 @@ const riverSelector = R.prop("rivers");
7
7
  const pathnameSelector = R.prop("pathname");
8
8
  const navigationStackSelector = R.prop("stack");
9
9
 
10
+ // @TODO extract to zapp-react-native-redux/selectors, remove ramda
10
11
  export const homeRiverSelector = createSelector(
11
12
  riverSelector,
12
13
  R.compose(R.find(R.propEq("home", true)), R.values)
@@ -1,11 +1,15 @@
1
1
  import * as React from "react";
2
2
  import * as R from "ramda";
3
3
  import { renderHook, act } from "@testing-library/react-hooks";
4
+ import configureStore from "redux-mock-store";
5
+ import thunk from "redux-thunk";
4
6
  import { NetworkStatusContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NetworkStatusContext";
5
7
  import { NetworkStatusProvider } from "../NetworkStatusProvider";
6
- import { WrappedWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
8
+ import { Provider } from "react-redux";
7
9
  import NetInfo from "@react-native-community/netinfo";
8
10
 
11
+ const mockStore = configureStore([thunk]);
12
+
9
13
  const NetInfoMock = {
10
14
  type: "cellular",
11
15
  details: {
@@ -20,9 +24,9 @@ const NetInfoMock = {
20
24
  const getWrapper = (store) => ({
21
25
  // eslint-disable-next-line react/prop-types,react/display-name
22
26
  wrapper: ({ children }) => (
23
- <WrappedWithProviders store={store}>
27
+ <Provider store={store}>
24
28
  <NetworkStatusProvider>{children}</NetworkStatusProvider>
25
- </WrappedWithProviders>
29
+ </Provider>
26
30
  ),
27
31
  });
28
32
 
@@ -37,9 +41,9 @@ const useNetInfoMock = () => {
37
41
 
38
42
  describe("NetworkStatusProvider", function () {
39
43
  it("should return netInfoData", function () {
40
- const store = {
44
+ const store = mockStore({
41
45
  plugins: [{}],
42
- };
46
+ });
43
47
 
44
48
  // @ts-ignore
45
49
  jest.spyOn(NetInfo, "useNetInfo").mockImplementation(useNetInfoMock);
@@ -55,9 +59,9 @@ describe("NetworkStatusProvider", function () {
55
59
  it("should call onConnectionLost callback when connection type changes to none", function () {
56
60
  const onConnectionLost = jest.fn();
57
61
 
58
- const store = {
62
+ const store = mockStore({
59
63
  plugins: [{ module: { networkHooks: { onConnectionLost } } }],
60
- };
64
+ });
61
65
 
62
66
  // @ts-ignore
63
67
  jest.spyOn(NetInfo, "useNetInfo").mockImplementation(useNetInfoMock);
@@ -82,9 +86,9 @@ describe("NetworkStatusProvider", function () {
82
86
  it("should call onConnectionRestored callback when connection type switches from none", function () {
83
87
  const onConnectionRestored = jest.fn();
84
88
 
85
- const store = {
89
+ const store = mockStore({
86
90
  plugins: [{ module: { networkHooks: { onConnectionRestored } } }],
87
- };
91
+ });
88
92
 
89
93
  // @ts-ignore
90
94
  jest.spyOn(NetInfo, "useNetInfo").mockImplementation(useNetInfoMock);
@@ -119,9 +123,9 @@ describe("NetworkStatusProvider", function () {
119
123
  it("should call onConnectionTypeChanged callback when connection type changes", function () {
120
124
  const onConnectionTypeChanged = jest.fn();
121
125
 
122
- const store = {
126
+ const store = mockStore({
123
127
  plugins: [{ module: { networkHooks: { onConnectionTypeChanged } } }],
124
- };
128
+ });
125
129
 
126
130
  // @ts-ignore
127
131
  jest.spyOn(NetInfo, "useNetInfo").mockImplementation(useNetInfoMock);
@@ -1,9 +1,11 @@
1
1
  import * as React from "react";
2
2
  import * as ReactIs from "react-is";
3
3
  import { View, Text } from "react-native";
4
- import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
4
+ import { render } from "@testing-library/react-native";
5
+ import configureStore from "redux-mock-store";
5
6
 
6
7
  import { storeConnector } from "../index";
8
+ import { Provider } from "react-redux";
7
9
 
8
10
  const styles = { foo: "bar" };
9
11
  const components = { grid: jest.fn() };
@@ -16,12 +18,12 @@ const Component = (props) => (
16
18
  </View>
17
19
  );
18
20
 
19
- const store = {
21
+ const store = configureStore()({
20
22
  styles,
21
23
  components,
22
24
  rivers,
23
25
  appSettings,
24
- };
26
+ });
25
27
 
26
28
  describe("storeConnector", () => {
27
29
  it("returns a Component", () => {
@@ -39,9 +41,10 @@ describe("storeConnector", () => {
39
41
  it("passes the props to the component", () => {
40
42
  const WrappedComponent = storeConnector(Component);
41
43
 
42
- const { getByText, getByTestId } = renderWithProviders(
43
- <WrappedComponent />,
44
- store
44
+ const { getByText, getByTestId } = render(
45
+ <Provider store={store}>
46
+ <WrappedComponent />
47
+ </Provider>
45
48
  );
46
49
 
47
50
  expect(getByText("I'm a component")).toBeTruthy();
@@ -1,5 +1,5 @@
1
1
  import * as R from "ramda";
2
- import { connectToStore } from "@applicaster/zapp-react-native-redux";
2
+ import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
3
3
 
4
4
  const REDUX_STORE_PROPS = [
5
5
  "components",
@@ -42,9 +42,12 @@ jest.mock("../AppStateDecorator", () => ({
42
42
  withAppManager: (Comp) => Comp,
43
43
  }));
44
44
 
45
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
46
- useDimensions: jest.fn(() => ({ width: 375, height: 800 })),
47
- }));
45
+ jest.mock(
46
+ "@applicaster/zapp-react-native-utils/reactHooks/layout/useDimensions",
47
+ () => ({
48
+ useDimensions: jest.fn(() => ({ width: 375, height: 800 })),
49
+ })
50
+ );
48
51
 
49
52
  jest.mock("react-native", () => {
50
53
  const RNMock = jest.genMockFromModule("react-native");
@@ -1,8 +1,8 @@
1
1
  import * as React from "react";
2
2
  import { View, Text } from "react-native";
3
- import { render, waitFor } from "@testing-library/react-native";
4
- import thunk from "redux-thunk";
5
- import configureStore from "redux-mock-store";
3
+ import { waitFor } from "@testing-library/react-native";
4
+ import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
5
+ import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
6
6
 
7
7
  let mocked_items: Record<string, any> = {};
8
8
 
@@ -10,17 +10,11 @@ import { appLifeCycleManager } from "../";
10
10
 
11
11
  const mock_actions = {};
12
12
 
13
- jest.mock(
14
- "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage",
15
- () => ({
16
- sessionStorage: {
17
- getAllItems: jest.fn(() => Promise.resolve(mocked_items)),
18
- },
19
- })
20
- );
21
-
22
- jest.mock("@applicaster/zapp-react-native-redux/AppData", () => ({
23
- loadAppData: jest.fn(() => () => Promise.resolve()),
13
+ jest.mock("@applicaster/zapp-react-native-redux", () => ({
14
+ ...jest.requireActual("@applicaster/zapp-react-native-redux"),
15
+ AppData: {
16
+ loadAppData: jest.fn(() => () => Promise.resolve()),
17
+ },
24
18
  }));
25
19
 
26
20
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/actions", () => ({
@@ -31,6 +25,9 @@ jest.mock(
31
25
  "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage",
32
26
  () => ({
33
27
  localStorage: {
28
+ ...jest.requireActual(
29
+ "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage"
30
+ ).localStorage,
34
31
  getAllItems: jest.fn(() => Promise.resolve(mocked_items)),
35
32
  setItem: jest.fn((key, value) => {
36
33
  mocked_items[key] = JSON.stringify(value);
@@ -73,12 +70,8 @@ const appLoader = jest.fn((_dispatch, _getState) => {
73
70
  return Promise.resolve();
74
71
  });
75
72
 
76
- const store = configureStore([thunk])({});
77
- const dispatch = store.dispatch;
78
-
79
73
  const state = {
80
- rivers: {},
81
- plugins: {},
74
+ plugins: {} as QuickBrickPlugin[],
82
75
  appSettings: { runtimeConfigurationUrls: { rivers: "http://rivers.url" } },
83
76
  };
84
77
 
@@ -100,19 +93,16 @@ describe("appLifeCycleManager", () => {
100
93
  it("runs the loaders, then sends quickBrickReady event", async () => {
101
94
  const testCallback = jest.fn(() => {});
102
95
 
103
- render(
104
- <DecoratedComponent
105
- dispatch={dispatch}
106
- {...state}
107
- testCallback={testCallback}
108
- />
96
+ renderWithProviders(
97
+ <DecoratedComponent {...state} testCallback={testCallback} />,
98
+ state
109
99
  );
110
100
 
111
101
  await waitFor(() => {
112
102
  return expect(testCallback).toHaveBeenCalled();
113
103
  });
114
104
 
115
- const actions = store.getActions();
105
+ const actions = appStore.testStore.getActions();
116
106
 
117
107
  expect(actions[0]).toMatchObject({ type: "SET_APP_READY" });
118
108
 
@@ -126,16 +116,12 @@ describe("appLifeCycleManager", () => {
126
116
  it("sends the quickBrickReady event when a loader doesn't resolves", async () => {
127
117
  const testCallback = jest.fn(() => {});
128
118
 
129
- render(
130
- <DecoratedComponent
131
- dispatch={dispatch}
132
- {...state}
133
- shouldFail
134
- testCallback={testCallback}
135
- />
119
+ renderWithProviders(
120
+ <DecoratedComponent {...state} shouldFail testCallback={testCallback} />,
121
+ state
136
122
  );
137
123
 
138
- const actions = store.getActions();
124
+ const actions = appStore.testStore.getActions();
139
125
 
140
126
  await waitFor(() => {
141
127
  return expect(testCallback).toHaveBeenCalled();
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import * as R from "ramda";
3
3
 
4
4
  import { sendLaunchEvent } from "@applicaster/zapp-react-native-utils/analyticsUtils";
5
- import { loadAppData } from "@applicaster/zapp-react-native-redux/AppData";
5
+ import { AppData, useAppDispatch } from "@applicaster/zapp-react-native-redux";
6
6
  import {
7
7
  setAppLaunched,
8
8
  setAppReady,
@@ -13,7 +13,6 @@ import { networkStatusReady } from "../NetworkStatusProvider/networkStatusReady"
13
13
  import { updateSessionNumber } from "../SessionCounter/sessionCounter";
14
14
 
15
15
  import { coreAppLogger } from "../logger";
16
- import { Dispatch } from "@reduxjs/toolkit";
17
16
  import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
18
17
  import { isEmptyOrNil } from "@applicaster/zapp-react-native-utils/cellUtils";
19
18
  import { requiredSessionKeys } from "../../const";
@@ -24,7 +23,6 @@ const logger = coreAppLogger.addSubsystem("AppLifeCycleManager");
24
23
  const isAndroid = isAndroidPlatform();
25
24
 
26
25
  type Props = {
27
- dispatch: Dispatch;
28
26
  testCallback: () => void;
29
27
  plugins: QuickBrickPlugin[];
30
28
  appSettings: { runtimeConfigurationUrls: { [key in string]: string } };
@@ -35,6 +33,7 @@ export function appLifeCycleManager(appLoader, QuickBrickManager) {
35
33
  // this function is not called until React View is mounted to activity(ie quickBrickReady event sent)
36
34
  return function AppLifeCycleManagerRenderer(props: Props) {
37
35
  const actionsInitialStateSetters = useActionSetters();
36
+ const dispatch = useAppDispatch();
38
37
  // using useLayoutEffect to call the loader just after the DOM render to mimic componentDidMount timing
39
38
 
40
39
  async function setUpdateSessionNumber(results: unknown[]) {
@@ -93,7 +92,7 @@ export function appLifeCycleManager(appLoader, QuickBrickManager) {
93
92
  }
94
93
 
95
94
  function makeAppReady() {
96
- const { dispatch, testCallback } = props;
95
+ const { testCallback } = props;
97
96
 
98
97
  dispatch(setAppReady());
99
98
  dispatch(setAppLaunched());
@@ -153,14 +152,14 @@ export function appLifeCycleManager(appLoader, QuickBrickManager) {
153
152
 
154
153
  const prepareApp = async () => {
155
154
  // eslint-disable-next-line unused-imports/no-unused-vars
156
- const { dispatch, testCallback, ...state } = props;
155
+ const { testCallback, ...state } = props;
157
156
 
158
157
  try {
159
158
  const getState = () => state;
160
159
 
161
160
  const loaders = [
162
161
  appLoader(dispatch, getState),
163
- dispatch<any>(loadAppData()),
162
+ dispatch<any>(AppData.loadAppData()),
164
163
  networkStatusReady(),
165
164
  ];
166
165
 
@@ -1,10 +1,16 @@
1
- import * as ReduxModule from "@applicaster/zapp-react-native-redux";
2
1
  import nock from "nock";
3
2
 
4
3
  jest.mock("../../AssetCache", () => ({
5
4
  cacheAssets: jest.fn((x) => x),
6
5
  }));
7
6
 
7
+ const mockLoadAppContextData = jest.fn(() => ({}));
8
+
9
+ jest.mock("@applicaster/zapp-react-native-redux", () => ({
10
+ ...jest.requireActual("@applicaster/zapp-react-native-redux"),
11
+ loadAppContextData: mockLoadAppContextData,
12
+ }));
13
+
8
14
  const uuid = "342ee911-03b6-4a16-adde-ece5ef739feb";
9
15
 
10
16
  const { getRemoteContextData } = require("../getRemoteContextData");
@@ -100,11 +106,12 @@ const failingRuntimeConfigurationUrls = {
100
106
  remote_configurations_url: "http://zapp.com/failing.json",
101
107
  };
102
108
 
103
- let reduxLoaderSpy;
104
109
  const dispatch = jest.fn();
105
110
 
106
111
  describe("getRemoteContextData", () => {
107
112
  beforeEach(() => {
113
+ mockLoadAppContextData.mockClear();
114
+
108
115
  nock("http://zapp.com").persist().get("/layout.json").reply(200, layout);
109
116
 
110
117
  nock("http://zapp.com")
@@ -120,20 +127,12 @@ describe("getRemoteContextData", () => {
120
127
  nock("http://zapp.com")
121
128
  .get("/failing.json")
122
129
  .reply(Math.floor(Math.random() * 200 + 400), 0);
123
-
124
- reduxLoaderSpy = jest
125
- .spyOn(ReduxModule, "loadAppContextData")
126
- .mockImplementation(() => ({}));
127
- });
128
-
129
- afterEach(() => {
130
- reduxLoaderSpy.mockRestore();
131
130
  });
132
131
 
133
132
  it("returns a map of context data with the result of the matched urls", async () => {
134
133
  await getRemoteContextData(dispatch, runtimeConfigurationUrls, plugins);
135
134
 
136
- return expect(reduxLoaderSpy).toHaveBeenCalledWith(
135
+ return expect(mockLoadAppContextData).toHaveBeenCalledWith(
137
136
  dispatch,
138
137
  expect.objectContaining({
139
138
  pluginConfigurations,
@@ -147,7 +146,7 @@ describe("getRemoteContextData", () => {
147
146
  });
148
147
 
149
148
  it("skips the context data if it cannot be retrieved", async () => {
150
- expect(reduxLoaderSpy).not.toHaveBeenCalled();
149
+ expect(mockLoadAppContextData).not.toHaveBeenCalled();
151
150
 
152
151
  return expect(
153
152
  getRemoteContextData(dispatch, failingRuntimeConfigurationUrls, plugins)
@@ -1,12 +1,14 @@
1
1
  import * as R from "ramda";
2
2
  import isEmpty from "lodash/isEmpty";
3
3
  import { Dimensions, NativeModules } from "react-native";
4
- import { loadAppContextData } from "@applicaster/zapp-react-native-redux";
4
+ import {
5
+ loadAppContextData,
6
+ AppData,
7
+ } from "@applicaster/zapp-react-native-redux";
5
8
  import { isTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
6
9
  import { mapPromises } from "@applicaster/zapp-react-native-utils/arrayUtils";
7
10
  import { fetchPluginConfiguration, getPromiseForType } from "../helpers";
8
11
  import { cacheAssets } from "../../AssetCache";
9
- import { actions as appDataActions } from "@applicaster/zapp-react-native-redux/AppData";
10
12
  import { logger } from "@applicaster/zapp-react-native-utils/logger";
11
13
  import { ACTIVE_LAYOUT_ID_STORAGE_KEY } from "../consts";
12
14
  const { AppLoaderBridge } = NativeModules;
@@ -74,7 +76,7 @@ export async function getNativeRemoteContextData(
74
76
 
75
77
  const apiVersion = layout?.layout?.["api_version"]; // Taken from remote configuration
76
78
 
77
- dispatch(appDataActions.merge({ layoutVersion: apiVersion || "v1" }));
79
+ dispatch(AppData.actions.merge({ layoutVersion: apiVersion || "v1" }));
78
80
 
79
81
  const resolvedPromises = await mapPromises(getPromiseForType, ["cellStyles"]);
80
82
 
package/README.md CHANGED
@@ -42,10 +42,6 @@ Creates a Zapp App with the provided options :
42
42
  - `module`: the plugin's callable function / React component
43
43
  - `name`: the name of the plugin - should match the `PascalCase`'d identifier of the plugin. If your plugin's identifier is `react-native-article`, the name should be `ReactNativeArticle`
44
44
  - `type`: the type of the plugin, as it is defined in the plugin's manifest in Zapp
45
- - `reduxStoreOptions`: (optional)
46
- - `additionalReducers`: map of reducers to load in the redux store, on top of the existing ones. See available reducers' names to avoid name collision which would override your own custom reducers
47
- - `additionalMiddlewares`: array of additional middlewares to load - by default, the ZappApp will have the `thunk` middleware, but others can be added
48
- - `initialState`: optional initial state for the redux store
49
45
  - `pluginConfigurations`: the remote configuration options for plugins, as coming from Zapp
50
46
  - `remoteConfigurations`: Zapp's remote configurations
51
47
  - `appSettings`: arbitrary app settings which will be stored in the redux store.
@@ -12,9 +12,10 @@ import {
12
12
  isNotNil,
13
13
  } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
14
14
 
15
+ import { createZappReduxStore } from "@applicaster/zapp-react-native-redux/utils/createZappReduxStore";
15
16
  import {
16
- createZappReduxStore,
17
17
  loadAppContextData,
18
+ AppData,
18
19
  } from "@applicaster/zapp-react-native-redux";
19
20
 
20
21
  import { coreLogger } from "@applicaster/zapp-react-native-utils/logger";
@@ -26,7 +27,6 @@ import { Provider } from "react-redux";
26
27
  import { EmptyZappApp } from "../defaults";
27
28
  import { mergeUiComponentPlugins } from "../helpers";
28
29
  import { isTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
29
- import { actions as appDataActions } from "@applicaster/zapp-react-native-redux/AppData";
30
30
  import { remoteDataLoader } from "../App/appRemoteDataLoader/remoteDataLoader";
31
31
  import * as QuickBrickManager from "@applicaster/zapp-react-native-bridge/QuickBrick";
32
32
  import { isAndroidPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
@@ -51,7 +51,6 @@ export function createZappApp(zappAppConfig: ZappAppConfig) {
51
51
  remoteConfigurations = {},
52
52
  layout = {},
53
53
  tabletLayout = {},
54
- reduxStoreOptions = {},
55
54
  appSettings = {},
56
55
  ZappApp = EmptyZappApp,
57
56
  presetsMapping = {},
@@ -89,7 +88,7 @@ export function createZappApp(zappAppConfig: ZappAppConfig) {
89
88
  injectCorePlugins
90
89
  )(plugins);
91
90
 
92
- const store = createZappReduxStore(reduxStoreOptions);
91
+ const store = createZappReduxStore();
93
92
 
94
93
  const appComponents = mergeUiComponentPlugins(components, plugins);
95
94
 
@@ -113,7 +112,7 @@ export function createZappApp(zappAppConfig: ZappAppConfig) {
113
112
  // Handle case when layout is backed in as part of the environment, dev only
114
113
  // TODO: Handle it inside getNativeRemoteContextData
115
114
  store.dispatch(
116
- appDataActions.merge({
115
+ AppData.actions.merge({
117
116
  layoutVersion: layout?.api_version ? layout.api_version : "v1",
118
117
  })
119
118
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/quick-brick-core",
3
- "version": "14.0.0-alpha.3259144304",
3
+ "version": "14.0.0-alpha.3471443312",
4
4
  "description": "Core package for Applicaster's Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,13 +28,13 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "14.0.0-alpha.3259144304",
32
- "@applicaster/quick-brick-core-plugins": "14.0.0-alpha.3259144304",
33
- "@applicaster/zapp-pipes-v2-client": "14.0.0-alpha.3259144304",
34
- "@applicaster/zapp-react-native-bridge": "14.0.0-alpha.3259144304",
35
- "@applicaster/zapp-react-native-redux": "14.0.0-alpha.3259144304",
36
- "@applicaster/zapp-react-native-ui-components": "14.0.0-alpha.3259144304",
37
- "@applicaster/zapp-react-native-utils": "14.0.0-alpha.3259144304",
31
+ "@applicaster/applicaster-types": "14.0.0-alpha.3471443312",
32
+ "@applicaster/quick-brick-core-plugins": "14.0.0-alpha.3471443312",
33
+ "@applicaster/zapp-pipes-v2-client": "14.0.0-alpha.3471443312",
34
+ "@applicaster/zapp-react-native-bridge": "14.0.0-alpha.3471443312",
35
+ "@applicaster/zapp-react-native-redux": "14.0.0-alpha.3471443312",
36
+ "@applicaster/zapp-react-native-ui-components": "14.0.0-alpha.3471443312",
37
+ "@applicaster/zapp-react-native-utils": "14.0.0-alpha.3471443312",
38
38
  "atob": "^2.1.2",
39
39
  "axios": "^0.28.0",
40
40
  "btoa": "^1.2.1",
@@ -42,7 +42,7 @@
42
42
  "md5": "^2.3.0",
43
43
  "promise": "^8.3.0",
44
44
  "query-string": "7.1.3",
45
- "react-redux": "9.2.0",
45
+ "react-redux": "^7.2.1",
46
46
  "redux": "^4.0.4",
47
47
  "reselect": "^4.0.0",
48
48
  "url": "^0.11.0",
@@ -60,10 +60,9 @@
60
60
  "react": "*",
61
61
  "react-native": "*",
62
62
  "react-native-fs": "*",
63
- "react-native-gesture-handler": "*",
64
63
  "react-native-linear-gradient": "*",
64
+ "react-native-safe-area-context": "*",
65
65
  "react-native-svg": "*",
66
- "react-native-web": "*",
67
66
  "react-native-webview": "*",
68
67
  "uglify-js": "*",
69
68
  "validate-color": "*",