@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.
Files changed (123) hide show
  1. package/.all-contributorsrc +170 -0
  2. package/.github/workflows/jira.yml +1 -2
  3. package/.github/workflows/main.yml +1 -6
  4. package/.github/workflows/test.yml +22 -0
  5. package/CHANGELOG.md +21 -54
  6. package/CONTRIBUTING.md +23 -0
  7. package/README.md +124 -75
  8. package/core/components/atoms/button/Button.tsx +56 -55
  9. package/core/components/atoms/button/__tests__/Button.test.tsx +3 -12
  10. package/core/components/atoms/checkbox/Checkbox.tsx +3 -6
  11. package/core/components/atoms/collapsible/__stories__/index.story.tsx +2 -2
  12. package/core/components/atoms/dropdown/DropdownList.tsx +1 -1
  13. package/core/components/atoms/dropdown/__stories__/Options.tsx +15 -0
  14. package/core/components/atoms/dropdown/__tests__/Dropdown.test.tsx +202 -1
  15. package/core/components/atoms/dropdown/__tests__/Option.test.tsx +3 -0
  16. package/core/components/atoms/message/__stories__/CustomDescription.tsx +25 -0
  17. package/core/components/atoms/metaList/Meta.tsx +3 -1
  18. package/core/components/atoms/metaList/__tests__/MetaList.test.tsx +30 -36
  19. package/core/components/atoms/metricInput/MetricInput.tsx +2 -2
  20. package/core/components/atoms/outsideClick/__stories__/index.story.tsx +1 -1
  21. package/core/components/atoms/radio/Radio.tsx +7 -10
  22. package/core/components/atoms/radio/__tests__/Radio.test.tsx +13 -7
  23. package/core/components/css-utilities/Align/Align.story.tsx +1 -1
  24. package/core/components/css-utilities/Background/Background.story.tsx +1 -1
  25. package/core/components/css-utilities/Border/Border.story.tsx +128 -0
  26. package/core/components/css-utilities/Display/Display.story.tsx +1 -1
  27. package/core/components/css-utilities/Flex/Flex.story.tsx +1 -1
  28. package/core/components/css-utilities/Miscellaneous/Miscellaneous.story.tsx +1 -1
  29. package/core/components/css-utilities/Overflow/Overflow.story.tsx +1 -1
  30. package/core/components/css-utilities/Position/Position.story.tsx +1 -1
  31. package/core/components/css-utilities/Sizing/Sizing.story.tsx +1 -1
  32. package/core/components/css-utilities/Spacing/Spacing.story.tsx +1 -1
  33. package/core/components/molecules/chatMessage/__tests__/ChatMessage.test.tsx +20 -46
  34. package/core/components/molecules/dropzone/__tests__/Dropzone.test.tsx +47 -111
  35. package/core/components/molecules/dropzone/__tests__/Utilities.test.tsx +13 -13
  36. package/core/components/molecules/editableChipInput/EditableChipInput.tsx +3 -1
  37. package/core/components/molecules/editableInput/EditableInput.tsx +5 -3
  38. package/core/components/molecules/editableInput/__stories__/variants/Uncontrolled.story.tsx +1 -1
  39. package/core/components/molecules/editableInput/__tests__/EditableInput.test.tsx +1 -3
  40. package/core/components/molecules/emptyState/_tests_/EmptyState.test.tsx +3 -7
  41. package/core/components/molecules/fileUploader/FileUploaderItem.tsx +13 -2
  42. package/core/components/molecules/fileUploader/__stories__/index.story.tsx +156 -21
  43. package/core/components/molecules/fileUploader/__tests__/FileUploader.test.tsx +21 -80
  44. package/core/components/molecules/fileUploader/__tests__/FileUploaderList.test.tsx +9 -40
  45. package/core/components/molecules/fullscreenModal/FullscreenModal.tsx +7 -13
  46. package/core/components/molecules/fullscreenModal/__stories__/Layering.story.tsx +2 -2
  47. package/core/components/molecules/modal/Modal.tsx +18 -17
  48. package/core/components/molecules/modal/ModalBody.tsx +1 -1
  49. package/core/components/molecules/modal/__stories__/Layering.story.tsx +1 -1
  50. package/core/components/molecules/modal/__stories__/NoFooter.story.tsx +0 -1
  51. package/core/components/molecules/modal/__stories__/Scrolling.story.tsx +20 -38
  52. package/core/components/molecules/modal/__tests__/Modal.test.tsx +1 -1
  53. package/core/components/molecules/sidesheet/Sidesheet.tsx +16 -17
  54. package/core/components/organisms/choiceList/ChoiceList.tsx +212 -0
  55. package/core/components/organisms/choiceList/__stories__/Alignment.story.tsx +32 -0
  56. package/core/components/organisms/choiceList/__stories__/AllowMultiple.story.tsx +23 -0
  57. package/core/components/organisms/choiceList/__stories__/Controlled.story.tsx +34 -0
  58. package/core/components/organisms/choiceList/__stories__/index.story.tsx +18 -0
  59. package/core/components/organisms/choiceList/__tests__/ChoiceList.test.tsx +155 -0
  60. package/core/components/organisms/choiceList/__tests__/__snapshots__/ChoiceList.test.tsx.snap +3393 -0
  61. package/core/components/organisms/choiceList/index.tsx +2 -0
  62. package/core/components/organisms/datePicker/__tests__/DatePicker.test.tsx +136 -46
  63. package/core/components/organisms/datePicker/__tests__/__snapshots__/DatePicker.test.tsx.snap +2594 -102
  64. package/core/components/organisms/dateRangePicker/DateRangePicker.tsx +5 -0
  65. package/core/components/organisms/dateRangePicker/__tests__/DateRangePicker.test.tsx +49 -410
  66. package/core/components/organisms/dateRangePicker/__tests__/Utilities.test.tsx +39 -0
  67. package/core/components/organisms/dateRangePicker/__tests__/__snapshots__/DateRangePicker.test.tsx.snap +45390 -2679
  68. package/core/components/organisms/dateRangePicker/utilities.tsx +2 -5
  69. package/core/components/organisms/grid/Cell.tsx +5 -4
  70. package/core/components/organisms/grid/Grid.tsx +1 -1
  71. package/core/components/organisms/grid/GridCell.tsx +18 -7
  72. package/core/components/organisms/grid/GridHead.tsx +1 -1
  73. package/core/components/organisms/grid/GridRow.tsx +5 -12
  74. package/core/components/organisms/grid/__tests__/Grid.test.tsx +179 -1
  75. package/core/components/organisms/grid/__tests__/GridCell.test.tsx +218 -0
  76. package/core/components/organisms/grid/__tests__/__snapshots__/Grid.test.tsx.snap +1024 -0
  77. package/core/components/organisms/grid/__tests__/rowUtility.test.tsx +62 -0
  78. package/core/components/organisms/inlineMessage/InlineMessage.tsx +10 -14
  79. package/core/components/organisms/inlineMessage/__stories__/InlineMessageWithinTable.story.tsx +9 -12
  80. package/core/components/organisms/inlineMessage/__stories__/variants/Default.story.tsx +2 -4
  81. package/core/components/organisms/inlineMessage/__stories__/variants/Error.story.tsx +2 -5
  82. package/core/components/organisms/inlineMessage/__stories__/variants/Info.story.tsx +2 -5
  83. package/core/components/organisms/inlineMessage/__stories__/variants/Success.story.tsx +2 -5
  84. package/core/components/organisms/inlineMessage/__stories__/variants/Warning.story.tsx +2 -5
  85. package/core/components/organisms/inlineMessage/__tests__/InlineMessage.test.tsx +4 -20
  86. package/core/components/organisms/navigation/VerticalNavigation.tsx +14 -3
  87. package/core/components/organisms/navigation/__tests__/Navigation.test.tsx +179 -0
  88. package/core/components/organisms/navigation/__tests__/__snapshots__/Navigation.test.tsx.snap +530 -0
  89. package/core/components/organisms/table/DraggableDropdown.tsx +1 -0
  90. package/core/components/organisms/table/Header.tsx +11 -2
  91. package/core/components/organisms/table/Table.tsx +2 -2
  92. package/core/components/organisms/table/__stories__/NestedTableWithNestedCard.story.tsx +4 -1
  93. package/core/components/organisms/table/__stories__/variants/nestedRows.story.tsx +5 -2
  94. package/core/components/organisms/table/__tests__/Table.test.tsx +292 -0
  95. package/core/components/organisms/table/__tests__/__snapshots__/Table.test.tsx.snap +349041 -0
  96. package/core/components/organisms/timePicker/__tests__/TimePicker.test.tsx +15 -66
  97. package/core/components/patterns/dateRangePicker/withCustomPopover.story.tsx +47 -36
  98. package/core/index.tsx +1 -1
  99. package/core/index.type.tsx +1 -0
  100. package/core/utils/OverlayManager.tsx +1 -3
  101. package/core/utils/__tests__/__snapshots__/TS.test.tsx.snap +4 -0
  102. package/core/utils/types.tsx +3 -4
  103. package/css/dist/index.css +78 -8
  104. package/css/dist/index.css.map +1 -1
  105. package/css/src/components/button.css +8 -4
  106. package/css/src/components/choiceList.css +25 -0
  107. package/css/src/components/modal.css +1 -2
  108. package/css/src/utils/border.css +39 -0
  109. package/dist/core/components/atoms/popperWrapper/PopperWrapper.d.ts +50 -49
  110. package/dist/core/components/css-utilities/Border/Border.story.d.ts +13 -0
  111. package/dist/core/components/organisms/choiceList/ChoiceList.d.ts +33 -0
  112. package/dist/core/components/organisms/choiceList/index.d.ts +2 -0
  113. package/dist/core/components/organisms/dateRangePicker/utilities.d.ts +2 -2
  114. package/dist/core/index.d.ts +1 -0
  115. package/dist/core/index.type.d.ts +1 -0
  116. package/dist/index.esm.js +207 -58
  117. package/dist/index.js +209 -57
  118. package/dist/index.js.map +1 -1
  119. package/dist/index.umd.js +1 -1
  120. package/dist/index.umd.js.br +0 -0
  121. package/dist/index.umd.js.gz +0 -0
  122. package/jest.config.js +2 -1
  123. package/package.json +6 -4
