diff --git a/packages/grafana-e2e-selectors/src/selectors/components.ts b/packages/grafana-e2e-selectors/src/selectors/components.ts index 3df323cd340..d99fbf51667 100644 --- a/packages/grafana-e2e-selectors/src/selectors/components.ts +++ b/packages/grafana-e2e-selectors/src/selectors/components.ts @@ -183,7 +183,7 @@ export const Components = { QueryTab: { content: 'Query editor tab content', queryInspectorButton: 'Query inspector button', - queryHistoryButton: 'Rich history button', + queryHistoryButton: 'data-testid query-history-button', addQuery: 'Query editor add query button', }, QueryHistory: { diff --git a/public/app/features/explore/SecondaryActions.test.tsx b/public/app/features/explore/SecondaryActions.test.tsx index e5684b9a1c9..eb04be2fc40 100644 --- a/public/app/features/explore/SecondaryActions.test.tsx +++ b/public/app/features/explore/SecondaryActions.test.tsx @@ -15,9 +15,9 @@ describe('SecondaryActions', () => { /> ); - expect(screen.getByRole('button', { name: /Add row button/i })).toBeInTheDocument(); - expect(screen.getByRole('button', { name: /Rich history button/i })).toBeInTheDocument(); - expect(screen.getByRole('button', { name: /Query inspector button/i })).toBeInTheDocument(); + expect(screen.getByRole('button', { name: /Add query/i })).toBeInTheDocument(); + expect(screen.getByRole('button', { name: /Query history/i })).toBeInTheDocument(); + expect(screen.getByRole('button', { name: /Query inspector/i })).toBeInTheDocument(); }); it('should not render hidden elements', () => { @@ -31,9 +31,9 @@ describe('SecondaryActions', () => { /> ); - expect(screen.queryByRole('button', { name: /Add row button/i })).not.toBeInTheDocument(); - expect(screen.queryByRole('button', { name: /Rich history button/i })).not.toBeInTheDocument(); - expect(screen.getByRole('button', { name: /Query inspector button/i })).toBeInTheDocument(); + expect(screen.queryByRole('button', { name: /Add query/i })).not.toBeInTheDocument(); + expect(screen.queryByRole('button', { name: /Query history/i })).not.toBeInTheDocument(); + expect(screen.getByRole('button', { name: /Query inspector/i })).toBeInTheDocument(); }); it('should disable add row button if addQueryRowButtonDisabled=true', () => { @@ -46,9 +46,9 @@ describe('SecondaryActions', () => { /> ); - expect(screen.getByRole('button', { name: /Add row button/i })).toBeDisabled(); - expect(screen.getByRole('button', { name: /Rich history button/i })).toBeInTheDocument(); - expect(screen.getByRole('button', { name: /Query inspector button/i })).toBeInTheDocument(); + expect(screen.getByRole('button', { name: /Add query/i })).toBeDisabled(); + expect(screen.getByRole('button', { name: /Query history/i })).toBeInTheDocument(); + expect(screen.getByRole('button', { name: /Query inspector/i })).toBeInTheDocument(); }); it('should map click handlers correctly', async () => { @@ -66,13 +66,13 @@ describe('SecondaryActions', () => { /> ); - await user.click(screen.getByRole('button', { name: /Add row button/i })); + await user.click(screen.getByRole('button', { name: /Add query/i })); expect(onClickAddRow).toBeCalledTimes(1); - await user.click(screen.getByRole('button', { name: /Rich history button/i })); + await user.click(screen.getByRole('button', { name: /Query history/i })); expect(onClickHistory).toBeCalledTimes(1); - await user.click(screen.getByRole('button', { name: /Query inspector button/i })); + await user.click(screen.getByRole('button', { name: /Query inspector/i })); expect(onClickQueryInspector).toBeCalledTimes(1); }); }); diff --git a/public/app/features/explore/SecondaryActions.tsx b/public/app/features/explore/SecondaryActions.tsx index 8a9196800b1..f0f4d4fbb3e 100644 --- a/public/app/features/explore/SecondaryActions.tsx +++ b/public/app/features/explore/SecondaryActions.tsx @@ -2,6 +2,7 @@ import { css } from '@emotion/css'; import React from 'react'; import { GrafanaTheme2 } from '@grafana/data'; +import { Components } from '@grafana/e2e-selectors'; import { HorizontalGroup, ToolbarButton, useTheme2 } from '@grafana/ui'; type Props = { @@ -33,7 +34,7 @@ export function SecondaryActions(props: Props) { {!props.addQueryRowButtonHidden && ( Query history @@ -53,11 +55,11 @@ export function SecondaryActions(props: Props) { )} - Inspector + Query inspector diff --git a/public/app/features/explore/spec/helper/interactions.ts b/public/app/features/explore/spec/helper/interactions.ts index 82ed540b1b7..2213c82b09a 100644 --- a/public/app/features/explore/spec/helper/interactions.ts +++ b/public/app/features/explore/spec/helper/interactions.ts @@ -27,7 +27,7 @@ export const runQuery = async (exploreId = 'left') => { export const openQueryHistory = async (exploreId = 'left') => { const selector = withinExplore(exploreId); - const button = selector.getByRole('button', { name: 'Rich history button' }); + const button = selector.getByRole('button', { name: 'Query history' }); await userEvent.click(button); expect(await selector.findByPlaceholderText('Search queries')).toBeInTheDocument(); };