@terreno/ui 57.20.0 → 57.21.0
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/CHANGELOG.md +50 -0
- package/dist/Common.d.ts +55 -27
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js.map +1 -1
- package/dist/DateTimeField.js +6 -6
- package/dist/DateTimeField.js.map +1 -1
- package/dist/HeightField.js +8 -8
- package/dist/HeightField.js.map +1 -1
- package/dist/OtpField.js +4 -4
- package/dist/OtpField.js.map +1 -1
- package/dist/PickerSelect.js +9 -9
- package/dist/PickerSelect.js.map +1 -1
- package/dist/TapToEdit.d.ts +1 -1
- package/dist/TapToEdit.d.ts.map +1 -1
- package/dist/TapToEdit.js.map +1 -1
- package/dist/TextField.js +4 -4
- package/dist/TextField.js.map +1 -1
- package/dist/Theme.d.ts.map +1 -1
- package/dist/Theme.js +16 -0
- package/dist/Theme.js.map +1 -1
- package/package.json +4 -2
- package/src/ActionSheet.test.tsx +13 -13
- package/src/AddressField.test.tsx +9 -3
- package/src/AnnouncementNavigator.test.tsx +4 -4
- package/src/Badge.test.tsx +1 -1
- package/src/Banner.test.tsx +0 -1
- package/src/Box.test.tsx +82 -74
- package/src/Button.test.tsx +11 -6
- package/src/Card.test.tsx +2 -2
- package/src/Common.ts +60 -29
- package/src/ConflictSheet.test.tsx +5 -5
- package/src/ConsentFormScreen.test.tsx +3 -1
- package/src/ConsentNavigator.test.tsx +1 -2
- package/src/CustomSelectField.test.tsx +16 -4
- package/src/DataTable.test.tsx +4 -4
- package/src/DataTableVirtualizationRegression.test.tsx +1 -0
- package/src/DateTimeActionSheet.test.tsx +2 -0
- package/src/DateTimeField.test.tsx +3 -12
- package/src/DateTimeField.tsx +6 -6
- package/src/DismissButton.test.tsx +22 -4
- package/src/EmailField.test.tsx +13 -22
- package/src/EmojiSelector.test.tsx +2 -2
- package/src/ErrorBoundary.test.tsx +5 -3
- package/src/Field.test.tsx +20 -44
- package/src/GPTChat.test.tsx +24 -16
- package/src/Heading.test.tsx +1 -1
- package/src/HeightField.tsx +8 -8
- package/src/Icon.test.tsx +2 -2
- package/src/Image.test.tsx +1 -1
- package/src/Link.test.tsx +11 -4
- package/src/MarkdownView.test.tsx +1 -1
- package/src/MobileAddressAutoComplete.test.tsx +2 -1
- package/src/Modal.test.tsx +7 -2
- package/src/ModalSheet.test.tsx +5 -4
- package/src/MultiselectField.test.tsx +17 -3
- package/src/NumberField.test.tsx +14 -14
- package/src/NumberPickerActionSheet.test.tsx +1 -1
- package/src/OpenAPIContext.test.tsx +4 -4
- package/src/OpenAPIRenderRegression.test.tsx +1 -1
- package/src/OtpField.tsx +4 -4
- package/src/P0RenderRegression.test.tsx +7 -1
- package/src/P1RenderRegression.test.tsx +1 -0
- package/src/P2ButtonRenderRegression.test.tsx +1 -0
- package/src/Page.test.tsx +1 -1
- package/src/PhoneNumberField.test.tsx +14 -38
- package/src/PickerSelect.tsx +9 -9
- package/src/Popover.test.tsx +2 -2
- package/src/RadioField.test.tsx +7 -2
- package/src/SegmentedControl.test.tsx +21 -12
- package/src/SidebarNavigation.test.tsx +18 -6
- package/src/Signature.test.tsx +20 -23
- package/src/Slider.test.tsx +1 -1
- package/src/SplitPage.test.tsx +15 -5
- package/src/TapToEdit.test.tsx +38 -15
- package/src/TapToEdit.tsx +1 -1
- package/src/TerrenoFontProvider.test.tsx +1 -1
- package/src/Text.test.tsx +4 -4
- package/src/TextField.test.tsx +82 -9
- package/src/TextField.tsx +4 -4
- package/src/Theme.test.tsx +49 -0
- package/src/Theme.tsx +16 -0
- package/src/Toast.test.tsx +5 -5
- package/src/ToastNotifications.test.tsx +73 -70
- package/src/ToastNotifications.webModal.test.tsx +2 -2
- package/src/Tooltip.test.tsx +3 -3
- package/src/UnifiedAddressAutoComplete.test.tsx +1 -1
- package/src/UserInactivity.test.tsx +4 -2
- package/src/WebAddressAutocomplete.test.tsx +12 -12
- package/src/WebDropdownMenu.test.tsx +16 -15
- package/src/__snapshots__/Card.test.tsx.snap +1 -1
- package/src/__snapshots__/DismissButton.test.tsx.snap +3 -3
- package/src/__snapshots__/Field.test.tsx.snap +4 -2
- package/src/__snapshots__/Heading.test.tsx.snap +1 -1
- package/src/__snapshots__/Image.test.tsx.snap +1 -1
- package/src/__snapshots__/Page.test.tsx.snap +2 -2
- package/src/__snapshots__/Text.test.tsx.snap +1 -1
- package/src/asks/AskCard.test.tsx +16 -13
- package/src/asks/AskFiles.test.tsx +5 -1
- package/src/asks/askFileRefs.test.ts +1 -1
- package/src/asks/askSummary.test.ts +2 -2
- package/src/benchmarks/importTiming.ts +1 -1
- package/src/blocks/BlocksView.test.tsx +20 -11
- package/src/bunSetup.ts +1 -1
- package/src/dataTableFilters.test.tsx +1 -1
- package/src/isolated/ListDetailLayout.isolated.tsx +2 -4
- package/src/login/LoginScreen.test.tsx +6 -6
- package/src/security/PasswordCard.test.tsx +3 -3
- package/src/signUp/SignUpScreen.test.tsx +4 -4
- package/src/table/tableContext.test.tsx +5 -5
- package/src/test-utils.tsx +56 -1
- package/src/testing/reactDomServer.d.ts +7 -0
- package/src/useConsentForms.test.ts +1 -1
|
@@ -4,7 +4,7 @@ import type {ReactElement} from "react";
|
|
|
4
4
|
import {Platform} from "react-native";
|
|
5
5
|
import {TextField} from "../TextField";
|
|
6
6
|
import {ThemeProvider} from "../Theme";
|
|
7
|
-
import {renderWithTheme} from "../test-utils";
|
|
7
|
+
import {elementProps, renderWithTheme} from "../test-utils";
|
|
8
8
|
import {defaultPasswordRequirements} from "./passwordPresets";
|
|
9
9
|
import {SignUpScreen} from "./SignUpScreen";
|
|
10
10
|
|
|
@@ -177,14 +177,14 @@ const renderWithHostMocks = (
|
|
|
177
177
|
): ReturnType<typeof render> & {focused: string[]} => {
|
|
178
178
|
const focused: string[] = [];
|
|
179
179
|
const result = render(ui, {
|
|
180
|
-
createNodeMock: (element: ReactElement
|
|
180
|
+
createNodeMock: (element: ReactElement) => {
|
|
181
181
|
if (element.type === "form") {
|
|
182
182
|
return requestSubmit ? {requestSubmit} : {};
|
|
183
183
|
}
|
|
184
184
|
return {
|
|
185
185
|
blur: (): void => {},
|
|
186
186
|
focus: (): void => {
|
|
187
|
-
focused.push(element.
|
|
187
|
+
focused.push(elementProps<{testID?: string}>(element).testID ?? "");
|
|
188
188
|
},
|
|
189
189
|
};
|
|
190
190
|
},
|
|
@@ -216,7 +216,7 @@ describe("SignUpScreen keyboard", () => {
|
|
|
216
216
|
});
|
|
217
217
|
|
|
218
218
|
it("submits once on Enter in the last field", async () => {
|
|
219
|
-
const onSubmit = mock(() => Promise.resolve());
|
|
219
|
+
const onSubmit = mock((_values: Record<string, string>) => Promise.resolve());
|
|
220
220
|
const {getByTestId} = renderWithTheme(
|
|
221
221
|
<SignUpScreen
|
|
222
222
|
fields={defaultFields}
|
|
@@ -37,7 +37,7 @@ describe("tableContext", () => {
|
|
|
37
37
|
expect(ctx.hasDrawerContents).toBe(false);
|
|
38
38
|
expect(typeof ctx.setSortColumn).toBe("function");
|
|
39
39
|
// Invoke default setSortColumn to cover the no-op default
|
|
40
|
-
expect(() => ctx.setSortColumn({column: 0, direction: "asc"})).not.toThrow();
|
|
40
|
+
expect(() => ctx.setSortColumn!({column: 0, direction: "asc"})).not.toThrow();
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
it("passes provided values through the provider", () => {
|
|
@@ -46,7 +46,7 @@ describe("tableContext", () => {
|
|
|
46
46
|
render(
|
|
47
47
|
<TableContextProvider
|
|
48
48
|
alternateRowBackground={false}
|
|
49
|
-
borderStyle="
|
|
49
|
+
borderStyle="none"
|
|
50
50
|
columns={[100, 200]}
|
|
51
51
|
hasDrawerContents
|
|
52
52
|
page={3}
|
|
@@ -62,9 +62,9 @@ describe("tableContext", () => {
|
|
|
62
62
|
expect(ctx.hasDrawerContents).toBe(true);
|
|
63
63
|
expect(ctx.stickyHeader).toBe(false);
|
|
64
64
|
expect(ctx.alternateRowBackground).toBe(false);
|
|
65
|
-
expect(ctx.borderStyle).toBe("
|
|
65
|
+
expect(ctx.borderStyle).toBe("none");
|
|
66
66
|
expect(ctx.sortColumn).toEqual({column: 1, direction: "desc"});
|
|
67
|
-
ctx.setSortColumn({column: 0, direction: "asc"});
|
|
67
|
+
ctx.setSortColumn!({column: 0, direction: "asc"});
|
|
68
68
|
expect(setSortColumn).toHaveBeenCalled();
|
|
69
69
|
});
|
|
70
70
|
|
|
@@ -73,7 +73,7 @@ describe("tableContext", () => {
|
|
|
73
73
|
const Consumer = () => {
|
|
74
74
|
const {setSortColumn: setter} = useTableContext();
|
|
75
75
|
useEffect(() => {
|
|
76
|
-
setter({column: 2, direction: "desc"});
|
|
76
|
+
setter!({column: 2, direction: "desc"});
|
|
77
77
|
}, [setter]);
|
|
78
78
|
return <Text>ok</Text>;
|
|
79
79
|
};
|
package/src/test-utils.tsx
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {mock} from "bun:test";
|
|
2
2
|
import {render} from "@testing-library/react-native";
|
|
3
|
+
import type {JestNativeMatchers} from "@testing-library/react-native/build/matchers/types";
|
|
3
4
|
import type React from "react";
|
|
4
5
|
import {View} from "react-native";
|
|
6
|
+
import type {ReactTestInstance, ReactTestRendererJSON} from "react-test-renderer";
|
|
5
7
|
|
|
6
8
|
import type {CustomIconProps, IconRegistryMap} from "./Common";
|
|
7
9
|
import {IconRegistryProvider} from "./IconRegistry";
|
|
@@ -15,6 +17,12 @@ declare module "./Common" {
|
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
|
|
20
|
+
// @testing-library/react-native registers its matchers (toHaveStyle, toHaveProp, ...) on the
|
|
21
|
+
// global expect at import time; expose their types on bun:test's expect as well.
|
|
22
|
+
declare module "bun:test" {
|
|
23
|
+
interface Matchers<T> extends JestNativeMatchers<void> {}
|
|
24
|
+
}
|
|
25
|
+
|
|
18
26
|
export const TEST_CUSTOM_ICON_TEST_ID = "test-custom-icon";
|
|
19
27
|
|
|
20
28
|
export const TestCustomIcon: React.FC<CustomIconProps> = ({size, testID}) => {
|
|
@@ -42,7 +50,7 @@ export const renderWithIcons = (
|
|
|
42
50
|
|
|
43
51
|
export const createCommonMocks = () => ({
|
|
44
52
|
onBlur: mock(() => {}),
|
|
45
|
-
onChange: mock(() => {}),
|
|
53
|
+
onChange: mock((_value: string) => {}),
|
|
46
54
|
onEnter: mock(() => {}),
|
|
47
55
|
onFocus: mock(() => {}),
|
|
48
56
|
onIconClick: mock(() => {}),
|
|
@@ -57,3 +65,50 @@ export const teardownComponentTest = () => {
|
|
|
57
65
|
// In Bun, mocks are automatically cleaned up
|
|
58
66
|
// No-op for compatibility
|
|
59
67
|
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Host element name (e.g. "View") of a test-renderer node. The react-native mock in bunSetup.ts
|
|
71
|
+
* renders string host types that React's DOM-only JSX typings do not list, so read it as a string.
|
|
72
|
+
*/
|
|
73
|
+
const hostTypeName = (node: ReactTestInstance): string | undefined => {
|
|
74
|
+
const type: unknown = node.type;
|
|
75
|
+
return typeof type === "string" ? type : undefined;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const isHostType = (node: ReactTestInstance, name: string): boolean => {
|
|
79
|
+
return hostTypeName(node) === name;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/** Typed equivalent of `root.findByType("View")` for string host types. */
|
|
83
|
+
export const findByHostType = (root: ReactTestInstance, name: string): ReactTestInstance => {
|
|
84
|
+
return root.find((node) => isHostType(node, name));
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/** Typed equivalent of `root.findAllByType("View")` for string host types. */
|
|
88
|
+
export const findAllByHostType = (
|
|
89
|
+
root: ReactTestInstance,
|
|
90
|
+
name: string,
|
|
91
|
+
options?: {deep: boolean}
|
|
92
|
+
): ReactTestInstance[] => {
|
|
93
|
+
return root.findAll((node) => isHostType(node, name), options);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Props of a React element handed to `createNodeMock` or returned from a render method. React
|
|
98
|
+
* types element props as `unknown`; tests read the few host props they inspect through this.
|
|
99
|
+
*/
|
|
100
|
+
export const elementProps = <P extends object = Record<string, unknown>>(
|
|
101
|
+
element: React.ReactElement
|
|
102
|
+
): Partial<P> => {
|
|
103
|
+
return (element.props ?? {}) as Partial<P>;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/** Narrows a `toJSON()` result to its single root node; fails when the render has several roots. */
|
|
107
|
+
export const rootJSONNode = (
|
|
108
|
+
tree: ReactTestRendererJSON | ReactTestRendererJSON[] | null
|
|
109
|
+
): ReactTestRendererJSON | null => {
|
|
110
|
+
if (Array.isArray(tree)) {
|
|
111
|
+
throw new Error(`Expected a single root node, got ${tree.length}`);
|
|
112
|
+
}
|
|
113
|
+
return tree;
|
|
114
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// ResponsiveBreakpoint.test.tsx renders through react-dom/server to cover the SSR path, and the
|
|
2
|
+
// workspace does not install @types/react-dom. Declare only the entry point the tests use.
|
|
3
|
+
declare module "react-dom/server" {
|
|
4
|
+
import type {ReactNode} from "react";
|
|
5
|
+
|
|
6
|
+
export const renderToString: (element: ReactNode) => string;
|
|
7
|
+
}
|
|
@@ -18,7 +18,7 @@ interface GlobalThisWithNavigator {
|
|
|
18
18
|
interface MockQueryDef {
|
|
19
19
|
onQueryStarted?: (
|
|
20
20
|
_arg: unknown,
|
|
21
|
-
helpers: {queryFulfilled: Promise<{data: ConsentFormPublic[]}> | Promise<never>}
|
|
21
|
+
helpers: {queryFulfilled: Promise<{data: Partial<ConsentFormPublic>[]}> | Promise<never>}
|
|
22
22
|
) => Promise<void>;
|
|
23
23
|
query: () => string;
|
|
24
24
|
}
|