@applicaster/zapp-react-dom-app 15.1.16-rc.1 → 15.1.16
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.
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { DISPLAY_STATES } from "@applicaster/zapp-react-native-ui-components/Contexts/DisplayStateContext";
|
|
2
|
+
import { confirmationDialogStore } from "@applicaster/zapp-react-native-ui-components/Contexts/ConfirmDialogState";
|
|
3
|
+
import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils";
|
|
4
|
+
|
|
5
|
+
import { InteractionManagerClass } from "..";
|
|
6
|
+
|
|
7
|
+
jest.mock("@applicaster/zapp-react-native-utils/alertUtils", () => ({
|
|
8
|
+
showConfirmationDialog: jest.fn(),
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
jest.mock(
|
|
12
|
+
"@applicaster/zapp-react-native-ui-components/Decorators/Navigator",
|
|
13
|
+
() => ({ withNavigator: (C) => C })
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
jest.mock("@applicaster/zapp-react-native-redux/utils/connectToStore", () => ({
|
|
17
|
+
connectToStore: () => (C) => C,
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
jest.mock("@applicaster/zapp-react-native-utils/logger", () => {
|
|
21
|
+
const actual = jest.requireActual(
|
|
22
|
+
"@applicaster/zapp-react-native-utils/logger"
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
...actual,
|
|
27
|
+
getXray: () => ({ ...actual.getXray(), withXray: (C) => C }),
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const createBackEvent = () => ({
|
|
32
|
+
code: "Escape",
|
|
33
|
+
preventDefault: jest.fn(),
|
|
34
|
+
stopPropagation: jest.fn(),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const createManager = (props = {}) => {
|
|
38
|
+
const navigator = {
|
|
39
|
+
canGoBack: jest.fn(() => false),
|
|
40
|
+
goBack: jest.fn(),
|
|
41
|
+
replace: jest.fn(),
|
|
42
|
+
currentRoute: "/river/home",
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const defaultProps = {
|
|
46
|
+
displayState: DISPLAY_STATES.DEFAULT,
|
|
47
|
+
setDisplayState: jest.fn(),
|
|
48
|
+
navigator,
|
|
49
|
+
rivers: {},
|
|
50
|
+
backToTopAction: jest.fn(() => "GO_BACK"),
|
|
51
|
+
emitFocusOnSelectedTopMenuItem: jest.fn(),
|
|
52
|
+
emitFocusOnSelectedTab: jest.fn(),
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const mergedProps = { ...defaultProps, ...props };
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
manager: new InteractionManagerClass(mergedProps as any),
|
|
59
|
+
props: mergedProps,
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
describe("InteractionManager (web)", () => {
|
|
64
|
+
beforeEach(() => {
|
|
65
|
+
jest.clearAllMocks();
|
|
66
|
+
(focusManager as any).setInitialFocus = jest.fn();
|
|
67
|
+
confirmationDialogStore.getState().hideDialog();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe("onBackPress with exit dialog visible", () => {
|
|
71
|
+
it.each([DISPLAY_STATES.DEFAULT, DISPLAY_STATES.PLAYER])(
|
|
72
|
+
"dismisses the dialog instead of navigating (displayState: %s)",
|
|
73
|
+
(displayState) => {
|
|
74
|
+
const { manager, props } = createManager({ displayState });
|
|
75
|
+
confirmationDialogStore.getState().showDialog();
|
|
76
|
+
|
|
77
|
+
const event = createBackEvent();
|
|
78
|
+
manager.onBackPress(event);
|
|
79
|
+
|
|
80
|
+
expect(confirmationDialogStore.getState().isDialogVisible).toBe(false);
|
|
81
|
+
expect(props.backToTopAction).not.toHaveBeenCalled();
|
|
82
|
+
expect(props.navigator.goBack).not.toHaveBeenCalled();
|
|
83
|
+
expect(event.preventDefault).toHaveBeenCalled();
|
|
84
|
+
|
|
85
|
+
expect(focusManager.setInitialFocus).toHaveBeenCalledWith(undefined, {
|
|
86
|
+
source: "cancel",
|
|
87
|
+
preserveScroll: true,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
it("resolves the back action normally when the dialog is hidden", () => {
|
|
93
|
+
const { manager, props } = createManager();
|
|
94
|
+
|
|
95
|
+
manager.onBackPress(createBackEvent());
|
|
96
|
+
|
|
97
|
+
expect(props.backToTopAction).toHaveBeenCalled();
|
|
98
|
+
expect(props.navigator.canGoBack).toHaveBeenCalled();
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|
|
@@ -92,7 +92,7 @@ type KeyCode = { code: string; keyCode: number | string };
|
|
|
92
92
|
const VIDEO_PLAYER_CONTROLS_NAVIGATION_MESSAGE =
|
|
93
93
|
"Video player controls - use left/right to navigate";
|
|
94
94
|
|
|
95
|
-
class InteractionManagerClass extends React.Component<Props, State> {
|
|
95
|
+
export class InteractionManagerClass extends React.Component<Props, State> {
|
|
96
96
|
onKeyDownListener: (keyCode: KeyCode) => void;
|
|
97
97
|
onMouseDownListener: (event: MouseEvent) => void;
|
|
98
98
|
onMouseMoveListener: (event: MouseEvent) => void;
|
|
@@ -421,6 +421,16 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
421
421
|
return;
|
|
422
422
|
}
|
|
423
423
|
|
|
424
|
+
// Focus is inside the dialog, so backToTopAction() can't resolve a
|
|
425
|
+
// meaningful action — Back must dismiss the dialog in every display state.
|
|
426
|
+
if (isDialogVisible) {
|
|
427
|
+
this.onConfirmDialogClose();
|
|
428
|
+
event.preventDefault();
|
|
429
|
+
event.stopPropagation();
|
|
430
|
+
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
|
|
424
434
|
const action = backToTopAction();
|
|
425
435
|
|
|
426
436
|
const effectiveDisplayState = this.getEffectiveDisplayState();
|
|
@@ -482,9 +492,7 @@ class InteractionManagerClass extends React.Component<Props, State> {
|
|
|
482
492
|
|
|
483
493
|
break;
|
|
484
494
|
case DISPLAY_STATES.PLAYER:
|
|
485
|
-
if (
|
|
486
|
-
this.onConfirmDialogClose();
|
|
487
|
-
} else if (navigator.canGoBack()) {
|
|
495
|
+
if (navigator.canGoBack()) {
|
|
488
496
|
navigator.goBack();
|
|
489
497
|
} else if (this.isHomeScreen()) {
|
|
490
498
|
this.platformBack();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-dom-app",
|
|
3
|
-
"version": "15.1.16
|
|
3
|
+
"version": "15.1.16",
|
|
4
4
|
"description": "Zapp App Component for Applicaster's Quick Brick React Native App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/applicaster/zapp-react-dom-app#readme",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@applicaster/zapp-react-dom-ui-components": "15.1.16
|
|
26
|
-
"@applicaster/zapp-react-native-bridge": "15.1.16
|
|
27
|
-
"@applicaster/zapp-react-native-redux": "15.1.16
|
|
28
|
-
"@applicaster/zapp-react-native-ui-components": "15.1.16
|
|
29
|
-
"@applicaster/zapp-react-native-utils": "15.1.16
|
|
25
|
+
"@applicaster/zapp-react-dom-ui-components": "15.1.16",
|
|
26
|
+
"@applicaster/zapp-react-native-bridge": "15.1.16",
|
|
27
|
+
"@applicaster/zapp-react-native-redux": "15.1.16",
|
|
28
|
+
"@applicaster/zapp-react-native-ui-components": "15.1.16",
|
|
29
|
+
"@applicaster/zapp-react-native-utils": "15.1.16",
|
|
30
30
|
"abortcontroller-polyfill": "^1.7.5",
|
|
31
31
|
"typeface-montserrat": "^0.0.54",
|
|
32
32
|
"video.js": "7.14.3",
|