mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 12:52:15 +08:00

* GrafanaUI: add option to close DeleteButton on confirm click * add datasource readOnly info to frontend settings * move isTruthy utility type guard * add generic non-visualization table component * Add correlations settings page * add missing readOnly in mock * Fix typo * avoid reloading correlations after add/remove * use DeepPartial from rhf * validate source data source * fix validation logic * fix navmodel test * add missing readonly property * remove unused styles * handle multiple clicks on elements * better UX for loading states * fix remove handler * add glue icon
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
import { render, screen } from '@testing-library/react';
|
|
import React from 'react';
|
|
|
|
import { DataSourcePluginMeta } from '@grafana/data';
|
|
import { addOperation } from 'app/plugins/datasource/prometheus/querybuilder/shared/OperationList.testUtils';
|
|
|
|
import { LokiDatasource } from '../../datasource';
|
|
|
|
import { LokiQueryBuilderContainer } from './LokiQueryBuilderContainer';
|
|
|
|
describe('LokiQueryBuilderContainer', () => {
|
|
it('translates query between string and model', async () => {
|
|
const props = {
|
|
query: {
|
|
expr: '{job="testjob"}',
|
|
refId: 'A',
|
|
},
|
|
datasource: new LokiDatasource(
|
|
{
|
|
id: 1,
|
|
uid: '',
|
|
type: 'loki',
|
|
name: 'loki-test',
|
|
access: 'proxy',
|
|
url: '',
|
|
jsonData: {},
|
|
meta: {} as DataSourcePluginMeta,
|
|
readOnly: false,
|
|
},
|
|
undefined,
|
|
undefined
|
|
),
|
|
onChange: jest.fn(),
|
|
onRunQuery: () => {},
|
|
showRawQuery: true,
|
|
showExplain: false,
|
|
};
|
|
props.datasource.getDataSamples = jest.fn().mockResolvedValue([]);
|
|
|
|
render(<LokiQueryBuilderContainer {...props} />);
|
|
const selector = await screen.findByLabelText('selector');
|
|
expect(selector.textContent).toBe('{job="testjob"}');
|
|
await addOperation('Range functions', 'Rate');
|
|
expect(await screen.findByText('Rate')).toBeInTheDocument();
|
|
expect(props.onChange).toBeCalledWith({
|
|
expr: 'rate({job="testjob"} [$__interval])',
|
|
refId: 'A',
|
|
});
|
|
});
|
|
});
|