@centreon/ui 24.4.1-MON-34691-improve-code-coverage.26 → 24.4.1-MON-23368-containers.68
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/package.json +24 -27
- package/src/Form/Inputs/CheckboxGroup.tsx +4 -1
- package/src/Graph/Gauge/Gauge.tsx +1 -1
- package/src/Graph/HeatMap/HeatMap.stories.tsx +25 -0
- package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +2 -8
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/index.tsx +4 -5
- package/src/Graph/LineChart/InteractiveComponents/Annotations/Annotation/index.tsx +3 -2
- package/src/Graph/LineChart/Legend/Legend.styles.ts +1 -1
- package/src/Graph/LineChart/Legend/LegendHeader.tsx +1 -1
- package/src/Graph/LineChart/Legend/useInteractiveValues.ts +2 -2
- package/src/Graph/LineChart/index.tsx +1 -1
- package/src/Graph/Text/Text.tsx +1 -1
- package/src/Graph/common/timeSeries/index.ts +11 -19
- package/src/Graph/index.ts +0 -1
- package/src/Graph/Gauge/Gauge.cypress.spec.tsx +0 -102
- package/src/Graph/HeatMap/HeatMap.cypress.spec.tsx +0 -145
- package/src/Graph/SingleBar/SingleBar.cypress.spec.tsx +0 -121
- package/src/Graph/Text/Text.cypress.spec.tsx +0 -101
- package/src/Graph/common/testUtils.ts +0 -71
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "24.4.1-MON-
|
|
3
|
+
"version": "24.4.1-MON-23368-containers.68",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"author": {
|
|
29
29
|
"name": "centreon@centreon.com"
|
|
30
30
|
},
|
|
31
|
-
"baseCodeCoveragePercentage": 60,
|
|
32
31
|
"license": "GPL-2.0",
|
|
33
32
|
"bugs": {
|
|
34
33
|
"url": "https://github.com/centreon/centreon/issues"
|
|
@@ -48,11 +47,11 @@
|
|
|
48
47
|
"test/*"
|
|
49
48
|
],
|
|
50
49
|
"devDependencies": {
|
|
51
|
-
"@cypress/react": "^
|
|
52
|
-
"@cypress/webpack-dev-server": "^3.
|
|
50
|
+
"@cypress/react": "^8.0.0",
|
|
51
|
+
"@cypress/webpack-dev-server": "^3.7.3",
|
|
53
52
|
"@faker-js/faker": "^8.0.2",
|
|
54
|
-
"@mdx-js/react": "^
|
|
55
|
-
"@simonsmith/cypress-image-snapshot": "^
|
|
53
|
+
"@mdx-js/react": "^3.0.0",
|
|
54
|
+
"@simonsmith/cypress-image-snapshot": "^9.0.1",
|
|
56
55
|
"@storybook/addon-a11y": "^7.0.9",
|
|
57
56
|
"@storybook/addon-docs": "^7.0.9",
|
|
58
57
|
"@storybook/addon-essentials": "^7.0.9",
|
|
@@ -73,16 +72,15 @@
|
|
|
73
72
|
"@testing-library/jest-dom": "^5.16.5",
|
|
74
73
|
"@testing-library/react": "^13.4.0",
|
|
75
74
|
"@testing-library/react-hooks": "^8.0.1",
|
|
76
|
-
"@types/
|
|
77
|
-
"@types/jest": "^27.5.0",
|
|
75
|
+
"@types/jest": "^29.5.11",
|
|
78
76
|
"@types/mocha": "^10.0.6",
|
|
79
|
-
"@types/ramda": "^0.29.
|
|
80
|
-
"@types/react": "^18.
|
|
81
|
-
"@types/testing-library__jest-dom": "^
|
|
77
|
+
"@types/ramda": "^0.29.9",
|
|
78
|
+
"@types/react": "^18.2.48",
|
|
79
|
+
"@types/testing-library__jest-dom": "^6.0.0",
|
|
82
80
|
"@vitejs/plugin-react": "^4.0.0",
|
|
83
81
|
"@vitejs/plugin-react-swc": "^3.3.0",
|
|
84
|
-
"axios-mock-adapter": "^1.
|
|
85
|
-
"cypress": "^13.
|
|
82
|
+
"axios-mock-adapter": "^1.22.0",
|
|
83
|
+
"cypress": "^13.6.2",
|
|
86
84
|
"identity-obj-proxy": "^3.0.0",
|
|
87
85
|
"jest-transform-stub": "^2.0.0",
|
|
88
86
|
"mochawesome": "^7.1.3",
|
|
@@ -93,27 +91,26 @@
|
|
|
93
91
|
"react-dom": "^18.2.0",
|
|
94
92
|
"react-test-renderer": "^18.2.0",
|
|
95
93
|
"remark-gfm": "^3.0.1",
|
|
96
|
-
"sass": "^1.62.1",
|
|
97
94
|
"speed-measure-vite-plugin": "^0.1.2",
|
|
98
|
-
"storybook": "^7.
|
|
95
|
+
"storybook": "^7.6.8",
|
|
99
96
|
"storybook-addon-mock": "^4.0.0",
|
|
100
|
-
"storybook-dark-mode": "^3.0.
|
|
97
|
+
"storybook-dark-mode": "^3.0.3",
|
|
101
98
|
"style-dictionary": "^3.8.0",
|
|
102
|
-
"ts-node": "^10.9.
|
|
99
|
+
"ts-node": "^10.9.2",
|
|
103
100
|
"use-resize-observer": "^9.1.0",
|
|
104
101
|
"vite": "^4.3.5",
|
|
105
102
|
"vite-plugin-istanbul": "^5.0.0",
|
|
106
103
|
"vite-plugin-svgr": "^3.2.0",
|
|
107
|
-
"vite-plugin-turbosnap": "^1.0.
|
|
104
|
+
"vite-plugin-turbosnap": "^1.0.3"
|
|
108
105
|
},
|
|
109
106
|
"dependencies": {
|
|
110
|
-
"@lexical/html": "^0.12.
|
|
111
|
-
"@lexical/link": "^0.12.
|
|
112
|
-
"@lexical/list": "^0.12.
|
|
113
|
-
"@lexical/react": "^0.12.
|
|
114
|
-
"@lexical/rich-text": "^0.12.
|
|
115
|
-
"@lexical/selection": "^0.12.
|
|
116
|
-
"@lexical/utils": "^0.12.
|
|
107
|
+
"@lexical/html": "^0.12.6",
|
|
108
|
+
"@lexical/link": "^0.12.6",
|
|
109
|
+
"@lexical/list": "^0.12.6",
|
|
110
|
+
"@lexical/react": "^0.12.6",
|
|
111
|
+
"@lexical/rich-text": "^0.12.6",
|
|
112
|
+
"@lexical/selection": "^0.12.6",
|
|
113
|
+
"@lexical/utils": "^0.12.6",
|
|
117
114
|
"@react-spring/web": "^9.7.3",
|
|
118
115
|
"@visx/curve": "^2.1.0",
|
|
119
116
|
"@visx/group": "^3.3.0",
|
|
@@ -123,9 +120,9 @@
|
|
|
123
120
|
"@visx/threshold": "^2.12.2",
|
|
124
121
|
"@visx/visx": "2.16.0",
|
|
125
122
|
"anylogger": "^1.0.11",
|
|
126
|
-
"d3-array": "3.2.
|
|
123
|
+
"d3-array": "3.2.4",
|
|
127
124
|
"humanize-duration": "^3.27.3",
|
|
128
|
-
"lexical": "^0.12.
|
|
125
|
+
"lexical": "^0.12.6",
|
|
129
126
|
"notistack": "^3.0.1",
|
|
130
127
|
"ramda": "0.29.1",
|
|
131
128
|
"react-grid-layout": "^1.3.4",
|
|
@@ -3,6 +3,8 @@ import { makeStyles } from 'tss-react/mui';
|
|
|
3
3
|
|
|
4
4
|
import { Box, Typography } from '@mui/material';
|
|
5
5
|
|
|
6
|
+
import EllipsisTypography from '../../Typography/EllipsisTypography';
|
|
7
|
+
|
|
6
8
|
import heatMapData from './HeatMapData.json';
|
|
7
9
|
|
|
8
10
|
import { HeatMap } from '.';
|
|
@@ -20,6 +22,29 @@ const meta: Meta<typeof HeatMap<Data>> = {
|
|
|
20
22
|
export default meta;
|
|
21
23
|
type Story = StoryObj<typeof HeatMap<Data>>;
|
|
22
24
|
|
|
25
|
+
const TileContent = ({
|
|
26
|
+
isSmallestSize,
|
|
27
|
+
data
|
|
28
|
+
}: {
|
|
29
|
+
data: Data;
|
|
30
|
+
isSmallestSize: boolean;
|
|
31
|
+
}): JSX.Element | false =>
|
|
32
|
+
!isSmallestSize && (
|
|
33
|
+
<Box
|
|
34
|
+
sx={{
|
|
35
|
+
alignItems: 'center',
|
|
36
|
+
color: 'common.black',
|
|
37
|
+
display: 'flex',
|
|
38
|
+
flexDirection: 'column',
|
|
39
|
+
width: '100%'
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
<EllipsisTypography textAlign="center">{data.host}</EllipsisTypography>
|
|
43
|
+
<EllipsisTypography textAlign="center">{data.service}</EllipsisTypography>
|
|
44
|
+
<EllipsisTypography textAlign="center">{data.counter}</EllipsisTypography>
|
|
45
|
+
</Box>
|
|
46
|
+
);
|
|
47
|
+
|
|
23
48
|
const TooltipContent = ({ data }: { data: Data }): JSX.Element => {
|
|
24
49
|
return (
|
|
25
50
|
<Box sx={{ backgroundColor: 'common.white', color: 'common.black' }}>
|
|
@@ -40,7 +40,7 @@ const ResponsiveHeatMap = <TData,>({
|
|
|
40
40
|
const theoricalTotalTilesWidth =
|
|
41
41
|
tilesLength * tileWidth + (tilesLength - 1) * gap;
|
|
42
42
|
|
|
43
|
-
if (lt(width, 680) && gt(maxTotalTilesWidth, width)
|
|
43
|
+
if (lt(width, 680) && gt(maxTotalTilesWidth, width)) {
|
|
44
44
|
return smallestTileSize;
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -66,19 +66,13 @@ const ResponsiveHeatMap = <TData,>({
|
|
|
66
66
|
}}
|
|
67
67
|
>
|
|
68
68
|
{tiles.map(({ backgroundColor, id, data }) => (
|
|
69
|
-
<Box
|
|
70
|
-
className={classes.heatMapTile}
|
|
71
|
-
data-testid={id}
|
|
72
|
-
key={id}
|
|
73
|
-
sx={{ backgroundColor }}
|
|
74
|
-
>
|
|
69
|
+
<Box className={classes.heatMapTile} key={id} sx={{ backgroundColor }}>
|
|
75
70
|
<Tooltip
|
|
76
71
|
hasCaret
|
|
77
72
|
classes={{
|
|
78
73
|
arrow: cx(classes.heatMapTooltipArrow, arrowClassName),
|
|
79
74
|
tooltip: classes.heatMapTooltip
|
|
80
75
|
}}
|
|
81
|
-
data-testid={`tooltip-${data?.id}`}
|
|
82
76
|
followCursor={false}
|
|
83
77
|
label={
|
|
84
78
|
displayTooltipCondition?.(data) &&
|
|
@@ -130,11 +130,10 @@ const WrapperThresholdLines = ({
|
|
|
130
130
|
|
|
131
131
|
return (
|
|
132
132
|
<g>
|
|
133
|
-
{filteredThresholdLines.map(
|
|
134
|
-
(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
))
|
|
133
|
+
{filteredThresholdLines.map((element) =>
|
|
134
|
+
element?.map(({ Component, props, key }) => (
|
|
135
|
+
<Component {...props} id={key} key={key} />
|
|
136
|
+
))
|
|
138
137
|
)}
|
|
139
138
|
</g>
|
|
140
139
|
);
|
|
@@ -43,8 +43,9 @@ const Annotation = ({
|
|
|
43
43
|
|
|
44
44
|
const setAnnotationHovered = useSetAtom(annotationHoveredAtom);
|
|
45
45
|
|
|
46
|
-
const content = `${truncate(event.content)} (${t(labelBy)} ${
|
|
47
|
-
?.name
|
|
46
|
+
const content = `${truncate(event.content)} (${t(labelBy)} ${
|
|
47
|
+
event.contact?.name
|
|
48
|
+
})`;
|
|
48
49
|
|
|
49
50
|
return (
|
|
50
51
|
<g>
|
|
@@ -8,7 +8,7 @@ interface MakeStylesProps {
|
|
|
8
8
|
|
|
9
9
|
export const legendWidth = 21;
|
|
10
10
|
const legendItemHeight = 5.25;
|
|
11
|
-
const legendItemHeightCompact =
|
|
11
|
+
const legendItemHeightCompact = 1.75;
|
|
12
12
|
|
|
13
13
|
export const useStyles = makeStyles<MakeStylesProps>()(
|
|
14
14
|
(theme, { limitLegendRows }) => ({
|
|
@@ -5,7 +5,7 @@ import { equals, find, isNil } from 'ramda';
|
|
|
5
5
|
|
|
6
6
|
import { mousePositionAtom } from '../InteractiveComponents/interactionWithGraphAtoms';
|
|
7
7
|
import {
|
|
8
|
-
|
|
8
|
+
formatMetricValue,
|
|
9
9
|
getLineForMetric,
|
|
10
10
|
getMetrics,
|
|
11
11
|
getTimeValue
|
|
@@ -73,7 +73,7 @@ const useInteractiveValues = ({
|
|
|
73
73
|
metric_id
|
|
74
74
|
}) as Line;
|
|
75
75
|
|
|
76
|
-
const formattedValue =
|
|
76
|
+
const formattedValue = formatMetricValue({
|
|
77
77
|
base,
|
|
78
78
|
unit,
|
|
79
79
|
value
|
package/src/Graph/Text/Text.tsx
CHANGED
|
@@ -476,7 +476,15 @@ const registerMsUnitToNumeral = (): null => {
|
|
|
476
476
|
|
|
477
477
|
registerMsUnitToNumeral();
|
|
478
478
|
|
|
479
|
-
const
|
|
479
|
+
const formatMetricValue = ({
|
|
480
|
+
value,
|
|
481
|
+
unit,
|
|
482
|
+
base = 1000
|
|
483
|
+
}: FormatMetricValueProps): string | null => {
|
|
484
|
+
if (isNil(value)) {
|
|
485
|
+
return null;
|
|
486
|
+
}
|
|
487
|
+
|
|
480
488
|
const base2Units = [
|
|
481
489
|
'B',
|
|
482
490
|
'bytes',
|
|
@@ -489,19 +497,7 @@ const getBase1024 = ({ unit, base }): boolean => {
|
|
|
489
497
|
'b'
|
|
490
498
|
];
|
|
491
499
|
|
|
492
|
-
|
|
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 });
|
|
500
|
+
const base1024 = base2Units.includes(unit) || Number(base) === 1024;
|
|
505
501
|
|
|
506
502
|
const formatSuffix = cond([
|
|
507
503
|
[equals('ms'), always(' ms')],
|
|
@@ -529,8 +525,6 @@ const formatMetricValueWithUnit = ({
|
|
|
529
525
|
return null;
|
|
530
526
|
}
|
|
531
527
|
|
|
532
|
-
const base1024 = getBase1024({ base, unit });
|
|
533
|
-
|
|
534
528
|
if (isRaw) {
|
|
535
529
|
const unitText = equals('%', unit) ? unit : ` ${unit}`;
|
|
536
530
|
|
|
@@ -543,9 +537,7 @@ const formatMetricValueWithUnit = ({
|
|
|
543
537
|
|
|
544
538
|
const formattedMetricValue = formatMetricValue({ base, unit, value });
|
|
545
539
|
|
|
546
|
-
return
|
|
547
|
-
? formattedMetricValue
|
|
548
|
-
: `${formattedMetricValue} ${unit}`;
|
|
540
|
+
return formattedMetricValue;
|
|
549
541
|
};
|
|
550
542
|
|
|
551
543
|
const getStackedYScale = ({
|
package/src/Graph/index.ts
CHANGED
|
@@ -1,102 +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 { Props, Gauge } from './Gauge';
|
|
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
|
-
<Gauge
|
|
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('Gauge', () => {
|
|
32
|
-
it('does not display the gauge when there is no data', () => {
|
|
33
|
-
initialize({ data: undefined, thresholds: successThresholds });
|
|
34
|
-
|
|
35
|
-
cy.contains('0.41 s').should('not.exist');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('displays the gauge as success when corresponding thresholds are set', () => {
|
|
39
|
-
initialize({ thresholds: successThresholds });
|
|
40
|
-
|
|
41
|
-
cy.contains('0.41 s').should('have.css', 'fill', 'rgb(136, 185, 34)');
|
|
42
|
-
cy.findByTestId('1.1500000000000001-arc').should('be.visible');
|
|
43
|
-
cy.findByTestId('0.15000000000000013-arc').should('be.visible');
|
|
44
|
-
|
|
45
|
-
cy.makeSnapshot();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('displays the gauge as warning when corresponding thresholds are set', () => {
|
|
49
|
-
initialize({ thresholds: warningThresholds });
|
|
50
|
-
|
|
51
|
-
cy.contains('0.41 s').should('have.css', 'fill', 'rgb(253, 155, 39)');
|
|
52
|
-
cy.findByTestId('1.25-arc').should('be.visible');
|
|
53
|
-
cy.findByTestId('0.15000000000000013-arc').should('be.visible');
|
|
54
|
-
|
|
55
|
-
cy.makeSnapshot();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('displays the gauge as critical when corresponding thresholds are set', () => {
|
|
59
|
-
initialize({ thresholds: criticalThresholds });
|
|
60
|
-
|
|
61
|
-
cy.contains('0.41 s').should('have.css', 'fill', 'rgb(255, 74, 74)');
|
|
62
|
-
cy.findByTestId('0.6399999999999999-arc').should('be.visible');
|
|
63
|
-
cy.findByTestId('0.54-arc').should('be.visible');
|
|
64
|
-
|
|
65
|
-
cy.makeSnapshot();
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('displays ranged thresholds', () => {
|
|
69
|
-
initialize({ thresholds: rangedThresholds });
|
|
70
|
-
|
|
71
|
-
cy.findByTestId('0.37-arc').should('be.visible');
|
|
72
|
-
cy.findByTestId('0.09999999999999998-arc').should('be.visible');
|
|
73
|
-
|
|
74
|
-
cy.makeSnapshot();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('displays the threshold tooltip when a threshold is hovered', () => {
|
|
78
|
-
initialize({ thresholds: successThresholds });
|
|
79
|
-
|
|
80
|
-
cy.findByTestId('1.1500000000000001-arc').trigger('mouseover', {
|
|
81
|
-
force: true
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
cy.contains('Warning').should('be.visible');
|
|
85
|
-
|
|
86
|
-
cy.findByTestId('0.15000000000000013-arc').trigger('mouseover', {
|
|
87
|
-
force: true
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
cy.contains('Critical').should('be.visible');
|
|
91
|
-
|
|
92
|
-
cy.makeSnapshot();
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('displays the value as raw when the prop is set', () => {
|
|
96
|
-
initialize({ displayAsRaw: true, thresholds: successThresholds });
|
|
97
|
-
|
|
98
|
-
cy.contains('0.40663333333 s').should('be.visible');
|
|
99
|
-
|
|
100
|
-
cy.makeSnapshot();
|
|
101
|
-
});
|
|
102
|
-
});
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { pluck } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import { Box, Typography } from '@mui/material';
|
|
4
|
-
|
|
5
|
-
import EllipsisTypography from '../../Typography/EllipsisTypography';
|
|
6
|
-
|
|
7
|
-
import HeatMap from './HeatMap';
|
|
8
|
-
import heatMapData from './HeatMapData.json';
|
|
9
|
-
import { HeatMapProps } from './model';
|
|
10
|
-
|
|
11
|
-
const dataIds = pluck('id', heatMapData);
|
|
12
|
-
|
|
13
|
-
interface Data {
|
|
14
|
-
counter: number;
|
|
15
|
-
host: string;
|
|
16
|
-
service: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const TileContent = ({
|
|
20
|
-
isSmallestSize,
|
|
21
|
-
data
|
|
22
|
-
}: {
|
|
23
|
-
data: Data;
|
|
24
|
-
isSmallestSize: boolean;
|
|
25
|
-
}): JSX.Element | false =>
|
|
26
|
-
!isSmallestSize && (
|
|
27
|
-
<Box
|
|
28
|
-
sx={{
|
|
29
|
-
alignItems: 'center',
|
|
30
|
-
color: 'common.black',
|
|
31
|
-
display: 'flex',
|
|
32
|
-
flexDirection: 'column',
|
|
33
|
-
width: '100%'
|
|
34
|
-
}}
|
|
35
|
-
>
|
|
36
|
-
<EllipsisTypography textAlign="center">{data.host}</EllipsisTypography>
|
|
37
|
-
<EllipsisTypography textAlign="center">{data.service}</EllipsisTypography>
|
|
38
|
-
<EllipsisTypography textAlign="center">{data.counter}</EllipsisTypography>
|
|
39
|
-
</Box>
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
const initialize = ({
|
|
43
|
-
width = '100vw',
|
|
44
|
-
height = '100vh',
|
|
45
|
-
...args
|
|
46
|
-
}: Omit<HeatMapProps<Data>, 'tiles' | 'children'> & {
|
|
47
|
-
height?: string;
|
|
48
|
-
width?: string;
|
|
49
|
-
}): void => {
|
|
50
|
-
cy.mount({
|
|
51
|
-
Component: (
|
|
52
|
-
<div style={{ height, width }}>
|
|
53
|
-
<HeatMap tiles={heatMapData} {...args}>
|
|
54
|
-
{TileContent}
|
|
55
|
-
</HeatMap>
|
|
56
|
-
</div>
|
|
57
|
-
)
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
describe('HeatMap', () => {
|
|
62
|
-
it('displays tiles', () => {
|
|
63
|
-
initialize({});
|
|
64
|
-
dataIds.forEach((id) => {
|
|
65
|
-
cy.findByTestId(id).should('be.visible');
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('does not display the tooltip when the prop is not set and the tile is hovered', () => {
|
|
70
|
-
initialize({});
|
|
71
|
-
|
|
72
|
-
cy.findByTestId(dataIds[0]).trigger('mouseover');
|
|
73
|
-
|
|
74
|
-
cy.findByTestId(`tooltip-${dataIds[0]}`).should('not.exist');
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('displays the tooltip when the prop is set and the tile is hovered', () => {
|
|
78
|
-
initialize({
|
|
79
|
-
tooltipContent: ({ data }) => (
|
|
80
|
-
<Typography>
|
|
81
|
-
This is the tooltip for {data.host}-{data.service}-{data.counter}
|
|
82
|
-
</Typography>
|
|
83
|
-
)
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
cy.findByTestId(dataIds[0]).trigger('mouseover');
|
|
87
|
-
|
|
88
|
-
cy.contains(`This is the tooltip for Server-Service Counter-53`).should(
|
|
89
|
-
'be.visible'
|
|
90
|
-
);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('displays the tooltip conditionally when the prop is set and the tile is hovered', () => {
|
|
94
|
-
initialize({
|
|
95
|
-
displayTooltipCondition: ({ counter }) => counter > 100,
|
|
96
|
-
tooltipContent: ({ data }) => (
|
|
97
|
-
<Typography>
|
|
98
|
-
This is the tooltip for {data.host}-{data.service}-{data.counter}
|
|
99
|
-
</Typography>
|
|
100
|
-
)
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
cy.findByTestId(dataIds[0]).trigger('mouseover');
|
|
104
|
-
|
|
105
|
-
cy.contains(`This is the tooltip for Server-Service Counter-53`).should(
|
|
106
|
-
'not.exist'
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
cy.findByTestId(dataIds[1]).trigger('mouseover');
|
|
110
|
-
|
|
111
|
-
cy.contains(`This is the tooltip for Server-Service Counter-779`).should(
|
|
112
|
-
'be.visible'
|
|
113
|
-
);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('displays tiles with fixed size', () => {
|
|
117
|
-
initialize({ height: '200px', tileSizeFixed: true, width: '590px' });
|
|
118
|
-
dataIds.forEach((id) => {
|
|
119
|
-
cy.findByTestId(id).should('be.visible');
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('displays tiles as small when the container width is under the breakpoint', () => {
|
|
124
|
-
initialize({ height: '200px', width: '590px' });
|
|
125
|
-
dataIds.forEach((id) => {
|
|
126
|
-
cy.findByTestId(id).should('be.visible');
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
cy.makeSnapshot();
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('does not display tiles as small when the contains width is 0', () => {
|
|
133
|
-
initialize({ height: '200px', width: '0px' });
|
|
134
|
-
dataIds.forEach((id) => {
|
|
135
|
-
cy.findByTestId(id).should('not.exist');
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
cy.makeSnapshot();
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('displays a single tile', () => {
|
|
142
|
-
initialize({ tiles: [heatMapData[0]] });
|
|
143
|
-
cy.findByTestId(dataIds[0]).should('be.visible');
|
|
144
|
-
});
|
|
145
|
-
});
|
|
@@ -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
|
-
};
|