Piechart: add e2e test (#33737)

This commit is contained in:
Jack Westbrook 2021-05-05 14:02:55 +02:00 committed by GitHub
parent 7f63efb941
commit 34d81b7d13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,18 @@
import { e2e } from '@grafana/e2e';
import { selectors } from '@grafana/e2e-selectors';
e2e.scenario({
describeName: 'Pie Chart Panel',
itName: 'Pie Chart rendering e2e tests',
addScenarioDataSource: false,
addScenarioDashBoard: false,
skipScenario: false,
scenario: () => {
// open Panel Tests - Pie Chart
e2e.flows.openDashboard({ uid: 'lVE-2YFMz' });
e2e()
.get(`[data-panelid=11] [aria-label^="${selectors.components.Panels.Visualization.PieChart.svgSlice}"]`)
.should('have.length', 5);
},
});

View File

@ -44,6 +44,9 @@ export const Components = {
BarGauge: {
value: 'Bar gauge value',
},
PieChart: {
svgSlice: 'Pie Chart Slice',
},
Text: {
container: () => '.markdown-html',
},

View File

@ -8,6 +8,7 @@ import {
getFieldDisplayValues,
GrafanaTheme2,
} from '@grafana/data';
import { selectors } from '@grafana/e2e-selectors';
import { useStyles2, useTheme2 } from '../../themes/ThemeContext';
import tinycolor from 'tinycolor2';
import Pie, { PieArcDatum, ProvidedProps } from '@visx/shape/lib/shapes/Pie';
@ -317,6 +318,7 @@ function PieSlice({ arc, pie, highlighted, openMenu, fill, tooltip, tooltipOptio
onMouseMove={tooltipOptions.mode !== 'none' ? onMouseMoveOverArc : undefined}
onMouseOut={tooltip.hideTooltip}
onClick={openMenu}
aria-label={selectors.components.Panels.Visualization.PieChart.svgSlice}
>
<path d={pie.path({ ...arc })!} fill={fill} stroke={theme.colors.background.primary} strokeWidth={1} />
</g>