@@ -61,11 +61,8 @@ export const getPrevious90Days = () => {
61
61
  };
62
62
 
63
63
  export const getCustomDates = () => {
64
- const current = new Date();
65
- const currentDate = current.getDate();
66
-
67
64
  return {
68
- startDate: setDate(currentDate),
69
- endDate: setDate(currentDate),
65
+ startDate: '',
66
+ endDate: '',
70
67
  };
71
68
  };
@@ -58,8 +58,8 @@ const HeaderCell = (props: HeaderCellProps) => {
58
58
  const el = React.createRef<HTMLDivElement>();
59
59
 
60
60
  const sortOptions: DropdownProps['options'] = [
61
- { label: 'Sort Ascending', value: 'sortAsc', icon: 'arrow_downward' },
62
- { label: 'Sort Descending', value: 'sortDesc', icon: 'arrow_upward' },
61
+ { label: 'Sort Ascending', value: 'sortAsc', icon: 'arrow_upward' },
62
+ { label: 'Sort Descending', value: 'sortDesc', icon: 'arrow_downward' },
63
63
  ];
64
64
  const pinOptions: DropdownProps['options'] = [
65
65
  { label: 'Pin Left', value: 'pinLeft', icon: 'skip_previous' },
@@ -98,9 +98,9 @@ const HeaderCell = (props: HeaderCellProps) => {
98
98
  <div className="Grid-sortingIcons">
99
99
  {sorted ? (
100
100
  sorted === 'asc' ? (
101
- <Icon name="arrow_downward" />
102
- ) : (
103
101
  <Icon name="arrow_upward" />
102
+ ) : (
103
+ <Icon name="arrow_downward" />
104
104
  )
105
105
  ) : (
106
106
  <Icon name="unfold_more" />
@@ -114,6 +114,7 @@ const HeaderCell = (props: HeaderCellProps) => {
114
114
  <div key={name} className={classes} ref={el}>
115
115
  <div
116
116
  className="Grid-cellContent"
117
+ data-test="DesignSystem-Grid-cellContent"
117
118
  onClick={() => {
118
119
  if (!loading && sorting) {
119
120
  if (sorted === 'asc') onMenuChange(name, 'sortDesc');
@@ -321,7 +321,7 @@ export class Grid extends React.Component<GridProps, GridState> {
321
321
  this.addScrollListeners();
322
322
  }
323
323
 
324
- if (prevProps.page !== this.props.page) {
324
+ if (prevProps.page !== this.props.page || prevProps.error !== this.props.error) {
325
325
  this.removeScrollListeners();
326
326
  this.addScrollListeners();
327
327
  }
@@ -128,7 +128,7 @@ const renderMetaList = (props: CellProps) => {
128
128
 
129
129
  if (metaList) {
130
130
  return (
131
- <div className="GridCell-metaList">
131
+ <div className="GridCell-metaList" data-test="DesignSystem-GridCell-metaList">
132
132
  {metaList.map((list, index) => (
133
133
  <Text key={index} className="ellipsis" appearance={'subtle'} size="small">
134
134
  {list}
@@ -204,7 +204,11 @@ export const GridCell = (props: GridCellProps) => {
204
204
  case 'DEFAULT':
205
205
  return (
206
206
  <div className={`${cellClass} GridCell--align-${align} GridCell--default`}>
207
- {loading ? <PlaceholderParagraph length="medium" /> : renderTitle({ tooltip, cellData })}
207
+ {loading ? (
208
+ <PlaceholderParagraph length="medium" data-test="DesignSystem-GridCell-placeHolder" />
209
+ ) : (
210
+ renderTitle({ tooltip, cellData })
211
+ )}
208
212
  </div>
209
213
  );
210
214
 
@@ -213,7 +217,7 @@ export const GridCell = (props: GridCellProps) => {
213
217
  <div className={`${cellClass} GridCell--metaList`}>
214
218
  {loading ? (
215
219
  <>
216
- <PlaceholderParagraph length="medium" />
220
+ <PlaceholderParagraph length="medium" data-test="DesignSystem-GridCell-withMetaList" />
217
221
  <PlaceholderParagraph length="large" size="xxs" />
218
222
  </>
219
223
  ) : (
@@ -230,7 +234,10 @@ export const GridCell = (props: GridCellProps) => {
230
234
  return <Placeholder className={`GridCell--align-${align}`} imageSize={'medium'} round={true} />;
231
235
  }
232
236
  return (
233
- <div className={`${cellClass} GridCell--align-${align} GridCell--avatar`}>
237
+ <div
238
+ className={`${cellClass} GridCell--align-${align} GridCell--avatar`}
239
+ data-test="DesignSystem-GridCell-avatar"
240
+ >
234
241
  {size !== 'tight' && renderAvatar({ cellData })}
235
242
  </div>
236
243
  );
@@ -244,7 +251,7 @@ export const GridCell = (props: GridCellProps) => {
244
251
  );
245
252
  }
246
253
  return (
247
- <div className={`${cellClass} GridCell--avatarWithText`}>
254
+ <div className={`${cellClass} `} data-test="DesignSystem-GridCell-avatarWithText">
248
255
  {size !== 'tight' && renderAvatar({ cellData })}
249
256
  {renderTitle({ tooltip, cellData })}
250
257
  </div>
@@ -260,7 +267,7 @@ export const GridCell = (props: GridCellProps) => {
260
267
  );
261
268
  }
262
269
  return (
263
- <div className={`${cellClass} GridCell--avatarWithText`}>
270
+ <div className={`${cellClass} GridCell--avatarWithText`} data-test="DesignSystem-GridCell-avatarWithMetaList">
264
271
  {size !== 'tight' && renderAvatar({ cellData })}
265
272
  <div className="GridCell-metaListWrapper">
266
273
  {renderTitle({ tooltip, cellData })}
@@ -273,7 +280,11 @@ export const GridCell = (props: GridCellProps) => {
273
280
  if (loading) {
274
281
  return <Placeholder className={`GridCell--align-${align}`} imageSize={'small'} round={true} />;
275
282
  }
276
- return <div className={`${cellClass} GridCell--align-${align} GridCell--icon`}>{renderIcon({ cellData })}</div>;
283
+ return (
284
+ <div className={`${cellClass} GridCell--align-${align} GridCell--icon`} data-test="DesignSystem-GridCell-icon">
285
+ {renderIcon({ cellData })}
286
+ </div>
287
+ );
277
288
 
278
289
  case 'STATUS_HINT':
279
290
  return (
@@ -81,7 +81,7 @@ export const GridHead = (props: GridHeadProps) => {
81
81
  };
82
82
 
83
83
  return (
84
- <div className="Grid-head">
84
+ <div className="Grid-head" data-test="DesignSystem-GridHead-wrapper">
85
85
  <div className="Grid-row Grid-row--head">
86
86
  {renderSchema(leftPinnedSchema, !!leftPinnedSchema.length, 'left')}
87
87
  {renderSchema(unpinnedSchema, !leftPinnedSchema.length && !!unpinnedSchema.length)}
@@ -25,13 +25,9 @@ export const GridRow = (props: GridRowProps) => {
25
25
  const rowRef = React.useRef<HTMLDivElement>(null);
26
26
  const [expanded, setExpanded] = React.useState<boolean>(false);
27
27
 
28
- const rowClasses = classNames(
29
- 'Grid-row',
30
- 'Grid-row--body',
31
- {
32
- 'Grid-row--selected': data._selected
33
- }
34
- );
28
+ const rowClasses = classNames('Grid-row', 'Grid-row--body', {
29
+ 'Grid-row--selected': data._selected,
30
+ });
35
31
 
36
32
  const onClickHandler = React.useCallback(() => {
37
33
  if (type === 'resource' && !loading) {
@@ -75,7 +71,7 @@ export const GridRow = (props: GridRowProps) => {
75
71
  });
76
72
 
77
73
  return (
78
- <div className={classes}>
74
+ <div className={classes} data-test="DesignSystem-Grid-cellGroup">
79
75
  {renderCheckbox(shouldRenderCheckbox)}
80
76
  {currSchema.map((s, index) => {
81
77
  let cI = pinned === 'left' ? index : leftPinnedSchema.length + index;
@@ -113,10 +109,7 @@ export const GridRow = (props: GridRowProps) => {
113
109
  </div>
114
110
  {nestedRows && expanded && (
115
111
  <div className="Grid-nestedRow">
116
- <GridNestedRow
117
- data={data}
118
- rowIndex={rI}
119
- />
112
+ <GridNestedRow data={data} rowIndex={rI} />
120
113
  </div>
121
114
  )}
122
115
  </div>
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { render } from '@testing-library/react';
2
+ import { render, fireEvent } from '@testing-library/react';
3
3
  import { Grid } from '@/index';
4
4
  import { GridProps as Props } from '@/index.type';
5
5
  import { testHelper, filterUndefined, valueHelper, testMessageHelper } from '@/utils/testHelper';
@@ -19,6 +19,11 @@ const headCellTooltip = [true, false];
19
19
  const separator = [true, false];
20
20
  const showFilters = [true, false];
21
21
  const FunctionValue = jest.fn();
22
+ const onSelectAll = jest.fn();
23
+ const updateSortingList = jest.fn();
24
+ const updateSchema = jest.fn();
25
+ const updateFilterList = jest.fn();
26
+ const nestedRowRenderer = jest.fn();
22
27
 
23
28
  describe('Grid component', () => {
24
29
  const mapper: Record<string, any> = {
@@ -55,3 +60,176 @@ describe('Grid component', () => {
55
60
 
56
61
  testHelper(mapper, testFunc);
57
62
  });
63
+
64
+ describe('renders Grid with showHead true and false', () => {
65
+ it('renders Grid with showHead true', () => {
66
+ const { queryByTestId } = render(<Grid showHead={true} />);
67
+ expect(queryByTestId('DesignSystem-GridHead-wrapper')).toBeInTheDocument();
68
+ });
69
+ it('renders Grid with showHead false', () => {
70
+ const { queryByTestId } = render(<Grid showHead={false} />);
71
+ expect(queryByTestId('DesignSystem-GridHead-wrapper')).not.toBeInTheDocument();
72
+ });
73
+ });
74
+
75
+ describe('Grid component prop: onSelectAll when withCheckbox is true', () => {
76
+ it('calls onSelectAll when head checkbox is rendered', () => {
77
+ const schema = [
78
+ {
79
+ name: 'name',
80
+ displayName: 'Name',
81
+ width: '50%',
82
+ },
83
+ ];
84
+ const { getByTestId } = render(<Grid schema={schema} withCheckbox={true} onSelectAll={onSelectAll} />);
85
+ const input = getByTestId('DesignSystem-Checkbox-InputBox');
86
+ fireEvent.click(input);
87
+ expect(onSelectAll).toHaveBeenCalledTimes(1);
88
+ });
89
+ });
90
+
91
+ describe('render Grid component prop: updateSortingList with sortTypes', () => {
92
+ const schema = [
93
+ {
94
+ name: 'name',
95
+ displayName: 'Name',
96
+ width: '50%',
97
+ },
98
+ ];
99
+ const data = [
100
+ {
101
+ name: 'Zara',
102
+ gender: 'f',
103
+ },
104
+ ];
105
+ it('calls updateSortingList with sorting order as asc when no sortingList is passed', () => {
106
+ const { getAllByTestId } = render(
107
+ <Grid
108
+ schema={schema}
109
+ data={data}
110
+ withCheckbox={true}
111
+ withPagination={true}
112
+ updateSortingList={updateSortingList}
113
+ />
114
+ );
115
+ const input = getAllByTestId('DesignSystem-Grid-cellContent')[0];
116
+ fireEvent.click(input);
117
+ expect(updateSortingList).toHaveBeenCalledTimes(1);
118
+ expect(updateSortingList).toHaveBeenCalledWith([{ name: 'name', type: 'asc' }]);
119
+ });
120
+
121
+ it('calls updateSortingList without sorting order when sortingList is passed with type desc', () => {
122
+ const { getByTestId } = render(
123
+ <Grid
124
+ schema={schema}
125
+ data={data}
126
+ withCheckbox={true}
127
+ withPagination={true}
128
+ updateSortingList={updateSortingList}
129
+ sortingList={[{ name: 'name', type: 'desc' }]}
130
+ />
131
+ );
132
+ const input = getByTestId('DesignSystem-Grid-cellContent');
133
+ fireEvent.click(input);
134
+ expect(updateSortingList).toHaveBeenCalled();
135
+ expect(updateSortingList.mock.calls[1]).toEqual([[]]);
136
+ });
137
+
138
+ it('calls updateSortingList with sorting order as desc when sortingList is passed with type asc', () => {
139
+ const { getByTestId } = render(
140
+ <Grid
141
+ schema={schema}
142
+ data={data}
143
+ withCheckbox={true}
144
+ withPagination={true}
145
+ updateSortingList={updateSortingList}
146
+ sortingList={[{ name: 'name', type: 'asc' }]}
147
+ />
148
+ );
149
+ const input = getByTestId('DesignSystem-Grid-cellContent');
150
+ fireEvent.click(input);
151
+ expect(updateSortingList).toHaveBeenCalled();
152
+ expect(updateSortingList.mock.calls[2]).toEqual([[{ name: 'name', type: 'desc' }]]);
153
+ });
154
+ });
155
+
156
+ describe('render Grid component prop: updateSchema ', () => {
157
+ const schema = [
158
+ {
159
+ name: 'name',
160
+ displayName: 'Name',
161
+ width: '50%',
162
+ },
163
+ ];
164
+ const data = [
165
+ {
166
+ name: 'Zara',
167
+ selected: true,
168
+ },
169
+ ];
170
+ it('calls updateSchema with pinned left', () => {
171
+ const { getAllByTestId } = render(<Grid schema={schema} showMenu={true} data={data} updateSchema={updateSchema} />);
172
+ const popoverButton = getAllByTestId('DesignSystem-Button')[0];
173
+ fireEvent.click(popoverButton);
174
+ const dropdownOption = getAllByTestId('DesignSystem-DropdownOption--WITH_ICON')[2];
175
+ fireEvent.click(dropdownOption);
176
+ expect(updateSchema).toHaveBeenCalledTimes(1);
177
+ expect(updateSchema).toHaveBeenCalledWith([{ displayName: 'Name', name: 'name', pinned: 'left', width: '50%' }]);
178
+ });
179
+ it('calls updateSchema with pinned right', () => {
180
+ const { getAllByTestId } = render(<Grid schema={schema} showMenu={true} data={data} updateSchema={updateSchema} />);
181
+ const popoverButton = getAllByTestId('DesignSystem-Button')[0];
182
+ fireEvent.click(popoverButton);
183
+ const dropdownOption = getAllByTestId('DesignSystem-DropdownOption--WITH_ICON')[3];
184
+ fireEvent.click(dropdownOption);
185
+ expect(updateSchema).toHaveBeenCalledTimes(2);
186
+ expect(updateSchema).toHaveBeenCalledWith([{ displayName: 'Name', name: 'name', pinned: 'right', width: '50%' }]);
187
+ });
188
+ it('calls updateSchema with hidden true', () => {
189
+ const { getAllByTestId } = render(<Grid schema={schema} showMenu={true} data={data} updateSchema={updateSchema} />);
190
+ const popoverButton = getAllByTestId('DesignSystem-Button')[0];
191
+ fireEvent.click(popoverButton);
192
+ const dropdownOption = getAllByTestId('DesignSystem-DropdownOption--WITH_ICON')[4];
193
+ fireEvent.click(dropdownOption);
194
+ expect(updateSchema).toHaveBeenCalledTimes(3);
195
+ expect(updateSchema).toHaveBeenCalledWith([{ displayName: 'Name', name: 'name', hidden: true, width: '50%' }]);
196
+ });
197
+ });
198
+
199
+ describe('renders children with pagination and page', () => {
200
+ const schema = [
201
+ {
202
+ name: 'name',
203
+ displayName: 'Name',
204
+ width: '50%',
205
+ filters: [{ label: 'Sort Descending', value: 'sortDesc', icon: 'arrow_upward' }],
206
+ },
207
+ ];
208
+ const data = [{ name: 'Zara' }];
209
+ it('renders children with pagination', () => {
210
+ const { getAllByTestId } = render(
211
+ <Grid withPagination={true} schema={schema} data={data} showFilters={true} updateFilterList={updateFilterList} />
212
+ );
213
+ const popoverButton = getAllByTestId('DesignSystem-Button')[0];
214
+ fireEvent.click(popoverButton);
215
+ const dropdownOption = getAllByTestId('DesignSystem-Checkbox-InputBox')[0];
216
+ fireEvent.click(dropdownOption);
217
+ const applyButton = getAllByTestId('DesignSystem-Button')[2];
218
+ fireEvent.click(applyButton);
219
+ expect(updateFilterList).toHaveBeenCalledTimes(1);
220
+ });
221
+ });
222
+
223
+ describe('renders children with nestedRows', () => {
224
+ const schema = [
225
+ {
226
+ name: 'name',
227
+ displayName: 'Name',
228
+ },
229
+ ];
230
+ const data = [{ name: 'Zara' }];
231
+ it('renders children with nestedRows', () => {
232
+ render(<Grid schema={schema} data={data} nestedRows={true} nestedRowRenderer={nestedRowRenderer} />);
233
+ expect(nestedRowRenderer).toBeCalled();
234
+ });
235
+ });
@@ -0,0 +1,218 @@
1
+ import * as React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import { GridCell } from '@/index';
4
+
5
+ describe('renders GridCell with no cellType ', () => {
6
+ it('renders Grid with no cellType , loading true ', () => {
7
+ const { queryByTestId } = render(
8
+ <GridCell
9
+ schema={{
10
+ displayName: 'Name',
11
+ name: 'name',
12
+ }}
13
+ data={{ name: 'Zara' }}
14
+ loading={true}
15
+ />
16
+ );
17
+ expect(queryByTestId('DesignSystem-GridCell-placeHolder')).toBeInTheDocument();
18
+ });
19
+ it('renders Grid with no cellType , loading false ', () => {
20
+ const { queryByTestId } = render(
21
+ <GridCell
22
+ schema={{
23
+ displayName: 'Name',
24
+ name: 'name',
25
+ }}
26
+ data={{ name: 'Zara' }}
27
+ />
28
+ );
29
+ expect(queryByTestId('DesignSystem-Text')).toBeInTheDocument();
30
+ });
31
+ });
32
+
33
+ describe('renders GridCell with cellType WITH_META_LIST', () => {
34
+ it('renders Grid with loading true ', () => {
35
+ const { getByTestId } = render(
36
+ <GridCell
37
+ schema={{
38
+ displayName: 'Name',
39
+ name: 'name',
40
+ cellType: 'WITH_META_LIST',
41
+ }}
42
+ data={{ name: 'Zara' }}
43
+ loading={true}
44
+ />
45
+ );
46
+ expect(getByTestId('DesignSystem-GridCell-withMetaList')).toBeInTheDocument();
47
+ });
48
+
49
+ it('renders Grid with loading false', () => {
50
+ const { queryByTestId } = render(
51
+ <GridCell
52
+ schema={{
53
+ cellType: 'WITH_META_LIST',
54
+ displayName: 'Name',
55
+ name: 'name',
56
+ }}
57
+ data={{ name: { metaList: ['Meta Item 1'] } }}
58
+ />
59
+ );
60
+ expect(queryByTestId('DesignSystem-GridCell-metaList')).toBeInTheDocument();
61
+ });
62
+ });
63
+
64
+ describe('renders GridCell with cellType AVATAR', () => {
65
+ it('renders Grid with loading true ', () => {
66
+ const { queryByTestId } = render(
67
+ <GridCell
68
+ schema={{
69
+ displayName: 'Name',
70
+ name: 'name',
71
+ cellType: 'AVATAR',
72
+ align: 'right',
73
+ }}
74
+ data={{ name: 'Zara' }}
75
+ loading={true}
76
+ />
77
+ );
78
+ expect(queryByTestId('DesignSystem-Placeholder')).toBeInTheDocument();
79
+ expect(queryByTestId('DesignSystem-Placeholder')).toHaveClass('GridCell--align-right');
80
+ });
81
+
82
+ it('renders Grid with loading false', () => {
83
+ const { queryByTestId } = render(
84
+ <GridCell
85
+ schema={{
86
+ cellType: 'AVATAR',
87
+ displayName: 'Name',
88
+ name: 'name',
89
+ }}
90
+ data={{ name: 'Zara' }}
91
+ />
92
+ );
93
+ expect(queryByTestId('DesignSystem-GridCell-avatar')).toBeInTheDocument();
94
+ expect(queryByTestId('DesignSystem-GridCell-avatar')).toHaveClass('GridCell--avatar');
95
+ });
96
+ });
97
+
98
+ describe('renders GridCell with cellType AVATAR_WITH_TEXT', () => {
99
+ it('renders Grid with loading true ', () => {
100
+ const { queryByTestId } = render(
101
+ <GridCell
102
+ schema={{
103
+ displayName: 'Name',
104
+ name: 'name',
105
+ cellType: 'AVATAR_WITH_TEXT',
106
+ }}
107
+ data={{ name: 'Zara' }}
108
+ loading={true}
109
+ />
110
+ );
111
+ expect(queryByTestId('DesignSystem-Placeholder')).toBeInTheDocument();
112
+ });
113
+
114
+ it('renders Grid with loading false', () => {
115
+ const { queryByTestId } = render(
116
+ <GridCell
117
+ schema={{
118
+ cellType: 'AVATAR_WITH_TEXT',
119
+ displayName: 'Name',
120
+ name: 'name',
121
+ }}
122
+ data={{ name: 'Zara' }}
123
+ />
124
+ );
125
+ expect(queryByTestId('DesignSystem-GridCell-avatarWithText')).toBeInTheDocument();
126
+ });
127
+ });
128
+ describe('renders GridCell with cellType AVATAR_WITH_META_LIST', () => {
129
+ it('renders Grid with loading true ', () => {
130
+ const { queryByTestId } = render(
131
+ <GridCell
132
+ schema={{
133
+ displayName: 'Name',
134
+ name: 'name',
135
+ cellType: 'AVATAR_WITH_META_LIST',
136
+ }}
137
+ data={{ name: 'Zara' }}
138
+ loading={true}
139
+ />
140
+ );
141
+ expect(queryByTestId('DesignSystem-Placeholder')).toBeInTheDocument();
142
+ });
143
+
144
+ it('renders Grid with loading false', () => {
145
+ const { queryByTestId } = render(
146
+ <GridCell
147
+ schema={{
148
+ cellType: 'AVATAR_WITH_META_LIST',
149
+ displayName: 'Name',
150
+ name: 'name',
151
+ }}
152
+ data={{ name: 'Zara' }}
153
+ />
154
+ );
155
+ expect(queryByTestId('DesignSystem-GridCell-avatarWithMetaList')).toBeInTheDocument();
156
+ expect(queryByTestId('DesignSystem-GridCell-avatarWithMetaList')).toHaveClass('GridCell--avatarWithText');
157
+ });
158
+ });
159
+ describe('renders GridCell with cellType ICON', () => {
160
+ it('renders Grid with loading true ', () => {
161
+ const { queryByTestId } = render(
162
+ <GridCell
163
+ schema={{
164
+ displayName: 'Name',
165
+ name: 'name',
166
+ cellType: 'ICON',
167
+ }}
168
+ data={{ name: 'Zara' }}
169
+ loading={true}
170
+ />
171
+ );
172
+ expect(queryByTestId('DesignSystem-Placeholder')).toBeInTheDocument();
173
+ });
174
+
175
+ it('renders Grid with loading false', () => {
176
+ const { queryByTestId } = render(
177
+ <GridCell
178
+ schema={{
179
+ cellType: 'ICON',
180
+ displayName: 'Name',
181
+ name: 'name',
182
+ }}
183
+ data={{ name: 'Zara' }}
184
+ />
185
+ );
186
+ expect(queryByTestId('DesignSystem-GridCell-icon')).toHaveClass('GridCell--icon');
187
+ });
188
+ });
189
+ describe('renders GridCell with cellType STATUS_HINT', () => {
190
+ it('renders Grid with loading true ', () => {
191
+ const { queryByTestId } = render(
192
+ <GridCell
193
+ schema={{
194
+ displayName: 'Name',
195
+ name: 'name',
196
+ cellType: 'STATUS_HINT',
197
+ }}
198
+ data={{ name: 'Zara' }}
199
+ loading={true}
200
+ />
201
+ );
202
+ expect(queryByTestId('DesignSystem-Placeholder')).toBeInTheDocument();
203
+ });
204
+
205
+ it('renders Grid with loading false', () => {
206
+ const { queryByTestId } = render(
207
+ <GridCell
208
+ schema={{
209
+ cellType: 'STATUS_HINT',
210
+ displayName: 'Name',
211
+ name: 'name',
212
+ }}
213
+ data={{ name: { statusAppearance: 'info', title: 'title' } }}
214
+ />
215
+ );
216
+ expect(queryByTestId('DesignSystem-StatusHint')).toBeInTheDocument();
217
+ });
218
+ });