@applicaster/quick-brick-core 13.0.0-alpha.6095951301 → 13.0.0-alpha.6179233127

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.
Files changed (27) hide show
  1. package/App/DeepLinking/URLSchemeListener/URLSchemeContextProvider.tsx +14 -7
  2. package/App/DeepLinking/URLSchemeListener/__tests__/URLSchemeListener.test.js +40 -0
  3. package/App/DeepLinking/URLSchemeListener/index.tsx +1 -1
  4. package/App/ErrorBoundary/__tests__/errorBoundary.test.js +20 -37
  5. package/App/LoadingOverlay/LoadingOverlayManager.tsx +27 -0
  6. package/App/LoadingOverlay/index.tsx +49 -0
  7. package/App/LoadingOverlay/useLoadingOverlayVisibility.tsx +18 -0
  8. package/App/ModalProvider/ModalBottomSheet/index.tsx +4 -2
  9. package/App/ModalProvider/index.tsx +3 -4
  10. package/App/NavigationProvider/NavigationProvider.tsx +27 -0
  11. package/App/NetworkStatusProvider/utils.ts +0 -1
  12. package/App/StoreConnector/__tests__/storeConnector.test.js +17 -11
  13. package/App/appLifeCycleManager/__tests__/appLifeCycleManager.test.tsx +146 -0
  14. package/App/appLifeCycleManager/index.tsx +6 -7
  15. package/App/index.tsx +2 -0
  16. package/App/remoteContextReloader/__tests__/remoteContextReloader.test.js +11 -21
  17. package/createZappApp/__tests__/__snapshots__/createZappApp.test.js.snap +5 -128
  18. package/createZappApp/__tests__/createZappApp.test.js +7 -20
  19. package/defaults/__tests__/defaults.test.js +3 -4
  20. package/index.d.ts +1 -1
  21. package/package.json +10 -13
  22. package/App/DeepLinking/URLSchemeListener/__tests__/URLSchemeListenerTest.js +0 -177
  23. package/App/ErrorBoundary/__tests__/__snapshots__/errorBoundary.test.js.snap +0 -9
  24. package/App/StoreConnector/__tests__/__snapshots__/storeConnector.test.js.snap +0 -35
  25. package/App/appLifeCycleManager/__tests__/__snapshots__/appLifeCycleManager.test.js.snap +0 -30
  26. package/App/appLifeCycleManager/__tests__/appLifeCycleManager.test.js +0 -134
  27. package/App/remoteContextReloader/__tests__/__snapshots__/remoteContextReloader.test.js.snap +0 -43
@@ -11,7 +11,10 @@ import * as ReactNative from "react-native";
11
11
  import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
12
12
  import { log_debug, log_error, log_info } from "../logger";
13
13
  import { getAppUrlScheme } from "@applicaster/zapp-react-native-utils/appDataUtils";
