fix: tests, minor bug, i18n

This commit is contained in:
Alex Spencer
2025-11-25 12:41:27 -08:00
parent 4badb645ba
commit 21d9b0ddcf
4 changed files with 32 additions and 11 deletions
@@ -85,9 +85,13 @@ describe('Explore QueryRows', () => {
// waiting for the d&d component to fully render.
await screen.findAllByText('someDs query editor');
let duplicateButton = screen.getByLabelText(/Duplicate query/i);
// Open the actions menu
const actionsMenuButton = screen.getByLabelText(/Query actions menu/i);
fireEvent.click(actionsMenuButton);
fireEvent.click(duplicateButton);
// Click duplicate query in the menu
const duplicateMenuItem = await screen.findByText(/Duplicate query/i);
fireEvent.click(duplicateMenuItem);
// We should have another row with refId B
expect(await screen.findByLabelText('Query editor row title B')).toBeInTheDocument();
@@ -490,6 +490,7 @@ export class QueryEditorRow<TQuery extends DataQuery> extends PureComponent<Prop
<Button
icon="ellipsis-v"
variant="secondary"
fill="text"
size="sm"
aria-label={t('query-operation.header.actions-menu', 'Query actions menu')}
data-testid={selectors.components.QueryEditorRow.actionButton('Actions menu')}
@@ -1,6 +1,7 @@
import { fireEvent, queryByLabelText, render, screen, waitFor } from '@testing-library/react';
import { fireEvent, queryByLabelText, render, screen, waitFor, within } from '@testing-library/react';
import type { DataSourceApi } from '@grafana/data';
import { selectors } from '@grafana/e2e-selectors';
import type { DataSourceSrv, GetDataSourceListFilters } from '@grafana/runtime';
import { DataSourceRef, type DataQuery } from '@grafana/schema';
import { mockDataSource } from 'app/features/alerting/unified/mocks';
@@ -251,13 +252,18 @@ describe('QueryEditorRows', () => {
renderScenario({ onAddQuery, onQueryCopied });
const queryEditorRows = await screen.findAllByTestId('query-editor-row');
queryEditorRows.map(async (childQuery) => {
const duplicateQueryButton = queryByLabelText(childQuery, 'Duplicate query') as HTMLElement;
expect(duplicateQueryButton).toBeInTheDocument();
for (const childQuery of queryEditorRows) {
// Open the actions menu
const actionsMenuButton = queryByLabelText(childQuery, 'Query actions menu') as HTMLElement;
expect(actionsMenuButton).toBeInTheDocument();
fireEvent.click(actionsMenuButton);
fireEvent.click(duplicateQueryButton);
});
// Click duplicate query in the menu
const duplicateMenuItem = await screen.findByText('Duplicate query');
expect(duplicateMenuItem).toBeInTheDocument();
fireEvent.click(duplicateMenuItem);
}
expect(onAddQuery).toHaveBeenCalledTimes(queryEditorRows.length);
expect(onQueryCopied).toHaveBeenCalledTimes(queryEditorRows.length);
@@ -269,13 +275,15 @@ describe('QueryEditorRows', () => {
renderScenario({ onQueriesChange, onQueryRemoved });
const queryEditorRows = await screen.findAllByTestId('query-editor-row');
queryEditorRows.map(async (childQuery) => {
const deleteQueryButton = queryByLabelText(childQuery, 'Remove query') as HTMLElement;
for (const childQuery of queryEditorRows) {
const deleteQueryButton = within(childQuery).getByTestId(
selectors.components.QueryEditorRow.actionButton('Remove query')
);
expect(deleteQueryButton).toBeInTheDocument();
fireEvent.click(deleteQueryButton);
});
}
expect(onQueriesChange).toHaveBeenCalledTimes(queryEditorRows.length);
expect(onQueryRemoved).toHaveBeenCalledTimes(queryEditorRows.length);
+8
View File
@@ -12248,6 +12248,10 @@
}
},
"query": {
"query-editor-row": {
"focused-message_one": "Query {{refId}} is focused, {{count}} queries are hidden from view.",
"focused-message_other": "Query {{refId}} is focused, {{count}} queries are hidden from view."
},
"query-editor-row-header": {
"hidden": "Hidden",
"query-name-div-title-edit-query-name": "Edit query name"
@@ -12297,11 +12301,15 @@
},
"query-operation": {
"header": {
"actions-menu": "Query actions menu",
"collapse": "Show all queries",
"collapse-row": "Collapse query row",
"datasource-help": "Show data source help",
"drag-and-drop": "Drag and drop to reorder",
"duplicate-query": "Duplicate query",
"expand-row": "Expand query row",
"focus": "Focus query",
"hide-datasource-help": "Hide data source help",
"hide-response": "Hide response",
"remove-query": "Remove query",
"show-response": "Show response"