@applicaster/quick-brick-core 15.0.0-rc.98 → 15.1.0-alpha.2915689988
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/App/ActionSetters/index.ts +4 -5
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useOpenSchemeHandler.test.tsx +27 -12
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/usePresentSchemeHandler.test.tsx +72 -35
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useUrlSchemeHandler.test.tsx +104 -197
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/useOpenSchemeHandler/index.ts +7 -4
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/usePresentSchemeHandler.ts +14 -12
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/useUrlSchemeHandler.ts +30 -42
- package/App/DeepLinking/URLSchemeHandler/URLSchemeHandler.tsx +1 -4
- package/App/DeepLinking/URLSchemeHandler/__tests__/URLSchemeHandler.test.tsx +13 -20
- package/App/DeepLinking/URLSchemeHandler/__tests__/__snapshots__/URLSchemeHandler.test.tsx.snap +24 -0
- package/App/DeepLinking/URLSchemeListener/URLSchemeContextProvider.tsx +59 -0
- package/App/DeepLinking/URLSchemeListener/index.tsx +4 -3
- package/App/DeepLinking/helpers/index.ts +3 -3
- package/App/ErrorBoundary/__tests__/store.test.js +1 -1
- package/App/NavigationProvider/Loader.tsx +4 -3
- package/App/NavigationProvider/NavigationProvider.tsx +48 -27
- package/App/NavigationProvider/ScreenHooks/usePluginScreenHooks.ts +2 -2
- package/App/NavigationProvider/__tests__/navigationProvider.test.tsx +152 -141
- package/App/NavigationProvider/navigator/selectors.ts +5 -21
- package/App/NetworkStatusProvider/NetworkStatusProvider.tsx +2 -2
- package/App/NetworkStatusProvider/__tests__/NetworkStatusProvider.test.tsx +4 -4
- package/App/__tests__/createQuickBrickApp.test.js +1 -1
- package/App/appRemoteDataLoader/index.tsx +2 -2
- package/App/remoteContextReloader/getRemoteContextData/getNativeRemoteContextData.ts +1 -1
- package/App/remoteContextReloader/helpers.ts +3 -3
- package/package.json +8 -8
|
@@ -21,8 +21,7 @@ const warnUndefinedContext = (context) =>
|
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
type Subscription = {
|
|
24
|
-
[x: string]: (
|
|
25
|
-
pluginId?: string;
|
|
24
|
+
[x: string]: () => any;
|
|
26
25
|
};
|
|
27
26
|
|
|
28
27
|
const getModuleContext = R.path(["module", "context"]);
|
|
@@ -30,7 +29,7 @@ const getModuleContext = R.path(["module", "context"]);
|
|
|
30
29
|
const getContexts = R.compose(
|
|
31
30
|
R.map((action) => {
|
|
32
31
|
const item = getModuleContext(action);
|
|
33
|
-
item
|
|
32
|
+
item["pluginId"] = action.name;
|
|
34
33
|
|
|
35
34
|
return item;
|
|
36
35
|
}),
|
|
@@ -47,10 +46,10 @@ const useSubscribeToActionProviders = () => {
|
|
|
47
46
|
}, [actionContext]);
|
|
48
47
|
|
|
49
48
|
const subscriptions = getContexts(actionContext.actions).map((context) => {
|
|
50
|
-
const subscription = React.useContext<
|
|
49
|
+
const subscription = React.useContext<{}>(context);
|
|
51
50
|
|
|
52
51
|
if (subscription) {
|
|
53
|
-
subscription
|
|
52
|
+
subscription["pluginId"] = context.pluginId;
|
|
54
53
|
|
|
55
54
|
return subscription;
|
|
56
55
|
} else {
|
package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useOpenSchemeHandler.test.tsx
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
|
+
import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
|
|
2
3
|
import * as feedLoader from "@applicaster/zapp-react-native-utils/reactHooks/feed/useFeedLoader";
|
|
3
4
|
import * as useNavigationHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
|
|
4
5
|
import { waitFor, cleanup, renderHook } from "@testing-library/react-native";
|
|
5
6
|
import nock from "nock";
|
|
7
|
+
import * as R from "ramda";
|
|
6
8
|
import React from "react";
|
|
7
|
-
import {
|
|
9
|
+
import { Provider } from "react-redux";
|
|
10
|
+
import configureStore from "redux-mock-store";
|
|
8
11
|
import * as helpers from "../../../helpers";
|
|
9
|
-
import { WrappedWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
10
|
-
|
|
11
12
|
import {
|
|
12
13
|
noTargetScreenError,
|
|
13
14
|
resolveError,
|
|
@@ -23,7 +24,6 @@ const rivers: Record<string, Partial<ZappRiver>> = {
|
|
|
23
24
|
home: true,
|
|
24
25
|
},
|
|
25
26
|
B0987: {
|
|
26
|
-
type: "any",
|
|
27
27
|
id: "B0987",
|
|
28
28
|
},
|
|
29
29
|
C5678: {
|
|
@@ -42,7 +42,7 @@ const contentTypes: ZappContentTypes = {
|
|
|
42
42
|
const endpoint = "http://feed.com";
|
|
43
43
|
|
|
44
44
|
const pipesEndpoints: ZappPipesEndpoints = {
|
|
45
|
-
[endpoint]: {
|
|
45
|
+
[`${endpoint}`]: {
|
|
46
46
|
context_keys: [],
|
|
47
47
|
context_obj: [],
|
|
48
48
|
},
|
|
@@ -55,6 +55,7 @@ const navigator = {
|
|
|
55
55
|
goHome: jest.fn(),
|
|
56
56
|
} as any;
|
|
57
57
|
|
|
58
|
+
const mockStore = configureStore();
|
|
58
59
|
jest.spyOn(useNavigationHooks, "useNavigation").mockReturnValue(navigator);
|
|
59
60
|
|
|
60
61
|
const helperSpy = jest.spyOn(helpers, "handlePresentNavigation");
|
|
@@ -79,17 +80,31 @@ jest.mock("../../../logger", () => ({
|
|
|
79
80
|
// to use import instead of require it's required to use jest.mock above
|
|
80
81
|
const { useOpenSchemeHandler } = require("../useOpenSchemeHandler");
|
|
81
82
|
|
|
82
|
-
const
|
|
83
|
+
const getWrapper = (storeProps = {}) => {
|
|
84
|
+
const store = mockStore(
|
|
85
|
+
R.mergeDeepRight(
|
|
86
|
+
{ rivers, contentTypes, pipesEndpoints, appData },
|
|
87
|
+
storeProps
|
|
88
|
+
)
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
appStore.set(store);
|
|
92
|
+
|
|
93
|
+
const Wrapper = ({ children }: { children: React.ReactChild }) => (
|
|
94
|
+
/* @ts-ignore */
|
|
95
|
+
<Provider store={store}>{children}</Provider>
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
return Wrapper;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const testHook = async ({ url, query, storeProps = {}, tests }) => {
|
|
102
|
+
const wrapper = getWrapper(storeProps);
|
|
83
103
|
|
|
84
|
-
const testHook = async ({ url, query, storeProps = {}, tests }: any) => {
|
|
85
104
|
const callback = jest.fn((fn) => fn(tests));
|
|
86
105
|
|
|
87
106
|
renderHook(() => useOpenSchemeHandler({ url, query, onFinish: callback }), {
|
|
88
|
-
wrapper
|
|
89
|
-
<WrappedWithProviders store={mergeDeepRight(mockStoreObj, storeProps)}>
|
|
90
|
-
{children}
|
|
91
|
-
</WrappedWithProviders>
|
|
92
|
-
),
|
|
107
|
+
wrapper,
|
|
93
108
|
});
|
|
94
109
|
|
|
95
110
|
await waitFor(() => expect(callback).toHaveBeenCalled());
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import * as R from "ramda";
|
|
2
1
|
import axios from "axios";
|
|
3
|
-
import { renderHook } from "@testing-library/react-native";
|
|
2
|
+
import { renderHook, waitFor } from "@testing-library/react-native";
|
|
4
3
|
import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
|
|
5
4
|
import * as helpers from "../../../helpers";
|
|
6
5
|
import * as feedLoader from "@applicaster/zapp-react-native-utils/reactHooks/feed/useFeedLoader";
|
|
7
6
|
import { WrappedWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
8
7
|
import { usePresentSchemeHandler } from "../usePresentSchemeHandler";
|
|
9
8
|
|
|
10
|
-
import configureStore from "redux-mock-store";
|
|
11
|
-
|
|
12
9
|
const rivers = {
|
|
13
10
|
A1234: {
|
|
14
11
|
id: "A1234",
|
|
@@ -28,8 +25,6 @@ jest.mock(
|
|
|
28
25
|
})
|
|
29
26
|
);
|
|
30
27
|
|
|
31
|
-
const mockStore = configureStore();
|
|
32
|
-
|
|
33
28
|
const helperSpy = jest.spyOn(helpers, "handlePresentNavigation");
|
|
34
29
|
const feedLoaderSpy = jest.spyOn(feedLoader, "useFeedLoader");
|
|
35
30
|
|
|
@@ -179,46 +174,88 @@ describe("usePresentSchemeHandler", () => {
|
|
|
179
174
|
});
|
|
180
175
|
|
|
181
176
|
describe("loading new river", () => {
|
|
182
|
-
|
|
183
|
-
const store = mockStore({ test: "test" });
|
|
184
|
-
|
|
185
|
-
const wrapper = WrappedWithProviders;
|
|
177
|
+
const query = { rivers_configuration_id: "layout-uuid" };
|
|
186
178
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
179
|
+
const baseSessionData = {
|
|
180
|
+
accountsAccountId: "account-123",
|
|
181
|
+
bundleIdentifier: "com.example.app",
|
|
182
|
+
app_family_id: "42",
|
|
183
|
+
version_name: "1.0.0",
|
|
184
|
+
};
|
|
190
185
|
|
|
191
|
-
|
|
192
|
-
|
|
186
|
+
let storageSpy: jest.SpyInstance;
|
|
187
|
+
let axiosGetSpy: jest.SpyInstance;
|
|
193
188
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
store: "store",
|
|
200
|
-
});
|
|
189
|
+
beforeEach(() => {
|
|
190
|
+
storageSpy = jest.spyOn(sessionStorage, "getAllItems");
|
|
191
|
+
axiosGetSpy = jest.spyOn(axios, "get");
|
|
192
|
+
axiosGetSpy.mockResolvedValue({ data: {} });
|
|
193
|
+
});
|
|
201
194
|
|
|
202
|
-
|
|
195
|
+
afterEach(() => {
|
|
196
|
+
storageSpy.mockRestore();
|
|
197
|
+
axiosGetSpy.mockRestore();
|
|
198
|
+
});
|
|
203
199
|
|
|
204
|
-
|
|
205
|
-
|
|
200
|
+
it("fetches the rivers, cell styles and presets mapping URLs", async () => {
|
|
201
|
+
storageSpy.mockResolvedValue({ ...baseSessionData, store: "store" });
|
|
206
202
|
|
|
207
203
|
renderHook(() => usePresentSchemeHandler({ query, url: "", onFinish }), {
|
|
208
|
-
wrapper,
|
|
204
|
+
wrapper: WrappedWithProviders,
|
|
209
205
|
});
|
|
210
206
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
207
|
+
await waitFor(() => {
|
|
208
|
+
expect(axiosGetSpy).toHaveBeenCalledWith(
|
|
209
|
+
expect.stringContaining("/layouts/layout-uuid.json")
|
|
210
|
+
);
|
|
211
|
+
});
|
|
212
|
+
});
|
|
217
213
|
|
|
218
|
-
|
|
214
|
+
describe("WEB_STORE_PLATFORM CDN store key mapping", () => {
|
|
215
|
+
it.each([
|
|
216
|
+
["samsung", "samsung_app_store"],
|
|
217
|
+
["lg", "lg_content_store"],
|
|
218
|
+
["vizio", "vizio_app_store"],
|
|
219
|
+
])(
|
|
220
|
+
'maps store="%s" to "%s" in the rivers URL',
|
|
221
|
+
async (store, expectedCdnKey) => {
|
|
222
|
+
storageSpy.mockResolvedValue({ ...baseSessionData, store });
|
|
223
|
+
|
|
224
|
+
renderHook(
|
|
225
|
+
() => usePresentSchemeHandler({ query, url: "", onFinish }),
|
|
226
|
+
{ wrapper: WrappedWithProviders }
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
await waitFor(() => {
|
|
230
|
+
expect(axiosGetSpy).toHaveBeenCalledWith(
|
|
231
|
+
expect.stringContaining(`/${expectedCdnKey}/`)
|
|
232
|
+
);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
// Confirm the raw store name is NOT used in the URL
|
|
236
|
+
expect(axiosGetSpy).not.toHaveBeenCalledWith(
|
|
237
|
+
expect.stringContaining(`/${store}/`)
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
);
|
|
219
241
|
|
|
220
|
-
|
|
221
|
-
|
|
242
|
+
it("passes through an unmapped store value unchanged", async () => {
|
|
243
|
+
storageSpy.mockResolvedValue({
|
|
244
|
+
...baseSessionData,
|
|
245
|
+
store: "apple_tv",
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
renderHook(
|
|
249
|
+
() => usePresentSchemeHandler({ query, url: "", onFinish }),
|
|
250
|
+
{ wrapper: WrappedWithProviders }
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
await waitFor(() => {
|
|
254
|
+
expect(axiosGetSpy).toHaveBeenCalledWith(
|
|
255
|
+
expect.stringContaining("/apple_tv/")
|
|
256
|
+
);
|
|
257
|
+
});
|
|
258
|
+
});
|
|
222
259
|
});
|
|
223
260
|
});
|
|
224
261
|
|
package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useUrlSchemeHandler.test.tsx
CHANGED
|
@@ -1,35 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { renderHook } from "@testing-library/react-
|
|
2
|
+
import { renderHook } from "@testing-library/react-hooks";
|
|
3
3
|
import * as URLHandlersMap from "..";
|
|
4
4
|
|
|
5
5
|
import { Provider } from "react-redux";
|
|
6
6
|
import configureStore from "redux-mock-store";
|
|
7
7
|
|
|
8
8
|
import { log_warning } from "../../../logger";
|
|
9
|
-
import { handleActionSchemeUrl } from "../useUrlSchemeHandler";
|
|
10
|
-
import { appStore } from "../../../../../../zapp-react-native-redux/AppStore";
|
|
11
|
-
|
|
12
|
-
type UrlSchemeHandlerArgs = {
|
|
13
|
-
query: Record<string, unknown>;
|
|
14
|
-
url: string;
|
|
15
|
-
onFinish?: (callback: () => void) => void;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
type PluginType = "general" | "player";
|
|
19
|
-
|
|
20
|
-
interface ZappPlugin {
|
|
21
|
-
urlScheme?: {
|
|
22
|
-
host: string;
|
|
23
|
-
handler: (args: UrlSchemeHandlerArgs) => void;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface QuickBrickPlugin {
|
|
28
|
-
module: ZappPlugin;
|
|
29
|
-
name: string;
|
|
30
|
-
identifier: string;
|
|
31
|
-
type: PluginType;
|
|
32
|
-
}
|
|
33
9
|
|
|
34
10
|
const mockStore = configureStore();
|
|
35
11
|
|
|
@@ -38,222 +14,153 @@ jest.mock("../../../logger", () => ({
|
|
|
38
14
|
log_warning: jest.fn(),
|
|
39
15
|
}));
|
|
40
16
|
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const mockComplexHandler = jest.fn(({ onFinish }) => {
|
|
46
|
-
onFinish?.(() => {});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const lambdaPlugin: QuickBrickPlugin = {
|
|
50
|
-
module: {} as ZappPlugin,
|
|
17
|
+
const lambdaPlugin = {
|
|
18
|
+
module: jest.fn() as ZappPlugin,
|
|
51
19
|
name: "Lambda plugin",
|
|
52
20
|
identifier: "someplugin",
|
|
53
|
-
type: "general",
|
|
21
|
+
type: "general" as PluginType,
|
|
54
22
|
};
|
|
55
23
|
|
|
56
|
-
const pluginWithHandler
|
|
24
|
+
const pluginWithHandler = {
|
|
57
25
|
name: "Plugin handling scheme",
|
|
58
26
|
identifier: "plugin-with-handler",
|
|
59
|
-
type: "general",
|
|
27
|
+
type: "general" as PluginType,
|
|
60
28
|
module: {
|
|
61
29
|
urlScheme: {
|
|
62
30
|
host: "foo",
|
|
63
|
-
handler:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const pluginWithComplexHandler: QuickBrickPlugin = {
|
|
69
|
-
name: "Plugin with nested handler",
|
|
70
|
-
identifier: "plugin-with-nested-handler",
|
|
71
|
-
type: "general",
|
|
72
|
-
module: {
|
|
73
|
-
urlScheme: {
|
|
74
|
-
host: "complex",
|
|
75
|
-
handler: mockComplexHandler,
|
|
31
|
+
handler: jest.fn(({ onFinish }) => {
|
|
32
|
+
onFinish(() => {});
|
|
33
|
+
}),
|
|
76
34
|
},
|
|
77
|
-
},
|
|
35
|
+
} as ZappPlugin,
|
|
78
36
|
};
|
|
79
37
|
|
|
80
|
-
const plugins = [lambdaPlugin, pluginWithHandler
|
|
38
|
+
const plugins: QuickBrickPlugin[] = [lambdaPlugin, pluginWithHandler];
|
|
81
39
|
|
|
82
40
|
const { useUrlSchemeHandler } = require("../useUrlSchemeHandler");
|
|
83
41
|
|
|
84
42
|
describe("useUrlSchemeHandler", () => {
|
|
85
|
-
|
|
43
|
+
// beforeEach(() => {
|
|
44
|
+
// log_warning.mockClear();
|
|
45
|
+
// });
|
|
86
46
|
|
|
87
|
-
|
|
47
|
+
const store = mockStore({ test: "test", plugins });
|
|
88
48
|
|
|
89
|
-
const wrapper: React.FC = ({ children }) => (
|
|
49
|
+
const wrapper: React.FC<any> = ({ children }) => (
|
|
90
50
|
<Provider store={store}>{children}</Provider>
|
|
91
51
|
);
|
|
92
52
|
|
|
93
|
-
|
|
94
|
-
jest.
|
|
53
|
+
it("calls correct urlScheme handler with query params", () => {
|
|
54
|
+
const presentSpy = jest.fn();
|
|
55
|
+
const onFinish = jest.fn();
|
|
56
|
+
const url = "test://present?foo=bar";
|
|
95
57
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
58
|
+
URLHandlersMap.schemeHandlerHooks.present = presentSpy;
|
|
59
|
+
|
|
60
|
+
renderHook(
|
|
61
|
+
() =>
|
|
62
|
+
useUrlSchemeHandler({
|
|
63
|
+
url,
|
|
64
|
+
onFinish,
|
|
65
|
+
}),
|
|
66
|
+
{ wrapper }
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
expect(presentSpy).toBeCalledWith({ query: { foo: "bar" }, url, onFinish });
|
|
99
70
|
});
|
|
100
71
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
renderHook(
|
|
108
|
-
() =>
|
|
109
|
-
useUrlSchemeHandler({
|
|
110
|
-
url: testUrl,
|
|
111
|
-
onFinish: jest.fn(),
|
|
112
|
-
}),
|
|
113
|
-
{ wrapper }
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
expect(testHandler).toBeCalledWith({
|
|
117
|
-
query: { foo: "bar" },
|
|
118
|
-
url: testUrl,
|
|
119
|
-
onFinish: expect.any(Function),
|
|
120
|
-
});
|
|
72
|
+
it("not throws an error and calls onFinish if correct url scheme handler can not be found", () => {
|
|
73
|
+
const url = "test://nonExistingHost?foo=bar";
|
|
74
|
+
|
|
75
|
+
const onFinish = jest.fn((cb) => {
|
|
76
|
+
cb();
|
|
121
77
|
});
|
|
122
78
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
79
|
+
renderHook(
|
|
80
|
+
() =>
|
|
81
|
+
useUrlSchemeHandler({
|
|
82
|
+
url,
|
|
83
|
+
onFinish,
|
|
84
|
+
}),
|
|
85
|
+
{ wrapper }
|
|
86
|
+
);
|
|
126
87
|
|
|
127
|
-
|
|
128
|
-
cb();
|
|
129
|
-
finishCallback();
|
|
130
|
-
});
|
|
88
|
+
expect(onFinish).toBeCalled();
|
|
131
89
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
onFinish,
|
|
137
|
-
}),
|
|
138
|
-
{ wrapper }
|
|
139
|
-
);
|
|
90
|
+
expect(log_warning).toHaveBeenCalledWith(
|
|
91
|
+
`unable to resolve ${url}: Non of the installed plugins knows how to handle this urlScheme ${url}`
|
|
92
|
+
);
|
|
93
|
+
});
|
|
140
94
|
|
|
141
|
-
|
|
95
|
+
it("calls onFinish when the handler does", () => {
|
|
96
|
+
const url = "test://present?foo=bar";
|
|
97
|
+
const onFinish = jest.fn();
|
|
142
98
|
|
|
143
|
-
|
|
99
|
+
const presentSpy = jest.fn(() => {
|
|
100
|
+
onFinish();
|
|
144
101
|
});
|
|
102
|
+
|
|
103
|
+
URLHandlersMap.schemeHandlerHooks.present = presentSpy;
|
|
104
|
+
|
|
105
|
+
renderHook(
|
|
106
|
+
() =>
|
|
107
|
+
useUrlSchemeHandler({
|
|
108
|
+
url,
|
|
109
|
+
onFinish,
|
|
110
|
+
}),
|
|
111
|
+
{ wrapper }
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
expect(onFinish).toBeCalled();
|
|
145
115
|
});
|
|
146
116
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const testUrl = "test://foo?param=test";
|
|
150
|
-
const onFinish = jest.fn();
|
|
151
|
-
|
|
152
|
-
renderHook(
|
|
153
|
-
() =>
|
|
154
|
-
useUrlSchemeHandler({
|
|
155
|
-
url: testUrl,
|
|
156
|
-
onFinish,
|
|
157
|
-
}),
|
|
158
|
-
{ wrapper }
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
expect(mockHandler).toBeCalledWith({
|
|
162
|
-
query: { param: "test" },
|
|
163
|
-
url: testUrl,
|
|
164
|
-
onFinish,
|
|
165
|
-
});
|
|
166
|
-
});
|
|
117
|
+
it("calls onFinish if handler returns an error", () => {
|
|
118
|
+
const url = "test://present?foo=bar";
|
|
167
119
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const onFinish = jest.fn();
|
|
171
|
-
|
|
172
|
-
renderHook(
|
|
173
|
-
() =>
|
|
174
|
-
useUrlSchemeHandler({
|
|
175
|
-
url: testUrl,
|
|
176
|
-
onFinish,
|
|
177
|
-
}),
|
|
178
|
-
{ wrapper }
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
expect(mockComplexHandler).toBeCalledWith({
|
|
182
|
-
query: { param: "nested" },
|
|
183
|
-
url: testUrl,
|
|
184
|
-
onFinish,
|
|
185
|
-
});
|
|
120
|
+
const onFinish = jest.fn((cb) => {
|
|
121
|
+
cb();
|
|
186
122
|
});
|
|
187
123
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
const finishCallback = jest.fn();
|
|
191
|
-
|
|
192
|
-
const onFinish = jest.fn((cb) => {
|
|
193
|
-
cb();
|
|
194
|
-
finishCallback();
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
renderHook(
|
|
198
|
-
() =>
|
|
199
|
-
useUrlSchemeHandler({
|
|
200
|
-
url: testUrl,
|
|
201
|
-
onFinish,
|
|
202
|
-
}),
|
|
203
|
-
{ wrapper }
|
|
204
|
-
);
|
|
205
|
-
|
|
206
|
-
expect(lambdaPlugin.module).not.toHaveProperty("urlScheme");
|
|
207
|
-
expect(finishCallback).toBeCalled();
|
|
124
|
+
const presentSpy = jest.fn(() => {
|
|
125
|
+
throw new Error("error");
|
|
208
126
|
});
|
|
209
|
-
});
|
|
210
127
|
|
|
211
|
-
|
|
212
|
-
it("handles action schemes using plugins", () => {
|
|
213
|
-
const testUrl = "test://foo?action=test";
|
|
128
|
+
URLHandlersMap.schemeHandlerHooks.present = presentSpy;
|
|
214
129
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
130
|
+
renderHook(
|
|
131
|
+
() =>
|
|
132
|
+
useUrlSchemeHandler({
|
|
133
|
+
url,
|
|
134
|
+
onFinish,
|
|
135
|
+
}),
|
|
136
|
+
{ wrapper }
|
|
137
|
+
);
|
|
219
138
|
|
|
220
|
-
|
|
221
|
-
query: { action: "test" },
|
|
222
|
-
url: testUrl,
|
|
223
|
-
});
|
|
224
|
-
});
|
|
139
|
+
expect(onFinish).toBeCalled();
|
|
225
140
|
|
|
226
|
-
|
|
227
|
-
|
|
141
|
+
expect(log_warning).toHaveBeenCalledWith(`unable to resolve ${url}: error`);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("finds the plugin for the host", () => {
|
|
145
|
+
const url = "scheme://foo?whatever=bar";
|
|
228
146
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
url: testUrl,
|
|
232
|
-
plugins,
|
|
233
|
-
} as any);
|
|
234
|
-
}).toThrow(/Non of the installed plugins/);
|
|
147
|
+
const onFinish = jest.fn((cb) => {
|
|
148
|
+
cb();
|
|
235
149
|
});
|
|
236
150
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
useUrlSchemeHandler({
|
|
249
|
-
url: testUrl,
|
|
250
|
-
onFinish,
|
|
251
|
-
}),
|
|
252
|
-
{ wrapper }
|
|
253
|
-
);
|
|
254
|
-
|
|
255
|
-
expect(log_warning).toBeCalled();
|
|
256
|
-
expect(finishCallback).toBeCalled();
|
|
151
|
+
renderHook(
|
|
152
|
+
() => {
|
|
153
|
+
useUrlSchemeHandler({ url, onFinish });
|
|
154
|
+
},
|
|
155
|
+
{ wrapper }
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
expect(pluginWithHandler.module.urlScheme.handler).toBeCalledWith({
|
|
159
|
+
url,
|
|
160
|
+
onFinish,
|
|
161
|
+
query: { whatever: "bar" },
|
|
257
162
|
});
|
|
163
|
+
|
|
164
|
+
expect(onFinish).toBeCalled();
|
|
258
165
|
});
|
|
259
166
|
});
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
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";
|
|
@@ -20,7 +24,6 @@ import {
|
|
|
20
24
|
withInitialPlayerState,
|
|
21
25
|
} from "./utils";
|
|
22
26
|
import { log_warning } from "../../../logger";
|
|
23
|
-
import { useRivers } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
24
27
|
|
|
25
28
|
async function handleQuery({
|
|
26
29
|
query,
|
|
@@ -98,8 +101,8 @@ async function handleQuery({
|
|
|
98
101
|
}
|
|
99
102
|
|
|
100
103
|
export function useOpenSchemeHandler({ query, url, onFinish }) {
|
|
101
|
-
const rivers =
|
|
102
|
-
const contentTypes =
|
|
104
|
+
const rivers = useAppSelector(selectRivers);
|
|
105
|
+
const contentTypes = useAppSelector(selectContentTypes);
|
|
103
106
|
const navigator = useNavigation();
|
|
104
107
|
const homeId = getHomeScreenId(rivers);
|
|
105
108
|
const homeRoute = `/river/${homeId}`;
|