@applicaster/quick-brick-core 15.0.0-rc.98 → 15.1.0-rc.1
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 +42 -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
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
+
import { act, create } from "react-test-renderer";
|
|
4
|
+
import { createStore } from "redux";
|
|
5
|
+
import { Provider } from "react-redux";
|
|
3
6
|
|
|
4
7
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
5
|
-
import { NavigationProvider } from "../NavigationProvider";
|
|
6
|
-
|
|
7
8
|
import { getByTestId } from "@applicaster/zapp-react-native-utils/testUtils/getByTestId";
|
|
8
|
-
|
|
9
|
-
import { act } from "@testing-library/react-native";
|
|
10
|
-
|
|
11
|
-
jest.useFakeTimers({
|
|
12
|
-
legacyFakeTimers: true,
|
|
13
|
-
});
|
|
9
|
+
// @TODO @szhigunov to complete the migration to @testing-library/react-native
|
|
10
|
+
// import { act, waitFor } from "@testing-library/react-native";
|
|
14
11
|
|
|
15
12
|
const rivers = {
|
|
16
13
|
A1234: {
|
|
@@ -30,20 +27,20 @@ const rivers = {
|
|
|
30
27
|
ui_components: [],
|
|
31
28
|
hooks: {
|
|
32
29
|
postload_plugins: [],
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
preload_plugins: [
|
|
31
|
+
{
|
|
32
|
+
screen_id: "hook_screen",
|
|
33
|
+
identifier: "test-hook",
|
|
34
|
+
type: "general",
|
|
35
|
+
weight: 7,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
screen_id: "hook_screen2",
|
|
39
|
+
identifier: "test-hook2",
|
|
40
|
+
type: "general",
|
|
41
|
+
weight: 7,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
47
44
|
},
|
|
48
45
|
},
|
|
49
46
|
D6543: {
|
|
@@ -84,9 +81,13 @@ const rivers = {
|
|
|
84
81
|
},
|
|
85
82
|
};
|
|
86
83
|
|
|
87
|
-
jest.mock("@applicaster/zapp-react-native-redux", () => ({
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
|
|
85
|
+
usePickFromState: jest.fn(() => ({
|
|
86
|
+
appData: { layoutVersion: "v2" },
|
|
87
|
+
rivers,
|
|
88
|
+
plugins: [],
|
|
89
|
+
appState: { appLaunched: true },
|
|
90
|
+
})),
|
|
90
91
|
useContentTypes: jest.fn(() => ({})),
|
|
91
92
|
}));
|
|
92
93
|
|
|
@@ -106,6 +107,8 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/connection", () => ({
|
|
|
106
107
|
})),
|
|
107
108
|
}));
|
|
108
109
|
|
|
110
|
+
const { NavigationProvider } = require("../NavigationProvider");
|
|
111
|
+
|
|
109
112
|
// eslint-disable-next-line react/prop-types
|
|
110
113
|
const HookComponent = ({ callback, payload }: Props) => {
|
|
111
114
|
if (payload?.id === "D6543") {
|
|
@@ -151,13 +154,18 @@ const failingHook = {
|
|
|
151
154
|
name: "failing hook",
|
|
152
155
|
};
|
|
153
156
|
|
|
154
|
-
const store = {
|
|
157
|
+
// const store = {
|
|
158
|
+
// rivers,
|
|
159
|
+
// plugins: [hookPlugin, hookPlugin2, failingHook],
|
|
160
|
+
// };
|
|
161
|
+
|
|
162
|
+
const store = createStore(() => ({
|
|
155
163
|
appData: { layoutVersion: "v1" },
|
|
156
|
-
contentTypes:
|
|
164
|
+
contentTypes: null,
|
|
157
165
|
rivers,
|
|
158
166
|
plugins: [hookPlugin, hookPlugin2, failingHook],
|
|
159
167
|
appState: { appLaunched: true },
|
|
160
|
-
};
|
|
168
|
+
}));
|
|
161
169
|
|
|
162
170
|
const ContextConsumer = () => {
|
|
163
171
|
const { state, ...navigator } = useNavigation();
|
|
@@ -165,7 +173,6 @@ const ContextConsumer = () => {
|
|
|
165
173
|
let renderHook;
|
|
166
174
|
|
|
167
175
|
if (navigator.currentRoute.includes("/hooks/")) {
|
|
168
|
-
// @ts-ignore
|
|
169
176
|
const { hookPlugin, payload, callback } = navigator.screenData;
|
|
170
177
|
const Component = hookPlugin.module.Component;
|
|
171
178
|
|
|
@@ -185,21 +192,18 @@ const ContextConsumer = () => {
|
|
|
185
192
|
|
|
186
193
|
const consoleSpy = jest.spyOn(console, "error").mockImplementation(() => {});
|
|
187
194
|
|
|
188
|
-
const renderContextConsumer = (_store = store) =>
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
195
|
+
// const renderContextConsumer = (_store = store) => {
|
|
196
|
+
// return renderWithProviders(<ContextConsumer />, _store);
|
|
197
|
+
// };
|
|
198
|
+
|
|
199
|
+
const renderContextConsumer = (_store = store) => {
|
|
200
|
+
return create(
|
|
201
|
+
<Provider store={store}>
|
|
202
|
+
<NavigationProvider>
|
|
203
|
+
<ContextConsumer />
|
|
204
|
+
</NavigationProvider>
|
|
205
|
+
</Provider>
|
|
194
206
|
);
|
|
195
|
-
|
|
196
|
-
const getNavigatorValues = (wrapper) => {
|
|
197
|
-
const view = getByTestId(wrapper, "WrapperView");
|
|
198
|
-
const navigator = view.props.navigator;
|
|
199
|
-
|
|
200
|
-
const state = view.props.state;
|
|
201
|
-
|
|
202
|
-
return { navigator, state };
|
|
203
207
|
};
|
|
204
208
|
|
|
205
209
|
afterAll(() => {
|
|
@@ -209,12 +213,14 @@ afterAll(() => {
|
|
|
209
213
|
describe("<NavigationProvider />", () => {
|
|
210
214
|
let wrapper;
|
|
211
215
|
|
|
212
|
-
beforeEach(() => {
|
|
213
|
-
wrapper = renderContextConsumer();
|
|
214
|
-
});
|
|
215
|
-
|
|
216
216
|
it("navigator contains expected properties", () => {
|
|
217
|
-
|
|
217
|
+
act(() => {
|
|
218
|
+
wrapper = renderContextConsumer();
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
const view = getByTestId(wrapper, "WrapperView");
|
|
222
|
+
|
|
223
|
+
const { navigator } = view.props;
|
|
218
224
|
expect(navigator.activeRiver).toEqual(rivers.B4567);
|
|
219
225
|
expect(navigator.currentRoute).toEqual("/river/B4567");
|
|
220
226
|
expect(navigator.previousAction).toEqual("REPLACE");
|
|
@@ -230,131 +236,148 @@ describe("<NavigationProvider />", () => {
|
|
|
230
236
|
});
|
|
231
237
|
});
|
|
232
238
|
|
|
233
|
-
|
|
239
|
+
describe("pushing a new route", () => {
|
|
234
240
|
act(() => {
|
|
235
|
-
|
|
241
|
+
wrapper = renderContextConsumer();
|
|
236
242
|
});
|
|
237
243
|
|
|
238
|
-
|
|
244
|
+
it("sets the data to that route", async () => {
|
|
245
|
+
const view = getByTestId(wrapper, "WrapperView");
|
|
239
246
|
|
|
240
|
-
|
|
247
|
+
act(() => view.props.navigator.push(rivers.A1234));
|
|
241
248
|
|
|
242
|
-
|
|
243
|
-
"currentRoute",
|
|
244
|
-
"/river/B4567/river/A1234"
|
|
245
|
-
);
|
|
249
|
+
expect(view.props.navigator).toHaveProperty("activeRiver", rivers.A1234);
|
|
246
250
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
+
expect(view.props.navigator).toHaveProperty(
|
|
252
|
+
"currentRoute",
|
|
253
|
+
"/river/B4567/river/A1234"
|
|
254
|
+
);
|
|
251
255
|
|
|
252
|
-
|
|
256
|
+
expect(view.props.navigator.screenData).toEqual({
|
|
257
|
+
...rivers.A1234,
|
|
258
|
+
targetScreen: rivers.A1234,
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
expect(view.props.state.stack.mainStack).toHaveLength(2);
|
|
262
|
+
});
|
|
253
263
|
});
|
|
254
264
|
|
|
255
265
|
describe("replacing a current route", () => {
|
|
266
|
+
act(() => {
|
|
267
|
+
wrapper = renderContextConsumer();
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
const view = getByTestId(wrapper, "WrapperView");
|
|
271
|
+
|
|
256
272
|
it("sets the data to that route", () => {
|
|
257
|
-
act(() =>
|
|
258
|
-
|
|
259
|
-
expect(navigator).toHaveProperty("activeRiver", rivers.A1234);
|
|
273
|
+
act(() => view.props.navigator.replace(rivers.A1234));
|
|
274
|
+
expect(view.props.navigator).toHaveProperty("activeRiver", rivers.A1234);
|
|
260
275
|
|
|
261
|
-
expect(navigator).toHaveProperty(
|
|
276
|
+
expect(view.props.navigator).toHaveProperty(
|
|
277
|
+
"currentRoute",
|
|
278
|
+
"/river/A1234"
|
|
279
|
+
);
|
|
262
280
|
|
|
263
|
-
expect(navigator.screenData).toEqual({
|
|
281
|
+
expect(view.props.navigator.screenData).toEqual({
|
|
264
282
|
...rivers.A1234,
|
|
265
283
|
targetScreen: rivers.A1234,
|
|
266
284
|
});
|
|
267
285
|
|
|
268
|
-
expect(state.stack.mainStack).toHaveLength(1);
|
|
286
|
+
expect(view.props.state.stack.mainStack).toHaveLength(1);
|
|
269
287
|
});
|
|
270
288
|
});
|
|
271
289
|
|
|
272
290
|
describe("going back", () => {
|
|
273
291
|
describe("when there is no previous route", () => {
|
|
292
|
+
act(() => {
|
|
293
|
+
wrapper = renderContextConsumer();
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
const view = getByTestId(wrapper, "WrapperView");
|
|
297
|
+
|
|
274
298
|
it("returns false when calling canGoBack", () => {
|
|
275
299
|
let result;
|
|
276
300
|
|
|
277
301
|
act(() => {
|
|
278
|
-
result =
|
|
302
|
+
result = view.props.navigator.canGoBack();
|
|
279
303
|
});
|
|
280
304
|
|
|
281
305
|
expect(result).toBe(false);
|
|
282
306
|
});
|
|
283
307
|
|
|
284
308
|
it("stays on the current route", () => {
|
|
285
|
-
act(() =>
|
|
286
|
-
const { navigator, state } = getNavigatorValues(wrapper);
|
|
309
|
+
act(() => view.props.navigator.goBack());
|
|
287
310
|
|
|
288
|
-
expect(navigator).toHaveProperty(
|
|
311
|
+
expect(view.props.navigator).toHaveProperty(
|
|
312
|
+
"activeRiver",
|
|
313
|
+
rivers.B4567
|
|
314
|
+
);
|
|
289
315
|
|
|
290
|
-
expect(navigator).toHaveProperty(
|
|
316
|
+
expect(view.props.navigator).toHaveProperty(
|
|
317
|
+
"currentRoute",
|
|
318
|
+
"/river/B4567"
|
|
319
|
+
);
|
|
291
320
|
|
|
292
|
-
expect(navigator.screenData).toEqual({
|
|
321
|
+
expect(view.props.navigator.screenData).toEqual({
|
|
293
322
|
...rivers.B4567,
|
|
294
323
|
targetScreen: rivers.B4567,
|
|
295
324
|
});
|
|
296
325
|
|
|
297
|
-
expect(state.stack.mainStack).toHaveLength(1);
|
|
326
|
+
expect(view.props.state.stack.mainStack).toHaveLength(1);
|
|
298
327
|
});
|
|
299
328
|
});
|
|
300
329
|
|
|
301
330
|
describe("when there is one route and we're going in a hook", () => {
|
|
302
|
-
|
|
303
|
-
getNavigatorValues(wrapper).navigator.replace(rivers.A1234);
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
it.skip("returns true when calling goBack()", () => {
|
|
331
|
+
act(() => {
|
|
307
332
|
wrapper = renderContextConsumer();
|
|
333
|
+
});
|
|
308
334
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
getNavigatorValues(wrapper).navigator.push(rivers.C0987);
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
const { navigator, state } = getNavigatorValues(wrapper);
|
|
335
|
+
const view = getByTestId(wrapper, "WrapperView");
|
|
336
|
+
act(() => view.props.navigator.replace(rivers.A1234));
|
|
315
337
|
|
|
316
|
-
|
|
317
|
-
|
|
338
|
+
it("returns true when calling goBack()", () => {
|
|
339
|
+
act(() => view.props.navigator.push(rivers.C0987));
|
|
340
|
+
expect(view.props.state.stack.mainStack.length).toBeGreaterThan(1);
|
|
341
|
+
expect(view.props.navigator.canGoBack()).toEqual(true);
|
|
318
342
|
});
|
|
319
343
|
|
|
320
344
|
// this test is skipped as it doesn't work on this version of react
|
|
321
345
|
// where we can't properly test async actions within components
|
|
322
346
|
it.skip("returns to the previous route when the hook is cancelled", () => {
|
|
323
|
-
|
|
347
|
+
act(() => view.props.navigator.replace(rivers.A1234));
|
|
348
|
+
act(() => view.props.navigator.push(rivers.D6543));
|
|
324
349
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
const { navigator, state } = getNavigatorValues(wrapper);
|
|
331
|
-
|
|
332
|
-
expect(navigator).toHaveProperty("activeRiver", rivers.A1234);
|
|
350
|
+
expect(view.props.navigator).toHaveProperty(
|
|
351
|
+
"activeRiver",
|
|
352
|
+
rivers.A1234
|
|
353
|
+
);
|
|
333
354
|
|
|
334
|
-
expect(navigator).toHaveProperty(
|
|
355
|
+
expect(view.props.navigator).toHaveProperty(
|
|
356
|
+
"currentRoute",
|
|
357
|
+
"/river/A1234"
|
|
358
|
+
);
|
|
335
359
|
|
|
336
|
-
expect(navigator.screenData).toEqual(rivers.A1234);
|
|
337
|
-
expect(state.stack.mainStack).toHaveLength(1);
|
|
360
|
+
expect(view.props.navigator.screenData).toEqual(rivers.A1234);
|
|
361
|
+
expect(view.props.state.stack.mainStack).toHaveLength(1);
|
|
338
362
|
});
|
|
339
363
|
});
|
|
340
364
|
|
|
341
365
|
describe("when there is a previous route", () => {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
act(() =>
|
|
346
|
-
getNavigatorValues(wrapper).navigator.push({
|
|
347
|
-
...rivers.B4567,
|
|
348
|
-
id: "B4567-1",
|
|
349
|
-
})
|
|
350
|
-
);
|
|
366
|
+
act(() => {
|
|
367
|
+
wrapper = renderContextConsumer();
|
|
351
368
|
});
|
|
352
369
|
|
|
370
|
+
const view = getByTestId(wrapper, "WrapperView");
|
|
371
|
+
|
|
372
|
+
act(() => view.props.navigator.push(rivers.A1234));
|
|
373
|
+
|
|
374
|
+
act(() => view.props.navigator.push({ ...rivers.B4567, id: "B4567-1" }));
|
|
375
|
+
|
|
353
376
|
it("returns true when calling canGoBack", () => {
|
|
354
377
|
let result;
|
|
355
378
|
|
|
356
379
|
act(() => {
|
|
357
|
-
result =
|
|
380
|
+
result = view.props.navigator.canGoBack();
|
|
358
381
|
});
|
|
359
382
|
|
|
360
383
|
expect(result).toBeTruthy();
|
|
@@ -364,86 +387,74 @@ describe("<NavigationProvider />", () => {
|
|
|
364
387
|
let result;
|
|
365
388
|
|
|
366
389
|
act(() => {
|
|
367
|
-
result =
|
|
368
|
-
false,
|
|
369
|
-
"B4567-1"
|
|
370
|
-
);
|
|
390
|
+
result = view.props.navigator.canGoBack(false, "B4567-1");
|
|
371
391
|
});
|
|
372
392
|
|
|
373
393
|
expect(result).toBeTruthy();
|
|
374
394
|
|
|
375
395
|
act(() => {
|
|
376
|
-
result =
|
|
377
|
-
false,
|
|
378
|
-
"A1234"
|
|
379
|
-
);
|
|
396
|
+
result = view.props.navigator.canGoBack(false, "A1234");
|
|
380
397
|
});
|
|
381
398
|
|
|
382
399
|
expect(result).toBeTruthy();
|
|
383
400
|
});
|
|
384
401
|
|
|
385
402
|
it("returns to the previous route", () => {
|
|
386
|
-
expect(
|
|
387
|
-
3
|
|
388
|
-
);
|
|
403
|
+
expect(view.props.state.stack.mainStack).toHaveLength(3);
|
|
389
404
|
|
|
390
|
-
act(() =>
|
|
405
|
+
act(() => view.props.navigator.goBack());
|
|
391
406
|
|
|
392
|
-
expect(
|
|
407
|
+
expect(view.props.navigator).toHaveProperty(
|
|
393
408
|
"activeRiver",
|
|
394
409
|
rivers.A1234
|
|
395
410
|
);
|
|
396
411
|
|
|
397
|
-
expect(
|
|
412
|
+
expect(view.props.navigator).toHaveProperty(
|
|
398
413
|
"currentRoute",
|
|
399
414
|
"/river/B4567/river/A1234"
|
|
400
415
|
);
|
|
401
416
|
|
|
402
|
-
expect(
|
|
417
|
+
expect(view.props.navigator.screenData).toEqual({
|
|
403
418
|
...rivers.A1234,
|
|
404
419
|
targetScreen: rivers.A1234,
|
|
405
420
|
});
|
|
406
421
|
|
|
407
|
-
expect(
|
|
408
|
-
2
|
|
409
|
-
);
|
|
422
|
+
expect(view.props.state.stack.mainStack).toHaveLength(2);
|
|
410
423
|
});
|
|
411
424
|
});
|
|
412
425
|
|
|
413
426
|
describe("when there is a previous route and there are hooks", () => {
|
|
414
|
-
|
|
427
|
+
act(() => {
|
|
415
428
|
wrapper = renderContextConsumer();
|
|
416
|
-
act(() => getNavigatorValues(wrapper).navigator.push(rivers.A1234));
|
|
417
|
-
act(() => getNavigatorValues(wrapper).navigator.push(rivers.C0987));
|
|
418
429
|
});
|
|
419
430
|
|
|
431
|
+
const view = getByTestId(wrapper, "WrapperView");
|
|
432
|
+
act(() => view.props.navigator.push(rivers.A1234));
|
|
433
|
+
act(() => view.props.navigator.push(rivers.C0987));
|
|
434
|
+
|
|
420
435
|
it("returns to the previous entry in the stack which is not a hook", () => {
|
|
421
|
-
expect(
|
|
422
|
-
3
|
|
423
|
-
);
|
|
436
|
+
expect(view.props.state.stack.mainStack).toHaveLength(3);
|
|
424
437
|
|
|
425
|
-
expect(
|
|
438
|
+
expect(view.props.navigator).toHaveProperty(
|
|
426
439
|
"currentRoute",
|
|
427
440
|
"/river/B4567/river/A1234/river/C0987"
|
|
428
441
|
);
|
|
429
442
|
|
|
430
|
-
expect(
|
|
443
|
+
expect(view.props.navigator.screenData).toMatchObject({
|
|
431
444
|
...rivers.C0987,
|
|
432
445
|
targetScreen: rivers.C0987,
|
|
433
446
|
});
|
|
434
447
|
|
|
435
|
-
act(() =>
|
|
448
|
+
act(() => view.props.navigator.goBack());
|
|
436
449
|
|
|
437
|
-
expect(
|
|
438
|
-
2
|
|
439
|
-
);
|
|
450
|
+
expect(view.props.state.stack.mainStack).toHaveLength(2);
|
|
440
451
|
|
|
441
|
-
expect(
|
|
452
|
+
expect(view.props.navigator).toHaveProperty(
|
|
442
453
|
"currentRoute",
|
|
443
454
|
"/river/B4567/river/A1234"
|
|
444
455
|
);
|
|
445
456
|
|
|
446
|
-
expect(
|
|
457
|
+
expect(view.props.navigator.screenData).toMatchObject({
|
|
447
458
|
...rivers.A1234,
|
|
448
459
|
targetScreen: rivers.A1234,
|
|
449
460
|
});
|
|
@@ -2,7 +2,6 @@ import * as R from "ramda";
|
|
|
2
2
|
import { createSelector } from "@reduxjs/toolkit";
|
|
3
3
|
|
|
4
4
|
import { getPathAttributes } from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
5
|
-
import { selectPluginConfigurations } from "@applicaster/zapp-react-native-redux";
|
|
6
5
|
|
|
7
6
|
const riverSelector = R.prop("rivers");
|
|
8
7
|
const pathnameSelector = R.prop("pathname");
|
|
@@ -57,26 +56,11 @@ export const previousStackEntriesSelector = createSelector(
|
|
|
57
56
|
)
|
|
58
57
|
);
|
|
59
58
|
|
|
60
|
-
export const lastEntrySelector = createSelector
|
|
59
|
+
export const lastEntrySelector = createSelector<
|
|
60
|
+
unknown,
|
|
61
|
+
unknown,
|
|
62
|
+
NavigationScreenState
|
|
63
|
+
>(
|
|
61
64
|
navigationStackSelector,
|
|
62
65
|
R.compose(R.last, R.when(R.has("mainStack"), R.prop("mainStack")))
|
|
63
|
-
) as (state: any) => any; // TODO: tighten type to NavigationScreenState
|
|
64
|
-
|
|
65
|
-
// Selector extracting identifiers of plugins requiring startup execution
|
|
66
|
-
export const startUpHookPluginIdentifiersSelector = createSelector(
|
|
67
|
-
selectPluginConfigurations,
|
|
68
|
-
(pluginConfigurations) => {
|
|
69
|
-
if (!pluginConfigurations) return [];
|
|
70
|
-
|
|
71
|
-
return Object.values(pluginConfigurations)
|
|
72
|
-
.filter(
|
|
73
|
-
(item) =>
|
|
74
|
-
item.plugin?.api &&
|
|
75
|
-
"require_startup_execution" in item.plugin.api &&
|
|
76
|
-
item.plugin.api.require_startup_execution === true &&
|
|
77
|
-
item.plugin.react_native === true &&
|
|
78
|
-
item.plugin.preload === true
|
|
79
|
-
)
|
|
80
|
-
.map((item: any) => item.plugin.identifier);
|
|
81
|
-
}
|
|
82
66
|
);
|
|
@@ -3,7 +3,7 @@ import { Platform } from "react-native";
|
|
|
3
3
|
import NetInfo, { NetInfoState } from "@react-native-community/netinfo";
|
|
4
4
|
|
|
5
5
|
import { NetworkStatusContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NetworkStatusContext";
|
|
6
|
-
import {
|
|
6
|
+
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
7
7
|
import {
|
|
8
8
|
callAllWith,
|
|
9
9
|
getNetworkHooks,
|
|
@@ -29,7 +29,7 @@ export const NetworkStatusProvider = ({
|
|
|
29
29
|
}: {
|
|
30
30
|
children: React.ReactNode;
|
|
31
31
|
}) => {
|
|
32
|
-
const plugins =
|
|
32
|
+
const { plugins } = usePickFromState("plugins");
|
|
33
33
|
const [deviceStatus, setDeviceStatus] = React.useState(null);
|
|
34
34
|
const currentNetInfo = NetInfo.useNetInfo();
|
|
35
35
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as R from "ramda";
|
|
3
|
-
import { renderHook, act } from "@testing-library/react-
|
|
3
|
+
import { renderHook, act } from "@testing-library/react-hooks";
|
|
4
4
|
import { NetworkStatusContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NetworkStatusContext";
|
|
5
5
|
import { NetworkStatusProvider } from "../NetworkStatusProvider";
|
|
6
6
|
import { WrappedWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
@@ -52,7 +52,7 @@ describe("NetworkStatusProvider", function () {
|
|
|
52
52
|
expect(result.current).toStrictEqual(NetInfoMock);
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
it("should call onConnectionLost callback when connection type changes to none",
|
|
55
|
+
it("should call onConnectionLost callback when connection type changes to none", function () {
|
|
56
56
|
const onConnectionLost = jest.fn();
|
|
57
57
|
|
|
58
58
|
const store = {
|
|
@@ -79,7 +79,7 @@ describe("NetworkStatusProvider", function () {
|
|
|
79
79
|
expect(onConnectionLost).toBeCalledTimes(1);
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
-
it("should call onConnectionRestored callback when connection type switches from none",
|
|
82
|
+
it("should call onConnectionRestored callback when connection type switches from none", function () {
|
|
83
83
|
const onConnectionRestored = jest.fn();
|
|
84
84
|
|
|
85
85
|
const store = {
|
|
@@ -116,7 +116,7 @@ describe("NetworkStatusProvider", function () {
|
|
|
116
116
|
expect(onConnectionRestored).toBeCalledTimes(1);
|
|
117
117
|
});
|
|
118
118
|
|
|
119
|
-
it("should call onConnectionTypeChanged callback when connection type changes",
|
|
119
|
+
it("should call onConnectionTypeChanged callback when connection type changes", function () {
|
|
120
120
|
const onConnectionTypeChanged = jest.fn();
|
|
121
121
|
|
|
122
122
|
const store = {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { render } from "@testing-library/react-native";
|
|
4
4
|
import { Provider } from "react-redux";
|
|
5
|
-
import
|
|
5
|
+
import thunk from "redux-thunk";
|
|
6
6
|
import configureStore from "redux-mock-store";
|
|
7
7
|
|
|
8
8
|
jest.mock(
|
|
@@ -3,7 +3,7 @@ import * as React from "react";
|
|
|
3
3
|
import { getRemoteContextData } from "../remoteContextReloader/getRemoteContextData";
|
|
4
4
|
|
|
5
5
|
import { coreAppLogger } from "../logger";
|
|
6
|
-
import {
|
|
6
|
+
import { AnyAction, Dispatch } from "@reduxjs/toolkit";
|
|
7
7
|
import { isAndroidPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
8
8
|
|
|
9
9
|
const logger = coreAppLogger.addSubsystem("AppRemoteDataLoader");
|
|
@@ -27,7 +27,7 @@ export function appRemoteDataLoader(Component: ReactComponent<any>) {
|
|
|
27
27
|
const [isDataLoaded, setIsDataLoaded] = React.useState(false);
|
|
28
28
|
|
|
29
29
|
const loadRemoteConfigurationJSONs = async (
|
|
30
|
-
dispatch: Dispatch<
|
|
30
|
+
dispatch: Dispatch<AnyAction>,
|
|
31
31
|
state
|
|
32
32
|
) => {
|
|
33
33
|
if (!__DEV__ || process.env.ENABLE_REMOTE_DATA_IN_DEV === "true") {
|
|
@@ -74,7 +74,7 @@ export async function getNativeRemoteContextData(
|
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
const apiVersion = layout?.layout?.api_version; // Taken from remote configuration
|
|
77
|
+
const apiVersion = layout?.layout?.["api_version"]; // Taken from remote configuration
|
|
78
78
|
|
|
79
79
|
dispatch(AppData.actions.merge({ layoutVersion: apiVersion || "v1" }));
|
|
80
80
|
|
|
@@ -113,15 +113,15 @@ export async function prepareRuntimeConfigurationUrls(
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
export async function getPromiseForType
|
|
116
|
+
export async function getPromiseForType(
|
|
117
117
|
key: string
|
|
118
|
-
): Promise<
|
|
118
|
+
): Promise<FileResponse | never> {
|
|
119
119
|
try {
|
|
120
120
|
const response = await AppLoaderBridge?.getFile(key, null);
|
|
121
121
|
|
|
122
122
|
return {
|
|
123
123
|
[key]: JSON.parse(response),
|
|
124
|
-
}
|
|
124
|
+
};
|
|
125
125
|
} catch (e) {
|
|
126
126
|
throw new Error("cannot retrieve configuration data for " + key);
|
|
127
127
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/quick-brick-core",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.1.0-rc.1",
|
|
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": "15.
|
|
32
|
-
"@applicaster/quick-brick-core-plugins": "15.
|
|
33
|
-
"@applicaster/zapp-pipes-v2-client": "15.
|
|
34
|
-
"@applicaster/zapp-react-native-bridge": "15.
|
|
35
|
-
"@applicaster/zapp-react-native-redux": "15.
|
|
36
|
-
"@applicaster/zapp-react-native-ui-components": "15.
|
|
37
|
-
"@applicaster/zapp-react-native-utils": "15.
|
|
31
|
+
"@applicaster/applicaster-types": "15.1.0-rc.1",
|
|
32
|
+
"@applicaster/quick-brick-core-plugins": "15.1.0-rc.1",
|
|
33
|
+
"@applicaster/zapp-pipes-v2-client": "15.1.0-rc.1",
|
|
34
|
+
"@applicaster/zapp-react-native-bridge": "15.1.0-rc.1",
|
|
35
|
+
"@applicaster/zapp-react-native-redux": "15.1.0-rc.1",
|
|
36
|
+
"@applicaster/zapp-react-native-ui-components": "15.1.0-rc.1",
|
|
37
|
+
"@applicaster/zapp-react-native-utils": "15.1.0-rc.1",
|
|
38
38
|
"atob": "^2.1.2",
|
|
39
39
|
"axios": "^0.28.0",
|
|
40
40
|
"btoa": "^1.2.1",
|