@centreon/ui 24.4.45-develop.0 → 24.4.45

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 (50) hide show
  1. package/package.json +5 -1
  2. package/src/Graph/BarStack/BarStack.cypress.spec.tsx +154 -0
  3. package/src/Graph/BarStack/BarStack.stories.tsx +123 -0
  4. package/src/Graph/BarStack/BarStack.styles.ts +36 -0
  5. package/src/Graph/BarStack/BarStack.tsx +14 -0
  6. package/src/Graph/BarStack/ResponsiveBarStack.tsx +208 -0
  7. package/src/Graph/BarStack/index.ts +1 -0
  8. package/src/Graph/BarStack/models.ts +19 -0
  9. package/src/Graph/BarStack/useResponsiveBarStack.ts +139 -0
  10. package/src/Graph/Gauge/Gauge.cypress.spec.tsx +102 -0
  11. package/src/Graph/Gauge/Gauge.tsx +1 -1
  12. package/src/Graph/HeatMap/HeatMap.cypress.spec.tsx +145 -0
  13. package/src/Graph/HeatMap/HeatMap.stories.tsx +0 -25
  14. package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +8 -2
  15. package/src/Graph/Legend/Legend.tsx +21 -0
  16. package/src/Graph/Legend/index.ts +1 -0
  17. package/src/Graph/Legend/models.ts +11 -0
  18. package/src/Graph/LineChart/Legend/Legend.styles.ts +1 -1
  19. package/src/Graph/LineChart/Legend/LegendHeader.tsx +1 -1
  20. package/src/Graph/LineChart/Legend/useInteractiveValues.ts +2 -2
  21. package/src/Graph/LineChart/index.tsx +1 -1
  22. package/src/Graph/PieChart/PieChart.cypress.spec.tsx +169 -0
  23. package/src/Graph/PieChart/PieChart.stories.tsx +194 -0
  24. package/src/Graph/PieChart/PieChart.styles.ts +39 -0
  25. package/src/Graph/PieChart/PieChart.tsx +14 -0
  26. package/src/Graph/PieChart/ResponsivePie.tsx +251 -0
  27. package/src/Graph/PieChart/index.ts +1 -0
  28. package/src/Graph/PieChart/models.ts +19 -0
  29. package/src/Graph/PieChart/useResponsivePie.ts +86 -0
  30. package/src/Graph/SingleBar/SingleBar.cypress.spec.tsx +121 -0
  31. package/src/Graph/Text/Text.cypress.spec.tsx +101 -0
  32. package/src/Graph/Text/Text.tsx +1 -1
  33. package/src/Graph/common/testUtils.ts +71 -0
  34. package/src/Graph/common/timeSeries/index.ts +19 -11
  35. package/src/Graph/common/utils.ts +19 -0
  36. package/src/Graph/index.ts +3 -0
  37. package/src/Graph/translatedLabels.ts +1 -0
  38. package/src/Listing/ActionBar/index.tsx +9 -8
  39. package/src/Listing/Cell/DataCell.styles.ts +3 -0
  40. package/src/Listing/Cell/DataCell.tsx +8 -4
  41. package/src/Listing/Listing.cypress.spec.tsx +80 -4
  42. package/src/Listing/Listing.styles.ts +3 -5
  43. package/src/Listing/index.stories.tsx +25 -2
  44. package/src/Listing/index.test.tsx +1 -1
  45. package/src/Listing/index.tsx +3 -1
  46. package/src/Listing/models.ts +1 -0
  47. package/src/api/useMutationQuery/index.test.ts +4 -4
  48. package/src/api/useMutationQuery/index.ts +24 -13
  49. package/src/components/Form/AccessRights/ShareInput/ContactSwitch.tsx +3 -3
  50. package/src/components/Form/AccessRights/ShareInput/ShareInput.tsx +1 -0
