@databricks/design-system 1.9.1 → 1.10.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/dist/{Typography-84a00e02.js → Spinner-140f57ac.js} +1135 -75
- package/dist/Spinner-140f57ac.js.map +1 -0
- package/dist/common-3ab0e300.js +15 -0
- package/dist/common-3ab0e300.js.map +1 -0
- package/dist/design-system/AutoComplete/AutoComplete.d.ts.map +1 -1
- package/dist/design-system/Button/Button.d.ts +5 -1
- package/dist/design-system/Button/Button.d.ts.map +1 -1
- package/dist/design-system/Button/styles.d.ts.map +1 -1
- package/dist/design-system/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/design-system/DatePicker/DatePicker.d.ts +18 -14
- package/dist/design-system/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/design-system/DesignSystemProvider/DesignSystemProvider.d.ts +3 -1
- package/dist/design-system/DesignSystemProvider/DesignSystemProvider.d.ts.map +1 -1
- package/dist/design-system/Drawer/Drawer.d.ts +12 -1
- package/dist/design-system/Drawer/Drawer.d.ts.map +1 -1
- package/dist/design-system/FormMessage/FormMessage.d.ts.map +1 -1
- package/dist/design-system/FormV2/RHFAdapters.d.ts +7 -7
- package/dist/design-system/FormV2/RHFAdapters.d.ts.map +1 -1
- package/dist/design-system/Hooks/useDesignSystemTheme.d.ts.map +1 -1
- package/dist/design-system/Icon/__generated/icons/BracketsXIcon.v2.d.ts +4 -0
- package/dist/design-system/Icon/__generated/icons/BracketsXIcon.v2.d.ts.map +1 -0
- package/dist/design-system/Icon/__generated/icons/CloudModelIcon.v2.d.ts +4 -0
- package/dist/design-system/Icon/__generated/icons/CloudModelIcon.v2.d.ts.map +1 -0
- package/dist/design-system/Icon/__generated/icons/CursorIcon.v2.d.ts +4 -0
- package/dist/design-system/Icon/__generated/icons/CursorIcon.v2.d.ts.map +1 -0
- package/dist/design-system/Icon/__generated/icons/DagIcon.v2.d.ts +4 -0
- package/dist/design-system/Icon/__generated/icons/DagIcon.v2.d.ts.map +1 -0
- package/dist/design-system/Icon/__generated/icons/DecimalIcon.v2.d.ts +4 -0
- package/dist/design-system/Icon/__generated/icons/DecimalIcon.v2.d.ts.map +1 -0
- package/dist/design-system/Icon/__generated/icons/DotsCircleIcon.v2.d.ts +4 -0
- package/dist/design-system/Icon/__generated/icons/DotsCircleIcon.v2.d.ts.map +1 -0
- package/dist/design-system/Icon/__generated/icons/LettersIcon.v2.d.ts +4 -0
- package/dist/design-system/Icon/__generated/icons/LettersIcon.v2.d.ts.map +1 -0
- package/dist/design-system/Icon/__generated/icons/NumbersIcon.v2.d.ts +4 -0
- package/dist/design-system/Icon/__generated/icons/NumbersIcon.v2.d.ts.map +1 -0
- package/dist/design-system/Icon/__generated/icons/index.d.ts +8 -1
- package/dist/design-system/Icon/__generated/icons/index.d.ts.map +1 -1
- package/dist/design-system/LegacyTable/LegacyTable.d.ts +100 -0
- package/dist/design-system/LegacyTable/LegacyTable.d.ts.map +1 -0
- package/dist/design-system/LegacyTable/index.d.ts +2 -0
- package/dist/design-system/LegacyTable/index.d.ts.map +1 -0
- package/dist/design-system/Modal/Modal.d.ts +3 -1
- package/dist/design-system/Modal/Modal.d.ts.map +1 -1
- package/dist/design-system/Notification/Notification.d.ts.map +1 -1
- package/dist/design-system/PageWrapper/PageWrapper.d.ts.map +1 -1
- package/dist/design-system/Popover/Popover.d.ts +2 -1
- package/dist/design-system/Popover/Popover.d.ts.map +1 -1
- package/dist/design-system/PopoverV2/PopoverV2.d.ts +1 -0
- package/dist/design-system/PopoverV2/PopoverV2.d.ts.map +1 -1
- package/dist/design-system/Radio/Radio.d.ts.map +1 -1
- package/dist/design-system/SegmentedControl/SegmentedControl.d.ts +0 -2
- package/dist/design-system/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/dist/design-system/Select/Select.d.ts.map +1 -1
- package/dist/design-system/Sidebar/Sidebar.d.ts +1 -1
- package/dist/design-system/Sidebar/Sidebar.d.ts.map +1 -1
- package/dist/design-system/SplitButton/Dropdown/DropdownButton.d.ts.map +1 -1
- package/dist/design-system/Table/index.d.ts +1 -1
- package/dist/design-system/ToggleButton/ToggleButton.d.ts.map +1 -1
- package/dist/design-system/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/design-system/index.d.ts +1 -1
- package/dist/design-system/index.d.ts.map +1 -1
- package/dist/development/Filter/Filter.d.ts +10 -0
- package/dist/development/Filter/Filter.d.ts.map +1 -0
- package/dist/development/Filter/Filter.test.d.ts +2 -0
- package/dist/development/Filter/Filter.test.d.ts.map +1 -0
- package/dist/development/Filter/FilterButtonContainer.d.ts +2 -0
- package/dist/development/Filter/FilterButtonContainer.d.ts.map +1 -0
- package/dist/development/Filter/FilterContent.d.ts +14 -0
- package/dist/development/Filter/FilterContent.d.ts.map +1 -0
- package/dist/development/Filter/FilterCountBadge.d.ts +2 -0
- package/dist/development/Filter/FilterCountBadge.d.ts.map +1 -0
- package/dist/development/Filter/FilterLoadingSpinner.d.ts +2 -0
- package/dist/development/Filter/FilterLoadingSpinner.d.ts.map +1 -0
- package/dist/development/Filter/FilterOptionControlledList.d.ts +9 -0
- package/dist/development/Filter/FilterOptionControlledList.d.ts.map +1 -0
- package/dist/development/Filter/FilterOptionList.d.ts +10 -0
- package/dist/development/Filter/FilterOptionList.d.ts.map +1 -0
- package/dist/development/Filter/FilterOptionListCheckboxItem.d.ts +11 -0
- package/dist/development/Filter/FilterOptionListCheckboxItem.d.ts.map +1 -0
- package/dist/development/Filter/FilterOptionListSearch.d.ts +7 -0
- package/dist/development/Filter/FilterOptionListSearch.d.ts.map +1 -0
- package/dist/development/Filter/FilterOptionListSelectItem.d.ts +10 -0
- package/dist/development/Filter/FilterOptionListSelectItem.d.ts.map +1 -0
- package/dist/development/Filter/FilterSectionHeader.d.ts +2 -0
- package/dist/development/Filter/FilterSectionHeader.d.ts.map +1 -0
- package/dist/development/Filter/FilterSeparator.d.ts +2 -0
- package/dist/development/Filter/FilterSeparator.d.ts.map +1 -0
- package/dist/development/Filter/FilterTrigger.d.ts +15 -0
- package/dist/development/Filter/FilterTrigger.d.ts.map +1 -0
- package/dist/development/Filter/hooks/useFilterContext.d.ts +2 -0
- package/dist/development/Filter/hooks/useFilterContext.d.ts.map +1 -0
- package/dist/development/Filter/hooks/useFilterOptionListContext.d.ts +2 -0
- package/dist/development/Filter/hooks/useFilterOptionListContext.d.ts.map +1 -0
- package/dist/development/Filter/index.d.ts +14 -0
- package/dist/development/Filter/index.d.ts.map +1 -0
- package/dist/development/Filter/providers/FilterContext.d.ts +15 -0
- package/dist/development/Filter/providers/FilterContext.d.ts.map +1 -0
- package/dist/development/Filter/providers/FilterOptionListContext.d.ts +10 -0
- package/dist/development/Filter/providers/FilterOptionListContext.d.ts.map +1 -0
- package/dist/development/Filter/shared.d.ts +3 -0
- package/dist/development/Filter/shared.d.ts.map +1 -0
- package/dist/development/Slider/Slider.d.ts.map +1 -1
- package/dist/development/TableUI/index.d.ts +33 -0
- package/dist/development/TableUI/index.d.ts.map +1 -1
- package/dist/development/index.d.ts +1 -0
- package/dist/development/index.d.ts.map +1 -1
- package/dist/development.js +1097 -472
- package/dist/development.js.map +1 -1
- package/dist/index-dark.css +1 -0
- package/dist/index-mfe-dark.css +1 -0
- package/dist/index-mfe.css +1 -0
- package/dist/index.css +1 -0
- package/dist/index.js +836 -1558
- package/dist/index.js.map +1 -1
- package/dist/test-utils/common.d.ts +11 -0
- package/dist/test-utils/common.d.ts.map +1 -0
- package/dist/test-utils/enzyme/index.d.ts +1 -0
- package/dist/test-utils/enzyme/index.d.ts.map +1 -1
- package/dist/test-utils/enzyme/selectEvent.d.ts +42 -0
- package/dist/test-utils/enzyme/selectEvent.d.ts.map +1 -0
- package/dist/test-utils/enzyme/selectEvent.test.d.ts +2 -0
- package/dist/test-utils/enzyme/selectEvent.test.d.ts.map +1 -0
- package/dist/test-utils/enzyme/utils.d.ts +33 -0
- package/dist/test-utils/enzyme/utils.d.ts.map +1 -0
- package/dist/test-utils/enzyme.js +258 -1
- package/dist/test-utils/enzyme.js.map +1 -1
- package/dist/test-utils/rtl/index.d.ts +1 -0
- package/dist/test-utils/rtl/index.d.ts.map +1 -1
- package/dist/test-utils/rtl/selectEvent.d.ts +41 -0
- package/dist/test-utils/rtl/selectEvent.d.ts.map +1 -0
- package/dist/test-utils/rtl/selectEvent.test.d.ts +2 -0
- package/dist/test-utils/rtl/selectEvent.test.d.ts.map +1 -0
- package/dist/test-utils/rtl.js +135 -1
- package/dist/test-utils/rtl.js.map +1 -1
- package/dist/test-utils/types.d.ts +1 -14
- package/dist/test-utils/types.d.ts.map +1 -1
- package/dist/theme/colorList.d.ts +7 -8
- package/dist/theme/colorList.d.ts.map +1 -1
- package/dist/theme/colors.d.ts +9 -11
- package/dist/theme/colors.d.ts.map +1 -1
- package/dist/theme/convertToLessVars.d.ts +3 -4
- package/dist/theme/convertToLessVars.d.ts.map +1 -1
- package/dist/theme/generalVariables.d.ts +4 -0
- package/dist/theme/generalVariables.d.ts.map +1 -1
- package/dist/theme/index.d.ts +7 -3
- package/dist/theme/index.d.ts.map +1 -1
- package/package.json +7 -6
- package/dist/Typography-52abe0b7.js +0 -1142
- package/dist/Typography-52abe0b7.js.map +0 -1
- package/dist/Typography-84a00e02.js.map +0 -1
- package/dist/design-system/Icon/__generated/icons/ArrayIcon.v2.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/ArrayIcon.v2.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/BookmarkBorderIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/BookmarkBorderIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/BracketsIcon.v2.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/BracketsIcon.v2.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/CheckCircleBorderIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/CheckCircleBorderIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/ClusterIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/ClusterIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/ClustersIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/ClustersIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/DataMarketplace.v2.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/DataMarketplace.v2.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/ErrorBorderIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/ErrorBorderIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/ErrorFillIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/ErrorFillIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/ExperimentIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/ExperimentIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/Folder1Icon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/Folder1Icon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/Gear1Icon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/Gear1Icon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/InfoBorderIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/InfoBorderIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/LifesaverIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/LifesaverIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/LinkRemoveIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/LinkRemoveIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/LockBorderIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/LockBorderIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/MinusCircleBorderIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/MinusCircleBorderIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/NotificationsOffIcon.v2.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/NotificationsOffIcon.v2.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/PinBorderIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/PinBorderIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/PlayCircleBorderIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/PlayCircleBorderIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/PlusCircleBorderIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/PlusCircleBorderIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/QueryListViewIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/QueryListViewIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/QueryNavIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/QueryNavIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/QuestionMarkBorderIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/QuestionMarkBorderIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/Redo.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/Redo.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/RedoIcon.v2.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/RedoIcon.v2.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/Refresh.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/Refresh.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/Refresh.v2.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/Refresh.v2.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/RefreshIcon.v2.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/RefreshIcon.v2.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/Search1Icon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/Search1Icon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/StarBorderIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/StarBorderIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/StopCircleBorderIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/StopCircleBorderIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/StopCricleFillIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/StopCricleFillIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/Undo.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/Undo.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/Visible.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/Visible.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/VisibleOff.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/VisibleOff.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/WarningBorderIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/WarningBorderIcon.d.ts.map +0 -1
- package/dist/design-system/Icon/__generated/icons/XCircleBorderIcon.d.ts +0 -4
- package/dist/design-system/Icon/__generated/icons/XCircleBorderIcon.d.ts.map +0 -1
- package/dist/test-utils/enzyme.d.ts +0 -8
- package/dist/test-utils/enzyme.d.ts.map +0 -1
- package/dist/test-utils/rtl.d.ts +0 -7
- package/dist/test-utils/rtl.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/test-utils/common.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;CAMzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/test-utils/enzyme/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,mBAAoB,YAAY,SAE5D,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/test-utils/enzyme/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE3C,OAAO,KAAK,WAAW,MAAM,eAAe,CAAC;AAE7C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,mBAAoB,YAAY,SAE5D,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ReactWrapper } from 'enzyme';
|
|
2
|
+
/**
|
|
3
|
+
* Clicks on the "Clear" button. In order for this function to work properly,
|
|
4
|
+
* the `allowClear` prop must be set to `true`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function clearAll(getSelect: () => ReactWrapper): void;
|
|
7
|
+
/**
|
|
8
|
+
* Closes the dropdown menu for the <Select/> by clicking. Will throw an error if
|
|
9
|
+
* the menu is already closed or if the menu is unable to be closed.
|
|
10
|
+
*/
|
|
11
|
+
export declare function closeMenu(getSelect: () => ReactWrapper): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Returns a string concatenating the labels for all selected options.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getLabelText(getSelect: () => ReactWrapper): string;
|
|
16
|
+
/**
|
|
17
|
+
* Selects options from the dropdown menu for a <Select/> component with `mode="multiple"`.
|
|
18
|
+
* The provided strings must match the option labels exactly. There is a known
|
|
19
|
+
* limitation for lists that are extremely long because AntD virtualizes the
|
|
20
|
+
* options so not all may options may be rendered in the DOM. If this is causing
|
|
21
|
+
* you issues, please let #help-frontend know.
|
|
22
|
+
*/
|
|
23
|
+
export declare function multiSelect(getSelect: () => ReactWrapper, options: string[]): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Selects options from the dropdown menu for a <Select/> component without a
|
|
26
|
+
* mode. The provided string must match an option label exactly. There is a known
|
|
27
|
+
* limitation for lists that are extremely long because AntD virtualizes the
|
|
28
|
+
* options so not all may options may be rendered in the DOM. If this is causing
|
|
29
|
+
* you issues, please let #help-frontend know.
|
|
30
|
+
*/
|
|
31
|
+
export declare function singleSelect(getSelect: () => ReactWrapper, option: string): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Opens the dropdown menu for the <Select/> by clicking. Will throw an error if
|
|
34
|
+
* the menu is already opened or if the menu is unable to be opened.
|
|
35
|
+
*/
|
|
36
|
+
export declare function openMenu(getSelect: () => ReactWrapper): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Opens the dropdown menu, finds all of the options in the dropdown, closes
|
|
39
|
+
* the menu, and returns a list of the text of each option in order.
|
|
40
|
+
*/
|
|
41
|
+
export declare function getAllOptions(getSelect: () => ReactWrapper): Promise<string[]>;
|
|
42
|
+
//# sourceMappingURL=selectEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectEvent.d.ts","sourceRoot":"","sources":["../../../src/test-utils/enzyme/selectEvent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAK3C;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,YAAY,GAAG,IAAI,CAE5D;AAED;;;GAGG;AACH,wBAAsB,SAAS,CAAC,SAAS,EAAE,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAW5E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,YAAY,GAAG,MAAM,CAKlE;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAOjG;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,SAAS,EAAE,MAAM,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI/F;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,SAAS,EAAE,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAW3E;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAQpF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectEvent.test.d.ts","sourceRoot":"","sources":["../../../src/test-utils/enzyme/selectEvent.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ReactWrapper } from 'enzyme';
|
|
3
|
+
interface QueryOptions {
|
|
4
|
+
/** Whether to trim the whitespace from DOM text using `String.prototype.trim` */
|
|
5
|
+
trim?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Finds a single element that contains the specified text in the wrapper. If
|
|
9
|
+
* there are 0 or more than 1 element that contains the specified text, an error
|
|
10
|
+
* is thrown. Returns the element in an enzyme wrapper.
|
|
11
|
+
*/
|
|
12
|
+
export declare function findByText<P, S, C>(wrapper: ReactWrapper<P, S, C>, text: string | RegExp, queryOptions?: QueryOptions): ReactWrapper<any, any, import("react").Component<{}, {}, any>>;
|
|
13
|
+
/**
|
|
14
|
+
* Finds all elements that contain the specified text. To avoid duplicate results,
|
|
15
|
+
* only the parents of text nodes are returned.
|
|
16
|
+
*/
|
|
17
|
+
export declare function findAllByText<P, S, C>(wrapper: ReactWrapper<P, S, C>, text: string | RegExp, { trim }?: QueryOptions): ReactWrapper<any, any, import("react").Component<{}, {}, any>>[];
|
|
18
|
+
interface WaitForOptions {
|
|
19
|
+
interval?: number;
|
|
20
|
+
stackTraceError?: Error;
|
|
21
|
+
timeout?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Wraps `_waitFor` in React's `act` testing utility. Used when the React component
|
|
25
|
+
* updates during the execution of the callback (either because of indirect effects
|
|
26
|
+
* being run or because of direct requests to update the component, like wrapper.update).
|
|
27
|
+
* Prevents updates related to the callback from being affected by other updates
|
|
28
|
+
* and more closely mimics how React runs in the browser. See
|
|
29
|
+
* https://reactjs.org/docs/test-utils.html#act for more info on `act`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function waitFor<T>(callback: () => T | Promise<T>, options?: WaitForOptions): Promise<T>;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/test-utils/enzyme/utils.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAG3C,UAAU,YAAY;IACpB,iFAAiF;IACjF,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAChC,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC9B,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,YAAY,CAAC,EAAE,YAAY,kEAS5B;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EACnC,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC9B,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,EAAE,IAAY,EAAE,GAAE,YAAiB,oEA0BpC;AAkBD,UAAU,cAAc;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,KAAK,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAmED;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CAYrG"}
|
|
@@ -1,5 +1,262 @@
|
|
|
1
|
+
import { s as selectClasses } from '../common-3ab0e300.js';
|
|
2
|
+
import { act } from 'react-dom/test-utils';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @databricks/no-restricted-imports-regexp
|
|
5
|
+
/**
|
|
6
|
+
* Finds a single element that contains the specified text in the wrapper. If
|
|
7
|
+
* there are 0 or more than 1 element that contains the specified text, an error
|
|
8
|
+
* is thrown. Returns the element in an enzyme wrapper.
|
|
9
|
+
*/
|
|
10
|
+
function findByText(wrapper, text, queryOptions) {
|
|
11
|
+
const newWrappers = findAllByText(wrapper, text, queryOptions);
|
|
12
|
+
if (newWrappers.length !== 1) {
|
|
13
|
+
throw new Error("Expected to find 1 node but found ".concat(newWrappers.length, " nodes for text \"").concat(text, "\".\n").concat(wrapper.debug()));
|
|
14
|
+
}
|
|
15
|
+
return newWrappers[0];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Finds all elements that contain the specified text. To avoid duplicate results,
|
|
20
|
+
* only the parents of text nodes are returned.
|
|
21
|
+
*/
|
|
22
|
+
function findAllByText(wrapper, text) {
|
|
23
|
+
let {
|
|
24
|
+
trim = false
|
|
25
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
26
|
+
const textNodes = wrapper.findWhere(n => {
|
|
27
|
+
if (n.type() !== undefined) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
let nodeText = n.text();
|
|
31
|
+
if (trim) {
|
|
32
|
+
nodeText = nodeText.trim();
|
|
33
|
+
}
|
|
34
|
+
return typeof text === 'string' ? nodeText === text : text.test(nodeText);
|
|
35
|
+
});
|
|
36
|
+
const newWrappers = textNodes.map(n => {
|
|
37
|
+
const textNodeParent = n.parents().first();
|
|
38
|
+
if (textNodeParent.name() === 'FormattedMessage') {
|
|
39
|
+
// Try not to return FormattedMessage since it breaks `simulate` due to a bug in `enzyme-adapter-react-17`
|
|
40
|
+
// Similar to https://github.com/wojtekmaj/enzyme-adapter-react-17/issues/45
|
|
41
|
+
const formattedMessageParents = textNodeParent.parents();
|
|
42
|
+
return formattedMessageParents.length > 0 ? formattedMessageParents.first() : textNodeParent;
|
|
43
|
+
} else {
|
|
44
|
+
return textNodeParent;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return newWrappers;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// We need to keep ref to original setTimeout to avoid SinonJS fake timers if enabled
|
|
51
|
+
const originalSetTimeout = window.setTimeout;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* This is so the stack trace the developer sees is one that's
|
|
55
|
+
* closer to their code (because async stack traces are hard to follow).
|
|
56
|
+
*
|
|
57
|
+
* The code is taken from
|
|
58
|
+
* https://github.com/testing-library/dom-testing-library/blob/f7b5c33c44632fba
|
|
59
|
+
* 1579cb44f9f175be1ec46087/src/wait-for.js#L15-L19
|
|
60
|
+
*/
|
|
61
|
+
function copyStackTrace(target, source) {
|
|
62
|
+
// eslint-disable-next-line no-param-reassign
|
|
63
|
+
target.stack = source.stack.replace(source.message, target.message);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Run an expectation until it succeeds or reaches the timeout. The timeout of 1500ms
|
|
67
|
+
* is chosen to be under the default Karma test timeout of 2000ms. This function will
|
|
68
|
+
* not work properly if fake timers are being used (since it expects the real setTimeout).
|
|
69
|
+
*
|
|
70
|
+
* The code is taken from
|
|
71
|
+
* https://github.com/TheBrainFamily/wait-for-expect/blob/master/src/index.ts,
|
|
72
|
+
* with slight modifications to support Karma (instead of Jest).
|
|
73
|
+
*
|
|
74
|
+
*
|
|
75
|
+
* Example
|
|
76
|
+
* The <App /> component does not render the header synchronously.
|
|
77
|
+
* Therefore, we cannot check that the wrapper's text is equal to the string
|
|
78
|
+
* immediately--this assertion will fail and cause the test to fail. To
|
|
79
|
+
* remediate this issue, we can run the expectation until it succeeds:
|
|
80
|
+
*
|
|
81
|
+
* function App() {
|
|
82
|
+
* const [value, setValue] = useState(null);
|
|
83
|
+
* useEffect(() => {
|
|
84
|
+
* const timeoutId = setTimeout(() => setValue("some value"), 100);
|
|
85
|
+
* return () => clearTimeout(timeoutId);
|
|
86
|
+
* }, []);
|
|
87
|
+
* return value === null ? null : <h1>The value is: {value}</h1>;
|
|
88
|
+
* }
|
|
89
|
+
*
|
|
90
|
+
* it('renders value', async () => {
|
|
91
|
+
* const wrapper = mount(<App />);
|
|
92
|
+
* await waitFor(() =>
|
|
93
|
+
* wrapper.update();
|
|
94
|
+
* expect(wrapper.text()).to.equal("The value is: some value")
|
|
95
|
+
* );
|
|
96
|
+
* });
|
|
97
|
+
*/
|
|
98
|
+
function _waitFor(f) {
|
|
99
|
+
let {
|
|
100
|
+
interval = 50,
|
|
101
|
+
stackTraceError,
|
|
102
|
+
timeout = 1500
|
|
103
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
104
|
+
const maxTries = Math.ceil(timeout / interval);
|
|
105
|
+
let tries = 0;
|
|
106
|
+
return new Promise((resolve, reject) => {
|
|
107
|
+
const rejectOrRerun = error => {
|
|
108
|
+
if (tries > maxTries) {
|
|
109
|
+
if (stackTraceError !== undefined) {
|
|
110
|
+
copyStackTrace(error, stackTraceError);
|
|
111
|
+
}
|
|
112
|
+
reject(error);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
originalSetTimeout(runExpectation, interval);
|
|
116
|
+
};
|
|
117
|
+
function runExpectation() {
|
|
118
|
+
tries += 1;
|
|
119
|
+
try {
|
|
120
|
+
Promise.resolve(f()).then(resolve).catch(rejectOrRerun);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
// @ts-expect-error ts-migrate(2571) Object is of type 'unknown'
|
|
123
|
+
rejectOrRerun(error);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
originalSetTimeout(runExpectation, 0);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Wraps `_waitFor` in React's `act` testing utility. Used when the React component
|
|
132
|
+
* updates during the execution of the callback (either because of indirect effects
|
|
133
|
+
* being run or because of direct requests to update the component, like wrapper.update).
|
|
134
|
+
* Prevents updates related to the callback from being affected by other updates
|
|
135
|
+
* and more closely mimics how React runs in the browser. See
|
|
136
|
+
* https://reactjs.org/docs/test-utils.html#act for more info on `act`.
|
|
137
|
+
*/
|
|
138
|
+
async function waitFor(callback, options) {
|
|
139
|
+
let result;
|
|
140
|
+
// See https://github.com/testing-library/dom-testing-library/blob/f7b5c33c44
|
|
141
|
+
// 632fba1579cb44f9f175be1ec46087/src/wait-for.js#L182-L184
|
|
142
|
+
const stackTraceError = new Error('STACK_TRACE_ERROR');
|
|
143
|
+
await act(async () => {
|
|
144
|
+
result = await _waitFor(callback, {
|
|
145
|
+
stackTraceError,
|
|
146
|
+
...options
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// @ts-expect-error: either `waitFor` will throw or `result` will be assigned
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
|
|
1
154
|
// eslint-disable-next-line @databricks/no-restricted-imports-regexp
|
|
2
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Clicks on the "Clear" button. In order for this function to work properly,
|
|
158
|
+
* the `allowClear` prop must be set to `true`.
|
|
159
|
+
*/
|
|
160
|
+
function clearAll(getSelect) {
|
|
161
|
+
getSelect().find(".".concat(selectClasses.clear)).hostNodes().simulate('mousedown');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Closes the dropdown menu for the <Select/> by clicking. Will throw an error if
|
|
166
|
+
* the menu is already closed or if the menu is unable to be closed.
|
|
167
|
+
*/
|
|
168
|
+
async function closeMenu(getSelect) {
|
|
169
|
+
if (!getSelect().find(".".concat(selectClasses.open)).exists()) {
|
|
170
|
+
throw new Error("Select is already closed\n".concat(getSelect().debug()));
|
|
171
|
+
}
|
|
172
|
+
getSelect().find(".".concat(selectClasses.selector)).simulate('mousedown');
|
|
173
|
+
await waitFor(() => {
|
|
174
|
+
const select = getSelect();
|
|
175
|
+
if (select.find(".".concat(selectClasses.open)).exists()) {
|
|
176
|
+
throw new Error("Select did not close\n".concat(select.debug()));
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Returns a string concatenating the labels for all selected options.
|
|
183
|
+
*/
|
|
184
|
+
function getLabelText(getSelect) {
|
|
185
|
+
// Trim the text to avoid weird whitespace issues non-label elements being added.
|
|
186
|
+
// For example, the input mirror is an empty span with some whitespace that is
|
|
187
|
+
// nested under the selector but does not show up in the label text.
|
|
188
|
+
return getSelect().find(".".concat(selectClasses.selector)).text().trim();
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Selects options from the dropdown menu for a <Select/> component with `mode="multiple"`.
|
|
193
|
+
* The provided strings must match the option labels exactly. There is a known
|
|
194
|
+
* limitation for lists that are extremely long because AntD virtualizes the
|
|
195
|
+
* options so not all may options may be rendered in the DOM. If this is causing
|
|
196
|
+
* you issues, please let #help-frontend know.
|
|
197
|
+
*/
|
|
198
|
+
async function multiSelect(getSelect, options) {
|
|
199
|
+
await openMenu(getSelect);
|
|
200
|
+
options.forEach(option => {
|
|
201
|
+
findByText(getSelect().find(".".concat(selectClasses.list)), option).simulate('click');
|
|
202
|
+
});
|
|
203
|
+
// Close the menu to indicate that selection has finished
|
|
204
|
+
await closeMenu(getSelect);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Selects options from the dropdown menu for a <Select/> component without a
|
|
209
|
+
* mode. The provided string must match an option label exactly. There is a known
|
|
210
|
+
* limitation for lists that are extremely long because AntD virtualizes the
|
|
211
|
+
* options so not all may options may be rendered in the DOM. If this is causing
|
|
212
|
+
* you issues, please let #help-frontend know.
|
|
213
|
+
*/
|
|
214
|
+
async function singleSelect(getSelect, option) {
|
|
215
|
+
await openMenu(getSelect);
|
|
216
|
+
findByText(getSelect().find(".".concat(selectClasses.list)), option).simulate('click');
|
|
217
|
+
// Menu automatically closes for a single <Select/> (no mode="multiple")
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Opens the dropdown menu for the <Select/> by clicking. Will throw an error if
|
|
222
|
+
* the menu is already opened or if the menu is unable to be opened.
|
|
223
|
+
*/
|
|
224
|
+
async function openMenu(getSelect) {
|
|
225
|
+
if (getSelect().find(".".concat(selectClasses.open)).exists()) {
|
|
226
|
+
throw new Error("Select is already open\n".concat(getSelect().debug()));
|
|
227
|
+
}
|
|
228
|
+
getSelect().find(".".concat(selectClasses.selector)).simulate('mousedown');
|
|
229
|
+
await waitFor(() => {
|
|
230
|
+
const select = getSelect();
|
|
231
|
+
if (!select.find(".".concat(selectClasses.open)).exists()) {
|
|
232
|
+
throw new Error("Select did not open\n".concat(select.debug()));
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Opens the dropdown menu, finds all of the options in the dropdown, closes
|
|
239
|
+
* the menu, and returns a list of the text of each option in order.
|
|
240
|
+
*/
|
|
241
|
+
async function getAllOptions(getSelect) {
|
|
242
|
+
await openMenu(getSelect);
|
|
243
|
+
const options = getSelect().find(".".concat(selectClasses.list)).find(".".concat(selectClasses.option)).map(option => option.text());
|
|
244
|
+
await closeMenu(getSelect);
|
|
245
|
+
return options;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
var selectEvent = /*#__PURE__*/Object.freeze({
|
|
249
|
+
__proto__: null,
|
|
250
|
+
clearAll: clearAll,
|
|
251
|
+
closeMenu: closeMenu,
|
|
252
|
+
getLabelText: getLabelText,
|
|
253
|
+
multiSelect: multiSelect,
|
|
254
|
+
singleSelect: singleSelect,
|
|
255
|
+
openMenu: openMenu,
|
|
256
|
+
getAllOptions: getAllOptions
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
// eslint-disable-next-line @databricks/no-restricted-imports-regexp
|
|
3
260
|
/**
|
|
4
261
|
* Open a dropdown menu by simulating a pointerDown event on the dropdown button.
|
|
5
262
|
*
|
|
@@ -12,5 +269,5 @@ const openDropdownMenu = dropdownButton => {
|
|
|
12
269
|
});
|
|
13
270
|
};
|
|
14
271
|
|
|
15
|
-
export { openDropdownMenu };
|
|
272
|
+
export { openDropdownMenu, selectEvent };
|
|
16
273
|
//# sourceMappingURL=enzyme.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enzyme.js","sources":["../../src/test-utils/enzyme/index.ts"],"sourcesContent":["// eslint-disable-next-line @databricks/no-restricted-imports-regexp\nimport type { ReactWrapper } from 'enzyme';\n\n/**\n * Open a dropdown menu by simulating a pointerDown event on the dropdown button.\n *\n * @param dropdownButton - The Dropdown Trigger button that opens the menu when clicked.\n */\nexport const openDropdownMenu = (dropdownButton: ReactWrapper) => {\n dropdownButton.hostNodes().simulate('pointerDown', { button: 0, ctrlKey: false });\n};\n"],"names":["openDropdownMenu","dropdownButton","hostNodes","simulate","button","ctrlKey"],"mappings":"AAAA;;AAGA;AACA;AACA;AACA;AACA;MACaA,gBAAgB,GAAIC,cAA4B,IAAK;EAChEA,cAAc,CAACC,SAAS,EAAE,CAACC,QAAQ,CAAC,aAAa,EAAE;IAAEC,MAAM,EAAE,CAAC;IAAEC,OAAO,EAAE;GAAO,CAAC;AACnF;;;;"}
|
|
1
|
+
{"version":3,"file":"enzyme.js","sources":["../../src/test-utils/enzyme/utils.ts","../../src/test-utils/enzyme/selectEvent.ts","../../src/test-utils/enzyme/index.ts"],"sourcesContent":["// eslint-disable-next-line @databricks/no-restricted-imports-regexp\nimport type { ReactWrapper } from 'enzyme';\nimport { act } from 'react-dom/test-utils';\n\ninterface QueryOptions {\n /** Whether to trim the whitespace from DOM text using `String.prototype.trim` */\n trim?: boolean;\n}\n\n/**\n * Finds a single element that contains the specified text in the wrapper. If\n * there are 0 or more than 1 element that contains the specified text, an error\n * is thrown. Returns the element in an enzyme wrapper.\n */\nexport function findByText<P, S, C>(\n wrapper: ReactWrapper<P, S, C>,\n text: string | RegExp,\n queryOptions?: QueryOptions\n) {\n const newWrappers = findAllByText<P, S, C>(wrapper, text, queryOptions);\n if (newWrappers.length !== 1) {\n throw new Error(\n `Expected to find 1 node but found ${newWrappers.length} nodes for text \"${text}\".\\n${wrapper.debug()}`\n );\n }\n return newWrappers[0];\n}\n\n/**\n * Finds all elements that contain the specified text. To avoid duplicate results,\n * only the parents of text nodes are returned.\n */\nexport function findAllByText<P, S, C>(\n wrapper: ReactWrapper<P, S, C>,\n text: string | RegExp,\n { trim = false }: QueryOptions = {}\n) {\n const textNodes = wrapper.findWhere((n) => {\n if (n.type() !== undefined) {\n return false;\n }\n\n let nodeText = n.text();\n if (trim) {\n nodeText = nodeText.trim();\n }\n\n return typeof text === 'string' ? nodeText === text : text.test(nodeText);\n });\n const newWrappers = textNodes.map((n) => {\n const textNodeParent = n.parents().first();\n if (textNodeParent.name() === 'FormattedMessage') {\n // Try not to return FormattedMessage since it breaks `simulate` due to a bug in `enzyme-adapter-react-17`\n // Similar to https://github.com/wojtekmaj/enzyme-adapter-react-17/issues/45\n const formattedMessageParents = textNodeParent.parents();\n return formattedMessageParents.length > 0 ? formattedMessageParents.first() : textNodeParent;\n } else {\n return textNodeParent;\n }\n });\n return newWrappers;\n}\n\n// We need to keep ref to original setTimeout to avoid SinonJS fake timers if enabled\nconst originalSetTimeout = window.setTimeout;\n\n/**\n * This is so the stack trace the developer sees is one that's\n * closer to their code (because async stack traces are hard to follow).\n *\n * The code is taken from\n * https://github.com/testing-library/dom-testing-library/blob/f7b5c33c44632fba\n * 1579cb44f9f175be1ec46087/src/wait-for.js#L15-L19\n */\nfunction copyStackTrace(target: Error, source: Error) {\n // eslint-disable-next-line no-param-reassign\n target.stack = source.stack!.replace(source.message, target.message);\n}\n\ninterface WaitForOptions {\n interval?: number;\n stackTraceError?: Error;\n timeout?: number;\n}\n\n/**\n * Run an expectation until it succeeds or reaches the timeout. The timeout of 1500ms\n * is chosen to be under the default Karma test timeout of 2000ms. This function will\n * not work properly if fake timers are being used (since it expects the real setTimeout).\n *\n * The code is taken from\n * https://github.com/TheBrainFamily/wait-for-expect/blob/master/src/index.ts,\n * with slight modifications to support Karma (instead of Jest).\n *\n *\n * Example\n * The <App /> component does not render the header synchronously.\n * Therefore, we cannot check that the wrapper's text is equal to the string\n * immediately--this assertion will fail and cause the test to fail. To\n * remediate this issue, we can run the expectation until it succeeds:\n *\n * function App() {\n * const [value, setValue] = useState(null);\n * useEffect(() => {\n * const timeoutId = setTimeout(() => setValue(\"some value\"), 100);\n * return () => clearTimeout(timeoutId);\n * }, []);\n * return value === null ? null : <h1>The value is: {value}</h1>;\n * }\n *\n * it('renders value', async () => {\n * const wrapper = mount(<App />);\n * await waitFor(() =>\n * wrapper.update();\n * expect(wrapper.text()).to.equal(\"The value is: some value\")\n * );\n * });\n */\nfunction _waitFor<T>(\n f: () => T | Promise<T>,\n { interval = 50, stackTraceError, timeout = 1500 }: WaitForOptions = {}\n): Promise<T> {\n const maxTries = Math.ceil(timeout / interval);\n let tries = 0;\n return new Promise((resolve, reject) => {\n const rejectOrRerun = (error: Error) => {\n if (tries > maxTries) {\n if (stackTraceError !== undefined) {\n copyStackTrace(error, stackTraceError);\n }\n reject(error);\n return;\n }\n originalSetTimeout(runExpectation, interval);\n };\n\n function runExpectation() {\n tries += 1;\n try {\n Promise.resolve(f()).then(resolve).catch(rejectOrRerun);\n } catch (error) {\n // @ts-expect-error ts-migrate(2571) Object is of type 'unknown'\n rejectOrRerun(error);\n }\n }\n\n originalSetTimeout(runExpectation, 0);\n });\n}\n\n/**\n * Wraps `_waitFor` in React's `act` testing utility. Used when the React component\n * updates during the execution of the callback (either because of indirect effects\n * being run or because of direct requests to update the component, like wrapper.update).\n * Prevents updates related to the callback from being affected by other updates\n * and more closely mimics how React runs in the browser. See\n * https://reactjs.org/docs/test-utils.html#act for more info on `act`.\n */\nexport async function waitFor<T>(callback: () => T | Promise<T>, options?: WaitForOptions): Promise<T> {\n let result: T | Promise<T>;\n // See https://github.com/testing-library/dom-testing-library/blob/f7b5c33c44\n // 632fba1579cb44f9f175be1ec46087/src/wait-for.js#L182-L184\n const stackTraceError = new Error('STACK_TRACE_ERROR');\n\n await act(async () => {\n result = await _waitFor(callback, { stackTraceError, ...options });\n });\n\n // @ts-expect-error: either `waitFor` will throw or `result` will be assigned\n return result;\n}\n","// eslint-disable-next-line @databricks/no-restricted-imports-regexp\nimport type { ReactWrapper } from 'enzyme';\n\nimport { selectClasses } from '../common';\nimport { findByText, waitFor } from './utils';\n\n/**\n * Clicks on the \"Clear\" button. In order for this function to work properly,\n * the `allowClear` prop must be set to `true`.\n */\nexport function clearAll(getSelect: () => ReactWrapper): void {\n getSelect().find(`.${selectClasses.clear}`).hostNodes().simulate('mousedown');\n}\n\n/**\n * Closes the dropdown menu for the <Select/> by clicking. Will throw an error if\n * the menu is already closed or if the menu is unable to be closed.\n */\nexport async function closeMenu(getSelect: () => ReactWrapper): Promise<void> {\n if (!getSelect().find(`.${selectClasses.open}`).exists()) {\n throw new Error(`Select is already closed\\n${getSelect().debug()}`);\n }\n getSelect().find(`.${selectClasses.selector}`).simulate('mousedown');\n await waitFor(() => {\n const select = getSelect();\n if (select.find(`.${selectClasses.open}`).exists()) {\n throw new Error(`Select did not close\\n${select.debug()}`);\n }\n });\n}\n\n/**\n * Returns a string concatenating the labels for all selected options.\n */\nexport function getLabelText(getSelect: () => ReactWrapper): string {\n // Trim the text to avoid weird whitespace issues non-label elements being added.\n // For example, the input mirror is an empty span with some whitespace that is\n // nested under the selector but does not show up in the label text.\n return getSelect().find(`.${selectClasses.selector}`).text().trim();\n}\n\n/**\n * Selects options from the dropdown menu for a <Select/> component with `mode=\"multiple\"`.\n * The provided strings must match the option labels exactly. There is a known\n * limitation for lists that are extremely long because AntD virtualizes the\n * options so not all may options may be rendered in the DOM. If this is causing\n * you issues, please let #help-frontend know.\n */\nexport async function multiSelect(getSelect: () => ReactWrapper, options: string[]): Promise<void> {\n await openMenu(getSelect);\n options.forEach((option) => {\n findByText(getSelect().find(`.${selectClasses.list}`), option).simulate('click');\n });\n // Close the menu to indicate that selection has finished\n await closeMenu(getSelect);\n}\n\n/**\n * Selects options from the dropdown menu for a <Select/> component without a\n * mode. The provided string must match an option label exactly. There is a known\n * limitation for lists that are extremely long because AntD virtualizes the\n * options so not all may options may be rendered in the DOM. If this is causing\n * you issues, please let #help-frontend know.\n */\nexport async function singleSelect(getSelect: () => ReactWrapper, option: string): Promise<void> {\n await openMenu(getSelect);\n findByText(getSelect().find(`.${selectClasses.list}`), option).simulate('click');\n // Menu automatically closes for a single <Select/> (no mode=\"multiple\")\n}\n\n/**\n * Opens the dropdown menu for the <Select/> by clicking. Will throw an error if\n * the menu is already opened or if the menu is unable to be opened.\n */\nexport async function openMenu(getSelect: () => ReactWrapper): Promise<void> {\n if (getSelect().find(`.${selectClasses.open}`).exists()) {\n throw new Error(`Select is already open\\n${getSelect().debug()}`);\n }\n getSelect().find(`.${selectClasses.selector}`).simulate('mousedown');\n await waitFor(() => {\n const select = getSelect();\n if (!select.find(`.${selectClasses.open}`).exists()) {\n throw new Error(`Select did not open\\n${select.debug()}`);\n }\n });\n}\n\n/**\n * Opens the dropdown menu, finds all of the options in the dropdown, closes\n * the menu, and returns a list of the text of each option in order.\n */\nexport async function getAllOptions(getSelect: () => ReactWrapper): Promise<string[]> {\n await openMenu(getSelect);\n const options = getSelect()\n .find(`.${selectClasses.list}`)\n .find(`.${selectClasses.option}`)\n .map((option) => option.text());\n await closeMenu(getSelect);\n return options;\n}\n","// eslint-disable-next-line @databricks/no-restricted-imports-regexp\nimport type { ReactWrapper } from 'enzyme';\n\nexport * as selectEvent from './selectEvent';\n\n/**\n * Open a dropdown menu by simulating a pointerDown event on the dropdown button.\n *\n * @param dropdownButton - The Dropdown Trigger button that opens the menu when clicked.\n */\nexport const openDropdownMenu = (dropdownButton: ReactWrapper) => {\n dropdownButton.hostNodes().simulate('pointerDown', { button: 0, ctrlKey: false });\n};\n"],"names":["findByText","wrapper","text","queryOptions","newWrappers","findAllByText","length","Error","debug","trim","textNodes","findWhere","n","type","undefined","nodeText","test","map","textNodeParent","parents","first","name","formattedMessageParents","originalSetTimeout","window","setTimeout","copyStackTrace","target","source","stack","replace","message","_waitFor","f","interval","stackTraceError","timeout","maxTries","Math","ceil","tries","Promise","resolve","reject","rejectOrRerun","error","runExpectation","then","catch","waitFor","callback","options","result","act","clearAll","getSelect","find","selectClasses","clear","hostNodes","simulate","closeMenu","open","exists","selector","select","getLabelText","multiSelect","openMenu","forEach","option","list","singleSelect","getAllOptions","openDropdownMenu","dropdownButton","button","ctrlKey"],"mappings":";;;AAAA;AASA;AACA;AACA;AACA;AACA;AACO,SAASA,UAAU,CACxBC,OAA8B,EAC9BC,IAAqB,EACrBC,YAA2B,EAC3B;EACA,MAAMC,WAAW,GAAGC,aAAa,CAAUJ,OAAO,EAAEC,IAAI,EAAEC,YAAY,CAAC;EACvE,IAAIC,WAAW,CAACE,MAAM,KAAK,CAAC,EAAE;IAC5B,MAAM,IAAIC,KAAK,6CACwBH,WAAW,CAACE,MAAM,+BAAoBJ,IAAI,kBAAOD,OAAO,CAACO,KAAK,EAAE,EACtG;;EAEH,OAAOJ,WAAW,CAAC,CAAC,CAAC;AACvB;;AAEA;AACA;AACA;AACA;AACO,SAASC,aAAa,CAC3BJ,OAA8B,EAC9BC,IAAqB,EAErB;EAAA,IADA;IAAEO,IAAI,GAAG;GAAqB,uEAAG,EAAE;EAEnC,MAAMC,SAAS,GAAGT,OAAO,CAACU,SAAS,C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;;;;;;;;;ACnGA;AAKA;AACA;AACA;AACA;AACA;MACauB,gBAAgB,GAAIC,cAA4B,IAAK;EAChEA,cAAc,CAAChB,SAAS,EAAE,CAACC,QAAQ,CAAC,aAAa,EAAE;IAAEgB,MAAM,EAAE,CAAC;IAAEC,OAAO,EAAE;GAAO,CAAC;AACnF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/test-utils/rtl/index.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,mBAA0B,WAAW,kBAEjE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/test-utils/rtl/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,WAAW,MAAM,eAAe,CAAC;AAE7C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,mBAA0B,WAAW,kBAEjE,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opens the dropdown menu for the <Select/> by clicking. Will throw an error if
|
|
3
|
+
* the menu is already opened or if the menu is unable to be opened.
|
|
4
|
+
*/
|
|
5
|
+
export declare function openMenu(select: HTMLElement): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Closes the dropdown menu for the <Select/> by clicking. Will throw an error if
|
|
8
|
+
* the menu is already closed or if the menu is unable to be closed.
|
|
9
|
+
*/
|
|
10
|
+
export declare function closeMenu(select: HTMLElement): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Returns a string concatenating the labels for all selected options.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getLabelText(select: HTMLElement): string;
|
|
15
|
+
/**
|
|
16
|
+
* Selects options from the dropdown menu for a <Select/> component with `mode="multiple"`.
|
|
17
|
+
* The provided strings must match the option labels exactly. There is a known
|
|
18
|
+
* limitation for lists that are extremely long because AntD virtualizes the
|
|
19
|
+
* options so not all may options may be rendered in the DOM. If this is causing
|
|
20
|
+
* you issues, please let #help-frontend know.
|
|
21
|
+
*/
|
|
22
|
+
export declare function multiSelect(select: HTMLElement, options: string[]): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Selects options from the dropdown menu for a <Select/> component without a
|
|
25
|
+
* mode. The provided string must match an option label exactly. There is a known
|
|
26
|
+
* limitation for lists that are extremely long because AntD virtualizes the
|
|
27
|
+
* options so not all may options may be rendered in the DOM. If this is causing
|
|
28
|
+
* you issues, please let #help-frontend know.
|
|
29
|
+
*/
|
|
30
|
+
export declare function singleSelect(select: HTMLElement, option: string): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Clicks on the "Clear" button. In order for this function to work properly,
|
|
33
|
+
* the `allowClear` prop must be set to `true`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function clearAll(select: HTMLElement): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Opens the dropdown menu, finds all of the options in the dropdown, closes
|
|
38
|
+
* the menu, and returns a list of the text of each option in order.
|
|
39
|
+
*/
|
|
40
|
+
export declare function getAllOptions(select: HTMLElement): Promise<string[]>;
|
|
41
|
+
//# sourceMappingURL=selectEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectEvent.d.ts","sourceRoot":"","sources":["../../../src/test-utils/rtl/selectEvent.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAUjE;AAED;;;GAGG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAUlE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CASxD;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CASvF;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKrF;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAMjE;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAe1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectEvent.test.d.ts","sourceRoot":"","sources":["../../../src/test-utils/rtl/selectEvent.test.tsx"],"names":[],"mappings":""}
|
package/dist/test-utils/rtl.js
CHANGED
|
@@ -1,4 +1,138 @@
|
|
|
1
1
|
import userEvent from '@testing-library/user-event';
|
|
2
|
+
import { waitFor, screen } from '@testing-library/react';
|
|
3
|
+
import { expect } from '@databricks/config-jest';
|
|
4
|
+
import { s as selectClasses } from '../common-3ab0e300.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Opens the dropdown menu for the <Select/> by clicking. Will throw an error if
|
|
8
|
+
* the menu is already opened or if the menu is unable to be opened.
|
|
9
|
+
*/
|
|
10
|
+
async function openMenu(select) {
|
|
11
|
+
expect(select).not.toHaveClass(selectClasses.open);
|
|
12
|
+
const selector = select.querySelector(".".concat(selectClasses.selector));
|
|
13
|
+
if (!selector) {
|
|
14
|
+
throw new Error("Selector not found\n".concat(select.innerHTML));
|
|
15
|
+
}
|
|
16
|
+
await userEvent.click(selector, {
|
|
17
|
+
pointerEventsCheck: 0
|
|
18
|
+
});
|
|
19
|
+
await waitFor(() => {
|
|
20
|
+
expect(select).toHaveClass(selectClasses.open);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Closes the dropdown menu for the <Select/> by clicking. Will throw an error if
|
|
26
|
+
* the menu is already closed or if the menu is unable to be closed.
|
|
27
|
+
*/
|
|
28
|
+
async function closeMenu(select) {
|
|
29
|
+
expect(select).toHaveClass(selectClasses.open);
|
|
30
|
+
const selector = select.querySelector(".".concat(selectClasses.selector));
|
|
31
|
+
if (!selector) {
|
|
32
|
+
throw new Error("Selector not found\n".concat(select.innerHTML));
|
|
33
|
+
}
|
|
34
|
+
await userEvent.click(selector, {
|
|
35
|
+
pointerEventsCheck: 0
|
|
36
|
+
});
|
|
37
|
+
await waitFor(() => {
|
|
38
|
+
expect(select).not.toHaveClass(selectClasses.open);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Returns a string concatenating the labels for all selected options.
|
|
44
|
+
*/
|
|
45
|
+
function getLabelText(select) {
|
|
46
|
+
var _selector$textContent, _selector$textContent2;
|
|
47
|
+
const selector = select.querySelector(".".concat(selectClasses.selector));
|
|
48
|
+
if (!selector) {
|
|
49
|
+
throw new Error("Selector not found\n".concat(select.innerHTML));
|
|
50
|
+
}
|
|
51
|
+
// Trim the text to avoid weird whitespace issues non-label elements being added.
|
|
52
|
+
// For example, the input mirror is an empty span with some whitespace that is
|
|
53
|
+
// nested under the selector but does not show up in the label text.
|
|
54
|
+
return (_selector$textContent = (_selector$textContent2 = selector.textContent) === null || _selector$textContent2 === void 0 ? void 0 : _selector$textContent2.trim()) !== null && _selector$textContent !== void 0 ? _selector$textContent : '';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Selects options from the dropdown menu for a <Select/> component with `mode="multiple"`.
|
|
59
|
+
* The provided strings must match the option labels exactly. There is a known
|
|
60
|
+
* limitation for lists that are extremely long because AntD virtualizes the
|
|
61
|
+
* options so not all may options may be rendered in the DOM. If this is causing
|
|
62
|
+
* you issues, please let #help-frontend know.
|
|
63
|
+
*/
|
|
64
|
+
async function multiSelect(select, options) {
|
|
65
|
+
await openMenu(select);
|
|
66
|
+
for (let i = 0; i < options.length; i++) {
|
|
67
|
+
const option = options[i];
|
|
68
|
+
const optionItem = screen.getByTitle(option);
|
|
69
|
+
await userEvent.click(optionItem, {
|
|
70
|
+
pointerEventsCheck: 0
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
// Close the menu to indicate that selection has finished
|
|
74
|
+
await closeMenu(select);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Selects options from the dropdown menu for a <Select/> component without a
|
|
79
|
+
* mode. The provided string must match an option label exactly. There is a known
|
|
80
|
+
* limitation for lists that are extremely long because AntD virtualizes the
|
|
81
|
+
* options so not all may options may be rendered in the DOM. If this is causing
|
|
82
|
+
* you issues, please let #help-frontend know.
|
|
83
|
+
*/
|
|
84
|
+
async function singleSelect(select, option) {
|
|
85
|
+
await openMenu(select);
|
|
86
|
+
const optionElem = screen.getByTitle(option);
|
|
87
|
+
await userEvent.click(optionElem, {
|
|
88
|
+
pointerEventsCheck: 0
|
|
89
|
+
});
|
|
90
|
+
// Menu automatically closes for a single <Select/> (no mode="multiple")
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Clicks on the "Clear" button. In order for this function to work properly,
|
|
95
|
+
* the `allowClear` prop must be set to `true`.
|
|
96
|
+
*/
|
|
97
|
+
async function clearAll(select) {
|
|
98
|
+
const clearBtn = select.querySelector(".".concat(selectClasses.clear));
|
|
99
|
+
if (!clearBtn) {
|
|
100
|
+
throw new Error("Select not clearable\n".concat(select.innerHTML));
|
|
101
|
+
}
|
|
102
|
+
await userEvent.click(clearBtn);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Opens the dropdown menu, finds all of the options in the dropdown, closes
|
|
107
|
+
* the menu, and returns a list of the text of each option in order.
|
|
108
|
+
*/
|
|
109
|
+
async function getAllOptions(select) {
|
|
110
|
+
await openMenu(select);
|
|
111
|
+
const optionsList = select.ownerDocument.body.querySelector(".".concat(selectClasses.list));
|
|
112
|
+
if (optionsList === null) {
|
|
113
|
+
throw new Error("Options list not found\n".concat(select.ownerDocument.body.innerHTML));
|
|
114
|
+
}
|
|
115
|
+
const options = [];
|
|
116
|
+
optionsList.querySelectorAll(".".concat(selectClasses.option)).forEach(option => {
|
|
117
|
+
if (option.textContent === null) {
|
|
118
|
+
throw new Error("Option had no text content\n".concat(option.innerHTML));
|
|
119
|
+
}
|
|
120
|
+
options.push(option.textContent);
|
|
121
|
+
});
|
|
122
|
+
await closeMenu(select);
|
|
123
|
+
return options;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
var selectEvent = /*#__PURE__*/Object.freeze({
|
|
127
|
+
__proto__: null,
|
|
128
|
+
openMenu: openMenu,
|
|
129
|
+
closeMenu: closeMenu,
|
|
130
|
+
getLabelText: getLabelText,
|
|
131
|
+
multiSelect: multiSelect,
|
|
132
|
+
singleSelect: singleSelect,
|
|
133
|
+
clearAll: clearAll,
|
|
134
|
+
getAllOptions: getAllOptions
|
|
135
|
+
});
|
|
2
136
|
|
|
3
137
|
/**
|
|
4
138
|
* Opens the dropdown menu by clicking on the dropdown button.
|
|
@@ -9,5 +143,5 @@ const openDropdownMenu = async dropdownButton => {
|
|
|
9
143
|
await userEvent.click(dropdownButton);
|
|
10
144
|
};
|
|
11
145
|
|
|
12
|
-
export { openDropdownMenu };
|
|
146
|
+
export { openDropdownMenu, selectEvent };
|
|
13
147
|
//# sourceMappingURL=rtl.js.map
|