mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* revert * works but needs clean up and tests * clean up * remove any * change confusing query var to expr * oops * add test * lint * cleanup * update docs * Update public/app/plugins/datasource/cloud-monitoring/components/PromQLEditor.tsx Co-authored-by: Andreas Christou <andreas.christou@grafana.com> * nit * lint fix? * remove comment from cue * go linter * removing parsing stuff parseresponse func --------- Co-authored-by: Andreas Christou <andreas.christou@grafana.com>
50 lines
1.9 KiB
TypeScript
50 lines
1.9 KiB
TypeScript
import { render, screen } from '@testing-library/react';
|
|
import React from 'react';
|
|
import { openMenu, select } from 'react-select-event';
|
|
|
|
import { createMockQuery } from '../__mocks__/cloudMonitoringQuery';
|
|
import { QueryType } from '../types/query';
|
|
|
|
import { QueryHeader } from './QueryHeader';
|
|
|
|
describe('QueryHeader', () => {
|
|
it('can change query types to SLO', async () => {
|
|
const query = createMockQuery();
|
|
const onChange = jest.fn();
|
|
const onRunQuery = jest.fn();
|
|
|
|
render(<QueryHeader query={query} onChange={onChange} onRunQuery={onRunQuery} />);
|
|
|
|
const queryType = screen.getByLabelText(/Query type/);
|
|
await openMenu(queryType);
|
|
await select(screen.getByLabelText('Select options menu'), 'Service Level Objectives (SLO)');
|
|
expect(onChange).toBeCalledWith(expect.objectContaining({ queryType: QueryType.SLO }));
|
|
});
|
|
|
|
it('can change query types to MQL', async () => {
|
|
const query = createMockQuery();
|
|
const onChange = jest.fn();
|
|
const onRunQuery = jest.fn();
|
|
|
|
render(<QueryHeader query={query} onChange={onChange} onRunQuery={onRunQuery} />);
|
|
|
|
const queryType = screen.getByLabelText(/Query type/);
|
|
await openMenu(queryType);
|
|
await select(screen.getByLabelText('Select options menu'), 'MQL');
|
|
expect(onChange).toBeCalledWith(expect.objectContaining({ queryType: QueryType.TIME_SERIES_QUERY }));
|
|
});
|
|
|
|
it('can change query types to PromQL', async () => {
|
|
const query = createMockQuery();
|
|
const onChange = jest.fn();
|
|
const onRunQuery = jest.fn();
|
|
|
|
render(<QueryHeader query={query} onChange={onChange} onRunQuery={onRunQuery} />);
|
|
|
|
const queryType = screen.getByLabelText(/Query type/);
|
|
await openMenu(queryType);
|
|
await select(screen.getByLabelText('Select options menu'), 'PromQL');
|
|
expect(onChange).toBeCalledWith(expect.objectContaining({ queryType: QueryType.PROMQL }));
|
|
});
|
|
});
|