@@ -0,0 +1,86 @@
1
+ import { equals, isEmpty, pluck, reject } from 'ramda';
2
+
3
+ import { LegendScale } from '../Legend/models';
4
+ import { getValueByUnit } from '../common/utils';
5
+
6
+ import { ArcType } from './models';
7
+
8
+ interface ResponsivePieProps {
9
+ data: Array<ArcType>;
10
+ defaultInnerRadius: number;
11
+ height: number;
12
+ legendRef;
13
+ titleRef;
14
+ unit: 'percentage' | 'number';
15
+ width: number;
16
+ }
17
+
18
+ interface ResponsivePieState {
19
+ areAllValuesNull: boolean;
20
+ half: number;
21
+ innerRadius: number;
22
+ isContainsExactlyOneNonZeroValue: boolean;
23
+ legendScale: LegendScale;
24
+ svgContainerSize: number;
25
+ svgSize: number;
26
+ svgWrapperWidth: number;
27
+ total: number;
28
+ }
29
+ export const useResponsivePie = ({
30
+ titleRef,
31
+ legendRef,
32
+ height,
33
+ width,
34
+ data,
35
+ unit,
36
+ defaultInnerRadius
37
+ }: ResponsivePieProps): ResponsivePieState => {
38
+ const heightOfTitle = titleRef.current?.offsetHeight || 0;
39
+ const widthOfLegend = legendRef.current?.offsetWidth || 0;
40
+
41
+ const horizontalGap = widthOfLegend > 0 ? 16 : 0;
42
+ const verticalGap = heightOfTitle > 0 ? 8 : 0;
43
+
44
+ const svgWrapperWidth = width - widthOfLegend - horizontalGap;
45
+
46
+ const svgContainerSize = Math.min(
47
+ height - heightOfTitle - verticalGap,
48
+ width - widthOfLegend - horizontalGap
49
+ );
50
+
51
+ const outerRadius = Math.min(32, svgContainerSize / 6);
52
+
53
+ const svgSize = svgContainerSize - outerRadius;
54
+
55
+ const half = svgSize / 2;
56
+
57
+ const total = Math.floor(data.reduce((acc, { value }) => acc + value, 0));
58
+
59
+ const innerRadius = Math.min(defaultInnerRadius, svgSize / 5);
60
+
61
+ const legendScale = {
62
+ domain: data.map(({ value }) => getValueByUnit({ total, unit, value })),
63
+ range: pluck('color', data)
64
+ };
65
+
66
+ const values = pluck('value', data);
67
+
68
+ const isContainsExactlyOneNonZeroValue = equals(
69
+ reject((value) => equals(value, 0), values).length,
70
+ 1
71
+ );
72
+
73
+ const areAllValuesNull = isEmpty(reject((value) => equals(value, 0), values));
74
+
75
+ return {
76
+ areAllValuesNull,
77
+ half,
78
+ innerRadius,
79
+ isContainsExactlyOneNonZeroValue,
80
+ legendScale,
81
+ svgContainerSize,
82
+ svgSize,
83
+ svgWrapperWidth,
84
+ total
85
+ };
86
+ };
@@ -0,0 +1,121 @@
1
+ import dataLastWeek from '../LineChart/mockedData/lastWeek.json';
2
+ import {
3
+ criticalThresholds,
4
+ rangedThresholds,
5
+ successThresholds,
6
+ warningThresholds
7
+ } from '../common/testUtils';
8
+
9
+ import SingleBar from './SingleBar';
10
+ import { SingleBarProps } from './models';
11
+
12
+ const initialize = (
13
+ args: Omit<SingleBarProps, 'data' | 'labels' | 'baseColor'>
14
+ ): void => {
15
+ cy.mount({
16
+ Component: (
17
+ <div style={{ height: '100vh', width: '100vw' }}>
18
+ <SingleBar
19
+ baseColor="#000"
20
+ data={dataLastWeek}
21
+ labels={{
22
+ critical: 'Critical',
23
+ warning: 'Warning'
24
+ }}
25
+ {...args}
26
+ />
27
+ </div>
28
+ )
29
+ });
30
+ };
31
+
32
+ describe('Single bar', () => {
33
+ it('displays the single bar as success when corresponding thresholds are set', () => {
34
+ initialize({ thresholds: successThresholds });
35
+
36
+ cy.contains('0.41 s').should('have.css', 'fill', 'rgb(136, 185, 34)');
37
+ cy.findByTestId('warning-line-0.5').should('be.visible');
38
+ cy.findByTestId('warning-line-0.5-tooltip').should('be.visible');
39
+ cy.findByTestId('critical-line-1.5').should('be.visible');
40
+ cy.findByTestId('critical-line-1.5-tooltip').should('be.visible');
41
+
42
+ cy.makeSnapshot();
43
+ });
44
+
45
+ it('displays the single bar as warning when corresponding thresholds are set', () => {
46
+ initialize({ thresholds: warningThresholds });
47
+
48
+ cy.contains('0.41 s').should('have.css', 'fill', 'rgb(253, 155, 39)');
49
+ cy.findByTestId('warning-line-0.4').should('be.visible');
50
+ cy.findByTestId('warning-line-0.4-tooltip').should('be.visible');
51
+ cy.findByTestId('critical-line-1.5').should('be.visible');
52
+ cy.findByTestId('critical-line-1.5-tooltip').should('be.visible');
53
+
54
+ cy.makeSnapshot();
55
+ });
56
+
57
+ it('displays the single bar as critical when corresponding thresholds are set', () => {
58
+ initialize({ thresholds: criticalThresholds });
59
+
60
+ cy.contains('0.41 s').should('have.css', 'fill', 'rgb(255, 74, 74)');
61
+ cy.findByTestId('warning-line-0.2').should('be.visible');
62
+ cy.findByTestId('warning-line-0.2-tooltip').should('be.visible');
63
+ cy.findByTestId('critical-line-0.3').should('be.visible');
64
+ cy.findByTestId('critical-line-0.3-tooltip').should('be.visible');
65
+
66
+ cy.makeSnapshot();
67
+ });
68
+
69
+ it('displays ranged thresholds', () => {
70
+ initialize({ thresholds: rangedThresholds });
71
+
72
+ cy.findByTestId('warning-line-0.13').should('be.visible');
73
+ cy.findByTestId('warning-line-0.13-tooltip').should('be.visible');
74
+ cy.findByTestId('warning-line-0.5').should('be.visible');
75
+ cy.findByTestId('warning-line-0.5-tooltip').should('be.visible');
76
+ cy.findByTestId('critical-line-0.55').should('be.visible');
77
+ cy.findByTestId('critical-line-0.55-tooltip').should('be.visible');
78
+ cy.findByTestId('critical-line-0.65').should('be.visible');
79
+ cy.findByTestId('critical-line-0.65-tooltip').should('be.visible');
80
+
81
+ cy.makeSnapshot();
82
+ });
83
+
84
+ it('displays the threshold tooltip when a threshold is hovered', () => {
85
+ initialize({ thresholds: successThresholds });
86
+
87
+ cy.findByTestId('warning-line-0.5-tooltip').trigger('mouseover');
88
+
89
+ cy.contains('Warning').should('be.visible');
90
+
91
+ cy.findByTestId('critical-line-1.5-tooltip').trigger('mouseover');
92
+
93
+ cy.contains('Critical').should('be.visible');
94
+
95
+ cy.makeSnapshot();
96
+ });
97
+
98
+ it('displays single bar as small when the props is set', () => {
99
+ initialize({ size: 'small', thresholds: successThresholds });
100
+
101
+ cy.findByTestId('warning-line-0.5-tooltip').should('be.visible');
102
+
103
+ cy.makeSnapshot();
104
+ });
105
+
106
+ it('displays the value as raw when the prop is set', () => {
107
+ initialize({ displayAsRaw: true, thresholds: successThresholds });
108
+
109
+ cy.contains('0.40663333333 s').should('be.visible');
110
+
111
+ cy.makeSnapshot();
112
+ });
113
+
114
+ it('does not display the value when the prop is set', () => {
115
+ initialize({ showLabels: false, thresholds: successThresholds });
116
+
117
+ cy.contains('0.41 s').should('not.exist');
118
+
119
+ cy.makeSnapshot();
120
+ });
121
+ });
@@ -0,0 +1,101 @@
1
+ import dataLastWeek from '../LineChart/mockedData/lastWeek.json';
2
+ import {
3
+ criticalThresholds,
4
+ rangedThresholds,
5
+ successThresholds,
6
+ warningThresholds
7
+ } from '../common/testUtils';
8
+
9
+ import { Text, Props } from './Text';
10
+
11
+ const initialize = (
12
+ args: Omit<Props, 'data' | 'labels' | 'baseColor'>
13
+ ): void => {
14
+ cy.mount({
15
+ Component: (
16
+ <div style={{ height: '100vh', width: '100vw' }}>
17
+ <Text
18
+ baseColor="#000"
19
+ data={dataLastWeek}
20
+ labels={{
21
+ critical: 'Critical',
22
+ warning: 'Warning'
23
+ }}
24
+ {...args}
25
+ />
26
+ </div>
27
+ )
28
+ });
29
+ };
30
+
31
+ describe('Text', () => {
32
+ it('displays the text as success when corresponding thresholds are set', () => {
33
+ initialize({ thresholds: successThresholds });
34
+
35
+ cy.contains('0.41 s').should('have.css', 'color', 'rgb(136, 185, 34)');
36
+ cy.contains('Warning: 0.5 s').should('be.visible');
37
+ cy.contains('Critical: 1.5 s').should('be.visible');
38
+
39
+ cy.makeSnapshot();
40
+ });
41
+
42
+ it('displays the text as warning when corresponding thresholds are set', () => {
43
+ initialize({ thresholds: warningThresholds });
44
+
45
+ cy.contains('0.41 s').should('have.css', 'color', 'rgb(253, 155, 39)');
46
+ cy.contains('Warning: 0.4 s').should('be.visible');
47
+ cy.contains('Critical: 1.5 s').should('be.visible');
48
+
49
+ cy.makeSnapshot();
50
+ });
51
+
52
+ it('displays the text as critical when corresponding thresholds are set', () => {
53
+ initialize({ thresholds: criticalThresholds });
54
+
55
+ cy.contains('0.41 s').should('have.css', 'color', 'rgb(255, 74, 74)');
56
+ cy.contains('Warning: 0.2 s').should('be.visible');
57
+ cy.contains('Critical: 0.3 s').should('be.visible');
58
+
59
+ cy.makeSnapshot();
60
+ });
61
+
62
+ it('displays ranged thresholds', () => {
63
+ initialize({ thresholds: rangedThresholds });
64
+
65
+ cy.contains('Warning: 0.13 s - 0.5 s').should('be.visible');
66
+ cy.contains('Critical: 0.55 s - 0.65 s').should('be.visible');
67
+
68
+ cy.makeSnapshot();
69
+ });
70
+
71
+ it('displays the value as raw when the prop is set', () => {
72
+ initialize({ displayAsRaw: true, thresholds: successThresholds });
73
+
74
+ cy.contains('0.40663333333 s').should('be.visible');
75
+
76
+ cy.makeSnapshot();
77
+ });
78
+
79
+ it('does not display the text', () => {
80
+ initialize({ data: undefined, thresholds: successThresholds });
81
+
82
+ cy.contains('0.41 s').should('not.exist');
83
+
84
+ cy.makeSnapshot();
85
+ });
86
+
87
+ it('displays text with default values when the data is empty', () => {
88
+ initialize({
89
+ data: {
90
+ global: {},
91
+ metrics: [],
92
+ times: []
93
+ },
94
+ thresholds: successThresholds
95
+ });
96
+
97
+ cy.contains('0').should('be.visible');
98
+
99
+ cy.makeSnapshot();
100
+ });
101
+ });
@@ -11,7 +11,7 @@ import { getColorFromDataAndTresholds } from '../common/utils';
11
11
 
12
12
  import { useTextStyles } from './Text.styles';
13
13
 
14
- interface Props {
14
+ export interface Props {
15
15
  baseColor?: string;
16
16
  data?: LineChartData;
17
17
  displayAsRaw?: boolean;
@@ -0,0 +1,71 @@
1
+ export const successThresholds = {
2
+ critical: [
3
+ {
4
+ label: 'Critical',
5
+ value: 1.5
6
+ }
7
+ ],
8
+ enabled: true,
9
+ warning: [
10
+ {
11
+ label: 'Warning',
12
+ value: 0.5
13
+ }
14
+ ]
15
+ };
16
+
17
+ export const warningThresholds = {
18
+ critical: [
19
+ {
20
+ label: 'Critical',
21
+ value: 1.5
22
+ }
23
+ ],
24
+ enabled: true,
25
+ warning: [
26
+ {
27
+ label: 'Warning',
28
+ value: 0.4
29
+ }
30
+ ]
31
+ };
32
+
33
+ export const criticalThresholds = {
34
+ critical: [
35
+ {
36
+ label: 'Critical',
37
+ value: 0.3
38
+ }
39
+ ],
40
+ enabled: true,
41
+ warning: [
42
+ {
43
+ label: 'Warning',
44
+ value: 0.2
45
+ }
46
+ ]
47
+ };
48
+
49
+ export const rangedThresholds = {
50
+ critical: [
51
+ {
52
+ label: 'Critical',
53
+ value: 0.55
54
+ },
55
+ {
56
+ label: 'Critical',
57
+ value: 0.65
58
+ }
59
+ ],
60
+ enabled: true,
61
+ warning: [
62
+ {
63
+ label: 'Warning',
64
+ value: 0.13
65
+ },
66
+ {
67
+ label: 'Warning',
68
+ value: 0.5
69
+ }
70
+ ]
71
+ };
@@ -476,15 +476,7 @@ const registerMsUnitToNumeral = (): null => {
476
476
 
477
477
  registerMsUnitToNumeral();
478
478
 
479
- const formatMetricValue = ({
480
- value,
481
- unit,
482
- base = 1000
483
- }: FormatMetricValueProps): string | null => {
484
- if (isNil(value)) {
485
- return null;
486
- }
487
-
479
+ const getBase1024 = ({ unit, base }): boolean => {
488
480
  const base2Units = [
489
481
  'B',
490
482
  'bytes',
@@ -497,7 +489,19 @@ const formatMetricValue = ({
497
489
  'b'
498
490
  ];
499
491
 
500
- const base1024 = base2Units.includes(unit) || Number(base) === 1024;
492
+ return base2Units.includes(unit) || Number(base) === 1024;
493
+ };
494
+
495
+ const formatMetricValue = ({
496
+ value,
497
+ unit,
498
+ base = 1000
499
+ }: FormatMetricValueProps): string | null => {
500
+ if (isNil(value)) {
501
+ return null;
502
+ }
503
+
504
+ const base1024 = getBase1024({ base, unit });
501
505
 
502
506
  const formatSuffix = cond([
503
507
  [equals('ms'), always(' ms')],
@@ -525,6 +529,8 @@ const formatMetricValueWithUnit = ({
525
529
  return null;
526
530
  }
527
531
 
532
+ const base1024 = getBase1024({ base, unit });
533
+
528
534
  if (isRaw) {
529
535
  const unitText = equals('%', unit) ? unit : ` ${unit}`;
530
536
 
@@ -537,7 +543,9 @@ const formatMetricValueWithUnit = ({
537
543
 
538
544
  const formattedMetricValue = formatMetricValue({ base, unit, value });
539
545
 
540
- return formattedMetricValue;
546
+ return base1024 || !unit || equals(unit, 'ms')
547
+ ? formattedMetricValue
548
+ : `${formattedMetricValue} ${unit}`;
541
549
  };
542
550
 
543
551
  const getStackedYScale = ({
@@ -11,6 +11,7 @@ import {
11
11
  lte,
12
12
  pluck
13
13
  } from 'ramda';
14
+ import numeral from 'numeral';
14
15
 
15
16
  import { Theme } from '@mui/material';
16
17
 
@@ -73,3 +74,21 @@ export const getColorFromDataAndTresholds = ({
73
74
  [T, always(theme.palette.error.main)]
74
75
  ])(data);
75
76
  };
77
+
78
+ interface ValueByUnitProps {
79
+ total: number;
80
+ unit: 'percentage' | 'number';
81
+ value: number;
82
+ }
83
+
84
+ export const getValueByUnit = ({
85
+ unit,
86
+ value,
87
+ total
88
+ }: ValueByUnitProps): string => {
89
+ if (equals(unit, 'number')) {
90
+ return numeral(value).format('0a').toUpperCase();
91
+ }
92
+
93
+ return `${((value * 100) / total).toFixed(1)}%`;
94
+ };
@@ -2,4 +2,7 @@ export { default as LineChart } from './LineChart';
2
2
  export { Gauge } from './Gauge';
3
3
  export { SingleBar } from './SingleBar';
4
4
  export { Text as GraphText } from './Text';
5
+
5
6
  export { HeatMap } from './HeatMap';
7
+ export { BarStack } from './BarStack';
8
+ export { PieChart } from './PieChart';
@@ -0,0 +1 @@
1
+ export const labelNoDataFound = 'No Data Available';
@@ -174,14 +174,15 @@ const MemoListingActionBar = ({
174
174
  </IconButton>
175
175
  )}
176
176
  <div className={classes.ModeViewer} />
177
- {columnConfiguration?.selectedColumnIds && (
178
- <ColumnMultiSelect
179
- columnConfiguration={columnConfiguration}
180
- columns={columns}
181
- onResetColumns={onResetColumns}
182
- onSelectColumns={onSelectColumns}
183
- />
184
- )}
177
+ {columnConfiguration?.selectedColumnIds &&
178
+ columnConfiguration?.sortable && (
179
+ <ColumnMultiSelect
180
+ columnConfiguration={columnConfiguration}
181
+ columns={columns}
182
+ onResetColumns={onResetColumns}
183
+ onSelectColumns={onSelectColumns}
184
+ />
185
+ )}
185
186
  {paginated && (
186
187
  <StyledPagination
187
188
  ActionsComponent={PaginationActions}
@@ -8,6 +8,9 @@ const useStyles = makeStyles()((theme) => ({
8
8
  overflow: 'hidden',
9
9
  whiteSpace: 'nowrap'
10
10
  },
11
+ clickable: {
12
+ cursor: 'default'
13
+ },
11
14
  componentColumn: {
12
15
  width: theme.spacing(2.75)
13
16
  },
@@ -46,7 +46,7 @@ const DataCell = ({
46
46
  labelCollapse,
47
47
  labelExpand
48
48
  }: Props): JSX.Element | null => {
49
- const { classes } = useStyles();
49
+ const { classes, cx } = useStyles();
50
50
  const { dataStyle } = useStyleTable({ listingVariant });
51
51
 
52
52
  const commonCellProps = {
@@ -64,7 +64,7 @@ const DataCell = ({
64
64
 
65
65
  const cellByColumnType = {
66
66
  [ColumnType.string]: (): JSX.Element => {
67
- const { getFormattedString, isTruncated, getColSpan } = column;
67
+ const { getFormattedString, isTruncated, getColSpan, align } = column;
68
68
 
69
69
  const colSpan = getColSpan?.(isRowSelected);
70
70
 
@@ -87,6 +87,7 @@ const DataCell = ({
87
87
  isRowHighlighted={isRowHighlighted}
88
88
  listingVariant={listingVariant}
89
89
  style={{
90
+ alignItems: align,
90
91
  gridColumn
91
92
  }}
92
93
  {...commonCellProps}
@@ -99,7 +100,7 @@ const DataCell = ({
99
100
  );
100
101
  },
101
102
  [ColumnType.component]: (): JSX.Element | null => {
102
- const { getHiddenCondition, clickable } = column;
103
+ const { getHiddenCondition, clickable, align } = column;
103
104
  const Component = column.Component as (
104
105
  props: ComponentColumnProps
105
106
  ) => JSX.Element;
@@ -126,9 +127,12 @@ const DataCell = ({
126
127
 
127
128
  return (
128
129
  <Cell
129
- className={classes.cell}
130
+ className={cx(classes.cell, clickable && classes.clickable)}
130
131
  isRowHighlighted={isRowHighlighted}
131
132
  listingVariant={listingVariant}
133
+ style={{
134
+ alignItems: align
135
+ }}
132
136
  onClick={(e): void => {
133
137
  if (!clickable) {
134
138
  return;
@@ -1,4 +1,6 @@
1
- import { Button } from '@mui/material';
1
+ import { Button, Typography } from '@mui/material';
2
+
3
+ import { ListingVariant } from '@centreon/ui-context';
2
4
 
3
5
  import { ColumnType } from './models';
4
6
 
@@ -12,6 +14,12 @@ const ButtonColumn = ({ row }: Props): JSX.Element => (
12
14
  <Button size="small">Click to reveal details about {row.name}</Button>
13
15
  );
14
16
 
17
+ const LargeText = (): JSX.Element => (
18
+ <Typography sx={{ whiteSpace: 'normal' }}>
19
+ This is a large text that fills the content
20
+ </Typography>
21
+ );
22
+
15
23
  const generateSubItems = (parentIndex: number): Array<unknown> => {
16
24
  return tenElements.map((__, subIndex) => ({
17
25
  active: false,
@@ -37,6 +45,28 @@ const listingWithSubItems = tenElements.map((_, index) => ({
37
45
  subItems: index % 2 === 0 ? generateSubItems(index) : undefined
38
46
  }));
39
47
 
48
+ const defaultColumn = [
49
+ {
50
+ getFormattedString: ({ name }): string => name,
51
+ id: 'name',
52
+ label: 'Name',
53
+ type: ColumnType.string
54
+ },
55
+ {
56
+ getFormattedString: ({ description }): string => description,
57
+ id: 'description',
58
+ label: 'Description',
59
+ type: ColumnType.string
60
+ },
61
+ {
62
+ Component: LargeText,
63
+ id: '#',
64
+ label: 'Custom',
65
+ type: ColumnType.component,
66
+ width: '100px'
67
+ }
68
+ ];
69
+
40
70
  const columnsWithSubItems = [
41
71
  {
42
72
  getFormattedString: ({ name }): string => name,
@@ -62,7 +92,27 @@ const columnsWithSubItems = [
62
92
 
63
93
  const expandedItems = [0, 8];
64
94
 
65
- const mountListing = (): void => {
95
+ const mountListingResponsive = (listingVariant: ListingVariant): void => {
96
+ cy.viewport('macbook-13');
97
+
98
+ cy.mount({
99
+ Component: (
100
+ <div style={{ height: '100vh' }}>
101
+ <Listing
102
+ isResponsive
103
+ columns={defaultColumn}
104
+ currentPage={1}
105
+ limit={10}
106
+ listingVariant={listingVariant}
107
+ rows={listingWithSubItems}
108
+ totalRows={10}
109
+ />
110
+ </div>
111
+ )
112
+ });
113
+ };
114
+
115
+ const mountListingForSubItems = (): void => {
66
116
  cy.viewport('macbook-13');
67
117
 
68
118
  cy.mount({
@@ -89,9 +139,9 @@ const mountListing = (): void => {
89
139
  };
90
140
 
91
141
  describe('Listing', () => {
92
- beforeEach(mountListing);
93
-
94
142
  it('expands the row when the corresponding icon si clicked', () => {
143
+ mountListingForSubItems();
144
+
95
145
  cy.contains('E0').should('be.visible');
96
146
 
97
147
  expandedItems.forEach((index) => {
@@ -111,6 +161,8 @@ describe('Listing', () => {
111
161
  });
112
162
 
113
163
  it('collapses the row when the corresponding icon si clicked', () => {
164
+ mountListingForSubItems();
165
+
114
166
  cy.contains('Sub item 100').should('be.visible');
115
167
 
116
168
  cy.findByLabelText('Collapse 0').click();
@@ -119,4 +171,28 @@ describe('Listing', () => {
119
171
 
120
172
  cy.makeSnapshot();
121
173
  });
174
+
175
+ it('displays the last column on several lines in compact mode when the isResponsive prop is set', () => {
176
+ mountListingResponsive(ListingVariant.compact);
177
+
178
+ cy.get('.MuiTable-root').should(
179
+ 'have.css',
180
+ 'grid-template-rows',
181
+ '30px 85px 85px 85px 85px 85px 85px 85px 85px 85px 85px'
182
+ );
183
+
184
+ cy.makeSnapshot();
185
+ });
186
+
187
+ it('displays the last column on several lines in extended mode when the isResponsive prop is set', () => {
188
+ mountListingResponsive(ListingVariant.extended);
189
+
190
+ cy.get('.MuiTable-root').should(
191
+ 'have.css',
192
+ 'grid-template-rows',
193
+ '38px 85px 85px 85px 85px 85px 85px 85px 85px 85px 85px'
194
+ );
195
+
196
+ cy.makeSnapshot();
197
+ });
122
198
  });