@terreno/ui 57.20.0 → 57.22.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 +81 -0
- package/dist/Common.d.ts +60 -27
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js.map +1 -1
- package/dist/DataTable.d.ts.map +1 -1
- package/dist/DataTable.js +2 -2
- package/dist/DataTable.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 +65 -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/DataTable.tsx +2 -1
- 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,6 +4,7 @@ import {
|
|
|
4
4
|
type EmitterSubscription,
|
|
5
5
|
type GestureResponderEvent,
|
|
6
6
|
Keyboard,
|
|
7
|
+
type KeyboardEventListener,
|
|
7
8
|
PanResponder,
|
|
8
9
|
type PanResponderCallbacks,
|
|
9
10
|
type PanResponderGestureState,
|
|
@@ -146,9 +147,10 @@ describe("UserInactivity", () => {
|
|
|
146
147
|
const onAction = mock((_active: boolean) => {});
|
|
147
148
|
let capturedHideCallback: (() => void) | undefined;
|
|
148
149
|
const addListenerSpy = spyOn(Keyboard, "addListener").mockImplementation(
|
|
149
|
-
(event: string, callback:
|
|
150
|
+
(event: string, callback: KeyboardEventListener) => {
|
|
150
151
|
if (event === "keyboardDidHide") {
|
|
151
|
-
|
|
152
|
+
// UserInactivity's keyboard handler ignores the event payload.
|
|
153
|
+
capturedHideCallback = callback as () => void;
|
|
152
154
|
}
|
|
153
155
|
return {remove: mock(() => {})} as unknown as EmitterSubscription;
|
|
154
156
|
}
|
|
@@ -5,6 +5,14 @@ import type {AddressInterface} from "./Common";
|
|
|
5
5
|
import {renderWithTheme} from "./test-utils";
|
|
6
6
|
import {WebAddressAutocomplete} from "./WebAddressAutocomplete";
|
|
7
7
|
|
|
8
|
+
interface PlaceResult {
|
|
9
|
+
address_components: {
|
|
10
|
+
long_name: string;
|
|
11
|
+
short_name: string;
|
|
12
|
+
types: string[];
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
describe("WebAddressAutocomplete", () => {
|
|
9
17
|
const defaultProps = {
|
|
10
18
|
handleAddressChange: () => {},
|
|
@@ -51,14 +59,6 @@ describe("WebAddressAutocomplete", () => {
|
|
|
51
59
|
});
|
|
52
60
|
|
|
53
61
|
describe("with Google Maps available", () => {
|
|
54
|
-
interface PlaceResult {
|
|
55
|
-
address_components: {
|
|
56
|
-
long_name: string;
|
|
57
|
-
short_name: string;
|
|
58
|
-
types: string[];
|
|
59
|
-
}[];
|
|
60
|
-
}
|
|
61
|
-
|
|
62
62
|
interface GoogleMapsWindow {
|
|
63
63
|
google?: {
|
|
64
64
|
maps?: {
|
|
@@ -80,7 +80,7 @@ describe("WebAddressAutocomplete", () => {
|
|
|
80
80
|
document?: MinimalDocument;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
const testGlobal = globalThis as TestGlobals;
|
|
83
|
+
const testGlobal = globalThis as unknown as TestGlobals;
|
|
84
84
|
const originalWindow = testGlobal.window;
|
|
85
85
|
const originalDocument = testGlobal.document;
|
|
86
86
|
|
|
@@ -207,7 +207,7 @@ describe("WebAddressAutocomplete", () => {
|
|
|
207
207
|
document?: MinimalDocument;
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
const testGlobal = globalThis as TestGlobals;
|
|
210
|
+
const testGlobal = globalThis as unknown as TestGlobals;
|
|
211
211
|
const originalWindow = testGlobal.window;
|
|
212
212
|
const originalDocument = testGlobal.document;
|
|
213
213
|
|
|
@@ -468,7 +468,7 @@ describe("WebAddressAutocomplete", () => {
|
|
|
468
468
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
469
469
|
});
|
|
470
470
|
|
|
471
|
-
const win = (globalThis as Record<string, Record<string, unknown>>).window;
|
|
471
|
+
const win = (globalThis as unknown as Record<string, Record<string, unknown>>).window;
|
|
472
472
|
expect(win.initAutocomplete).toBeDefined();
|
|
473
473
|
|
|
474
474
|
unmount();
|
|
@@ -502,7 +502,7 @@ describe("WebAddressAutocomplete", () => {
|
|
|
502
502
|
}),
|
|
503
503
|
}));
|
|
504
504
|
|
|
505
|
-
const win = (globalThis as Record<string, Record<string, unknown>>).window;
|
|
505
|
+
const win = (globalThis as unknown as Record<string, Record<string, unknown>>).window;
|
|
506
506
|
win.google = {
|
|
507
507
|
maps: {places: {Autocomplete: autocompleteConstructor}},
|
|
508
508
|
};
|
|
@@ -4,11 +4,12 @@ import {assert} from "chai";
|
|
|
4
4
|
import type {ComponentProps} from "react";
|
|
5
5
|
import {Dimensions} from "react-native";
|
|
6
6
|
|
|
7
|
-
import {renderWithTheme} from "./test-utils";
|
|
7
|
+
import {findAllByHostType, renderWithTheme} from "./test-utils";
|
|
8
8
|
import {
|
|
9
9
|
resolveDocumentBodyPortalTarget,
|
|
10
10
|
scheduleAfterPaint,
|
|
11
11
|
useWebDropdownAnchor,
|
|
12
|
+
type WebDropdownAnchor,
|
|
12
13
|
WebDropdownMenu,
|
|
13
14
|
} from "./WebDropdownMenu";
|
|
14
15
|
|
|
@@ -63,7 +64,7 @@ describe("WebDropdownMenu", () => {
|
|
|
63
64
|
});
|
|
64
65
|
|
|
65
66
|
it("invokes onSelect with value and index when an option is pressed", () => {
|
|
66
|
-
const onSelect = mock(() => {});
|
|
67
|
+
const onSelect = mock((_value: string, _index: number) => {});
|
|
67
68
|
const {getByTestId} = renderWithTheme(
|
|
68
69
|
<WebDropdownMenu
|
|
69
70
|
anchor={anchor}
|
|
@@ -365,7 +366,7 @@ describe("WebDropdownMenu disableSearch", () => {
|
|
|
365
366
|
});
|
|
366
367
|
|
|
367
368
|
it("reports the original index when selecting a filtered option", () => {
|
|
368
|
-
const onSelect = mock(() => {});
|
|
369
|
+
const onSelect = mock((_value: string, _index: number) => {});
|
|
369
370
|
const {getByTestId} = renderWithTheme(
|
|
370
371
|
<WebDropdownMenu
|
|
371
372
|
anchor={anchor}
|
|
@@ -469,7 +470,7 @@ describe("WebDropdownMenu keepTriggerFocus portal overlay", () => {
|
|
|
469
470
|
keyupListeners.push(listener);
|
|
470
471
|
}
|
|
471
472
|
},
|
|
472
|
-
body: body as HTMLElement,
|
|
473
|
+
body: body as unknown as HTMLElement,
|
|
473
474
|
removeEventListener: (type: string, listener: (event: KeyboardEvent) => void) => {
|
|
474
475
|
if (type === "keyup") {
|
|
475
476
|
keyupListeners = keyupListeners.filter((registered) => registered !== listener);
|
|
@@ -488,7 +489,7 @@ describe("WebDropdownMenu keepTriggerFocus portal overlay", () => {
|
|
|
488
489
|
};
|
|
489
490
|
|
|
490
491
|
const dispatchEscapeKey = (): void => {
|
|
491
|
-
const event = {key: "Escape", stopPropagation: mock(() => {})} as KeyboardEvent;
|
|
492
|
+
const event = {key: "Escape", stopPropagation: mock(() => {})} as unknown as KeyboardEvent;
|
|
492
493
|
for (const listener of keyupListeners) {
|
|
493
494
|
listener(event);
|
|
494
495
|
}
|
|
@@ -542,7 +543,7 @@ describe("WebDropdownMenu keepTriggerFocus portal overlay", () => {
|
|
|
542
543
|
expect(style.position).toBe("fixed");
|
|
543
544
|
expect(style.left).toBe(anchor.x);
|
|
544
545
|
|
|
545
|
-
const modals = root
|
|
546
|
+
const modals = findAllByHostType(root, "Modal");
|
|
546
547
|
expect(modals.length).toBe(0);
|
|
547
548
|
} finally {
|
|
548
549
|
PlatformModule.OS = savedOS;
|
|
@@ -562,7 +563,7 @@ describe("WebDropdownMenu keepTriggerFocus portal overlay", () => {
|
|
|
562
563
|
|
|
563
564
|
assert.isOk(getByTestId("web_dropdown_menu"));
|
|
564
565
|
assert.isNull(queryByTestId("web_dropdown_modal"));
|
|
565
|
-
assert.equal(root
|
|
566
|
+
assert.equal(findAllByHostType(root, "Modal").length, 0);
|
|
566
567
|
} finally {
|
|
567
568
|
PlatformModule.OS = savedOS;
|
|
568
569
|
restoreWebDocument();
|
|
@@ -578,7 +579,7 @@ describe("WebDropdownMenu keepTriggerFocus portal overlay", () => {
|
|
|
578
579
|
const placeholder = getByTestId("web_dropdown_modal");
|
|
579
580
|
expect(placeholder.props.visible).toBeUndefined();
|
|
580
581
|
|
|
581
|
-
const modals = root
|
|
582
|
+
const modals = findAllByHostType(root, "Modal");
|
|
582
583
|
expect(modals.length).toBe(0);
|
|
583
584
|
} finally {
|
|
584
585
|
PlatformModule.OS = savedOS;
|
|
@@ -712,7 +713,7 @@ describe("useWebDropdownAnchor", () => {
|
|
|
712
713
|
|
|
713
714
|
it("invokes the callback synchronously with the existing anchor when the ref is empty", () => {
|
|
714
715
|
const {result} = renderHook(() => useWebDropdownAnchor());
|
|
715
|
-
const onMeasured = mock(() => {});
|
|
716
|
+
const onMeasured = mock((_anchor: WebDropdownAnchor) => {});
|
|
716
717
|
act(() => {
|
|
717
718
|
result.current.measure(onMeasured);
|
|
718
719
|
});
|
|
@@ -726,7 +727,7 @@ describe("useWebDropdownAnchor", () => {
|
|
|
726
727
|
cb(10, 20, 100, 40);
|
|
727
728
|
});
|
|
728
729
|
(result.current.triggerRef as {current: unknown}).current = {measureInWindow};
|
|
729
|
-
const onMeasured = mock(() => {});
|
|
730
|
+
const onMeasured = mock((_anchor: WebDropdownAnchor) => {});
|
|
730
731
|
act(() => {
|
|
731
732
|
result.current.measure(onMeasured);
|
|
732
733
|
});
|
|
@@ -886,14 +887,14 @@ describe("WebDropdownMenu layout callbacks", () => {
|
|
|
886
887
|
visible
|
|
887
888
|
/>
|
|
888
889
|
);
|
|
889
|
-
const scrollView = root
|
|
890
|
+
const scrollView = findAllByHostType(root, "ScrollView")[0];
|
|
890
891
|
expect(scrollView).toBeTruthy();
|
|
891
892
|
act(() => {
|
|
892
893
|
fireEvent(scrollView, "layout", {nativeEvent: {layout: {height: 200, width: 200}}});
|
|
893
894
|
});
|
|
894
895
|
// The list viewport height is recorded and a scroll is scheduled; the
|
|
895
896
|
// component should remain mounted and functional.
|
|
896
|
-
expect(root
|
|
897
|
+
expect(findAllByHostType(root, "ScrollView").length).toBeGreaterThan(0);
|
|
897
898
|
});
|
|
898
899
|
|
|
899
900
|
it("records option layout and schedules a scroll for the selected option", () => {
|
|
@@ -936,7 +937,7 @@ describe("WebDropdownMenu layout callbacks", () => {
|
|
|
936
937
|
/>
|
|
937
938
|
);
|
|
938
939
|
|
|
939
|
-
const scrollView = root
|
|
940
|
+
const scrollView = findAllByHostType(root, "ScrollView")[0];
|
|
940
941
|
const scrollCalls: Array<{animated?: boolean; y?: number}> = [];
|
|
941
942
|
const scrollRef = scrollView.props.ref as {current: unknown};
|
|
942
943
|
scrollRef.current = {
|
|
@@ -975,7 +976,7 @@ describe("WebDropdownMenu layout callbacks", () => {
|
|
|
975
976
|
/>
|
|
976
977
|
);
|
|
977
978
|
|
|
978
|
-
const scrollView = root
|
|
979
|
+
const scrollView = findAllByHostType(root, "ScrollView")[0];
|
|
979
980
|
const scrollCalls: Array<{animated?: boolean; y?: number}> = [];
|
|
980
981
|
const scrollRef = scrollView.props.ref as {current: unknown};
|
|
981
982
|
scrollRef.current = {
|
|
@@ -1013,7 +1014,7 @@ describe("WebDropdownMenu layout callbacks", () => {
|
|
|
1013
1014
|
/>
|
|
1014
1015
|
);
|
|
1015
1016
|
|
|
1016
|
-
const scrollView = root
|
|
1017
|
+
const scrollView = findAllByHostType(root, "ScrollView")[0];
|
|
1017
1018
|
const scrollCalls: Array<{animated?: boolean; y?: number}> = [];
|
|
1018
1019
|
const scrollRef = scrollView.props.ref as {current: unknown};
|
|
1019
1020
|
scrollRef.current = {
|
|
@@ -142,7 +142,7 @@ exports[`Card container variant (default) applies custom color 1`] = `
|
|
|
142
142
|
"onPointerEnter": [Function: AsyncFunction],
|
|
143
143
|
"onPointerLeave": [Function: AsyncFunction],
|
|
144
144
|
"style": {
|
|
145
|
-
"backgroundColor":
|
|
145
|
+
"backgroundColor": "#2B6072",
|
|
146
146
|
"borderBottomColor": "#CDCDCD",
|
|
147
147
|
"borderBottomWidth": 1,
|
|
148
148
|
"borderRadius": undefined,
|
|
@@ -17,7 +17,7 @@ exports[`DismissButton renders correctly with default props 1`] = `
|
|
|
17
17
|
},
|
|
18
18
|
],
|
|
19
19
|
"props": {
|
|
20
|
-
"accessibilityHint":
|
|
20
|
+
"accessibilityHint": "Dismisses the message",
|
|
21
21
|
"aria-label": "Dismiss",
|
|
22
22
|
"aria-role": "button",
|
|
23
23
|
"onPress": [Function],
|
|
@@ -49,7 +49,7 @@ exports[`DismissButton renders with primary color (default) 1`] = `
|
|
|
49
49
|
},
|
|
50
50
|
],
|
|
51
51
|
"props": {
|
|
52
|
-
"accessibilityHint":
|
|
52
|
+
"accessibilityHint": "Dismisses the message",
|
|
53
53
|
"aria-label": "Dismiss",
|
|
54
54
|
"aria-role": "button",
|
|
55
55
|
"onPress": [Function],
|
|
@@ -81,7 +81,7 @@ exports[`DismissButton renders with inverted color 1`] = `
|
|
|
81
81
|
},
|
|
82
82
|
],
|
|
83
83
|
"props": {
|
|
84
|
-
"accessibilityHint":
|
|
84
|
+
"accessibilityHint": "Dismisses the message",
|
|
85
85
|
"aria-label": "Dismiss",
|
|
86
86
|
"aria-role": "button",
|
|
87
87
|
"onPress": [Function],
|
|
@@ -3607,7 +3607,9 @@ exports[`Field renders multiselect field 1`] = `
|
|
|
3607
3607
|
"children": [
|
|
3608
3608
|
{
|
|
3609
3609
|
"$$typeof": Symbol(react.test.json),
|
|
3610
|
-
"children":
|
|
3610
|
+
"children": [
|
|
3611
|
+
"Skills",
|
|
3612
|
+
],
|
|
3611
3613
|
"props": {
|
|
3612
3614
|
"numberOfLines": 0,
|
|
3613
3615
|
"style": {
|
|
@@ -3830,7 +3832,7 @@ exports[`Field renders multiselect field 1`] = `
|
|
|
3830
3832
|
],
|
|
3831
3833
|
"props": {
|
|
3832
3834
|
"accessibilityHint": "Contains a prompt and list of options to select",
|
|
3833
|
-
"aria-label":
|
|
3835
|
+
"aria-label": "Skills",
|
|
3834
3836
|
"aria-role": "combobox",
|
|
3835
3837
|
"style": {
|
|
3836
3838
|
"display": "flex",
|
|
@@ -237,7 +237,7 @@ exports[`Image renders with background color 1`] = `
|
|
|
237
237
|
"onPointerEnter": [Function: AsyncFunction],
|
|
238
238
|
"onPointerLeave": [Function: AsyncFunction],
|
|
239
239
|
"style": {
|
|
240
|
-
"backgroundColor":
|
|
240
|
+
"backgroundColor": "#2B6072",
|
|
241
241
|
},
|
|
242
242
|
"testID": undefined,
|
|
243
243
|
},
|
|
@@ -1405,7 +1405,7 @@ exports[`Page renders with custom color 1`] = `
|
|
|
1405
1405
|
"onPointerLeave": [Function: AsyncFunction],
|
|
1406
1406
|
"style": {
|
|
1407
1407
|
"alignSelf": "center",
|
|
1408
|
-
"backgroundColor":
|
|
1408
|
+
"backgroundColor": "#2B6072",
|
|
1409
1409
|
"display": "flex",
|
|
1410
1410
|
"flex": undefined,
|
|
1411
1411
|
"flexDirection": "column",
|
|
@@ -1437,7 +1437,7 @@ exports[`Page renders with custom color 1`] = `
|
|
|
1437
1437
|
"scrollEventThrottle": 50,
|
|
1438
1438
|
"style": {
|
|
1439
1439
|
"alignSelf": "center",
|
|
1440
|
-
"backgroundColor":
|
|
1440
|
+
"backgroundColor": "#2B6072",
|
|
1441
1441
|
"display": "flex",
|
|
1442
1442
|
"flex": undefined,
|
|
1443
1443
|
"flexDirection": "column",
|
|
@@ -9,12 +9,12 @@ import {
|
|
|
9
9
|
import {act, fireEvent, render, waitFor, within} from "@testing-library/react-native";
|
|
10
10
|
import {assert} from "chai";
|
|
11
11
|
import {createRef} from "react";
|
|
12
|
-
import type {Text as NativeText} from "react-native";
|
|
12
|
+
import type {Text as NativeText, TextProps} from "react-native";
|
|
13
13
|
import {ThemeProvider} from "../Theme";
|
|
14
14
|
import {TimezonePicker} from "../TimezonePicker";
|
|
15
|
-
import {renderWithTheme} from "../test-utils";
|
|
15
|
+
import {elementProps, findAllByHostType, renderWithTheme} from "../test-utils";
|
|
16
16
|
import {AskCard, type AskCardProps} from "./AskCard";
|
|
17
|
-
import type {AskSubmission, ChatAsk} from "./askTypes";
|
|
17
|
+
import type {AskSubmission, ChatAsk, ChatAskState} from "./askTypes";
|
|
18
18
|
|
|
19
19
|
const PLAN_INPUT: ChoiceAskInput = {
|
|
20
20
|
default: ["team"],
|
|
@@ -49,7 +49,7 @@ const COUNTRY_INPUT: ChoiceAskInput = {
|
|
|
49
49
|
select: "one",
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
const pendingAsk = (input: ChoiceAskInput, state: Partial<
|
|
52
|
+
const pendingAsk = (input: ChoiceAskInput, state: Partial<ChatAskState> = {}): ChatAsk => ({
|
|
53
53
|
input,
|
|
54
54
|
kind: "choice",
|
|
55
55
|
status: "pending",
|
|
@@ -556,7 +556,7 @@ describe("AskCard", () => {
|
|
|
556
556
|
|
|
557
557
|
await press(getByTestId("ask-card-button-approve"));
|
|
558
558
|
assert.lengthOf(
|
|
559
|
-
getByTestId("ask-card-button-approve")
|
|
559
|
+
findAllByHostType(getByTestId("ask-card-button-approve"), "ActivityIndicator"),
|
|
560
560
|
1
|
|
561
561
|
);
|
|
562
562
|
assert.isTrue(isDisabled(getByTestId("ask-card-button-deny")));
|
|
@@ -1010,11 +1010,12 @@ describe("AskCard", () => {
|
|
|
1010
1010
|
assert.isNull(card.queryByText("Enter a complete time, or clear it."));
|
|
1011
1011
|
assert.isNull(card.queryByText("Enter a complete date and time, or clear it."));
|
|
1012
1012
|
await press(card.getByTestId("ask-card-submit"));
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1013
|
+
const response = onSubmit.mock.calls[0]?.[0]?.response;
|
|
1014
|
+
const values = response?.action === "accept" ? response.content.values : undefined;
|
|
1015
|
+
assert.deepInclude((values ?? {}) as Record<string, unknown>, {
|
|
1016
|
+
meeting: "2026-10-01T09:30:00Z",
|
|
1017
|
+
reminder: "10:30",
|
|
1018
|
+
});
|
|
1018
1019
|
});
|
|
1019
1020
|
|
|
1020
1021
|
it("keeps Submit disabled when the hour of an on-the-hour time is cleared, and keeps the time", async () => {
|
|
@@ -1244,8 +1245,9 @@ describe("AskCard", () => {
|
|
|
1244
1245
|
const {getByTestId} = renderCard({ask: pendingAsk(PLAN_INPUT), onSubmit});
|
|
1245
1246
|
|
|
1246
1247
|
await press(getByTestId("ask-card-button-option:team"));
|
|
1247
|
-
const spinners =
|
|
1248
|
-
(
|
|
1248
|
+
const spinners = findAllByHostType(
|
|
1249
|
+
getByTestId("ask-card-button-option:team"),
|
|
1250
|
+
"ActivityIndicator"
|
|
1249
1251
|
);
|
|
1250
1252
|
assert.lengthOf(spinners, 1);
|
|
1251
1253
|
assert.isTrue(isDisabled(getByTestId("ask-card-button-option:team")));
|
|
@@ -1306,7 +1308,8 @@ describe("AskCard", () => {
|
|
|
1306
1308
|
const {getByRole} = render(
|
|
1307
1309
|
<AskCard ask={pendingAsk(PLAN_INPUT)} onSubmit={async () => {}} promptRef={promptRef} />,
|
|
1308
1310
|
{
|
|
1309
|
-
createNodeMock: (element) =>
|
|
1311
|
+
createNodeMock: (element) =>
|
|
1312
|
+
elementProps<TextProps>(element).accessibilityRole === "header" ? prompt : null,
|
|
1310
1313
|
wrapper: ThemeProvider,
|
|
1311
1314
|
}
|
|
1312
1315
|
);
|
|
@@ -306,7 +306,11 @@ describe("AskCard files", () => {
|
|
|
306
306
|
assert.isNull(rendered.queryByTestId("ask-card-errors"));
|
|
307
307
|
assert.isFalse(isDisabled(rendered.getByTestId("ask-card-submit")));
|
|
308
308
|
|
|
309
|
-
const tooLarge = {
|
|
309
|
+
const tooLarge = {
|
|
310
|
+
...mismatch,
|
|
311
|
+
code: "FILE_TOO_LARGE" as const,
|
|
312
|
+
message: "items.txt is too large.",
|
|
313
|
+
};
|
|
310
314
|
rendered.rerender(<AskCard ask={ask} errors={[tooLarge]} onSubmit={onSubmit} />);
|
|
311
315
|
assert.isOk(within(rendered.getByTestId("ask-card-errors")).getByText(tooLarge.message));
|
|
312
316
|
|
|
@@ -57,7 +57,7 @@ describe("askFileRefs", () => {
|
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
assert.equal(ref.mimeType, "text/csv");
|
|
60
|
-
assert.isTrue(ref.url
|
|
60
|
+
assert.isTrue(ref.url?.startsWith("data:text/csv;base64,"));
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
it("reads a picked file into a data URL of its declared type, with its byte size", async () => {
|
|
@@ -3,7 +3,7 @@ import type {ChoiceAskInput, ConfirmAskInput, FormAskInput} from "@terreno/block
|
|
|
3
3
|
import {assert} from "chai";
|
|
4
4
|
|
|
5
5
|
import {askSummary} from "./askSummary";
|
|
6
|
-
import type {ChatAsk} from "./askTypes";
|
|
6
|
+
import type {ChatAsk, ChatAskState} from "./askTypes";
|
|
7
7
|
|
|
8
8
|
const PLAN_INPUT: ChoiceAskInput = {
|
|
9
9
|
options: [
|
|
@@ -15,7 +15,7 @@ const PLAN_INPUT: ChoiceAskInput = {
|
|
|
15
15
|
select: "one",
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
const planAsk = (state: Partial<
|
|
18
|
+
const planAsk = (state: Partial<ChatAskState> & {input?: ChoiceAskInput}): ChatAsk => ({
|
|
19
19
|
input: PLAN_INPUT,
|
|
20
20
|
kind: "choice",
|
|
21
21
|
status: "answered",
|
|
@@ -28,7 +28,7 @@ describe("fresh import timing", () => {
|
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
30
|
`;
|
|
31
|
-
const childEnv = {...process.env, TZ: "America/New_York"};
|
|
31
|
+
const childEnv: NodeJS.ProcessEnv = {...process.env, TZ: "America/New_York"};
|
|
32
32
|
delete childEnv.BUN_OPTIONS;
|
|
33
33
|
writeFileSync(PROBE_FILE, probeSource, "utf8");
|
|
34
34
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {afterEach, describe, expect, it, jest, mock} from "bun:test";
|
|
2
2
|
import {readdirSync, readFileSync} from "node:fs";
|
|
3
3
|
import {join} from "node:path";
|
|
4
|
-
import type {Block} from "@terreno/blocks";
|
|
4
|
+
import type {Block, BlocksDocument} from "@terreno/blocks";
|
|
5
5
|
import {act, fireEvent, waitFor} from "@testing-library/react-native";
|
|
6
6
|
import {setStringAsync} from "expo-clipboard";
|
|
7
7
|
import {ActivityIndicator, Image as NativeImage, ScrollView, StyleSheet} from "react-native";
|
|
@@ -14,6 +14,11 @@ import {renderWithTheme} from "../test-utils";
|
|
|
14
14
|
import {BlocksView} from "./BlocksView";
|
|
15
15
|
import {renderBlock} from "./blockRenderers";
|
|
16
16
|
|
|
17
|
+
/** Treats a document assembled field by field, as untyped model JSON arrives, as a BlocksDocument. */
|
|
18
|
+
const untypedDocument = (fields: Record<string, unknown>): BlocksDocument => {
|
|
19
|
+
return fields as unknown as BlocksDocument;
|
|
20
|
+
};
|
|
21
|
+
|
|
17
22
|
const ACTIONS = `v: 1
|
|
18
23
|
datasets:
|
|
19
24
|
signups:
|
|
@@ -357,8 +362,9 @@ blocks:
|
|
|
357
362
|
data: lamb
|
|
358
363
|
`;
|
|
359
364
|
type StyledNode = {parent: StyledNode | null; props: {style?: unknown}};
|
|
360
|
-
const flatStyle = (node: StyledNode): {textAlign?: string; width?: number} =>
|
|
365
|
+
const flatStyle = (node: StyledNode): {height?: number; textAlign?: string; width?: number} =>
|
|
361
366
|
(StyleSheet.flatten(node.props.style as never) ?? {}) as {
|
|
367
|
+
height?: number;
|
|
362
368
|
textAlign?: string;
|
|
363
369
|
width?: number;
|
|
364
370
|
};
|
|
@@ -771,9 +777,10 @@ blocks:
|
|
|
771
777
|
block.type = "html";
|
|
772
778
|
block.title = "Invoice preview";
|
|
773
779
|
block.html = "<h1>Invoice #1042</h1>";
|
|
774
|
-
const
|
|
775
|
-
|
|
776
|
-
|
|
780
|
+
const fields: Record<string, unknown> = {};
|
|
781
|
+
fields.v = 1;
|
|
782
|
+
fields.blocks = [block];
|
|
783
|
+
const document = untypedDocument(fields);
|
|
777
784
|
|
|
778
785
|
const off = renderWithTheme(<BlocksView document={document} />);
|
|
779
786
|
expect(off.getByText("HTML preview is turned off.")).toBeTruthy();
|
|
@@ -804,9 +811,10 @@ blocks:
|
|
|
804
811
|
details.type = "details";
|
|
805
812
|
details.title = "Invoice notes";
|
|
806
813
|
details.text = "Twelve seats, billed monthly.";
|
|
807
|
-
const
|
|
808
|
-
|
|
809
|
-
|
|
814
|
+
const fields: Record<string, unknown> = {};
|
|
815
|
+
fields.v = 1;
|
|
816
|
+
fields.blocks = [callout, picture, details];
|
|
817
|
+
const document = untypedDocument(fields);
|
|
810
818
|
|
|
811
819
|
const {getByText} = renderWithTheme(<BlocksView document={document} />);
|
|
812
820
|
|
|
@@ -821,9 +829,10 @@ blocks:
|
|
|
821
829
|
block.type = "image";
|
|
822
830
|
block.alt = "Pixel";
|
|
823
831
|
block.src = "https://evil.test/pixel.png";
|
|
824
|
-
const
|
|
825
|
-
|
|
826
|
-
|
|
832
|
+
const fields: Record<string, unknown> = {};
|
|
833
|
+
fields.v = 1;
|
|
834
|
+
fields.blocks = [block];
|
|
835
|
+
const document = untypedDocument(fields);
|
|
827
836
|
|
|
828
837
|
const blocked = renderWithTheme(<BlocksView document={document} />);
|
|
829
838
|
expect(blocked.getByText(/IMAGE_HOST_NOT_ALLOWED|allowed host/)).toBeTruthy();
|
package/src/bunSetup.ts
CHANGED
|
@@ -158,7 +158,7 @@ const createSimpleFlatList = () => {
|
|
|
158
158
|
const createVirtualizedFlatList = (): React.ForwardRefExoticComponent<
|
|
159
159
|
MockFlatListProps & React.RefAttributes<unknown>
|
|
160
160
|
> =>
|
|
161
|
-
React.forwardRef((props, ref) => {
|
|
161
|
+
React.forwardRef((props: MockFlatListProps, ref) => {
|
|
162
162
|
const {
|
|
163
163
|
data,
|
|
164
164
|
renderItem,
|
|
@@ -450,7 +450,7 @@ describe("DataTableAdditionalFiltersWeb", () => {
|
|
|
450
450
|
});
|
|
451
451
|
|
|
452
452
|
it("keeps in-progress drafts when the filters array is recreated", async () => {
|
|
453
|
-
const onApply = mock(() => {});
|
|
453
|
+
const onApply = mock((_values: Record<string, unknown>) => {});
|
|
454
454
|
const departmentFilter = {
|
|
455
455
|
field: "department",
|
|
456
456
|
kind: "choice" as const,
|
|
@@ -5,7 +5,7 @@ import {useEffect} from "react";
|
|
|
5
5
|
import {Text, useWindowDimensions} from "react-native";
|
|
6
6
|
|
|
7
7
|
import type {ListDetailState} from "../Common";
|
|
8
|
-
import {renderWithTheme} from "../test-utils";
|
|
8
|
+
import {findAllByHostType, renderWithTheme} from "../test-utils";
|
|
9
9
|
|
|
10
10
|
// This file runs in its own process (src/isolated), so it can install route and router doubles
|
|
11
11
|
// for the hooks this layout reads without affecting other suites.
|
|
@@ -126,9 +126,7 @@ describe("ListDetailLayout", () => {
|
|
|
126
126
|
const {getByTestId, queryByTestId} = renderLayout();
|
|
127
127
|
|
|
128
128
|
expect(queryByTestId("list-detail-list-pane")).toBeNull();
|
|
129
|
-
expect(
|
|
130
|
-
getByTestId("list-detail-detail-pane").findAll((node) => node.type === "Stack")
|
|
131
|
-
).toHaveLength(1);
|
|
129
|
+
expect(findAllByHostType(getByTestId("list-detail-detail-pane"), "Stack")).toHaveLength(1);
|
|
132
130
|
expect(getByTestId("split-probe").props.children).toBe("stacked");
|
|
133
131
|
});
|
|
134
132
|
|
|
@@ -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 {LoginScreen} from "./LoginScreen";
|
|
9
9
|
import type {LoginAccountOption} from "./loginTypes";
|
|
10
10
|
|
|
@@ -252,7 +252,7 @@ describe("LoginScreen", () => {
|
|
|
252
252
|
});
|
|
253
253
|
|
|
254
254
|
it("calls onSubmit with form values when submit button is pressed", async () => {
|
|
255
|
-
const onSubmit = mock(() => Promise.resolve());
|
|
255
|
+
const onSubmit = mock((_values: Record<string, string>) => Promise.resolve());
|
|
256
256
|
const {getByTestId} = renderWithTheme(
|
|
257
257
|
<LoginScreen fields={defaultFields} onSubmit={onSubmit} />
|
|
258
258
|
);
|
|
@@ -845,14 +845,14 @@ const renderWithHostMocks = (
|
|
|
845
845
|
): ReturnType<typeof render> & {focused: string[]} => {
|
|
846
846
|
const focused: string[] = [];
|
|
847
847
|
const result = render(ui, {
|
|
848
|
-
createNodeMock: (element: ReactElement
|
|
848
|
+
createNodeMock: (element: ReactElement) => {
|
|
849
849
|
if (element.type === "form") {
|
|
850
850
|
return requestSubmit ? {requestSubmit} : {};
|
|
851
851
|
}
|
|
852
852
|
return {
|
|
853
853
|
blur: (): void => {},
|
|
854
854
|
focus: (): void => {
|
|
855
|
-
focused.push(element.
|
|
855
|
+
focused.push(elementProps<{testID?: string}>(element).testID ?? "");
|
|
856
856
|
},
|
|
857
857
|
};
|
|
858
858
|
},
|
|
@@ -900,7 +900,7 @@ describe("LoginScreen keyboard and autofill", () => {
|
|
|
900
900
|
});
|
|
901
901
|
|
|
902
902
|
it("submits once on Enter in the password field", async () => {
|
|
903
|
-
const onSubmit = mock(() => Promise.resolve());
|
|
903
|
+
const onSubmit = mock((_values: Record<string, string>) => Promise.resolve());
|
|
904
904
|
const {getByTestId} = renderWithTheme(
|
|
905
905
|
<LoginScreen fields={defaultFields} onSubmit={onSubmit} />
|
|
906
906
|
);
|
|
@@ -973,7 +973,7 @@ describe("LoginScreen keyboard and autofill", () => {
|
|
|
973
973
|
Platform.OS = "web";
|
|
974
974
|
try {
|
|
975
975
|
const requestSubmit = mock(() => {});
|
|
976
|
-
const onSubmit = mock(() => Promise.resolve());
|
|
976
|
+
const onSubmit = mock((_values: Record<string, string>) => Promise.resolve());
|
|
977
977
|
const {UNSAFE_getByType, getByTestId} = renderWithHostMocks(
|
|
978
978
|
<LoginScreen fields={defaultFields} onSubmit={onSubmit} />,
|
|
979
979
|
{requestSubmit}
|
|
@@ -2,7 +2,7 @@ import {describe, expect, it, mock, spyOn} from "bun:test";
|
|
|
2
2
|
import {act, fireEvent, render, waitFor} from "@testing-library/react-native";
|
|
3
3
|
import type {ReactElement} from "react";
|
|
4
4
|
import {ThemeProvider} from "../Theme";
|
|
5
|
-
import {renderWithTheme} from "../test-utils";
|
|
5
|
+
import {elementProps, renderWithTheme} from "../test-utils";
|
|
6
6
|
import {PasswordCard} from "./PasswordCard";
|
|
7
7
|
import type {PasswordCardSubmission} from "./securityTypes";
|
|
8
8
|
|
|
@@ -18,11 +18,11 @@ const press = async (element: Parameters<typeof fireEvent.press>[0]): Promise<vo
|
|
|
18
18
|
const renderTrackingFocus = (ui: ReactElement): ReturnType<typeof render> & {focused: string[]} => {
|
|
19
19
|
const focused: string[] = [];
|
|
20
20
|
const result = render(ui, {
|
|
21
|
-
createNodeMock: (element: ReactElement
|
|
21
|
+
createNodeMock: (element: ReactElement) => ({
|
|
22
22
|
blur: (): void => {},
|
|
23
23
|
clear: (): void => {},
|
|
24
24
|
focus: (): void => {
|
|
25
|
-
focused.push(element.
|
|
25
|
+
focused.push(elementProps<{testID?: string}>(element).testID ?? "");
|
|
26
26
|
},
|
|
27
27
|
isFocused: (): boolean => false,
|
|
28
28
|
}),
|