Chore: Refactor dataviz aria-label e2e selectors to data-testid (#78938)

Co-authored-by: nmarrs <nathanielmarrs@gmail.com>
This commit is contained in:
Khushi Jain
2023-12-17 05:40:04 +05:30
committed by GitHub
parent dba690d653
commit 54dc5846c2
14 changed files with 30 additions and 39 deletions

View File

@@ -21,10 +21,10 @@ describe('Legend', () => {
},
] as NodeDatum[];
render(<Legend nodes={nodes} onSort={(sort) => {}} sortable={false} />);
const items = screen.getAllByLabelText(/VizLegend series/);
const items = screen.getAllByTestId(/VizLegend series/);
expect(items.length).toBe(3);
const item = screen.getByLabelText(/VizLegend series error/);
const item = screen.getByTestId(/VizLegend series error/);
expect((item.firstChild as HTMLDivElement).style.getPropertyValue('background')).toBe('rgb(242, 73, 92)');
});
});

View File

@@ -249,7 +249,7 @@ function PieSlice({ arc, pie, highlightState, openMenu, fill, tooltip, tooltipOp
onMouseMove={tooltipOptions.mode !== 'none' ? onMouseMoveOverArc : undefined}
onMouseOut={onMouseOut}
onClick={openMenu}
aria-label={selectors.components.Panels.Visualization.PieChart.svgSlice}
data-testid={selectors.components.Panels.Visualization.PieChart.svgSlice}
>
<path d={pie.path({ ...arc })!} fill={fill} stroke={theme.colors.background.primary} strokeWidth={1} />
</g>

View File

@@ -60,7 +60,7 @@ describe('PieChartPanel', () => {
it('should not filter out any slices or legend items', () => {
setup({ data: { series: seriesWithNoOverrides } });
const slices = screen.queryAllByLabelText('Pie Chart Slice');
const slices = screen.queryAllByTestId('data testid Pie Chart Slice');
expect(slices.length).toBe(3);
expect(screen.queryByText(/Chrome/i)).toBeInTheDocument();
expect(screen.queryByText(/Firefox/i)).toBeInTheDocument();
@@ -92,7 +92,7 @@ describe('PieChartPanel', () => {
it('should filter out the Firefox pie chart slice but not the legend', () => {
setup({ data: { series: seriesWithFirefoxOverride } });
const slices = screen.queryAllByLabelText('Pie Chart Slice');
const slices = screen.queryAllByTestId('data testid Pie Chart Slice');
expect(slices.length).toBe(2);
expect(screen.queryByText(/Firefox/i)).toBeInTheDocument();
});
@@ -122,13 +122,13 @@ describe('PieChartPanel', () => {
it('should filter out the Firefox series with value 190 from the multi tooltip', async () => {
setup({ data: { series: seriesWithFirefoxOverride } });
await userEvent.hover(screen.getAllByLabelText('Pie Chart Slice')[0]);
await userEvent.hover(screen.getAllByTestId('data testid Pie Chart Slice')[0]);
expect(screen.queryByText(/600/i)).toBeInTheDocument();
expect(screen.queryByText(/190/i)).not.toBeInTheDocument();
expect(screen.queryByText(/210/i)).toBeInTheDocument();
expect(screen.queryByText(/Firefox/i)).toBeInTheDocument();
const slices = screen.queryAllByLabelText('Pie Chart Slice');
const slices = screen.queryAllByTestId('data testid Pie Chart Slice');
expect(slices.length).toBe(3);
});
});
@@ -158,7 +158,7 @@ describe('PieChartPanel', () => {
setup({ data: { series: seriesWithFirefoxOverride } });
expect(screen.queryByText(/Firefox/i)).not.toBeInTheDocument();
const slices = screen.queryAllByLabelText('Pie Chart Slice');
const slices = screen.queryAllByTestId('data testid Pie Chart Slice');
expect(slices.length).toBe(3);
});
});

View File

@@ -220,7 +220,7 @@ export const ExemplarMarker = ({
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
className={styles.markerWrapper}
aria-label={selectors.components.DataSource.Prometheus.exemplarMarker}
data-testid={selectors.components.DataSource.Prometheus.exemplarMarker}
role="button"
tabIndex={0}
>