Commit 611d416f by Steven Vachon Committed by GitHub

Selector improvements for E2E (#27271)

parent 7d72837d
...@@ -125,7 +125,9 @@ export const Pages = { ...@@ -125,7 +125,9 @@ export const Pages = {
url: '/explore', url: '/explore',
General: { General: {
container: 'Explore', container: 'Explore',
graph: 'Explore Graph',
runButton: 'Run button', runButton: 'Run button',
table: 'Explore Table',
}, },
Toolbar: { Toolbar: {
navBar: '.explore-toolbar', navBar: '.explore-toolbar',
......
...@@ -13,6 +13,7 @@ import { GraphDimensions } from './GraphTooltip/types'; ...@@ -13,6 +13,7 @@ import { GraphDimensions } from './GraphTooltip/types';
import { graphTimeFormat, graphTickFormatter } from './utils'; import { graphTimeFormat, graphTickFormatter } from './utils';
export interface GraphProps { export interface GraphProps {
ariaLabel?: string;
children?: JSX.Element | JSX.Element[]; children?: JSX.Element | JSX.Element[];
series: GraphSeriesXY[]; series: GraphSeriesXY[];
timeRange: TimeRange; // NOTE: we should aim to make `time` a property of the axis, not force it for all graphs timeRange: TimeRange; // NOTE: we should aim to make `time` a property of the axis, not force it for all graphs
...@@ -361,12 +362,12 @@ export class Graph extends PureComponent<GraphProps, GraphState> { ...@@ -361,12 +362,12 @@ export class Graph extends PureComponent<GraphProps, GraphState> {
} }
render() { render() {
const { height, width, series } = this.props; const { ariaLabel, height, width, series } = this.props;
const noDataToBeDisplayed = series.length === 0; const noDataToBeDisplayed = series.length === 0;
const tooltip = this.renderTooltip(); const tooltip = this.renderTooltip();
const context = this.renderContextMenu(); const context = this.renderContextMenu();
return ( return (
<div className="graph-panel"> <div className="graph-panel" aria-label={ariaLabel}>
<div <div
className="graph-panel__chart" className="graph-panel__chart"
ref={e => (this.element = e)} ref={e => (this.element = e)}
......
...@@ -73,6 +73,7 @@ export const GraphWithLegend: React.FunctionComponent<GraphWithLegendProps> = (p ...@@ -73,6 +73,7 @@ export const GraphWithLegend: React.FunctionComponent<GraphWithLegendProps> = (p
onHorizontalRegionSelected, onHorizontalRegionSelected,
timeZone, timeZone,
children, children,
ariaLabel,
} = props; } = props;
const { graphContainer, wrapper, legendContainer } = getGraphWithLegendStyles(props); const { graphContainer, wrapper, legendContainer } = getGraphWithLegendStyles(props);
...@@ -91,7 +92,7 @@ export const GraphWithLegend: React.FunctionComponent<GraphWithLegendProps> = (p ...@@ -91,7 +92,7 @@ export const GraphWithLegend: React.FunctionComponent<GraphWithLegendProps> = (p
}, []); }, []);
return ( return (
<div className={wrapper}> <div className={wrapper} aria-label={ariaLabel}>
<div className={graphContainer}> <div className={graphContainer}>
<Graph <Graph
series={series} series={series}
......
...@@ -28,6 +28,7 @@ import { CustomScrollbar } from '../CustomScrollbar/CustomScrollbar'; ...@@ -28,6 +28,7 @@ import { CustomScrollbar } from '../CustomScrollbar/CustomScrollbar';
const COLUMN_MIN_WIDTH = 150; const COLUMN_MIN_WIDTH = 150;
export interface Props { export interface Props {
ariaLabel?: string;
data: DataFrame; data: DataFrame;
width: number; width: number;
height: number; height: number;
...@@ -111,6 +112,7 @@ function getInitialState(props: Props, columns: Column[]): Partial<ReactTableInt ...@@ -111,6 +112,7 @@ function getInitialState(props: Props, columns: Column[]): Partial<ReactTableInt
export const Table: FC<Props> = memo((props: Props) => { export const Table: FC<Props> = memo((props: Props) => {
const { const {
ariaLabel,
data, data,
height, height,
onCellFilterAdded, onCellFilterAdded,
...@@ -182,7 +184,7 @@ export const Table: FC<Props> = memo((props: Props) => { ...@@ -182,7 +184,7 @@ export const Table: FC<Props> = memo((props: Props) => {
const headerHeight = noHeader ? 0 : tableStyles.cellHeight; const headerHeight = noHeader ? 0 : tableStyles.cellHeight;
return ( return (
<div {...getTableProps()} className={tableStyles.table}> <div {...getTableProps()} className={tableStyles.table} aria-label={ariaLabel}>
<CustomScrollbar hideVerticalTrack={true}> <CustomScrollbar hideVerticalTrack={true}>
<div style={{ width: `${totalColumnsWidth}px` }}> <div style={{ width: `${totalColumnsWidth}px` }}>
{!noHeader && ( {!noHeader && (
......
...@@ -389,6 +389,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> { ...@@ -389,6 +389,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
<> <>
{showMetrics && ( {showMetrics && (
<ExploreGraphPanel <ExploreGraphPanel
ariaLabel={selectors.pages.Explore.General.graph}
series={graphResult} series={graphResult}
width={width} width={width}
loading={loading} loading={loading}
...@@ -406,6 +407,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> { ...@@ -406,6 +407,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
)} )}
{showTable && ( {showTable && (
<TableContainer <TableContainer
ariaLabel={selectors.pages.Explore.General.table}
width={width} width={width}
exploreId={exploreId} exploreId={exploreId}
onCellFilterAdded={ onCellFilterAdded={
......
...@@ -40,6 +40,7 @@ const getStyles = (theme: GrafanaTheme) => ({ ...@@ -40,6 +40,7 @@ const getStyles = (theme: GrafanaTheme) => ({
}); });
interface Props extends Themeable { interface Props extends Themeable {
ariaLabel?: string;
series?: GraphSeriesXY[] | null; series?: GraphSeriesXY[] | null;
width: number; width: number;
absoluteRange: AbsoluteTimeRange; absoluteRange: AbsoluteTimeRange;
...@@ -87,6 +88,7 @@ class UnThemedExploreGraphPanel extends PureComponent<Props, State> { ...@@ -87,6 +88,7 @@ class UnThemedExploreGraphPanel extends PureComponent<Props, State> {
renderGraph = () => { renderGraph = () => {
const { const {
ariaLabel,
width, width,
series, series,
onHiddenSeriesChanged, onHiddenSeriesChanged,
...@@ -123,6 +125,7 @@ class UnThemedExploreGraphPanel extends PureComponent<Props, State> { ...@@ -123,6 +125,7 @@ class UnThemedExploreGraphPanel extends PureComponent<Props, State> {
{({ onSeriesToggle, toggledSeries }: GraphSeriesTogglerAPI) => { {({ onSeriesToggle, toggledSeries }: GraphSeriesTogglerAPI) => {
return ( return (
<GraphWithLegend <GraphWithLegend
ariaLabel={ariaLabel}
displayMode={LegendDisplayMode.List} displayMode={LegendDisplayMode.List}
height={height} height={height}
isLegendVisible={true} isLegendVisible={true}
......
...@@ -13,6 +13,7 @@ import { FilterItem } from '@grafana/ui/src/components/Table/types'; ...@@ -13,6 +13,7 @@ import { FilterItem } from '@grafana/ui/src/components/Table/types';
import { getFieldLinksForExplore } from './utils/links'; import { getFieldLinksForExplore } from './utils/links';
interface TableContainerProps { interface TableContainerProps {
ariaLabel?: string;
exploreId: ExploreId; exploreId: ExploreId;
loading: boolean; loading: boolean;
width: number; width: number;
...@@ -41,7 +42,7 @@ export class TableContainer extends PureComponent<TableContainerProps> { ...@@ -41,7 +42,7 @@ export class TableContainer extends PureComponent<TableContainerProps> {
} }
render() { render() {
const { loading, onCellFilterAdded, showingTable, tableResult, width, splitOpen, range } = this.props; const { loading, onCellFilterAdded, showingTable, tableResult, width, splitOpen, range, ariaLabel } = this.props;
const height = this.getTableHeight(); const height = this.getTableHeight();
const tableWidth = width - config.theme.panelPadding * 2 - PANEL_BORDER; const tableWidth = width - config.theme.panelPadding * 2 - PANEL_BORDER;
...@@ -61,7 +62,13 @@ export class TableContainer extends PureComponent<TableContainerProps> { ...@@ -61,7 +62,13 @@ export class TableContainer extends PureComponent<TableContainerProps> {
return ( return (
<Collapse label="Table" loading={loading} collapsible isOpen={showingTable} onToggle={this.onClickTableButton}> <Collapse label="Table" loading={loading} collapsible isOpen={showingTable} onToggle={this.onClickTableButton}>
{hasTableResult ? ( {hasTableResult ? (
<Table data={tableResult!} width={tableWidth} height={height} onCellFilterAdded={onCellFilterAdded} /> <Table
ariaLabel={ariaLabel}
data={tableResult!}
width={tableWidth}
height={height}
onCellFilterAdded={onCellFilterAdded}
/>
) : ( ) : (
<MetaInfoText metaItems={[{ value: '0 series returned' }]} /> <MetaInfoText metaItems={[{ value: '0 series returned' }]} />
)} )}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment