@centreon/ui 24.4.58 → 24.4.59

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 (149) hide show
  1. package/package.json +31 -38
  2. package/public/mockServiceWorker.js +1 -1
  3. package/src/Button/Icon/index.tsx +1 -1
  4. package/src/Button/Save/StartIcon.tsx +3 -3
  5. package/src/Button/Save/index.tsx +5 -9
  6. package/src/Checkbox/Checkbox.tsx +2 -2
  7. package/src/Checkbox/CheckboxGroup/index.tsx +2 -2
  8. package/src/Dashboard/Item.tsx +1 -1
  9. package/src/Dashboard/Layout.tsx +2 -2
  10. package/src/Dialog/Confirm/index.tsx +2 -10
  11. package/src/Dialog/index.tsx +2 -9
  12. package/src/FallbackPage/FallbackPage.tsx +3 -3
  13. package/src/FileDropZone/index.tsx +1 -3
  14. package/src/Form/Inputs/index.tsx +1 -3
  15. package/src/Form/Inputs/models.ts +1 -9
  16. package/src/Graph/Gauge/Gauge.tsx +1 -1
  17. package/src/Graph/HeatMap/HeatMap.stories.tsx +25 -0
  18. package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +2 -8
  19. package/src/Graph/LineChart/BasicComponents/Lines/Threshold/Circle.tsx +2 -2
  20. package/src/Graph/LineChart/BasicComponents/Thresholds.tsx +2 -2
  21. package/src/Graph/LineChart/BasicComponents/useFilterLines.ts +1 -1
  22. package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/GuidingLines.tsx +2 -2
  23. package/src/Graph/LineChart/InteractiveComponents/Annotations/EventAnnotations.tsx +1 -1
  24. package/src/Graph/LineChart/Legend/Legend.styles.ts +1 -1
  25. package/src/Graph/LineChart/Legend/LegendHeader.tsx +1 -1
  26. package/src/Graph/LineChart/Legend/useInteractiveValues.ts +2 -2
  27. package/src/Graph/LineChart/Legend/useLegend.ts +3 -3
  28. package/src/Graph/LineChart/helpers/doc.ts +13 -16
  29. package/src/Graph/LineChart/helpers/index.ts +1 -1
  30. package/src/Graph/LineChart/index.stories.tsx +2 -4
  31. package/src/Graph/LineChart/index.tsx +1 -1
  32. package/src/Graph/SingleBar/Thresholds.tsx +2 -2
  33. package/src/Graph/Text/Text.stories.tsx +4 -60
  34. package/src/Graph/Text/Text.tsx +1 -1
  35. package/src/Graph/common/timeSeries/index.ts +14 -22
  36. package/src/Graph/common/utils.ts +0 -19
  37. package/src/Graph/index.ts +0 -3
  38. package/src/InputField/Select/Autocomplete/Connected/index.tsx +7 -10
  39. package/src/InputField/Select/Autocomplete/Draggable/SortableList.tsx +1 -1
  40. package/src/InputField/Select/Autocomplete/Draggable/SortableListContent.tsx +1 -1
  41. package/src/InputField/Select/Autocomplete/Draggable/index.tsx +1 -1
  42. package/src/InputField/Select/Autocomplete/Multi/index.tsx +2 -4
  43. package/src/InputField/Select/Autocomplete/index.tsx +116 -129
  44. package/src/InputField/Select/IconPopover/index.tsx +2 -2
  45. package/src/InputField/Select/index.tsx +1 -12
  46. package/src/InputField/Text/index.tsx +2 -2
  47. package/src/Listing/ActionBar/index.tsx +8 -9
  48. package/src/Listing/Cell/DataCell.styles.ts +0 -3
  49. package/src/Listing/Cell/DataCell.tsx +5 -23
  50. package/src/Listing/Header/ListingHeader.tsx +1 -1
  51. package/src/Listing/Listing.cypress.spec.tsx +33 -218
  52. package/src/Listing/Listing.styles.ts +7 -4
  53. package/src/Listing/Row/Row.tsx +3 -7
  54. package/src/Listing/index.stories.tsx +3 -37
  55. package/src/Listing/index.test.tsx +1 -1
  56. package/src/Listing/index.tsx +36 -80
  57. package/src/Listing/models.ts +0 -1
  58. package/src/Listing/useStyleTable.ts +0 -1
  59. package/src/Module/index.tsx +4 -2
  60. package/src/PopoverMenu/index.tsx +5 -6
  61. package/src/RichTextEditor/RichTextEditor.tsx +1 -12
  62. package/src/SortableItems/index.tsx +7 -2
  63. package/src/ThemeProvider/index.tsx +0 -24
  64. package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts +7 -6
  65. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +3 -8
  66. package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +2 -0
  67. package/src/TimePeriods/DateTimePickerInput.tsx +19 -56
  68. package/src/TimePeriods/ResolutionTimePeriod.cypress.spec.tsx +9 -12
  69. package/src/TimePeriods/TimePeriods.cypress.spec.tsx +33 -9
  70. package/src/TimePeriods/helpers/index.ts +1 -1
  71. package/src/TimePeriods/index.stories.tsx +4 -12
  72. package/src/TimePeriods/index.tsx +2 -2
  73. package/src/Typography/FluidTypography/index.stories.tsx +2 -2
  74. package/src/Typography/FluidTypography/index.tsx +28 -21
  75. package/src/Typography/FluidTypography/useFluidResizeObserver.ts +56 -0
  76. package/src/api/QueryProvider.tsx +1 -1
  77. package/src/api/TestQueryProvider.tsx +1 -1
  78. package/src/api/index.ts +3 -3
  79. package/src/api/useFetchQuery/index.ts +23 -27
  80. package/src/api/useMutationQuery/index.test.ts +4 -4
  81. package/src/api/useMutationQuery/index.ts +25 -60
  82. package/src/components/Button/Icon/IconButton.tsx +2 -6
  83. package/src/components/DataTable/DataTable.stories.tsx +0 -40
  84. package/src/components/DataTable/DataTable.styles.ts +0 -3
  85. package/src/components/DataTable/DataTable.tsx +3 -3
  86. package/src/components/DataTable/Item/DataTableItem.styles.ts +2 -7
  87. package/src/components/DataTable/Item/DataTableItem.tsx +28 -9
  88. package/src/components/DataTable/index.ts +1 -3
  89. package/src/components/Form/AccessRights/ShareInput/ContactSwitch.tsx +3 -3
  90. package/src/components/Form/AccessRights/ShareInput/ShareInput.tsx +0 -1
  91. package/src/components/Form/Dashboard/DashboardForm.tsx +12 -15
  92. package/src/components/Layout/PageLayout/PageLayout.tsx +1 -1
  93. package/src/components/Layout/PageLayout/PageLayoutActions.tsx +0 -1
  94. package/src/components/Layout/PageLayout/PageLayoutBody.tsx +0 -1
  95. package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +1 -5
  96. package/src/components/Layout/PageLayout/index.ts +1 -3
  97. package/src/components/List/Item/ListItem.tsx +3 -3
  98. package/src/components/Modal/Modal.styles.ts +3 -8
  99. package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.stories.tsx +3 -3
  100. package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.tsx +1 -1
  101. package/src/components/Tooltip/ConfirmationTooltip/models.ts +1 -1
  102. package/src/index.ts +2 -2
  103. package/src/queryParameters/url/index.ts +1 -5
  104. package/src/screens/dashboard/DashboardsDetail.stories.tsx +108 -0
  105. package/src/screens/dashboard/DashboardsOverview.stories.tsx +281 -0
  106. package/src/utils/index.ts +1 -1
  107. package/src/utils/useDateTimePickerAdapter.ts +309 -0
  108. package/src/utils/useFullscreen/Fullscreen.cypress.spec.tsx +3 -1
  109. package/src/utils/useFullscreen/useFullscreenListener.ts +7 -10
  110. package/src/utils/useInfiniteScrollListing.ts +1 -4
  111. package/src/utils/{useLicenseExpirationWarning.test.tsx → useLicenseExpirationWarning.cypress.spec.tsx} +37 -48
  112. package/src/utils/useLicenseExpirationWarning.ts +18 -18
  113. package/src/Form/Form.cypress.spec.tsx +0 -133
  114. package/src/Form/Inputs/List/Content.tsx +0 -62
  115. package/src/Form/Inputs/List/List.styles.ts +0 -29
  116. package/src/Form/Inputs/List/List.tsx +0 -58
  117. package/src/Form/Inputs/List/useList.ts +0 -81
  118. package/src/Graph/BarStack/BarStack.cypress.spec.tsx +0 -154
  119. package/src/Graph/BarStack/BarStack.stories.tsx +0 -123
  120. package/src/Graph/BarStack/BarStack.styles.ts +0 -37
  121. package/src/Graph/BarStack/BarStack.tsx +0 -14
  122. package/src/Graph/BarStack/ResponsiveBarStack.tsx +0 -222
  123. package/src/Graph/BarStack/index.ts +0 -1
  124. package/src/Graph/BarStack/models.ts +0 -20
  125. package/src/Graph/BarStack/useResponsiveBarStack.ts +0 -137
  126. package/src/Graph/Gauge/Gauge.cypress.spec.tsx +0 -102
  127. package/src/Graph/HeatMap/HeatMap.cypress.spec.tsx +0 -145
  128. package/src/Graph/Legend/Legend.tsx +0 -21
  129. package/src/Graph/Legend/index.ts +0 -1
  130. package/src/Graph/Legend/models.ts +0 -11
  131. package/src/Graph/PieChart/PieChart.cypress.spec.tsx +0 -169
  132. package/src/Graph/PieChart/PieChart.stories.tsx +0 -194
  133. package/src/Graph/PieChart/PieChart.styles.ts +0 -39
  134. package/src/Graph/PieChart/PieChart.tsx +0 -14
  135. package/src/Graph/PieChart/ResponsivePie.tsx +0 -254
  136. package/src/Graph/PieChart/index.ts +0 -1
  137. package/src/Graph/PieChart/models.ts +0 -20
  138. package/src/Graph/PieChart/useResponsivePie.ts +0 -85
  139. package/src/Graph/SingleBar/SingleBar.cypress.spec.tsx +0 -121
  140. package/src/Graph/Text/Text.cypress.spec.tsx +0 -101
  141. package/src/Graph/common/testUtils.ts +0 -71
  142. package/src/Graph/translatedLabels.ts +0 -1
  143. package/src/Module/Module.cypress.spec.tsx +0 -129
  144. package/src/Typography/FluidTypography/FluidTypography.cypress.spec.tsx +0 -27
  145. package/src/components/DataTable/DataListing.tsx +0 -6
  146. package/src/components/DataTable/DataTable.cypress.spec.tsx +0 -193
  147. package/src/components/Layout/PageLayout/PageQuickAccess.tsx +0 -76
  148. package/src/components/Layout/PageLayout.cypress.spec.tsx +0 -66
  149. package/src/utils/usePluralizedTranslation.ts +0 -21
