From 53867e3fcdaec140736441963390d51c2a75c9a9 Mon Sep 17 00:00:00 2001 From: Giordano Ricci Date: Tue, 22 Aug 2023 14:47:45 +0100 Subject: [PATCH] Dashboards: relabel add query button (#73607) --- .betterer.results | 3 +-- packages/grafana-e2e-selectors/src/selectors/components.ts | 2 +- public/app/features/query/components/QueryGroup.test.tsx | 6 +++--- public/app/features/query/components/QueryGroup.tsx | 5 ++--- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.betterer.results b/.betterer.results index 35f20e39fac..dca9ab54b73 100644 --- a/.betterer.results +++ b/.betterer.results @@ -2859,8 +2859,7 @@ exports[`better eslint`] = { ], "public/app/features/query/components/QueryGroup.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"], - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"], - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "2"] + [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"] ], "public/app/features/query/state/DashboardQueryRunner/AlertStatesWorker.test.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], diff --git a/packages/grafana-e2e-selectors/src/selectors/components.ts b/packages/grafana-e2e-selectors/src/selectors/components.ts index d99fbf51667..adef35cd7c4 100644 --- a/packages/grafana-e2e-selectors/src/selectors/components.ts +++ b/packages/grafana-e2e-selectors/src/selectors/components.ts @@ -184,7 +184,7 @@ export const Components = { content: 'Query editor tab content', queryInspectorButton: 'Query inspector button', queryHistoryButton: 'data-testid query-history-button', - addQuery: 'Query editor add query button', + addQuery: 'data-testid query-tab-add-query', }, QueryHistory: { queryText: 'Query text', diff --git a/public/app/features/query/components/QueryGroup.test.tsx b/public/app/features/query/components/QueryGroup.test.tsx index 101ed4fb066..2d4b671e061 100644 --- a/public/app/features/query/components/QueryGroup.test.tsx +++ b/public/app/features/query/components/QueryGroup.test.tsx @@ -61,7 +61,7 @@ describe('QueryGroup', () => { it('Should add query on click', async () => { renderScenario({}); - const addQueryButton = await screen.findByTestId('query-tab-add-query'); + const addQueryButton = await screen.findByRole('button', { name: /Add query/i }); const queryRowsContainer = await screen.findByTestId('query-editor-rows'); expect(queryRowsContainer.children.length).toBe(2); @@ -92,7 +92,7 @@ describe('QueryGroup', () => { it('New query should be expanded', async () => { renderScenario({}); - const addQueryButton = await screen.findByTestId('query-tab-add-query'); + const addQueryButton = await screen.findByRole('button', { name: /Add query/i }); const queryRowsContainer = await screen.findByTestId('query-editor-rows'); await userEvent.click(addQueryButton); @@ -119,7 +119,7 @@ describe('QueryGroup', () => { it('Should not show add expression button when expressions are disabled', async () => { config.expressionsEnabled = false; renderScenario({}); - await screen.findByTestId('query-tab-add-query'); + await screen.findByRole('button', { name: /Add query/i }); const addExpressionButton = screen.queryByTestId('query-tab-add-expression'); expect(addExpressionButton).not.toBeInTheDocument(); }); diff --git a/public/app/features/query/components/QueryGroup.tsx b/public/app/features/query/components/QueryGroup.tsx index f2edc8761a2..09d133ea850 100644 --- a/public/app/features/query/components/QueryGroup.tsx +++ b/public/app/features/query/components/QueryGroup.tsx @@ -371,10 +371,9 @@ export class QueryGroup extends PureComponent { icon="plus" onClick={this.onAddQueryClick} variant="secondary" - aria-label={selectors.components.QueryTab.addQuery} - data-testid="query-tab-add-query" + data-testid={selectors.components.QueryTab.addQuery} > - Query + Add query )} {config.expressionsEnabled && this.isExpressionsSupported(dsSettings) && (