@innovaccer/design-system 2.5.0-2 → 2.5.1
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/.all-contributorsrc +170 -0
- package/.github/workflows/jira.yml +1 -2
- package/.github/workflows/main.yml +1 -6
- package/.github/workflows/test.yml +22 -0
- package/CHANGELOG.md +21 -54
- package/CONTRIBUTING.md +23 -0
- package/README.md +124 -75
- package/core/components/atoms/button/Button.tsx +56 -55
- package/core/components/atoms/button/__tests__/Button.test.tsx +3 -12
- package/core/components/atoms/checkbox/Checkbox.tsx +3 -6
- package/core/components/atoms/collapsible/__stories__/index.story.tsx +2 -2
- package/core/components/atoms/dropdown/DropdownList.tsx +1 -1
- package/core/components/atoms/dropdown/__stories__/Options.tsx +15 -0
- package/core/components/atoms/dropdown/__tests__/Dropdown.test.tsx +202 -1
- package/core/components/atoms/dropdown/__tests__/Option.test.tsx +3 -0
- package/core/components/atoms/message/__stories__/CustomDescription.tsx +25 -0
- package/core/components/atoms/metaList/Meta.tsx +3 -1
- package/core/components/atoms/metaList/__tests__/MetaList.test.tsx +30 -36
- package/core/components/atoms/metricInput/MetricInput.tsx +2 -2
- package/core/components/atoms/outsideClick/__stories__/index.story.tsx +1 -1
- package/core/components/atoms/radio/Radio.tsx +7 -10
- package/core/components/atoms/radio/__tests__/Radio.test.tsx +13 -7
- package/core/components/css-utilities/Align/Align.story.tsx +1 -1
- package/core/components/css-utilities/Background/Background.story.tsx +1 -1
- package/core/components/css-utilities/Border/Border.story.tsx +128 -0
- package/core/components/css-utilities/Display/Display.story.tsx +1 -1
- package/core/components/css-utilities/Flex/Flex.story.tsx +1 -1
- package/core/components/css-utilities/Miscellaneous/Miscellaneous.story.tsx +1 -1
- package/core/components/css-utilities/Overflow/Overflow.story.tsx +1 -1
- package/core/components/css-utilities/Position/Position.story.tsx +1 -1
- package/core/components/css-utilities/Sizing/Sizing.story.tsx +1 -1
- package/core/components/css-utilities/Spacing/Spacing.story.tsx +1 -1
- package/core/components/molecules/chatMessage/__tests__/ChatMessage.test.tsx +20 -46
- package/core/components/molecules/dropzone/__tests__/Dropzone.test.tsx +47 -111
- package/core/components/molecules/dropzone/__tests__/Utilities.test.tsx +13 -13
- package/core/components/molecules/editableChipInput/EditableChipInput.tsx +3 -1
- package/core/components/molecules/editableInput/EditableInput.tsx +5 -3
- package/core/components/molecules/editableInput/__stories__/variants/Uncontrolled.story.tsx +1 -1
- package/core/components/molecules/editableInput/__tests__/EditableInput.test.tsx +1 -3
- package/core/components/molecules/emptyState/_tests_/EmptyState.test.tsx +3 -7
- package/core/components/molecules/fileUploader/FileUploaderItem.tsx +13 -2
- package/core/components/molecules/fileUploader/__stories__/index.story.tsx +156 -21
- package/core/components/molecules/fileUploader/__tests__/FileUploader.test.tsx +21 -80
- package/core/components/molecules/fileUploader/__tests__/FileUploaderList.test.tsx +9 -40
- package/core/components/molecules/fullscreenModal/FullscreenModal.tsx +7 -13
- package/core/components/molecules/fullscreenModal/__stories__/Layering.story.tsx +2 -2
- package/core/components/molecules/modal/Modal.tsx +18 -17
- package/core/components/molecules/modal/ModalBody.tsx +1 -1
- package/core/components/molecules/modal/__stories__/Layering.story.tsx +1 -1
- package/core/components/molecules/modal/__stories__/NoFooter.story.tsx +0 -1
- package/core/components/molecules/modal/__stories__/Scrolling.story.tsx +20 -38
- package/core/components/molecules/modal/__tests__/Modal.test.tsx +1 -1
- package/core/components/molecules/sidesheet/Sidesheet.tsx +16 -17
- package/core/components/organisms/choiceList/ChoiceList.tsx +212 -0
- package/core/components/organisms/choiceList/__stories__/Alignment.story.tsx +32 -0
- package/core/components/organisms/choiceList/__stories__/AllowMultiple.story.tsx +23 -0
- package/core/components/organisms/choiceList/__stories__/Controlled.story.tsx +34 -0
- package/core/components/organisms/choiceList/__stories__/index.story.tsx +18 -0
- package/core/components/organisms/choiceList/__tests__/ChoiceList.test.tsx +155 -0
- package/core/components/organisms/choiceList/__tests__/__snapshots__/ChoiceList.test.tsx.snap +3393 -0
- package/core/components/organisms/choiceList/index.tsx +2 -0
- package/core/components/organisms/datePicker/__tests__/DatePicker.test.tsx +136 -46
- package/core/components/organisms/datePicker/__tests__/__snapshots__/DatePicker.test.tsx.snap +2594 -102
- package/core/components/organisms/dateRangePicker/DateRangePicker.tsx +5 -0
- package/core/components/organisms/dateRangePicker/__tests__/DateRangePicker.test.tsx +49 -410
- package/core/components/organisms/dateRangePicker/__tests__/Utilities.test.tsx +39 -0
- package/core/components/organisms/dateRangePicker/__tests__/__snapshots__/DateRangePicker.test.tsx.snap +45390 -2679
- package/core/components/organisms/dateRangePicker/utilities.tsx +2 -5
- package/core/components/organisms/grid/Cell.tsx +5 -4
- package/core/components/organisms/grid/Grid.tsx +1 -1
- package/core/components/organisms/grid/GridCell.tsx +18 -7
- package/core/components/organisms/grid/GridHead.tsx +1 -1
- package/core/components/organisms/grid/GridRow.tsx +5 -12
- package/core/components/organisms/grid/__tests__/Grid.test.tsx +179 -1
- package/core/components/organisms/grid/__tests__/GridCell.test.tsx +218 -0
- package/core/components/organisms/grid/__tests__/__snapshots__/Grid.test.tsx.snap +1024 -0
- package/core/components/organisms/grid/__tests__/rowUtility.test.tsx +62 -0
- package/core/components/organisms/inlineMessage/InlineMessage.tsx +10 -14
- package/core/components/organisms/inlineMessage/__stories__/InlineMessageWithinTable.story.tsx +9 -12
- package/core/components/organisms/inlineMessage/__stories__/variants/Default.story.tsx +2 -4
- package/core/components/organisms/inlineMessage/__stories__/variants/Error.story.tsx +2 -5
- package/core/components/organisms/inlineMessage/__stories__/variants/Info.story.tsx +2 -5
- package/core/components/organisms/inlineMessage/__stories__/variants/Success.story.tsx +2 -5
- package/core/components/organisms/inlineMessage/__stories__/variants/Warning.story.tsx +2 -5
- package/core/components/organisms/inlineMessage/__tests__/InlineMessage.test.tsx +4 -20
- package/core/components/organisms/navigation/VerticalNavigation.tsx +14 -3
- package/core/components/organisms/navigation/__tests__/Navigation.test.tsx +179 -0
- package/core/components/organisms/navigation/__tests__/__snapshots__/Navigation.test.tsx.snap +530 -0
- package/core/components/organisms/table/DraggableDropdown.tsx +1 -0
- package/core/components/organisms/table/Header.tsx +11 -2
- package/core/components/organisms/table/Table.tsx +2 -2
- package/core/components/organisms/table/__stories__/NestedTableWithNestedCard.story.tsx +4 -1
- package/core/components/organisms/table/__stories__/variants/nestedRows.story.tsx +5 -2
- package/core/components/organisms/table/__tests__/Table.test.tsx +292 -0
- package/core/components/organisms/table/__tests__/__snapshots__/Table.test.tsx.snap +349041 -0
- package/core/components/organisms/timePicker/__tests__/TimePicker.test.tsx +15 -66
- package/core/components/patterns/dateRangePicker/withCustomPopover.story.tsx +47 -36
- package/core/index.tsx +1 -1
- package/core/index.type.tsx +1 -0
- package/core/utils/OverlayManager.tsx +1 -3
- package/core/utils/__tests__/__snapshots__/TS.test.tsx.snap +4 -0
- package/core/utils/types.tsx +3 -4
- package/css/dist/index.css +78 -8
- package/css/dist/index.css.map +1 -1
- package/css/src/components/button.css +8 -4
- package/css/src/components/choiceList.css +25 -0
- package/css/src/components/modal.css +1 -2
- package/css/src/utils/border.css +39 -0
- package/dist/core/components/atoms/popperWrapper/PopperWrapper.d.ts +50 -49
- package/dist/core/components/css-utilities/Border/Border.story.d.ts +13 -0
- package/dist/core/components/organisms/choiceList/ChoiceList.d.ts +33 -0
- package/dist/core/components/organisms/choiceList/index.d.ts +2 -0
- package/dist/core/components/organisms/dateRangePicker/utilities.d.ts +2 -2
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.type.d.ts +1 -0
- package/dist/index.esm.js +207 -58
- package/dist/index.js +209 -57
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.br +0 -0
- package/dist/index.umd.js.gz +0 -0
- package/jest.config.js +2 -1
- package/package.json +6 -4
|
@@ -94,7 +94,7 @@ const sizeMapping: Record<Size, number> = {
|
|
|
94
94
|
large: 20,
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
const ButtonBase = React.forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
|
|
98
98
|
const {
|
|
99
99
|
size = 'regular',
|
|
100
100
|
appearance = 'basic',
|
|
@@ -129,61 +129,62 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>((props, r
|
|
|
129
129
|
[`Button-icon--${iconAlign}`]: children && iconAlign,
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
-
const ButtonElement = () => {
|
|
133
|
-
return (
|
|
134
|
-
<button
|
|
135
|
-
data-test="DesignSystem-Button"
|
|
136
|
-
ref={ref}
|
|
137
|
-
type={type}
|
|
138
|
-
className={buttonClass}
|
|
139
|
-
disabled={disabled || loading}
|
|
140
|
-
tabIndex={tabIndex}
|
|
141
|
-
{...rest}
|
|
142
|
-
>
|
|
143
|
-
{loading ? (
|
|
144
|
-
<>
|
|
145
|
-
<Spinner
|
|
146
|
-
size="small"
|
|
147
|
-
appearance={appearance === 'basic' || appearance === 'transparent' ? 'secondary' : 'white'}
|
|
148
|
-
data-test="DesignSystem-Button--Spinner"
|
|
149
|
-
className="Button-spinner"
|
|
150
|
-
/>
|
|
151
|
-
<Text className="Button-text Button-text--hidden">{children || ''}</Text>
|
|
152
|
-
</>
|
|
153
|
-
) : (
|
|
154
|
-
<>
|
|
155
|
-
{icon && (
|
|
156
|
-
<div className={iconClass}>
|
|
157
|
-
<Icon
|
|
158
|
-
data-test="DesignSystem-Button--Icon"
|
|
159
|
-
name={icon}
|
|
160
|
-
appearance={
|
|
161
|
-
disabled
|
|
162
|
-
? 'disabled'
|
|
163
|
-
: appearance === 'basic' || appearance === 'transparent'
|
|
164
|
-
? selected
|
|
165
|
-
? 'info'
|
|
166
|
-
: 'default'
|
|
167
|
-
: 'white'
|
|
168
|
-
}
|
|
169
|
-
size={largeIcon && !children ? sizeMapping[size] + 4 : sizeMapping[size]}
|
|
170
|
-
/>
|
|
171
|
-
</div>
|
|
172
|
-
)}
|
|
173
|
-
{children}
|
|
174
|
-
</>
|
|
175
|
-
)}
|
|
176
|
-
</button>
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
132
|
return (
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
133
|
+
<button
|
|
134
|
+
data-test="DesignSystem-Button"
|
|
135
|
+
ref={ref}
|
|
136
|
+
type={type}
|
|
137
|
+
className={buttonClass}
|
|
138
|
+
disabled={disabled || loading}
|
|
139
|
+
tabIndex={tabIndex}
|
|
140
|
+
{...rest}
|
|
141
|
+
>
|
|
142
|
+
{loading ? (
|
|
143
|
+
<>
|
|
144
|
+
<Spinner
|
|
145
|
+
size="small"
|
|
146
|
+
appearance={appearance === 'basic' || appearance === 'transparent' ? 'secondary' : 'white'}
|
|
147
|
+
data-test="DesignSystem-Button--Spinner"
|
|
148
|
+
className="Button-spinner"
|
|
149
|
+
/>
|
|
150
|
+
<Text className="Button-text Button-text--hidden">{children || ''}</Text>
|
|
151
|
+
</>
|
|
152
|
+
) : (
|
|
153
|
+
<>
|
|
154
|
+
{icon && (
|
|
155
|
+
<div className={iconClass}>
|
|
156
|
+
<Icon
|
|
157
|
+
data-test="DesignSystem-Button--Icon"
|
|
158
|
+
name={icon}
|
|
159
|
+
appearance={
|
|
160
|
+
disabled
|
|
161
|
+
? 'disabled'
|
|
162
|
+
: appearance === 'basic' || appearance === 'transparent'
|
|
163
|
+
? selected
|
|
164
|
+
? 'info'
|
|
165
|
+
: 'default'
|
|
166
|
+
: 'white'
|
|
167
|
+
}
|
|
168
|
+
size={largeIcon && !children ? sizeMapping[size] + 4 : sizeMapping[size]}
|
|
169
|
+
/>
|
|
170
|
+
</div>
|
|
171
|
+
)}
|
|
172
|
+
{children}
|
|
173
|
+
</>
|
|
174
|
+
)}
|
|
175
|
+
</button>
|
|
176
|
+
);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
|
|
180
|
+
const { icon, tooltip, children } = { ...props };
|
|
181
|
+
|
|
182
|
+
return icon && tooltip && !children ? (
|
|
183
|
+
<Tooltip tooltip={tooltip}>
|
|
184
|
+
<ButtonBase {...props} ref={ref} />
|
|
185
|
+
</Tooltip>
|
|
186
|
+
) : (
|
|
187
|
+
<ButtonBase {...props} ref={ref} />
|
|
187
188
|
);
|
|
188
189
|
});
|
|
189
190
|
|
|
@@ -234,11 +234,8 @@ describe('Button component with icon', () => {
|
|
|
234
234
|
});
|
|
235
235
|
|
|
236
236
|
describe('Button component with Tooltip', () => {
|
|
237
|
-
|
|
238
237
|
it('check for tooltip attribute', () => {
|
|
239
|
-
const { getByTestId } = render(
|
|
240
|
-
<Button appearance="basic" icon="keyboard_arrow_right" tooltip="Next in rank" />
|
|
241
|
-
);
|
|
238
|
+
const { getByTestId } = render(<Button appearance="basic" icon="keyboard_arrow_right" tooltip="Next in rank" />);
|
|
242
239
|
|
|
243
240
|
fireEvent.mouseEnter(getByTestId('DesignSystem-Button'));
|
|
244
241
|
expect(getByTestId('DesignSystem-Popover')).toBeInTheDocument();
|
|
@@ -246,11 +243,7 @@ describe('Button component with Tooltip', () => {
|
|
|
246
243
|
|
|
247
244
|
it('check for tooltip when children is given', () => {
|
|
248
245
|
render(
|
|
249
|
-
<Button
|
|
250
|
-
appearance="basic"
|
|
251
|
-
icon="keyboard_arrow_right"
|
|
252
|
-
tooltip="Next in rank"
|
|
253
|
-
>
|
|
246
|
+
<Button appearance="basic" icon="keyboard_arrow_right" tooltip="Next in rank">
|
|
254
247
|
Click Me
|
|
255
248
|
</Button>
|
|
256
249
|
);
|
|
@@ -260,9 +253,7 @@ describe('Button component with Tooltip', () => {
|
|
|
260
253
|
});
|
|
261
254
|
|
|
262
255
|
it('check for tooltip when icon is not given', () => {
|
|
263
|
-
render(
|
|
264
|
-
<Button appearance="basic" tooltip="Next in rank" />
|
|
265
|
-
);
|
|
256
|
+
render(<Button appearance="basic" tooltip="Next in rank" />);
|
|
266
257
|
const TooltipComponent = screen.queryByText('DesignSystem-Popover');
|
|
267
258
|
expect(TooltipComponent).not.toBeInTheDocument();
|
|
268
259
|
});
|
|
@@ -81,12 +81,9 @@ export const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>((props
|
|
|
81
81
|
|
|
82
82
|
const ref = React.useRef<HTMLInputElement>(null);
|
|
83
83
|
|
|
84
|
-
React.useImperativeHandle(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return ref.current as HTMLInputElement;
|
|
88
|
-
}
|
|
89
|
-
);
|
|
84
|
+
React.useImperativeHandle(forwardedRef, (): HTMLInputElement => {
|
|
85
|
+
return ref.current as HTMLInputElement;
|
|
86
|
+
});
|
|
90
87
|
|
|
91
88
|
const [checked, setChecked] = React.useState(props.checked === undefined ? defaultChecked : props.checked);
|
|
92
89
|
|
|
@@ -12,7 +12,7 @@ export const all = () => {
|
|
|
12
12
|
<div className="d-flex">
|
|
13
13
|
<Collapsible expanded={expanded} hoverable={hoverable} height="100vh" onToggle={setExpanded}>
|
|
14
14
|
<div className="d-flex pt-4">
|
|
15
|
-
<Icon name="events" className="d-flex align-items-center px-5" />
|
|
15
|
+
<Icon name="events" className="d-flex align-items-center px-5 Text--regular" />
|
|
16
16
|
{expanded && <Text className="mr-6">Collapsible</Text>}
|
|
17
17
|
</div>
|
|
18
18
|
</Collapsible>
|
|
@@ -31,7 +31,7 @@ const customCode = `() => {
|
|
|
31
31
|
onToggle={setExpanded}
|
|
32
32
|
>
|
|
33
33
|
<div className="d-flex pt-4">
|
|
34
|
-
<Icon name="events" className="d-flex align-items-center px-5" />
|
|
34
|
+
<Icon name="events" className="d-flex align-items-center px-5 Text--regular" />
|
|
35
35
|
{expanded && (
|
|
36
36
|
<Text className="mr-6">Collapsible</Text>
|
|
37
37
|
)}
|
|
@@ -499,7 +499,7 @@ const DropdownList = (props: OptionsProps) => {
|
|
|
499
499
|
if (listOptions.length === 0 && !loadingOptions) {
|
|
500
500
|
const { noResultMessage = 'No result found' } = props;
|
|
501
501
|
return (
|
|
502
|
-
<div className={'Dropdown-errorWrapper'}>
|
|
502
|
+
<div className={'Dropdown-errorWrapper'} data-test="DesignSystem-Dropdown--errorWrapper">
|
|
503
503
|
<div className={'Option'}>
|
|
504
504
|
<div className={'Option-subinfo'}>{noResultMessage}</div>
|
|
505
505
|
</div>
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getSearchedOptions } from '../utility';
|
|
2
|
+
|
|
1
3
|
export const dropdownOptions: any[] = [];
|
|
2
4
|
export const preSelectedOptions: any[] = [];
|
|
3
5
|
export const storyOptions: any[] = [];
|
|
@@ -152,3 +154,16 @@ export const iconItems = [
|
|
|
152
154
|
icon: 'events',
|
|
153
155
|
},
|
|
154
156
|
];
|
|
157
|
+
|
|
158
|
+
export const fetchOptions = (searchTerm: string) => {
|
|
159
|
+
const searchedOptions = searchTerm ? getSearchedOptions(dropdownOptions, searchTerm) : dropdownOptions;
|
|
160
|
+
return new Promise<any>((resolve) => {
|
|
161
|
+
window.setTimeout(() => {
|
|
162
|
+
resolve({
|
|
163
|
+
searchTerm,
|
|
164
|
+
options: searchedOptions,
|
|
165
|
+
count: searchedOptions.length,
|
|
166
|
+
});
|
|
167
|
+
}, 1000);
|
|
168
|
+
});
|
|
169
|
+
};
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { render, fireEvent } from '@testing-library/react';
|
|
2
|
+
import { render, fireEvent, waitFor, screen } from '@testing-library/react';
|
|
3
3
|
import { testHelper, filterUndefined, valueHelper, testMessageHelper } from '@/utils/testHelper';
|
|
4
4
|
import { Dropdown } from '@/index';
|
|
5
5
|
import { DropdownProps as Props } from '@/index.type';
|
|
6
|
+
import { _isEqual } from '../utility';
|
|
6
7
|
import {
|
|
7
8
|
storyOptions,
|
|
8
9
|
storyWrapOptions,
|
|
9
10
|
iconOptions,
|
|
10
11
|
subInfoOptions,
|
|
11
12
|
iconWithSubinfoOptions,
|
|
13
|
+
dropdownOptions,
|
|
14
|
+
fetchOptions,
|
|
15
|
+
preSelectedOptions,
|
|
12
16
|
} from '../__stories__/Options';
|
|
13
17
|
|
|
14
18
|
const size = ['tiny', 'regular'];
|
|
@@ -29,6 +33,8 @@ for (let i = 1; i <= 10; i++) {
|
|
|
29
33
|
const FunctionValue = jest.fn();
|
|
30
34
|
const trigger = 'DesignSystem-DropdownTrigger';
|
|
31
35
|
|
|
36
|
+
const keyDownEvents = ['ArrowUp', 'ArrowDown', 'Enter', 'Tab', 'Default'];
|
|
37
|
+
|
|
32
38
|
describe('Dropdown component', () => {
|
|
33
39
|
const mapper: Record<string, any> = {
|
|
34
40
|
triggerSize: valueHelper(size, { required: true, iterate: true }),
|
|
@@ -257,3 +263,198 @@ describe('renders dropdown', () => {
|
|
|
257
263
|
expect(getByTestId('DesignSystem-Popover')).toBeInTheDocument();
|
|
258
264
|
});
|
|
259
265
|
});
|
|
266
|
+
|
|
267
|
+
describe('renders async dropdown', () => {
|
|
268
|
+
it('check prop:fetchOptions', () => {
|
|
269
|
+
const { getByTestId, getAllByTestId } = render(<Dropdown fetchOptions={fetchOptions} />);
|
|
270
|
+
const dropdownTrigger = getByTestId(trigger);
|
|
271
|
+
|
|
272
|
+
fireEvent.click(dropdownTrigger);
|
|
273
|
+
const searchInput = getByTestId('DesignSystem-Input');
|
|
274
|
+
expect(searchInput).toBeInTheDocument();
|
|
275
|
+
|
|
276
|
+
fireEvent.input(searchInput, { target: { value: 'Option 50' } });
|
|
277
|
+
expect(getAllByTestId('DesignSystem-Dropdown--PlaceholderParagraph')).toHaveLength(10);
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
it('renders async search', async () => {
|
|
281
|
+
const { getByTestId, getAllByTestId } = render(<Dropdown fetchOptions={fetchOptions} />);
|
|
282
|
+
const dropdownTrigger = getByTestId(trigger);
|
|
283
|
+
|
|
284
|
+
fireEvent.click(dropdownTrigger);
|
|
285
|
+
const searchInput = getByTestId('DesignSystem-Input');
|
|
286
|
+
expect(searchInput).toBeInTheDocument();
|
|
287
|
+
|
|
288
|
+
fireEvent.input(searchInput, { target: { value: 'Option 30' } });
|
|
289
|
+
expect(getAllByTestId('DesignSystem-Dropdown--PlaceholderParagraph')).toHaveLength(10);
|
|
290
|
+
await waitFor(() => {
|
|
291
|
+
expect(getAllByTestId('DesignSystem-DropdownOption--DEFAULT')).toHaveLength(50);
|
|
292
|
+
expect(getAllByTestId('DesignSystem-DropdownOption--DEFAULT')[29]).toHaveTextContent('Option 30');
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it('renders async search with default fetchOptions', async () => {
|
|
297
|
+
const { getByTestId, getAllByTestId } = render(<Dropdown fetchOptions={undefined} noResultMessage="No result" />);
|
|
298
|
+
const dropdownTrigger = getByTestId(trigger);
|
|
299
|
+
|
|
300
|
+
fireEvent.click(dropdownTrigger);
|
|
301
|
+
const searchInput = getByTestId('DesignSystem-Input');
|
|
302
|
+
expect(searchInput).toBeInTheDocument();
|
|
303
|
+
fireEvent.change(searchInput, { target: { value: 'Option 30' } });
|
|
304
|
+
|
|
305
|
+
await waitFor(() => {
|
|
306
|
+
expect(getAllByTestId('DesignSystem-Dropdown--errorWrapper')).toHaveLength(1);
|
|
307
|
+
expect(getByTestId('DesignSystem-Dropdown--errorWrapper')).toHaveTextContent('No result');
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
describe('Dropdown component', () => {
|
|
313
|
+
it('check prop:showApplyButton', () => {
|
|
314
|
+
const { getByTestId, getAllByTestId } = render(
|
|
315
|
+
<Dropdown
|
|
316
|
+
options={dropdownOptions}
|
|
317
|
+
showApplyButton={true}
|
|
318
|
+
withCheckbox={true}
|
|
319
|
+
withSearch={false}
|
|
320
|
+
totalOptions={dropdownOptions.length}
|
|
321
|
+
/>
|
|
322
|
+
);
|
|
323
|
+
const dropdownTrigger = getByTestId(trigger);
|
|
324
|
+
fireEvent.click(dropdownTrigger);
|
|
325
|
+
expect(getAllByTestId('DesignSystem-Button')).toHaveLength(2);
|
|
326
|
+
expect(getAllByTestId('DesignSystem-Button')[0]).toHaveTextContent('Cancel');
|
|
327
|
+
expect(getAllByTestId('DesignSystem-Button')[1]).toHaveTextContent('Apply');
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
it('check checkbox classes with onClick event', () => {
|
|
331
|
+
const { getByTestId, getAllByTestId } = render(
|
|
332
|
+
<Dropdown options={storyOptions} showApplyButton={true} withCheckbox={true} withSearch={false} />
|
|
333
|
+
);
|
|
334
|
+
const dropdownTrigger = getByTestId(trigger);
|
|
335
|
+
fireEvent.click(dropdownTrigger);
|
|
336
|
+
const optionList = getAllByTestId('DesignSystem-Checkbox-Label');
|
|
337
|
+
fireEvent.click(optionList[1]);
|
|
338
|
+
expect(getAllByTestId('DesignSystem-Checkbox-InputBox')[1]).toHaveClass('Checkbox-input--checked');
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
it('check checkbox classes with mouseEnter event', () => {
|
|
342
|
+
const { getByTestId, getAllByTestId } = render(
|
|
343
|
+
<Dropdown options={storyOptions} showApplyButton={true} withCheckbox={true} withSearch={false} />
|
|
344
|
+
);
|
|
345
|
+
const dropdownTrigger = getByTestId(trigger);
|
|
346
|
+
fireEvent.click(dropdownTrigger);
|
|
347
|
+
const optionList = getAllByTestId('DesignSystem-DropdownOption--WITH_CHECKBOX');
|
|
348
|
+
fireEvent.mouseEnter(optionList[1]);
|
|
349
|
+
expect(optionList[1]).toHaveClass('Option-checkbox--active');
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
describe('renders dropdown component onKeyDown Handler', () => {
|
|
354
|
+
const dropdownListId = 'DesignSystem-DropdownList-Wrapper';
|
|
355
|
+
keyDownEvents.forEach((action, key) => {
|
|
356
|
+
it(`checks for keyDown ${action} event with dropdownOpen set as true `, () => {
|
|
357
|
+
const { getByTestId } = render(
|
|
358
|
+
<Dropdown
|
|
359
|
+
options={storyOptions}
|
|
360
|
+
showApplyButton={true}
|
|
361
|
+
withCheckbox={true}
|
|
362
|
+
withSearch={false}
|
|
363
|
+
data-test={dropdownListId}
|
|
364
|
+
/>
|
|
365
|
+
);
|
|
366
|
+
const dropdownTrigger = getByTestId(trigger);
|
|
367
|
+
fireEvent.click(dropdownTrigger);
|
|
368
|
+
fireEvent.keyDown(getByTestId(dropdownListId), { key: action });
|
|
369
|
+
expect(getByTestId('DesignSystem-Popover')).toBeInTheDocument();
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
it(`checks for keyDown ${action} event with dropdownOpen set as false `, () => {
|
|
373
|
+
const { getByTestId } = render(
|
|
374
|
+
<Dropdown options={storyOptions} withCheckbox={true} withSearch={false} data-test={dropdownListId} />
|
|
375
|
+
);
|
|
376
|
+
fireEvent.keyDown(getByTestId(dropdownListId), { key: action });
|
|
377
|
+
expect(getByTestId('DesignSystem-DropdownTrigger')).toBeInTheDocument();
|
|
378
|
+
});
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
it('checks for keyDown Tab event with showApplyButton as false', () => {
|
|
382
|
+
const { getByTestId } = render(
|
|
383
|
+
<Dropdown
|
|
384
|
+
options={storyOptions}
|
|
385
|
+
showApplyButton={false}
|
|
386
|
+
withCheckbox={true}
|
|
387
|
+
withSearch={false}
|
|
388
|
+
data-test={dropdownListId}
|
|
389
|
+
/>
|
|
390
|
+
);
|
|
391
|
+
const dropdownTrigger = getByTestId(trigger);
|
|
392
|
+
fireEvent.click(dropdownTrigger);
|
|
393
|
+
fireEvent.keyDown(getByTestId(dropdownListId), { key: 'Tab' });
|
|
394
|
+
expect(screen.queryByText('DesignSystem-Popover')).not.toBeInTheDocument();
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
it('checks for keyDown Tab event with showApplyButton as false', () => {
|
|
398
|
+
const { getByTestId } = render(
|
|
399
|
+
<Dropdown
|
|
400
|
+
options={storyOptions}
|
|
401
|
+
showApplyButton={true}
|
|
402
|
+
withCheckbox={true}
|
|
403
|
+
withSearch={false}
|
|
404
|
+
data-test={dropdownListId}
|
|
405
|
+
/>
|
|
406
|
+
);
|
|
407
|
+
const dropdownTrigger = getByTestId(trigger);
|
|
408
|
+
fireEvent.click(dropdownTrigger);
|
|
409
|
+
fireEvent.keyDown(getByTestId(dropdownListId), { key: 'Tab' });
|
|
410
|
+
expect(screen.queryByText('DesignSystem-Popover')).not.toBeInTheDocument();
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
describe('Dropdown component utility function', () => {
|
|
415
|
+
it('checks isEqual utility function', () => {
|
|
416
|
+
expect(_isEqual(storyOptions, iconOptions));
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
it('checks isEqual utility function with same label', () => {
|
|
420
|
+
const Options = [
|
|
421
|
+
{
|
|
422
|
+
label: 'Design System Dropdown',
|
|
423
|
+
value: 'Options 1',
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
label: 'UI Kit Dropdown',
|
|
427
|
+
value: 'Options 2',
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
label: 'Innovaccer Analytics',
|
|
431
|
+
value: 'Options 3',
|
|
432
|
+
},
|
|
433
|
+
];
|
|
434
|
+
expect(_isEqual(storyWrapOptions, Options));
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
describe('Dropdown component action buttons', () => {
|
|
439
|
+
it('check cancelButton click handler', async () => {
|
|
440
|
+
const { getByTestId, getAllByTestId } = render(
|
|
441
|
+
<Dropdown
|
|
442
|
+
options={preSelectedOptions}
|
|
443
|
+
showApplyButton={true}
|
|
444
|
+
withCheckbox={true}
|
|
445
|
+
withSearch={false}
|
|
446
|
+
onUpdate={FunctionValue}
|
|
447
|
+
/>
|
|
448
|
+
);
|
|
449
|
+
const dropdownTrigger = getByTestId(trigger);
|
|
450
|
+
fireEvent.click(dropdownTrigger);
|
|
451
|
+
|
|
452
|
+
await waitFor(() => {
|
|
453
|
+
expect(getAllByTestId('DesignSystem-DropdownOption--WITH_CHECKBOX')[1]).toBeInTheDocument();
|
|
454
|
+
});
|
|
455
|
+
expect(getAllByTestId('DesignSystem-Button')[1]).toHaveTextContent('Cancel');
|
|
456
|
+
fireEvent.click(getAllByTestId('DesignSystem-DropdownOption--WITH_CHECKBOX')[1]);
|
|
457
|
+
fireEvent.click(getAllByTestId('DesignSystem-Button')[1]);
|
|
458
|
+
expect(screen.queryByText('DesignSystem-Popover')).not.toBeInTheDocument();
|
|
459
|
+
});
|
|
460
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Message, Row, Column, Text } from '@/index';
|
|
3
|
+
|
|
4
|
+
export const CustomDescription = () => (
|
|
5
|
+
<Row>
|
|
6
|
+
<Column size="4">
|
|
7
|
+
<Message
|
|
8
|
+
actions={
|
|
9
|
+
<>
|
|
10
|
+
<Text className="cursor-pointer" appearance="link">
|
|
11
|
+
Try again
|
|
12
|
+
</Text>
|
|
13
|
+
</>
|
|
14
|
+
}
|
|
15
|
+
>
|
|
16
|
+
<Text appearance="default">Sorry we couldn't subscribe you. Please try again.</Text>
|
|
17
|
+
</Message>
|
|
18
|
+
</Column>
|
|
19
|
+
</Row>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
title: 'Components/Message/Custom Description',
|
|
24
|
+
component: Message,
|
|
25
|
+
};
|
|
@@ -22,7 +22,9 @@ export const Meta = (props: MetaProps) => {
|
|
|
22
22
|
className={'Meta-icon'}
|
|
23
23
|
/>
|
|
24
24
|
)}
|
|
25
|
-
<Text data-test="DesignSystem-MetaList--MetaLabel" appearance={labelAppearance}>
|
|
25
|
+
<Text data-test="DesignSystem-MetaList--MetaLabel" appearance={labelAppearance}>
|
|
26
|
+
{label}
|
|
27
|
+
</Text>
|
|
26
28
|
</span>
|
|
27
29
|
);
|
|
28
30
|
};
|
|
@@ -37,24 +37,16 @@ const appearance: IconAppearance[] = [
|
|
|
37
37
|
'accent3_dark',
|
|
38
38
|
'accent4_lighter',
|
|
39
39
|
'accent4_dark',
|
|
40
|
-
'inverse'
|
|
40
|
+
'inverse',
|
|
41
41
|
];
|
|
42
42
|
|
|
43
|
-
const labelAppearance: TextAppearance[] = [
|
|
44
|
-
'success',
|
|
45
|
-
'default',
|
|
46
|
-
'disabled',
|
|
47
|
-
'link',
|
|
48
|
-
'subtle',
|
|
49
|
-
'white',
|
|
50
|
-
'destructive'
|
|
51
|
-
];
|
|
43
|
+
const labelAppearance: TextAppearance[] = ['success', 'default', 'disabled', 'link', 'subtle', 'white', 'destructive'];
|
|
52
44
|
|
|
53
45
|
const booleanValues = [true, false];
|
|
54
46
|
|
|
55
47
|
const listWithTwoElements = [
|
|
56
48
|
{ icon: 'assessment', label: 'Meta data' },
|
|
57
|
-
{ icon: 'assessment', label: 'Meta data two' }
|
|
49
|
+
{ icon: 'assessment', label: 'Meta data two' },
|
|
58
50
|
];
|
|
59
51
|
|
|
60
52
|
const getIconAppearance = (iconColor: string) => {
|
|
@@ -74,9 +66,11 @@ describe('MetaList component prop:seperatorAppearance options', () => {
|
|
|
74
66
|
const tree = render(
|
|
75
67
|
<MetaList
|
|
76
68
|
{...attr}
|
|
77
|
-
list={[
|
|
69
|
+
list={[
|
|
70
|
+
{ icon: 'assessment', label: 'Meta data' },
|
|
71
|
+
{ icon: 'assessment', label: 'Meta data' },
|
|
72
|
+
]}
|
|
78
73
|
/>
|
|
79
|
-
|
|
80
74
|
);
|
|
81
75
|
expect(tree).toMatchSnapshot();
|
|
82
76
|
});
|
|
@@ -94,13 +88,7 @@ describe('MetaList component prop:IconAppearance options', () => {
|
|
|
94
88
|
const attr = filterUndefined(props) as Props;
|
|
95
89
|
|
|
96
90
|
it(testMessageHelper(attr), () => {
|
|
97
|
-
const tree = render(
|
|
98
|
-
<MetaList
|
|
99
|
-
{...attr}
|
|
100
|
-
list={[{ icon: 'assessment', label: 'Meta data' }]}
|
|
101
|
-
/>
|
|
102
|
-
|
|
103
|
-
);
|
|
91
|
+
const tree = render(<MetaList {...attr} list={[{ icon: 'assessment', label: 'Meta data' }]} />);
|
|
104
92
|
expect(tree).toMatchSnapshot();
|
|
105
93
|
});
|
|
106
94
|
};
|
|
@@ -120,9 +108,11 @@ describe('MetaList component prop:labelAppearance options', () => {
|
|
|
120
108
|
const tree = render(
|
|
121
109
|
<MetaList
|
|
122
110
|
{...attr}
|
|
123
|
-
list={[
|
|
111
|
+
list={[
|
|
112
|
+
{ icon: 'assessment', label: 'Meta data' },
|
|
113
|
+
{ icon: 'assessment', label: 'Meta data' },
|
|
114
|
+
]}
|
|
124
115
|
/>
|
|
125
|
-
|
|
126
116
|
);
|
|
127
117
|
expect(tree).toMatchSnapshot();
|
|
128
118
|
});
|
|
@@ -140,13 +130,7 @@ describe('MetaList component prop:seperator options', () => {
|
|
|
140
130
|
const attr = filterUndefined(props) as Props;
|
|
141
131
|
|
|
142
132
|
it(testMessageHelper(attr), () => {
|
|
143
|
-
const tree = render(
|
|
144
|
-
<MetaList
|
|
145
|
-
{...attr}
|
|
146
|
-
list={[{ icon: 'assessment', label: 'Meta data' }]}
|
|
147
|
-
/>
|
|
148
|
-
|
|
149
|
-
);
|
|
133
|
+
const tree = render(<MetaList {...attr} list={[{ icon: 'assessment', label: 'Meta data' }]} />);
|
|
150
134
|
expect(tree).toMatchSnapshot();
|
|
151
135
|
});
|
|
152
136
|
};
|
|
@@ -155,7 +139,6 @@ describe('MetaList component prop:seperator options', () => {
|
|
|
155
139
|
});
|
|
156
140
|
|
|
157
141
|
describe('MetaList component with prop:list', () => {
|
|
158
|
-
|
|
159
142
|
it('renders list when one element is given', () => {
|
|
160
143
|
const { getByTestId } = render(<MetaList list={[{ icon: 'assessment', label: 'Meta data' }]} seperator={true} />);
|
|
161
144
|
expect(getByTestId('DesignSystem-MetaList--MetaLabel').textContent).toMatch('Meta data');
|
|
@@ -195,7 +178,11 @@ describe('MetaList component with prop:Icon', () => {
|
|
|
195
178
|
});
|
|
196
179
|
|
|
197
180
|
it('check for icon prop when list contain more than one element', () => {
|
|
198
|
-
const { getAllByTestId } = render(
|
|
181
|
+
const { getAllByTestId } = render(
|
|
182
|
+
<MetaList
|
|
183
|
+
list={[{ label: 'Meta data' }, { icon: 'assessment', label: 'Meta data two' }, { label: 'Meta data three' }]}
|
|
184
|
+
/>
|
|
185
|
+
);
|
|
199
186
|
expect(getAllByTestId('DesignSystem-MetaList--MetaIcon')).toHaveLength(1);
|
|
200
187
|
});
|
|
201
188
|
});
|
|
@@ -218,7 +205,6 @@ describe('MetaList component with prop:separator', () => {
|
|
|
218
205
|
});
|
|
219
206
|
|
|
220
207
|
describe('MetaList component with rightSeparator element', () => {
|
|
221
|
-
|
|
222
208
|
it('check for rightSeparator prop when list is empty', () => {
|
|
223
209
|
const { getByTestId } = render(<MetaList list={[]} />);
|
|
224
210
|
expect(getByTestId('DesignSystem-MetaList')).not.toContainHTML('DesignSystem-MetaList--rightSeperator');
|
|
@@ -249,7 +235,9 @@ describe('MetaList component tagName', () => {
|
|
|
249
235
|
|
|
250
236
|
describe('MetaList Component with overwrite class', () => {
|
|
251
237
|
it('overwrite MetaList class', () => {
|
|
252
|
-
const { getByTestId } = render(
|
|
238
|
+
const { getByTestId } = render(
|
|
239
|
+
<MetaList list={[{ icon: 'assessment', label: 'Meta data' }]} className="MetaListClass" />
|
|
240
|
+
);
|
|
253
241
|
expect(getByTestId('DesignSystem-MetaList')).toHaveClass('MetaListClass');
|
|
254
242
|
});
|
|
255
243
|
});
|
|
@@ -259,7 +247,9 @@ describe('MetaList component with different prop:seperatorAppearance', () => {
|
|
|
259
247
|
const colorOption = color && color.includes('_') ? getIconAppearance(color) : color;
|
|
260
248
|
|
|
261
249
|
it(`should have the Icon--${color} class when seperatorAppearance=${color} `, () => {
|
|
262
|
-
const { getByTestId } = render(
|
|
250
|
+
const { getByTestId } = render(
|
|
251
|
+
<MetaList list={[{ icon: 'assessment', label: 'Meta data' }]} seperator={true} seperatorAppearance={color} />
|
|
252
|
+
);
|
|
263
253
|
expect(getByTestId('DesignSystem-MetaList--Seperator')).toHaveClass(`Icon--${colorOption}`);
|
|
264
254
|
});
|
|
265
255
|
});
|
|
@@ -270,7 +260,9 @@ describe('MetaList component with different prop:IconAppearance', () => {
|
|
|
270
260
|
const colorOption = color && color.includes('_') ? getIconAppearance(color) : color;
|
|
271
261
|
|
|
272
262
|
it(`should have the Icon--${color} class when IconAppearance=${color} `, () => {
|
|
273
|
-
const { getByTestId } = render(
|
|
263
|
+
const { getByTestId } = render(
|
|
264
|
+
<MetaList list={[{ icon: 'assessment', label: 'Meta data' }]} iconAppearance={color} />
|
|
265
|
+
);
|
|
274
266
|
expect(getByTestId('DesignSystem-MetaList--MetaIcon')).toHaveClass(`Icon--${colorOption}`);
|
|
275
267
|
});
|
|
276
268
|
});
|
|
@@ -279,7 +271,9 @@ describe('MetaList component with different prop:IconAppearance', () => {
|
|
|
279
271
|
describe('MetaList component with different prop:labelAppearance', () => {
|
|
280
272
|
labelAppearance.forEach((color) => {
|
|
281
273
|
it(`should have the Text--${color} class when labelAppearance=${color} `, () => {
|
|
282
|
-
const { getByTestId } = render(
|
|
274
|
+
const { getByTestId } = render(
|
|
275
|
+
<MetaList list={[{ icon: 'assessment', label: 'Meta data' }]} labelAppearance={color} />
|
|
276
|
+
);
|
|
283
277
|
expect(getByTestId('DesignSystem-MetaList--MetaLabel')).toHaveClass(`Text--${color}`);
|
|
284
278
|
});
|
|
285
279
|
});
|
|
@@ -200,8 +200,8 @@ export const MetricInput = React.forwardRef<HTMLInputElement, MetricInputProps>(
|
|
|
200
200
|
if (onChange) {
|
|
201
201
|
const syntheticEvent = Object.create(e, {
|
|
202
202
|
target: {
|
|
203
|
-
value: { value: newValue }
|
|
204
|
-
}
|
|
203
|
+
value: { value: newValue },
|
|
204
|
+
},
|
|
205
205
|
});
|
|
206
206
|
onChange(syntheticEvent);
|
|
207
207
|
}
|