@jobber/components-native 0.95.4-improve-co-ca924fd.14 → 0.95.4
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/dist/package.json +5 -3
- package/dist/src/ContentOverlay/ContentOverlay.js +107 -128
- package/dist/src/ContentOverlay/ContentOverlay.style.js +12 -8
- package/dist/src/ContentOverlay/UNSAFE_WrappedModalize.js +23 -0
- package/dist/src/ContentOverlay/index.js +0 -1
- package/dist/src/InputFieldWrapper/InputFieldWrapper.js +12 -2
- package/dist/src/InputText/InputText.js +2 -36
- package/dist/src/utils/meta/meta.json +0 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/src/ContentOverlay/ContentOverlay.d.ts +5 -1
- package/dist/types/src/ContentOverlay/ContentOverlay.style.d.ts +10 -11
- package/dist/types/src/ContentOverlay/UNSAFE_WrappedModalize.d.ts +3 -0
- package/dist/types/src/ContentOverlay/index.d.ts +0 -1
- package/dist/types/src/ContentOverlay/types.d.ts +12 -5
- package/dist/types/src/InputFieldWrapper/InputFieldWrapper.d.ts +5 -1
- package/jestSetup.js +0 -2
- package/package.json +5 -3
- package/src/ContentOverlay/ContentOverlay.style.ts +12 -12
- package/src/ContentOverlay/ContentOverlay.test.tsx +79 -157
- package/src/ContentOverlay/ContentOverlay.tsx +210 -223
- package/src/ContentOverlay/UNSAFE_WrappedModalize.tsx +41 -0
- package/src/ContentOverlay/index.ts +0 -1
- package/src/ContentOverlay/types.ts +13 -5
- package/src/InputFieldWrapper/InputFieldWrapper.test.tsx +47 -0
- package/src/InputFieldWrapper/InputFieldWrapper.tsx +19 -1
- package/src/InputText/InputText.test.tsx +0 -122
- package/src/InputText/InputText.tsx +3 -52
- package/src/ThumbnailList/__snapshots__/ThumbnailList.test.tsx.snap +20 -0
- package/src/utils/meta/meta.json +0 -1
- package/dist/src/ContentOverlay/ContentOverlayProvider.js +0 -5
- package/dist/src/ContentOverlay/computeContentOverlayBehavior.js +0 -76
- package/dist/src/ContentOverlay/hooks/useBottomSheetModalBackHandler.js +0 -25
- package/dist/types/src/ContentOverlay/ContentOverlayProvider.d.ts +0 -6
- package/dist/types/src/ContentOverlay/computeContentOverlayBehavior.d.ts +0 -32
- package/dist/types/src/ContentOverlay/hooks/useBottomSheetModalBackHandler.d.ts +0 -7
- package/src/ContentOverlay/ContentOverlay.stories.tsx +0 -59
- package/src/ContentOverlay/ContentOverlayProvider.tsx +0 -12
- package/src/ContentOverlay/computeContentOverlayBehavior.test.ts +0 -276
- package/src/ContentOverlay/computeContentOverlayBehavior.ts +0 -119
- package/src/ContentOverlay/hooks/useBottomSheetModalBackHandler.test.ts +0 -81
- package/src/ContentOverlay/hooks/useBottomSheetModalBackHandler.ts +0 -36
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import type { Modalize } from "react-native-modalize";
|
|
2
3
|
import type { ContentOverlayProps } from "./types";
|
|
3
|
-
export declare
|
|
4
|
+
export declare const ContentOverlay: React.ForwardRefExoticComponent<ContentOverlayProps & React.RefAttributes<{
|
|
5
|
+
open?: Modalize["open"];
|
|
6
|
+
close?: Modalize["close"];
|
|
7
|
+
} | undefined>>;
|
|
@@ -1,33 +1,32 @@
|
|
|
1
1
|
export declare const useStyles: () => {
|
|
2
|
-
handleWrapper: {
|
|
3
|
-
paddingBottom: number;
|
|
4
|
-
paddingTop: number;
|
|
5
|
-
};
|
|
6
2
|
handle: {
|
|
7
3
|
width: number;
|
|
8
4
|
height: number;
|
|
9
5
|
backgroundColor: string;
|
|
6
|
+
top: number;
|
|
10
7
|
borderRadius: number;
|
|
11
8
|
};
|
|
12
|
-
|
|
9
|
+
overlay: {
|
|
13
10
|
backgroundColor: string;
|
|
14
11
|
};
|
|
15
|
-
|
|
12
|
+
modal: {
|
|
16
13
|
borderTopLeftRadius: number;
|
|
17
14
|
borderTopRightRadius: number;
|
|
18
15
|
};
|
|
16
|
+
modalForLargeScreens: {
|
|
17
|
+
width: number;
|
|
18
|
+
alignSelf: "center";
|
|
19
|
+
};
|
|
19
20
|
header: {
|
|
20
21
|
flexDirection: "row";
|
|
22
|
+
backgroundColor: string;
|
|
23
|
+
paddingTop: number;
|
|
21
24
|
zIndex: number;
|
|
22
|
-
minHeight: number;
|
|
23
25
|
borderTopLeftRadius: number;
|
|
24
26
|
borderTopRightRadius: number;
|
|
27
|
+
minHeight: number;
|
|
25
28
|
};
|
|
26
29
|
headerShadow: {
|
|
27
|
-
position: "absolute";
|
|
28
|
-
top: number;
|
|
29
|
-
height: number;
|
|
30
|
-
width: "100%";
|
|
31
30
|
shadowColor: string;
|
|
32
31
|
shadowOffset: {
|
|
33
32
|
width: number;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { IHandles } from "react-native-modalize/lib/options";
|
|
3
|
+
export declare const UNSAFE_WrappedModalize: React.ForwardRefExoticComponent<Omit<import("react-native-modalize/lib/options").IProps<any> & React.RefAttributes<any>, "ref"> & React.RefAttributes<IHandles | undefined>>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ReactNode
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { Modalize } from "react-native-modalize";
|
|
2
3
|
export interface ContentOverlayProps {
|
|
3
4
|
/**
|
|
4
5
|
* Content to be passed into the overlay
|
|
@@ -63,18 +64,24 @@ export interface ContentOverlayProps {
|
|
|
63
64
|
* Callback that is called between overlay is closed and when the "x" button is pressed
|
|
64
65
|
*/
|
|
65
66
|
readonly onBeforeExit?: () => void;
|
|
67
|
+
/**
|
|
68
|
+
* Define the behavior of the keyboard when having inputs inside the modal.
|
|
69
|
+
* @default padding
|
|
70
|
+
*/
|
|
71
|
+
readonly keyboardAvoidingBehavior?: "height" | "padding" | "position";
|
|
66
72
|
/**
|
|
67
73
|
* Boolean to show a disabled state
|
|
68
74
|
* @default false
|
|
69
75
|
*/
|
|
70
76
|
readonly loading?: boolean;
|
|
71
77
|
/**
|
|
72
|
-
*
|
|
78
|
+
* Define keyboard's Android behavior like iOS's one.
|
|
79
|
+
* @default Platform.select({ ios: true, android: false })
|
|
73
80
|
*/
|
|
74
|
-
readonly
|
|
81
|
+
readonly avoidKeyboardLikeIOS?: boolean;
|
|
75
82
|
}
|
|
76
83
|
export type ModalBackgroundColor = "surface" | "background";
|
|
77
84
|
export type ContentOverlayRef = {
|
|
78
|
-
open?:
|
|
79
|
-
close?:
|
|
85
|
+
open?: Modalize["open"];
|
|
86
|
+
close?: Modalize["close"];
|
|
80
87
|
} | undefined;
|
|
@@ -82,7 +82,11 @@ export interface InputFieldWrapperProps {
|
|
|
82
82
|
* Change the type of loading indicator to spinner or glimmer.
|
|
83
83
|
*/
|
|
84
84
|
readonly loadingType?: "spinner" | "glimmer";
|
|
85
|
+
/**
|
|
86
|
+
* Whether the input is a multiline input.
|
|
87
|
+
*/
|
|
88
|
+
readonly multiline?: boolean;
|
|
85
89
|
}
|
|
86
90
|
export declare const INPUT_FIELD_WRAPPER_GLIMMERS_TEST_ID = "ATL-InputFieldWrapper-Glimmers";
|
|
87
91
|
export declare const INPUT_FIELD_WRAPPER_SPINNER_TEST_ID = "ATL-InputFieldWrapper-Spinner";
|
|
88
|
-
export declare function InputFieldWrapper({ invalid, disabled, placeholder, assistiveText, prefix, suffix, placeholderMode, hasValue, error, focused, children, onClear, showClearAction, styleOverride, toolbar, toolbarVisibility, loading, loadingType, }: InputFieldWrapperProps): React.JSX.Element;
|
|
92
|
+
export declare function InputFieldWrapper({ invalid, disabled, placeholder, assistiveText, prefix, suffix, placeholderMode, hasValue, error, focused, children, onClear, showClearAction, styleOverride, toolbar, toolbarVisibility, loading, loadingType, multiline, }: InputFieldWrapperProps): React.JSX.Element;
|
package/jestSetup.js
CHANGED
|
@@ -16,8 +16,6 @@ jest.mock("./dist/src/Button/components/InternalButtonLoading", () => {
|
|
|
16
16
|
};
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
// NOTE: this is the old way we used to mock reanimated. We actually do not need to mock it anymore.
|
|
20
|
-
// To ensure correct test behaviour, please add `jest.unmock("react-native-reanimated")` to your test suite.
|
|
21
19
|
jest.mock("react-native-reanimated", () => {
|
|
22
20
|
const reanimated = require("react-native-reanimated/mock");
|
|
23
21
|
const timing = () => ({ start: () => undefined });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.95.4
|
|
3
|
+
"version": "0.95.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -44,8 +44,9 @@
|
|
|
44
44
|
"deepmerge": "^4.2.2",
|
|
45
45
|
"lodash": "^4.17.21",
|
|
46
46
|
"react-hook-form": "^7.52.0",
|
|
47
|
-
"react-intl": "^
|
|
47
|
+
"react-intl": "^7.1.11",
|
|
48
48
|
"react-native-keyboard-aware-scroll-view": "^0.9.5",
|
|
49
|
+
"react-native-modalize": "^2.0.13",
|
|
49
50
|
"react-native-portalize": "^1.0.7",
|
|
50
51
|
"react-native-toast-message": "^2.1.6",
|
|
51
52
|
"react-native-uuid": "^1.4.9",
|
|
@@ -89,10 +90,11 @@
|
|
|
89
90
|
"react-native-gesture-handler": ">=2.22.0",
|
|
90
91
|
"react-native-keyboard-aware-scroll-view": "^0.9.5",
|
|
91
92
|
"react-native-modal-datetime-picker": " >=13.0.0",
|
|
93
|
+
"react-native-modalize": "^2.0.13",
|
|
92
94
|
"react-native-portalize": "^1.0.7",
|
|
93
95
|
"react-native-reanimated": "^3.0.0",
|
|
94
96
|
"react-native-safe-area-context": "^5.4.0",
|
|
95
97
|
"react-native-svg": ">=12.0.0"
|
|
96
98
|
},
|
|
97
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "7ebeebd8f3798c54d5c1b3399f25bac554768e3d"
|
|
98
100
|
}
|
|
@@ -2,43 +2,43 @@ import { buildThemedStyles } from "../AtlantisThemeContext";
|
|
|
2
2
|
|
|
3
3
|
export const useStyles = buildThemedStyles(tokens => {
|
|
4
4
|
const modalBorderRadius = tokens["radius-larger"];
|
|
5
|
+
const titleOffsetFromHandle = tokens["space-base"];
|
|
5
6
|
|
|
6
7
|
return {
|
|
7
|
-
handleWrapper: {
|
|
8
|
-
paddingBottom: tokens["space-smallest"],
|
|
9
|
-
paddingTop: tokens["space-small"],
|
|
10
|
-
},
|
|
11
|
-
|
|
12
8
|
handle: {
|
|
13
9
|
width: tokens["space-largest"],
|
|
14
10
|
height: tokens["space-smaller"] + tokens["space-smallest"],
|
|
15
11
|
backgroundColor: tokens["color-border"],
|
|
12
|
+
top: tokens["space-small"],
|
|
16
13
|
borderRadius: tokens["radius-circle"],
|
|
17
14
|
},
|
|
18
15
|
|
|
19
|
-
|
|
16
|
+
overlay: {
|
|
20
17
|
backgroundColor: tokens["color-overlay"],
|
|
21
18
|
},
|
|
22
19
|
|
|
23
|
-
|
|
20
|
+
modal: {
|
|
24
21
|
borderTopLeftRadius: modalBorderRadius,
|
|
25
22
|
borderTopRightRadius: modalBorderRadius,
|
|
26
23
|
},
|
|
27
24
|
|
|
25
|
+
modalForLargeScreens: {
|
|
26
|
+
width: 640,
|
|
27
|
+
alignSelf: "center",
|
|
28
|
+
},
|
|
29
|
+
|
|
28
30
|
header: {
|
|
29
31
|
flexDirection: "row",
|
|
32
|
+
backgroundColor: tokens["color-surface"],
|
|
33
|
+
paddingTop: titleOffsetFromHandle,
|
|
30
34
|
zIndex: tokens["elevation-base"],
|
|
31
|
-
minHeight: tokens["space-extravagant"] - tokens["space-base"],
|
|
32
35
|
borderTopLeftRadius: modalBorderRadius,
|
|
33
36
|
borderTopRightRadius: modalBorderRadius,
|
|
37
|
+
minHeight: tokens["space-extravagant"],
|
|
34
38
|
},
|
|
35
39
|
|
|
36
40
|
headerShadow: {
|
|
37
41
|
...tokens["shadow-base"],
|
|
38
|
-
position: "absolute",
|
|
39
|
-
top: -20,
|
|
40
|
-
height: 20,
|
|
41
|
-
width: "100%",
|
|
42
42
|
},
|
|
43
43
|
|
|
44
44
|
childrenStyle: {
|
|
@@ -1,41 +1,27 @@
|
|
|
1
1
|
import React, { createRef } from "react";
|
|
2
|
-
import {
|
|
3
|
-
act,
|
|
4
|
-
render,
|
|
5
|
-
screen,
|
|
6
|
-
userEvent,
|
|
7
|
-
waitFor,
|
|
8
|
-
} from "@testing-library/react-native";
|
|
2
|
+
import { fireEvent, render, waitFor } from "@testing-library/react-native";
|
|
9
3
|
import { AccessibilityInfo, View } from "react-native";
|
|
4
|
+
import { Host } from "react-native-portalize";
|
|
10
5
|
import type { ReactTestInstance } from "react-test-renderer";
|
|
6
|
+
import { act } from "react-test-renderer";
|
|
11
7
|
import type { ContentOverlayRef, ModalBackgroundColor } from "./types";
|
|
12
8
|
import { ContentOverlay } from "./ContentOverlay";
|
|
13
|
-
import { ContentOverlayProvider } from "./ContentOverlayProvider";
|
|
14
9
|
import { tokens } from "../utils/design";
|
|
15
10
|
import { Button } from "../Button";
|
|
16
11
|
import { Content } from "../Content";
|
|
17
12
|
import { Text } from "../Text";
|
|
18
13
|
|
|
19
14
|
jest.unmock("../hooks/useIsScreenReaderEnabled");
|
|
20
|
-
jest.unmock("react-native-reanimated");
|
|
21
|
-
jest.unmock("@gorhom/bottom-sheet");
|
|
22
|
-
jest.mock("@gorhom/bottom-sheet/lib/commonjs/hooks/useAnimatedLayout", () => ({
|
|
23
|
-
// Fix for reanimated not actually running in the test environment.
|
|
24
|
-
useAnimatedLayout: () => {
|
|
25
|
-
const value = {
|
|
26
|
-
containerHeight: 600,
|
|
27
|
-
rawContainerHeight: 600,
|
|
28
|
-
handleHeight: 24,
|
|
29
|
-
footerHeight: 0,
|
|
30
|
-
contentHeight: 400,
|
|
31
|
-
containerOffset: { top: 0, bottom: 0, left: 0, right: 0 },
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
return { value, get: () => value };
|
|
35
|
-
},
|
|
36
|
-
}));
|
|
37
15
|
|
|
38
|
-
|
|
16
|
+
function fireLayoutEvent(childrenContent: ReactTestInstance) {
|
|
17
|
+
fireEvent(childrenContent, "onLayout", {
|
|
18
|
+
nativeEvent: {
|
|
19
|
+
layout: {
|
|
20
|
+
height: 100,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
}
|
|
39
25
|
|
|
40
26
|
interface testRendererOptions {
|
|
41
27
|
text: string;
|
|
@@ -58,6 +44,12 @@ function getDefaultOptions(): testRendererOptions {
|
|
|
58
44
|
fullScreen: false,
|
|
59
45
|
showDismiss: false,
|
|
60
46
|
modalBackgroundColor: "surface",
|
|
47
|
+
onCloseCallback: () => {
|
|
48
|
+
return;
|
|
49
|
+
},
|
|
50
|
+
onOpenCallback: () => {
|
|
51
|
+
return;
|
|
52
|
+
},
|
|
61
53
|
};
|
|
62
54
|
}
|
|
63
55
|
|
|
@@ -77,8 +69,8 @@ function renderContentOverlay(
|
|
|
77
69
|
) {
|
|
78
70
|
const contentOverlayRef = createRef<ContentOverlayRef>();
|
|
79
71
|
|
|
80
|
-
render(
|
|
81
|
-
<
|
|
72
|
+
const renderResult = render(
|
|
73
|
+
<Host>
|
|
82
74
|
<View>
|
|
83
75
|
<Text>I am a bunch of text</Text>
|
|
84
76
|
<Button
|
|
@@ -103,31 +95,32 @@ function renderContentOverlay(
|
|
|
103
95
|
</Content>
|
|
104
96
|
</ContentOverlay>
|
|
105
97
|
</View>
|
|
106
|
-
</
|
|
98
|
+
</Host>,
|
|
107
99
|
);
|
|
100
|
+
|
|
101
|
+
const childrenView = renderResult.getByTestId("ATL-Overlay-Children");
|
|
102
|
+
fireLayoutEvent(childrenView);
|
|
103
|
+
const headerComponent = renderResult.getByTestId("ATL-Overlay-Header");
|
|
104
|
+
fireLayoutEvent(headerComponent);
|
|
105
|
+
|
|
106
|
+
return renderResult;
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
async function renderAndOpenContentOverlay(
|
|
111
110
|
defaultOptions = getDefaultOptions(),
|
|
112
111
|
) {
|
|
113
|
-
|
|
114
|
-
const props = {
|
|
115
|
-
onOpenCallback: jest.fn(),
|
|
116
|
-
onCloseCallback: jest.fn(),
|
|
117
|
-
...defaultOptions,
|
|
118
|
-
};
|
|
112
|
+
const rendered = renderContentOverlay(defaultOptions);
|
|
119
113
|
|
|
120
|
-
renderContentOverlay(props);
|
|
121
|
-
|
|
122
|
-
await user.press(screen.getByLabelText(defaultOptions.buttonLabel));
|
|
123
114
|
await act(async () => {
|
|
124
|
-
|
|
115
|
+
fireEvent.press(rendered.getByLabelText(defaultOptions.buttonLabel));
|
|
125
116
|
});
|
|
126
117
|
|
|
118
|
+
// Wait for the modal to open asynchronously (due to requestAnimationFrame)
|
|
127
119
|
await waitFor(() => {
|
|
128
|
-
expect(
|
|
129
|
-
expect(props.onOpenCallback).toHaveBeenCalledTimes(1);
|
|
120
|
+
expect(rendered.getByTestId("ATL-Overlay-Header")).toBeDefined();
|
|
130
121
|
});
|
|
122
|
+
|
|
123
|
+
return rendered;
|
|
131
124
|
}
|
|
132
125
|
|
|
133
126
|
describe("when open is called on the content overlay ref", () => {
|
|
@@ -136,9 +129,9 @@ describe("when open is called on the content overlay ref", () => {
|
|
|
136
129
|
...getDefaultOptions(),
|
|
137
130
|
text: "I am text within the content overlay",
|
|
138
131
|
};
|
|
139
|
-
await renderAndOpenContentOverlay(options);
|
|
132
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
140
133
|
|
|
141
|
-
expect(
|
|
134
|
+
expect(contentOverlayScreen.getByText(options.text)).toBeDefined();
|
|
142
135
|
});
|
|
143
136
|
});
|
|
144
137
|
|
|
@@ -149,16 +142,16 @@ describe("when the close button is clicked on an open content overlay", () => {
|
|
|
149
142
|
text: "I am text within the content overlay",
|
|
150
143
|
showDismiss: true,
|
|
151
144
|
};
|
|
152
|
-
await renderAndOpenContentOverlay(options);
|
|
145
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
153
146
|
|
|
154
|
-
const closeButton = await screen.findByTestId("ATL-Overlay-CloseButton");
|
|
155
|
-
await user.press(closeButton);
|
|
156
147
|
await act(async () => {
|
|
157
|
-
|
|
148
|
+
fireEvent.press(
|
|
149
|
+
contentOverlayScreen.getByTestId("ATL-Overlay-CloseButton"),
|
|
150
|
+
);
|
|
158
151
|
});
|
|
159
152
|
|
|
160
153
|
await waitFor(() => {
|
|
161
|
-
expect(
|
|
154
|
+
expect(contentOverlayScreen.queryByText(options.text)).toBeNull();
|
|
162
155
|
});
|
|
163
156
|
});
|
|
164
157
|
});
|
|
@@ -170,12 +163,12 @@ describe("when the close button is clicked on an open content overlay with a def
|
|
|
170
163
|
onCloseCallback: jest.fn(),
|
|
171
164
|
showDismiss: true,
|
|
172
165
|
};
|
|
173
|
-
await renderAndOpenContentOverlay(options);
|
|
166
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
174
167
|
|
|
175
|
-
const closeButton = await screen.findByTestId("ATL-Overlay-CloseButton");
|
|
176
|
-
await user.press(closeButton);
|
|
177
168
|
await act(async () => {
|
|
178
|
-
|
|
169
|
+
fireEvent.press(
|
|
170
|
+
contentOverlayScreen.getByTestId("ATL-Overlay-CloseButton"),
|
|
171
|
+
);
|
|
179
172
|
});
|
|
180
173
|
|
|
181
174
|
await waitFor(() => {
|
|
@@ -220,9 +213,9 @@ describe("when title prop passed to content overlay", () => {
|
|
|
220
213
|
...getDefaultOptions(),
|
|
221
214
|
title: "Awesome Title",
|
|
222
215
|
};
|
|
223
|
-
await renderAndOpenContentOverlay(options);
|
|
216
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
224
217
|
|
|
225
|
-
expect(
|
|
218
|
+
expect(contentOverlayScreen.getByText(options.title)).toBeDefined();
|
|
226
219
|
});
|
|
227
220
|
});
|
|
228
221
|
|
|
@@ -233,9 +226,11 @@ describe("when accessibilityLabel prop passed to content overlay", () => {
|
|
|
233
226
|
a11yLabel: "Awesome a11y Label",
|
|
234
227
|
showDismiss: true,
|
|
235
228
|
};
|
|
236
|
-
await renderAndOpenContentOverlay(options);
|
|
229
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
237
230
|
|
|
238
|
-
expect(
|
|
231
|
+
expect(
|
|
232
|
+
contentOverlayScreen.getByLabelText(options.a11yLabel || "ohno"),
|
|
233
|
+
).toBeDefined();
|
|
239
234
|
});
|
|
240
235
|
});
|
|
241
236
|
|
|
@@ -246,10 +241,10 @@ describe("when accessibilityLabel prop NOT passed to content overlay", () => {
|
|
|
246
241
|
title: "Awesome Title",
|
|
247
242
|
showDismiss: true,
|
|
248
243
|
};
|
|
249
|
-
await renderAndOpenContentOverlay(options);
|
|
244
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
250
245
|
|
|
251
246
|
expect(
|
|
252
|
-
|
|
247
|
+
contentOverlayScreen.getAllByLabelText(`Close ${options.title} modal`),
|
|
253
248
|
).toHaveLength(2);
|
|
254
249
|
});
|
|
255
250
|
});
|
|
@@ -263,9 +258,11 @@ describe("when there is a screen reader enabled", () => {
|
|
|
263
258
|
const options: testRendererOptions = {
|
|
264
259
|
...getDefaultOptions(),
|
|
265
260
|
};
|
|
266
|
-
await renderAndOpenContentOverlay(options);
|
|
261
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
267
262
|
|
|
268
|
-
expect(
|
|
263
|
+
expect(
|
|
264
|
+
await contentOverlayScreen.findByTestId("ATL-Overlay-CloseButton"),
|
|
265
|
+
).toBeDefined();
|
|
269
266
|
});
|
|
270
267
|
});
|
|
271
268
|
|
|
@@ -275,8 +272,10 @@ describe("when fullScreen is set to true", () => {
|
|
|
275
272
|
...getDefaultOptions(),
|
|
276
273
|
fullScreen: true,
|
|
277
274
|
};
|
|
278
|
-
await renderAndOpenContentOverlay(options);
|
|
279
|
-
expect(
|
|
275
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
276
|
+
expect(
|
|
277
|
+
contentOverlayScreen.getByTestId("ATL-Overlay-CloseButton"),
|
|
278
|
+
).toBeDefined();
|
|
280
279
|
});
|
|
281
280
|
});
|
|
282
281
|
|
|
@@ -286,8 +285,10 @@ describe("when showDismiss is set to true", () => {
|
|
|
286
285
|
...getDefaultOptions(),
|
|
287
286
|
showDismiss: true,
|
|
288
287
|
};
|
|
289
|
-
await renderAndOpenContentOverlay(options);
|
|
290
|
-
expect(
|
|
288
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
289
|
+
expect(
|
|
290
|
+
contentOverlayScreen.getByTestId("ATL-Overlay-CloseButton"),
|
|
291
|
+
).toBeDefined();
|
|
291
292
|
});
|
|
292
293
|
});
|
|
293
294
|
|
|
@@ -298,9 +299,13 @@ describe("when the close button is clicked on an open content overlay with a def
|
|
|
298
299
|
onBeforeExitCallback: jest.fn(),
|
|
299
300
|
showDismiss: true,
|
|
300
301
|
};
|
|
301
|
-
await renderAndOpenContentOverlay(options);
|
|
302
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
302
303
|
|
|
303
|
-
await
|
|
304
|
+
await act(async () => {
|
|
305
|
+
fireEvent.press(
|
|
306
|
+
contentOverlayScreen.getByTestId("ATL-Overlay-CloseButton"),
|
|
307
|
+
);
|
|
308
|
+
});
|
|
304
309
|
|
|
305
310
|
await waitFor(() => {
|
|
306
311
|
expect(options.onBeforeExitCallback).toHaveBeenCalled();
|
|
@@ -314,9 +319,10 @@ describe("modalBackgroundColor prop", () => {
|
|
|
314
319
|
const options: testRendererOptions = {
|
|
315
320
|
...getDefaultOptions(),
|
|
316
321
|
};
|
|
317
|
-
await renderAndOpenContentOverlay(options);
|
|
318
|
-
const OverlayHeader =
|
|
319
|
-
|
|
322
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
323
|
+
const OverlayHeader = contentOverlayScreen.getByTestId(
|
|
324
|
+
"ATL-Overlay-Header",
|
|
325
|
+
).children[0] as ReactTestInstance;
|
|
320
326
|
const OverlayHeaderStyles = OverlayHeader.props.style;
|
|
321
327
|
|
|
322
328
|
expect(OverlayHeaderStyles).toEqual(
|
|
@@ -343,9 +349,10 @@ describe("modalBackgroundColor prop", () => {
|
|
|
343
349
|
...getDefaultOptions(),
|
|
344
350
|
modalBackgroundColor: "background",
|
|
345
351
|
};
|
|
346
|
-
await renderAndOpenContentOverlay(options);
|
|
347
|
-
const OverlayHeader =
|
|
348
|
-
|
|
352
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
353
|
+
const OverlayHeader = contentOverlayScreen.getByTestId(
|
|
354
|
+
"ATL-Overlay-Header",
|
|
355
|
+
).children[0] as ReactTestInstance;
|
|
349
356
|
const OverlayHeaderStyles = OverlayHeader.props.style;
|
|
350
357
|
|
|
351
358
|
expect(OverlayHeaderStyles).toEqual(
|
|
@@ -358,88 +365,3 @@ describe("modalBackgroundColor prop", () => {
|
|
|
358
365
|
});
|
|
359
366
|
});
|
|
360
367
|
});
|
|
361
|
-
|
|
362
|
-
describe("scrollEnabled prop", () => {
|
|
363
|
-
describe("when scrollEnabled is false (default)", () => {
|
|
364
|
-
it("should render content in BottomSheetView", async () => {
|
|
365
|
-
const options: testRendererOptions = {
|
|
366
|
-
...getDefaultOptions(),
|
|
367
|
-
};
|
|
368
|
-
await renderAndOpenContentOverlay(options);
|
|
369
|
-
|
|
370
|
-
expect(screen.getByText(options.text)).toBeDefined();
|
|
371
|
-
expect(screen.getByTestId("ATL-Overlay-Children")).toBeDefined();
|
|
372
|
-
});
|
|
373
|
-
});
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
describe("loading prop", () => {
|
|
377
|
-
describe("when loading is true", () => {
|
|
378
|
-
it("should show subdued heading text", async () => {
|
|
379
|
-
const overlayRef = createRef<ContentOverlayRef>();
|
|
380
|
-
|
|
381
|
-
render(
|
|
382
|
-
<ContentOverlayProvider>
|
|
383
|
-
<View>
|
|
384
|
-
<ContentOverlay
|
|
385
|
-
ref={overlayRef}
|
|
386
|
-
title="Loading Overlay"
|
|
387
|
-
loading={true}
|
|
388
|
-
showDismiss={true}
|
|
389
|
-
>
|
|
390
|
-
<Text>Loading content</Text>
|
|
391
|
-
</ContentOverlay>
|
|
392
|
-
</View>
|
|
393
|
-
</ContentOverlayProvider>,
|
|
394
|
-
);
|
|
395
|
-
|
|
396
|
-
await act(async () => {
|
|
397
|
-
overlayRef.current?.open?.();
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
await waitFor(() => {
|
|
401
|
-
expect(screen.getByText("Loading Overlay")).toBeDefined();
|
|
402
|
-
});
|
|
403
|
-
});
|
|
404
|
-
});
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
describe("onBeforeExit callback", () => {
|
|
408
|
-
describe("when close button is pressed with onBeforeExit defined", () => {
|
|
409
|
-
it("should call onBeforeExit instead of immediately closing", async () => {
|
|
410
|
-
const overlayRef = createRef<ContentOverlayRef>();
|
|
411
|
-
const onBeforeExitCallback = jest.fn();
|
|
412
|
-
|
|
413
|
-
render(
|
|
414
|
-
<ContentOverlayProvider>
|
|
415
|
-
<View>
|
|
416
|
-
<ContentOverlay
|
|
417
|
-
ref={overlayRef}
|
|
418
|
-
title="Confirmation Required"
|
|
419
|
-
onBeforeExit={onBeforeExitCallback}
|
|
420
|
-
showDismiss={true}
|
|
421
|
-
>
|
|
422
|
-
<Text>Must confirm to close</Text>
|
|
423
|
-
</ContentOverlay>
|
|
424
|
-
</View>
|
|
425
|
-
</ContentOverlayProvider>,
|
|
426
|
-
);
|
|
427
|
-
|
|
428
|
-
await act(async () => {
|
|
429
|
-
overlayRef.current?.open?.();
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
await waitFor(() => {
|
|
433
|
-
expect(screen.getByText("Must confirm to close")).toBeDefined();
|
|
434
|
-
});
|
|
435
|
-
|
|
436
|
-
const closeButton = screen.getByTestId("ATL-Overlay-CloseButton");
|
|
437
|
-
await user.press(closeButton);
|
|
438
|
-
|
|
439
|
-
await waitFor(() => {
|
|
440
|
-
expect(onBeforeExitCallback).toHaveBeenCalled();
|
|
441
|
-
expect(screen.getByText("Must confirm to close")).toBeDefined();
|
|
442
|
-
});
|
|
443
|
-
});
|
|
444
|
-
});
|
|
445
|
-
});
|