mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki: Remove imported test utility function from Prometheus (#78901)
Loki: Remove import from prometheus test utility
This commit is contained in:
parent
eff9374a63
commit
953d0d4c70
@ -1,8 +1,7 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import React from 'react';
|
||||
|
||||
import { addOperation } from 'app/plugins/datasource/prometheus/querybuilder/shared/OperationList.testUtils';
|
||||
|
||||
import { createLokiDatasource } from '../../mocks';
|
||||
|
||||
import { LokiQueryBuilderContainer } from './LokiQueryBuilderContainer';
|
||||
@ -32,3 +31,19 @@ describe('LokiQueryBuilderContainer', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
async function addOperation(section: string, op: string) {
|
||||
const addOperationButton = screen.getByTitle('Add operation');
|
||||
expect(addOperationButton).toBeInTheDocument();
|
||||
await userEvent.click(addOperationButton);
|
||||
const sectionItem = await screen.findByTitle(section);
|
||||
expect(sectionItem).toBeInTheDocument();
|
||||
// Weirdly the await userEvent.click doesn't work here, it reports the item has pointer-events: none. Don't see that
|
||||
// anywhere when debugging so not sure what style is it picking up.
|
||||
await userEvent.click(sectionItem.children[0], { pointerEventsCheck: 0 });
|
||||
const opItem = screen.getByTitle(op);
|
||||
expect(opItem).toBeInTheDocument();
|
||||
// Weirdly the await userEvent.click doesn't work here, it reports the item has pointer-events: none. Don't see that
|
||||
// anywhere when debugging so not sure what style is it picking up.
|
||||
await userEvent.click(opItem, { pointerEventsCheck: 0 });
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import PromQlLanguageProvider from '../../language_provider';
|
||||
import { EmptyLanguageProviderMock } from '../../language_provider.mock';
|
||||
import { PromQuery } from '../../types';
|
||||
import { getOperationParamId } from '../operationUtils';
|
||||
import { addOperation } from '../shared/OperationList.testUtils';
|
||||
import { addOperationInQueryBuilder } from '../testUtils';
|
||||
|
||||
import { PromQueryBuilderContainer } from './PromQueryBuilderContainer';
|
||||
|
||||
@ -18,7 +18,7 @@ describe('PromQueryBuilderContainer', () => {
|
||||
const { props } = setup({ expr: 'rate(metric_test{job="testjob"}[$__rate_interval])' });
|
||||
|
||||
expect(screen.getByText('metric_test')).toBeInTheDocument();
|
||||
await addOperation('Range functions', 'Rate');
|
||||
await addOperationInQueryBuilder('Range functions', 'Rate');
|
||||
expect(props.onChange).toBeCalledWith({
|
||||
expr: 'rate(metric_test{job="testjob"}[$__rate_interval])',
|
||||
refId: 'A',
|
||||
|
@ -9,10 +9,10 @@ import PromQlLanguageProvider from '../../language_provider';
|
||||
import { EmptyLanguageProviderMock } from '../../language_provider.mock';
|
||||
import { PromOptions } from '../../types';
|
||||
import { promQueryModeller } from '../PromQueryModeller';
|
||||
import { addOperationInQueryBuilder } from '../testUtils';
|
||||
import { PromVisualQuery } from '../types';
|
||||
|
||||
import { OperationList } from './OperationList';
|
||||
import { addOperation } from './OperationList.testUtils';
|
||||
|
||||
const defaultQuery: PromVisualQuery = {
|
||||
metric: 'random_metric',
|
||||
@ -50,7 +50,7 @@ describe('OperationList', () => {
|
||||
|
||||
it('adds an operation', async () => {
|
||||
const { onChange } = setup();
|
||||
await addOperation('Aggregations', 'Min');
|
||||
await addOperationInQueryBuilder('Aggregations', 'Min');
|
||||
expect(onChange).toBeCalledWith({
|
||||
labels: [{ label: 'instance', op: '=', value: 'localhost:9090' }],
|
||||
metric: 'random_metric',
|
||||
|
@ -1,18 +0,0 @@
|
||||
import { screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
|
||||
export async function addOperation(section: string, op: string) {
|
||||
const addOperationButton = screen.getByTitle('Add operation');
|
||||
expect(addOperationButton).toBeInTheDocument();
|
||||
await userEvent.click(addOperationButton);
|
||||
const sectionItem = await screen.findByTitle(section);
|
||||
expect(sectionItem).toBeInTheDocument();
|
||||
// Weirdly the await userEvent.click doesn't work here, it reports the item has pointer-events: none. Don't see that
|
||||
// anywhere when debugging so not sure what style is it picking up.
|
||||
await userEvent.click(sectionItem.children[0], { pointerEventsCheck: 0 });
|
||||
const opItem = screen.getByTitle(op);
|
||||
expect(opItem).toBeInTheDocument();
|
||||
// Weirdly the await userEvent.click doesn't work here, it reports the item has pointer-events: none. Don't see that
|
||||
// anywhere when debugging so not sure what style is it picking up.
|
||||
await userEvent.click(opItem, { pointerEventsCheck: 0 });
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import { screen, getAllByRole } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
|
||||
export function getLabelSelects(index = 0) {
|
||||
const labels = screen.getByText(/Label filters/);
|
||||
@ -8,3 +9,19 @@ export function getLabelSelects(index = 0) {
|
||||
value: selects[3 * index + 2],
|
||||
};
|
||||
}
|
||||
|
||||
export async function addOperationInQueryBuilder(section: string, op: string) {
|
||||
const addOperationButton = screen.getByTitle('Add operation');
|
||||
expect(addOperationButton).toBeInTheDocument();
|
||||
await userEvent.click(addOperationButton);
|
||||
const sectionItem = await screen.findByTitle(section);
|
||||
expect(sectionItem).toBeInTheDocument();
|
||||
// Weirdly the await userEvent.click doesn't work here, it reports the item has pointer-events: none. Don't see that
|
||||
// anywhere when debugging so not sure what style is it picking up.
|
||||
await userEvent.click(sectionItem.children[0], { pointerEventsCheck: 0 });
|
||||
const opItem = screen.getByTitle(op);
|
||||
expect(opItem).toBeInTheDocument();
|
||||
// Weirdly the await userEvent.click doesn't work here, it reports the item has pointer-events: none. Don't see that
|
||||
// anywhere when debugging so not sure what style is it picking up.
|
||||
await userEvent.click(opItem, { pointerEventsCheck: 0 });
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user