Files
grafana/public/app/plugins/datasource/loki/components/monaco-query-field/MonacoQueryField.test.tsx
Gareth Dawson 9def0d2305 Loki: Fix timerange for query stats request (#72193)
* call query stats with whole query

* call stats when query type changes

* fix stats request timerange

* feedback: extract functions from component

* feedback: remove "or string" types

* feedback: use ds timerange picker end

* partial: fix broken test

* changes

* update test comment

* rename variable

* add comment explain message prop

* make getStatsTimeRange a datasource method

* update tests for getStatsTimeRange

* make getStats a datasource method

* update failing tests

* update failing tests

* remove import

* Update public/app/plugins/datasource/loki/datasource.test.ts

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>

---------

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
2023-09-20 16:47:21 +01:00

37 lines
890 B
TypeScript

import { render, screen } from '@testing-library/react';
import React from 'react';
import { createLokiDatasource } from '../../mocks';
import MonacoQueryField from './MonacoQueryField';
import { Props } from './MonacoQueryFieldProps';
function renderComponent({
initialValue = '',
onRunQuery = jest.fn(),
onBlur = jest.fn(),
onChange = jest.fn(),
}: Partial<Props> = {}) {
const datasource = createLokiDatasource();
render(
<MonacoQueryField
datasource={datasource}
initialValue={initialValue}
history={[]}
onRunQuery={onRunQuery}
onBlur={onBlur}
onChange={onChange}
placeholder="Enter a Loki query (run with Shift+Enter)"
/>
);
}
describe('MonacoQueryField', () => {
test('Renders with no errors', async () => {
renderComponent();
expect(await screen.findByText('Loading...')).toBeInTheDocument();
});
});