14
-
14
+ import {
15
+ getZappPlatform,
16
+ ZappPlatform,
17
+ } from "@applicaster/zapp-react-native-utils/appUtils/platform";
15
18
  type Props = {
16
19
  listenerSpy?: (...any) => void;
17
20
  children: ReactChild;
@@ -36,6 +39,8 @@ const initialState = { url: null, done: () => {} };
36
39
  export const URLSchemeContext = createContext<State>(initialState);
37
40
 
38
41
  const getWebDeepLink = (initialURL: string) => {
42
+ if (!initialURL) return null;
43
+
39
44
  const index = initialURL.indexOf("?");
40
45
  if (index === -1) return;
41
46
 
@@ -62,14 +67,16 @@ function URLSchemeContextProvider(props: Props) {
62
67
  const url = await Linking.getInitialURL();
63
68
 
64
69
  if (isWeb()) {
65
- const deepLink = getWebDeepLink(url);
70
+ if (getZappPlatform() === ZappPlatform.Vizio) {
71
+ const deepLink = getWebDeepLink(url);
66
72
 
67
- if (deepLink) {
68
- log_info(
69
- `URLSchemeContextProvider: Retrieved initial deep link: ${deepLink}`
70
- );
73
+ if (deepLink) {
74
+ log_info(
75
+ `URLSchemeContextProvider: Retrieved initial deep link: ${deepLink}`
76
+ );
71
77
 
72
- return setState(deepLink);
78
+ return setState(deepLink);
79
+ }
73
80
  }
74
81
 
75
82
  return;
@@ -0,0 +1,40 @@
1
+ import * as React from "react";
2
+ import { View, Text } from "react-native";
3
+ import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
4
+
5
+ import { URLSchemeListener } from "../index";
6
+
7
+ const TestComponent = (props) => (
8
+ <View testID="test-comp" {...props}>
9
+ <Text>I'm a test component</Text>
10
+ </View>
11
+ );
12
+
13
+ const navigator = {
14
+ push: jest.fn(),
15
+ replace: jest.fn(),
16
+ };
17
+
18
+ jest.spyOn(console, "warn").mockImplementation(() => jest.fn());
19
+
20
+ function clearMocks() {
21
+ navigator.push.mockClear();
22
+ navigator.replace.mockClear();
23
+ console.warn.mockClear();
24
+ }
25
+
26
+ describe("URLSchemeHandler", () => {
27
+ const renderComponent = (props = {}) =>
28
+ renderWithProviders(
29
+ <URLSchemeListener {...props}>
30
+ <TestComponent />
31
+ </URLSchemeListener>
32
+ );
33
+
34
+ beforeEach(clearMocks);
35
+
36
+ it("renders correctly (default case)", () => {
37
+ const { getByTestId } = renderComponent();
38
+ expect(getByTestId("test-comp")).toBeDefined();
39
+ });
40
+ });
@@ -5,7 +5,7 @@ import { URLSchemeContext } from "./URLSchemeContextProvider";
5
5
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
6
6
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
7
7
 
8
- export function URLSchemeListener({ children }) {
8
+ export function URLSchemeListener({ children }: { children: React.ReactNode }) {
9
9
  const { url, done } = useContext(URLSchemeContext);
10
10
 
11
11
  const navigator = useNavigation();
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
  import { View, Text } from "react-native";
3
- import { shallow } from "enzyme";
4
- import { shallowToJson } from "enzyme-to-json";
3
+ import { render } from "@testing-library/react-native";
5
4
 
6
5
  import { ErrorBoundary } from "../index";
7
6
 
@@ -17,56 +16,40 @@ const TestComponent = ({ error }: { error: any }) => {
17
16
  );
18
17
  };
19
18
 
20
- const errorState = {
21
- hasError: true,
22
- error: new Error("oh no"),
23
- info: { componentStack: "error at ... \n ..." },
24
- };
25
-
26
19
  describe("<ErrorBoundary />", () => {
27
20
  describe("when there is no error", () => {
28
- const wrapper = shallow(
29
- <ErrorBoundary>
30
- <TestComponent />
31
- </ErrorBoundary>
32
- );
33
-
34
21
  it("renders correctly", () => {
35
- expect(shallowToJson(wrapper)).toMatchSnapshot();
22
+ const { getByText } = render(
23
+ <ErrorBoundary>
24
+ <TestComponent />
25
+ </ErrorBoundary>
26
+ );
27
+
28
+ expect(getByText("all is good")).toBeTruthy();
36
29
  });
37
30
  });
38
31
 
39
32
  describe("When an error is caught", () => {
40
- const _consoleLog = console.log; // eslint-disable-line no-console
41
-
42
- const didCatchSpy = jest.spyOn(
43
- ErrorBoundary.prototype,
44
- "componentDidCatch"
45
- );
46
-
47
- const wrapper = shallow(
48
- <ErrorBoundary>
49
- <TestComponent error />
50
- </ErrorBoundary>
51
- );
52
-
53
- wrapper.setState(errorState);
33
+ const _consoleLog = console.log;
54
34
 
55
35
  beforeAll(() => {
56
- console.log = jest.fn(); // eslint-disable-line no-console
36
+ console.log = jest.fn();
57
37
  });
58
38
 
59
39
  afterAll(() => {
60
- console.log = _consoleLog; // eslint-disable-line no-console
40
+ console.log = _consoleLog;
61
41
  });
62
42
 
63
- it.skip("the componentDidCatch method is called", () => {
64
- // a current bug with enzyme doesn't allow this to be tested
65
- expect(didCatchSpy).toHaveBeenCalled();
66
- });
43
+ it("renders error state correctly", () => {
44
+ const { getByText } = render(
45
+ <ErrorBoundary>
46
+ <TestComponent error />
47
+ </ErrorBoundary>
48
+ );
67
49
 
68
- it("renders correctly", () => {
69
- expect(shallowToJson(wrapper)).toMatchSnapshot();
50
+ // Note: You'll need to verify what your ErrorBoundary actually renders in error state
51
+ // This is just an example assertion:
52
+ expect(getByText(/error/i)).toBeTruthy();
70
53
  });
71
54
  });
72
55
  });
@@ -0,0 +1,27 @@
1
+ import { BehaviorSubject } from "rxjs";
2
+
3
+ class LoadingOverlayManager {
4
+ visibilitySubject: BehaviorSubject<boolean>;
5
+
6
+ constructor() {
7
+ this.visibilitySubject = new BehaviorSubject(false);
8
+ }
9
+
10
+ show() {
11
+ this.visibilitySubject.next(true);
12
+ }
13
+
14
+ hide() {
15
+ this.visibilitySubject.next(false);
16
+ }
17
+
18
+ onVisibilityStateChange(cb: (value: boolean) => void) {
19
+ return this.visibilitySubject.subscribe(cb);
20
+ }
21
+
22
+ get visibility(): boolean {
23
+ return this.visibilitySubject.value;
24
+ }
25
+ }
26
+
27
+ export const loadingOverlayManager = new LoadingOverlayManager();
@@ -0,0 +1,49 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet } from "react-native";
3
+ import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
4
+ import { isVizioPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
5
+ import { Spinner } from "@applicaster/zapp-react-native-ui-components/Components/Spinner";
6
+ import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
7
+
8
+ import { useLoadingOverlayVisibility } from "./useLoadingOverlayVisibility";
9
+
10
+ export { loadingOverlayManager } from "./LoadingOverlayManager";
11
+
12
+ const styles = StyleSheet.create({
13
+ container: {
14
+ opacity: 0.5,
15
+ alignItems: "center",
16
+ justifyContent: "center",
17
+ zIndex: 100,
18
+ flex: 1,
19
+ },
20
+ });
21
+
22
+ const LoadingOverlayComponent = () => {
23
+ const visible = useLoadingOverlayVisibility();
24
+ const theme = useTheme();
25
+
26
+ const backgroundColor = React.useMemo(() => {
27
+ return theme?.app_background_color || "black";
28
+ }, [theme?.app_background_color]);
29
+
30
+ React.useEffect(() => {
31
+ if (visible) {
32
+ focusManager.disableFocus();
33
+ } else {
34
+ focusManager.enableFocus();
35
+ }
36
+ }, [visible]);
37
+
38
+ return visible ? (
39
+ <View
40
+ style={[StyleSheet.absoluteFill, styles.container, { backgroundColor }]}
41
+ >
42
+ <Spinner />
43
+ </View>
44
+ ) : null;
45
+ };
46
+
47
+ export const LoadingOverlay = isVizioPlatform()
48
+ ? LoadingOverlayComponent
49
+ : () => null;
@@ -0,0 +1,18 @@
1
+ import * as React from "react";
2
+ import { loadingOverlayManager } from "./LoadingOverlayManager";
3
+
4
+ export const useLoadingOverlayVisibility = () => {
5
+ const [visible, setVisible] = React.useState(
6
+ loadingOverlayManager.visibility
7
+ );
8
+
9
+ React.useEffect(() => {
10
+ const listener = loadingOverlayManager.onVisibilityStateChange(setVisible);
11
+
12
+ return () => {
13
+ listener.unsubscribe();
14
+ };
15
+ }, []);
16
+
17
+ return visible;
18
+ };
@@ -4,7 +4,7 @@ import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils"
4
4
  import { useSafeAreaInsets } from "react-native-safe-area-context";
5
5
 
6
6
  import React, { useCallback, useEffect, useMemo, useState } from "react";
7
- import { View, StyleSheet, Keyboard } from "react-native";
7
+ import { Keyboard, StyleSheet, View } from "react-native";
8
8
 
9
9
  import { Overlay } from "./Overlay";
10
10
  import { ModalBottomSheetFrame } from "./ModalBottomSheetFrame";
@@ -83,6 +83,8 @@ export function ModalBottomSheet(props: Props) {
83
83
  [isTablet]
84
84
  );
85
85
 
86
+ const modalVisible = visible && sheetHeight > 0;
87
+
86
88
  return (
87
89
  <View style={styles.container}>
88
90
  <Overlay
@@ -98,7 +100,7 @@ export function ModalBottomSheet(props: Props) {
98
100
  paddingBottom={bottomOffset}
99
101
  maxWidth={maxWidth}
100
102
  dimensions={dimensions}
101
- visible={visible && sheetHeight > 0}
103
+ visible={modalVisible}
102
104
  closeToast={dismiss}
103
105
  handleProps={{
104
106
  enabled: sheetHandleEnabled,
@@ -35,13 +35,12 @@ export function ModalProvider() {
35
35
 
36
36
  const pathname = `${ROUTE_TYPES.MODAL}/${modalScreenProps?.screenId}`;
37
37
 
38
+ const shouldShowModal = modalVisible && modalState?.visible;
39
+
38
40
  return (
39
41
  <PathnameContext.Provider value={pathname}>
40
42
  <ScreenContextProvider pathname={pathname}>
41
- <ModalPresenter
42
- visible={modalVisible && modalState?.visible}
43
- {...modalState?.options}
44
- >
43
+ <ModalPresenter visible={shouldShowModal} {...modalState?.options}>
45
44
  <ModalChildrenWrapper>
46
45
  <ModalContent modalScreenProps={modalScreenProps} />
47
46
  </ModalChildrenWrapper>
@@ -49,6 +49,7 @@ import { coreAppLogger } from "../logger";
49
49
  import {
50
50
  getPlatform,
51
51
  isTV,
52
+ isVizioPlatform,
52
53
  } from "@applicaster/zapp-react-native-utils/reactUtils";
53
54
  import { useConnectionInfo } from "@applicaster/zapp-react-native-utils/reactHooks/connection";
54
55
  import {
@@ -67,6 +68,9 @@ import { useModalStore } from "@applicaster/zapp-react-native-utils/modalState";
67
68
  import { useSubscriberFor } from "@applicaster/zapp-react-native-utils/reactHooks/useSubscriberFor";
68
69
  import { QBUIComponentEvents } from "@applicaster/zapp-react-native-ui-components/events";
69
70
  import { Hook } from "@applicaster/zapp-react-native-utils/appUtils/HooksManager/Hook";
71
+ import { URLSchemeContext } from "../DeepLinking/URLSchemeListener/URLSchemeContextProvider";
72
+
73
+ import { loadingOverlayManager } from "../LoadingOverlay";
70
74
 
71
75
  const logger = coreAppLogger.addSubsystem("Navigator");
72
76
 
@@ -86,6 +90,8 @@ const navigationActions = {
86
90
  const platform = getPlatform();
87
91
 
88
92
  export function NavigationProvider({ children }: Props) {
93
+ const { url: deepLinkURL } = React.useContext(URLSchemeContext);
94
+
89
95
  const {
90
96
  appData: { layoutVersion },
91
97
  rivers,
@@ -393,6 +399,8 @@ export function NavigationProvider({ children }: Props) {
393
399
  } else {
394
400
  dispatch(push(route, { entry: payload, screen: hookPlugin }));
395
401
  }
402
+
403
+ closeLoadingOverlay();
396
404
  };
397
405
 
398
406
  const handleHookError = ({ error, hookPlugin, callback }, dispose) => {
@@ -411,6 +419,8 @@ export function NavigationProvider({ children }: Props) {
411
419
  if (callback && typeof callback === "function") {
412
420
  callback();
413
421
  }
422
+
423
+ closeLoadingOverlay();
414
424
  };
415
425
 
416
426
  const handleHookCancel = ({ hookPlugin, callback }, dispose) => {
@@ -426,6 +436,8 @@ export function NavigationProvider({ children }: Props) {
426
436
  } else {
427
437
  goBack(true, true);
428
438
  }
439
+
440
+ closeLoadingOverlay();
429
441
  };
430
442
 
431
443
  const handleHookSuccess = ({ hookPlugin, callback }) => {
@@ -436,6 +448,10 @@ export function NavigationProvider({ children }: Props) {
436
448
  }
437
449
  };
438
450
 
451
+ const handleBackgroundHook = () => {
452
+ openLoadingOverlay();
453
+ };
454
+
439
455
  const checkStartUpHooks = React.useMemo(() => {
440
456
  if (!pluginConfigurations) return false;
441
457
 
@@ -505,6 +521,8 @@ export function NavigationProvider({ children }: Props) {
505
521
  );
506
522
 
507
523
  callback?.();
524
+
525
+ closeLoadingOverlay();
508
526
  };
509
527
 
510
528
  const offlinePlugin = React.useMemo(() => {
@@ -619,6 +637,7 @@ export function NavigationProvider({ children }: Props) {
619
637
  .on(HOOKS_EVENTS.ERROR, handleHookError)
620
638
  .on(HOOKS_EVENTS.CANCEL, handleHookCancel)
621
639
  .on(HOOKS_EVENTS.SUCCESS, handleHookSuccess)
640
+ .on(HOOKS_EVENTS.START_BACKGROUND_HOOK, handleBackgroundHook)
622
641
  .on(
623
642
  HOOKS_EVENTS.COMPLETE,
624
643
  handleHookComplete(navigationAction, targetRoute, {
@@ -634,6 +653,14 @@ export function NavigationProvider({ children }: Props) {
634
653
  },
635
654
  });
636
655
 
656
+ const openLoadingOverlay = React.useCallback(() => {
657
+ deepLinkURL && isVizioPlatform() && loadingOverlayManager.show();
658
+ }, [deepLinkURL]);
659
+
660
+ const closeLoadingOverlay = React.useCallback(() => {
661
+ loadingOverlayManager.hide();
662
+ }, []);
663
+
637
664
  const openPiP = React.useCallback(() => {
638
665
  dispatch(setVideoPiP());
639
666
  }, []);
@@ -1,4 +1,3 @@
1
- /// <reference types="@types/tizen-tv-webapis" />
2
1
  import * as R from "ramda";
3
2
 
4
3
  import { NetInfoState } from "@react-native-community/netinfo";
@@ -1,19 +1,19 @@
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 { shallow } from "enzyme";
5
- import { shallowToJson } from "enzyme-to-json";
4
+ import { render } from "@testing-library/react-native";
6
5
  import configureStore from "redux-mock-store";
7
6
 
8
7
  import { storeConnector } from "../index";
8
+ import { Provider } from "react-redux";
9
9
 
10
10
  const styles = { foo: "bar" };
11
11
  const components = { grid: jest.fn() };
12
12
  const rivers = { A123: { name: "home", id: "A123" } };
13
13
  const appSettings = { bundleIdentifier: "com.app.test" };
14
14
 
15
- const Component = () => (
16
- <View>
15
+ const Component = (props) => (
16
+ <View testID="test-comp" {...props}>
17
17
  <Text>I'm a component</Text>
18
18
  </View>
19
19
  );
@@ -28,7 +28,6 @@ const store = configureStore()({
28
28
  describe("storeConnector", () => {
29
29
  it("returns a Component", () => {
30
30
  const WrappedComponent = storeConnector(Component);
31
-
32
31
  expect(ReactIs.isValidElementType(WrappedComponent)).toBe(true);
33
32
 
34
33
  expect(WrappedComponent).toEqual(
@@ -41,12 +40,19 @@ describe("storeConnector", () => {
41
40
 
42
41
  it("passes the props to the component", () => {
43
42
  const WrappedComponent = storeConnector(Component);
44
- const wrapper = shallow(<WrappedComponent store={store} />).dive();
45
- const wrapperProps = wrapper.first().props();
46
43
 
47
- expect(shallowToJson(wrapper)).toMatchSnapshot();
48
- expect(wrapperProps).toHaveProperty("components", components);
49
- expect(wrapperProps).toHaveProperty("rivers", rivers);
50
- expect(wrapperProps).toHaveProperty("appSettings", appSettings);
44
+ const { getByText, getByTestId } = render(
45
+ <Provider store={store}>
46
+ <WrappedComponent />
47
+ </Provider>
48
+ );
49
+
50
+ expect(getByText("I'm a component")).toBeTruthy();
51
+
52
+ expect(getByTestId("test-comp").props).toMatchObject({
53
+ appSettings,
54
+ components,
55
+ rivers,
56
+ });
51
57
  });
52
58
  });
@@ -0,0 +1,146 @@
1
+ import * as React from "react";
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";
6
+
7
+ let mocked_items: Record<string, any> = {};
8
+
9
+ import { appLifeCycleManager } from "../";
10
+
11
+ const mock_actions = {};
12
+
13
+ jest.mock("@applicaster/zapp-react-native-redux/AppData", () => ({
14
+ loadAppData: jest.fn(() => () => Promise.resolve()),
15
+ }));
16
+
17
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/actions", () => ({
18
+ useActions: jest.fn(() => ({ actions: mock_actions })),
19
+ }));
20
+
21
+ jest.mock(
22
+ "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage",
23
+ () => ({
24
+ localStorage: {
25
+ getAllItems: jest.fn(() => Promise.resolve(mocked_items)),
26
+ setItem: jest.fn((key, value) => {
27
+ mocked_items[key] = JSON.stringify(value);
28
+
29
+ return Promise.resolve(true);
30
+ }),
31
+ getItem: jest.fn((key) => {
32
+ if (mocked_items[key]) {
33
+ if (typeof mocked_items[key] === "string") {
34
+ return Promise.resolve(JSON.parse(mocked_items[key]));
35
+ } else {
36
+ return Promise.resolve(mocked_items[key]);
37
+ }
38
+ } else {
39
+ return Promise.resolve([]);
40
+ }
41
+ }),
42
+ __reset() {
43
+ mocked_items = {};
44
+ },
45
+ },
46
+ })
47
+ );
48
+
49
+ const Component = () => (
50
+ <View>
51
+ <Text>I'm a component</Text>
52
+ </View>
53
+ );
54
+
55
+ const QuickBrickManager = {
56
+ sendQuickBrickEvent: jest.fn(),
57
+ };
58
+
59
+ const LOADING_ERROR = new Error("loading failed");
60
+
61
+ const appLoader = jest.fn((_dispatch, _getState) => {
62
+ if (_getState().shouldFail) return Promise.reject(LOADING_ERROR);
63
+
64
+ return Promise.resolve();
65
+ });
66
+
67
+ const store = configureStore([thunk])({});
68
+ const dispatch = store.dispatch;
69
+
70
+ const state = {
71
+ rivers: {},
72
+ plugins: {},
73
+ appSettings: { runtimeConfigurationUrls: { rivers: "http://rivers.url" } },
74
+ };
75
+
76
+ const QUICK_BRICK_READY_EVENT = "quickBrickReady";
77
+
78
+ describe("appLifeCycleManager", () => {
79
+ const decorator = appLifeCycleManager(appLoader, QuickBrickManager);
80
+ const DecoratedComponent = decorator(Component);
81
+
82
+ beforeEach(() => {
83
+ appLoader.mockClear();
84
+ QuickBrickManager.sendQuickBrickEvent.mockClear();
85
+ });
86
+
87
+ it("returns a function to decorate a component", () => {
88
+ expect(decorator).toBeDefined();
89
+ });
90
+
91
+ it("runs the loaders, then sends quickBrickReady event", async () => {
92
+ const testCallback = jest.fn(() => {});
93
+
94
+ render(
95
+ <DecoratedComponent
96
+ dispatch={dispatch}
97
+ {...state}
98
+ testCallback={testCallback}
99
+ />
100
+ );
101
+
102
+ await waitFor(() => {
103
+ return expect(testCallback).toHaveBeenCalled();
104
+ });
105
+
106
+ const actions = store.getActions();
107
+
108
+ expect(actions[0]).toMatchObject({ type: "SET_APP_READY" });
109
+
110
+ expect(QuickBrickManager.sendQuickBrickEvent).toHaveBeenCalledWith(
111
+ QUICK_BRICK_READY_EVENT
112
+ );
113
+
114
+ expect(appLoader).toHaveBeenCalled();
115
+ });
116
+
117
+ it("sends the quickBrickReady event when a loader doesn't resolves", async () => {
118
+ const testCallback = jest.fn(() => {});
119
+
120
+ render(
121
+ <DecoratedComponent
122
+ dispatch={dispatch}
123
+ {...state}
124
+ shouldFail
125
+ testCallback={testCallback}
126
+ />
127
+ );
128
+
129
+ const actions = store.getActions();
130
+
131
+ await waitFor(() => {
132
+ return expect(testCallback).toHaveBeenCalled();
133
+ });
134
+
135
+ expect(actions[0]).toMatchObject({ type: "SET_APP_READY" });
136
+ expect(actions[1]).toMatchObject({ type: "SET_APP_LAUNCHED" });
137
+
138
+ expect(QuickBrickManager.sendQuickBrickEvent).toHaveBeenCalledWith(
139
+ QUICK_BRICK_READY_EVENT
140
+ );
141
+
142
+ expect(testCallback).toHaveBeenCalled();
143
+
144
+ expect(appLoader).toHaveBeenCalled();
145
+ });
146
+ });
@@ -131,9 +131,8 @@ export function appLifeCycleManager(appLoader, QuickBrickManager) {
131
131
  )
132
132
  .map((plugin: any) => plugin.module?.getLoginProtocol?.());
133
133
 
134
- const loginProtocols: LoginProtocol[] = await Promise.all(
135
- promiseProtocols
136
- );
134
+ const loginProtocols: LoginProtocol[] =
135
+ await Promise.all(promiseProtocols);
137
136
 
138
137
  // Await all does not work here
139
138
  for (const protocol of loginProtocols) {
@@ -183,13 +182,13 @@ export function appLifeCycleManager(appLoader, QuickBrickManager) {
183
182
  data: { error },
184
183
  });
185
184
  }
186
-
187
- makeAppReady();
188
- checkStoredContextKeys();
189
185
  };
190
186
 
191
187
  React.useLayoutEffect(() => {
192
- prepareApp();
188
+ prepareApp().then(() => {
189
+ makeAppReady();
190
+ checkStoredContextKeys();
191
+ });
193
192
  }, []);
194
193
 
195
194
  return <Component {...props} />;
package/App/index.tsx CHANGED
@@ -29,6 +29,7 @@ import { appRemoteDataLoader } from "./appRemoteDataLoader";
29
29
  import { withActionExecutor } from "@applicaster/zapp-react-native-utils/actionsExecutor/ActionExecutorContext";
30
30
  import { withScreenDataContextProvider } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenDataContext";
31
31
  import { LogicAggregatorContainer } from "./LogicAggregatorContainer";
32
+ import { LoadingOverlay } from "./LoadingOverlay";
32
33
 
33
34
  interface AppOptions {
34
35
  Layout: React.ComponentType;
@@ -74,6 +75,7 @@ const App = ({
74
75
  <LogicAggregatorContainer
75
76
  components={[InteractionManager, ApplyScreenHooks]}
76
77
  />
78
+ <LoadingOverlay />
77
79
  </ErrorBoundary>
78
80
  </AppContainer>
79
81
  </SafeAreaProvider>