@@ -1,254 +0,0 @@
1
- import { useRef } from 'react';
2
-
3
- import { Pie } from '@visx/shape';
4
- import { Group } from '@visx/group';
5
- import { Text } from '@visx/text';
6
- import numeral from 'numeral';
7
- import { always, equals, gt, ifElse, lt } from 'ramda';
8
- import { useTranslation } from 'react-i18next';
9
-
10
- import { Typography, useTheme } from '@mui/material';
11
-
12
- import { Tooltip } from '../../components';
13
- import { Legend as LegendComponent } from '../Legend';
14
- import { LegendProps } from '../Legend/models';
15
- import { getValueByUnit } from '../common/utils';
16
- import { labelNoDataFound as defaultlabelNoDataFound } from '../translatedLabels';
17
-
18
- import { PieProps } from './models';
19
- import { usePieStyles } from './PieChart.styles';
20
- import { useResponsivePie } from './useResponsivePie';
21
-
22
- const DefaultLengd = ({ scale, direction }: LegendProps): JSX.Element => (
23
- <LegendComponent direction={direction} scale={scale} />
24
- );
25
-
26
- type Placement = 'left' | 'right' | 'top' | 'bottom';
27
-
28
- const getTooltipPlacement = ({ radianX, radianY }): Placement => {
29
- if (gt(Math.abs(radianX), Math.abs(radianY))) {
30
- return ifElse<[b: number], Placement, Placement>(
31
- lt(0),
32
- always<Placement>('right'),
33
- always<Placement>('left')
34
- )(radianX);
35
- }
36
-
37
- return ifElse<[b: number], Placement, Placement>(
38
- lt(0),
39
- always<Placement>('bottom'),
40
- always<Placement>('top')
41
- )(radianY);
42
- };
43
-
44
- const ResponsivePie = ({
45
- title,
46
- variant = 'pie',
47
- width,
48
- height,
49
- data,
50
- unit = 'number',
51
- Legend = DefaultLengd,
52
- displayLegend = true,
53
- innerRadius: defaultInnerRadius = 40,
54
- onArcClick,
55
- displayValues,
56
- TooltipContent,
57
- legendDirection = 'column',
58
- labelNoDataFound = defaultlabelNoDataFound
59
- }: PieProps & { height: number; width: number }): JSX.Element => {
60
- const { t } = useTranslation();
61
- const theme = useTheme();
62
-
63
- const legendRef = useRef(null);
64
- const titleRef = useRef(null);
65
-
66
- const {
67
- half,
68
- legendScale,
69
- svgContainerSize,
70
- svgSize,
71
- svgWrapperWidth,
72
- total,
73
- innerRadius,
74
- isContainsExactlyOneNonZeroValue,
75
- areAllValuesNull
76
- } = useResponsivePie({
77
- data,
78
- defaultInnerRadius,
79
- height,
80
- legendRef,
81
- titleRef,
82
- unit,
83
- width
84
- });
85
-
86
- const { classes } = usePieStyles({ svgSize });
87
-
88
- if (areAllValuesNull) {
89
- return (
90
- <div className={classes.container} style={{ height, width }}>
91
- <Typography variant="h3">{t(labelNoDataFound)}</Typography>
92
- </div>
93
- );
94
- }
95
-
96
- return (
97
- <div
98
- className={classes.container}
99
- style={{
100
- height,
101
- width
102
- }}
103
- >
104
- <div
105
- className={classes.svgWrapper}
106
- style={{
107
- height,
108
- width: svgWrapperWidth
109
- }}
110
- >
111
- {equals(variant, 'pie') && title && (
112
- <div className={classes.title} data-testid="Title" ref={titleRef}>
113
- {`${numeral(total).format('0a').toUpperCase()} `} {t(title)}
114
- </div>
115
- )}
116
- <div
117
- className={classes.svgContainer}
118
- data-testid="pieChart"
119
- style={{
120
- height: svgContainerSize,
121
- width: svgContainerSize
122
- }}
123
- >
124
- <svg data-variant={variant} height={svgSize} width={svgSize}>
125
- <Group left={half} top={half}>
126
- <Pie
127
- cornerRadius={4}
128
- data={data}
129
- innerRadius={() => {
130
- return equals(variant, 'pie') ? 0 : half - innerRadius;
131
- }}
132
- outerRadius={half}
133
- pieValue={(items) => items.value}
134
- >
135
- {(pie) => {
136
- return pie.arcs.map((arc) => {
137
- const [centroidX, centroidY] = pie.path.centroid(arc);
138
- const midAngle = Math.atan2(centroidY, centroidX);
139
-
140
- const labelRadius = half * 0.8;
141
-
142
- const labelX = Math.cos(midAngle) * labelRadius;
143
- const labelY = Math.sin(midAngle) * labelRadius;
144
-
145
- const angle = arc.endAngle - arc.startAngle;
146
- const minAngle = 0.2;
147
-
148
- const x = equals(variant, 'donut') ? centroidX : labelX;
149
- const y = equals(variant, 'donut') ? centroidY : labelY;
150
-
151
- const onClick = (): void => {
152
- onArcClick?.(arc.data);
153
- };
154
-
155
- return (
156
- <Tooltip
157
- hasCaret
158
- classes={{
159
- tooltip: classes.pieChartTooltip
160
- }}
161
- followCursor={false}
162
- key={arc.data.label}
163
- label={
164
- TooltipContent && (
165
- <TooltipContent
166
- color={arc.data.color}
167
- label={arc.data.label}
168
- title={title}
169
- total={total}
170
- value={arc.data.value}
171
- />
172
- )
173
- }
174
- leaveDelay={200}
175
- placement={getTooltipPlacement({
176
- radianX: Math.cos(midAngle),
177
- radianY: Math.sin(midAngle)
178
- })}
179
- >
180
- <g data-testid={arc.data.label} onClick={onClick}>
181
- <path
182
- cursor="pointer"
183
- d={pie.path(arc) as string}
184
- fill={arc.data.color}
185
- />
186
- {displayValues &&
187
- !isContainsExactlyOneNonZeroValue &&
188
- angle > minAngle && (
189
- <Text
190
- data-testid="value"
191
- dy=".33em"
192
- fill="#000"
193
- fontSize={12}
194
- fontWeight={600}
195
- pointerEvents="none"
196
- textAnchor="middle"
197
- x={x}
198
- y={y}
199
- >
200
- {getValueByUnit({
201
- total,
202
- unit,
203
- value: arc.data.value
204
- })}
205
- </Text>
206
- )}
207
- </g>
208
- </Tooltip>
209
- );
210
- });
211
- }}
212
- </Pie>
213
- {equals(variant, 'donut') && title && (
214
- <>
215
- <Text
216
- className={classes.title}
217
- dy={lt(svgSize, 150) ? -10 : -15}
218
- fill={theme.palette.text.primary}
219
- textAnchor="middle"
220
- >
221
- {numeral(total).format('0a').toUpperCase()}
222
- </Text>
223
- <Text
224
- className={classes.title}
225
- data-testid="Title"
226
- dy={lt(svgSize, 150) ? 10 : 15}
227
- fill={theme.palette.text.primary}
228
- textAnchor="middle"
229
- >
230
- {t(title)}
231
- </Text>
232
- </>
233
- )}
234
- </Group>
235
- </svg>
236
- </div>
237
- </div>
238
- {displayLegend && (
239
- <div data-testid="Legend" ref={legendRef}>
240
- <Legend
241
- data={data}
242
- direction={legendDirection}
243
- scale={legendScale}
244
- title={title}
245
- total={total}
246
- unit={unit}
247
- />
248
- </div>
249
- )}
250
- </div>
251
- );
252
- };
253
-
254
- export default ResponsivePie;
@@ -1 +0,0 @@
1
- export { default as PieChart } from './PieChart';
@@ -1,20 +0,0 @@
1
- export interface ArcType {
2
- color: string;
3
- label: string;
4
- value: number;
5
- }
6
-
7
- export interface PieProps {
8
- Legend?: ({ scale, direction, data, title, total, unit }) => JSX.Element;
9
- TooltipContent?: (arcData) => JSX.Element | boolean | null;
10
- data: Array<ArcType>;
11
- displayLegend?: boolean;
12
- displayValues?: boolean;
13
- innerRadius?: number;
14
- labelNoDataFound?: string;
15
- legendDirection?: 'row' | 'column';
16
- onArcClick?: (ardata) => void;
17
- title?: string;
18
- unit?: 'percentage' | 'number';
19
- variant?: 'pie' | 'donut';
20
- }
@@ -1,85 +0,0 @@
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 svgContainerSize = Math.min(
45
- height - heightOfTitle - verticalGap,
46
- width - widthOfLegend - horizontalGap
47
- );
48
- const svgWrapperWidth = svgContainerSize;
49
-
50
- const outerRadius = Math.min(32, svgContainerSize / 6);
51
-
52
- const svgSize = svgContainerSize - outerRadius;
53
-
54
- const half = svgSize / 2;
55
-
56
- const total = Math.floor(data.reduce((acc, { value }) => acc + value, 0));
57
-
58
- const innerRadius = Math.min(defaultInnerRadius, svgSize / 5);
59
-
60
- const legendScale = {
61
- domain: data.map(({ value }) => getValueByUnit({ total, unit, value })),
62
- range: pluck('color', data)
63
- };
64
-
65
- const values = pluck('value', data);
66
-
67
- const isContainsExactlyOneNonZeroValue = equals(
68
- reject((value) => equals(value, 0), values).length,
69
- 1
70
- );
71
-
72
- const areAllValuesNull = isEmpty(reject((value) => equals(value, 0), values));
73
-
74
- return {
75
- areAllValuesNull,
76
- half,
77
- innerRadius,
78
- isContainsExactlyOneNonZeroValue,
79
- legendScale,
80
- svgContainerSize,
81
- svgSize,
82
- svgWrapperWidth,
83
- total
84
- };
85
- };
@@ -1,121 +0,0 @@
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
- });
@@ -1,101 +0,0 @@
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
- });
@@ -1,71 +0,0 @@
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
- };
@@ -1 +0,0 @@
1
- export const labelNoDataFound = 'No Data Available';