[v11.0.x] Loki: Fix test flake (#86353)

Loki: Fix test flake (#85356)

attempt to fix flake

(cherry picked from commit 0c78d80ef1)

Co-authored-by: Galen Kistler <109082771+gtk-grafana@users.noreply.github.com>
This commit is contained in:
grafana-delivery-bot[bot]
2024-04-16 16:09:43 +01:00
committed by GitHub
co-authored by Galen Kistler
parent d81380cc21
commit c4e057eddf
@@ -6,6 +6,16 @@ import { dateTime } from '@grafana/data';
import { createLokiDatasource } from '../__mocks__/datasource';
import { LokiQueryField } from './LokiQueryField';
import { Props as MonacoProps } from './monaco-query-field/MonacoQueryFieldProps';
jest.mock('./monaco-query-field/MonacoQueryFieldLazy', () => {
const fakeQueryField = (props: MonacoProps) => {
return <input onBlur={(e) => props.onBlur(e.currentTarget.value)} data-testid={'dummy-code-input'} type={'text'} />;
};
return {
MonacoQueryFieldLazy: fakeQueryField,
};
});
type Props = ComponentProps<typeof LokiQueryField>;
describe('LokiQueryField', () => {
@@ -34,7 +44,7 @@ describe('LokiQueryField', () => {
const { rerender } = render(<LokiQueryField {...props} />);
await waitFor(async () => {
expect(await screen.findByText('Loading...')).toBeInTheDocument();
expect(await screen.findByTestId('dummy-code-input')).toBeInTheDocument();
});
expect(props.datasource.languageProvider.fetchLabels).not.toHaveBeenCalled();
@@ -58,7 +68,7 @@ describe('LokiQueryField', () => {
const { rerender } = render(<LokiQueryField {...props} />);
await waitFor(async () => {
expect(await screen.findByText('Loading...')).toBeInTheDocument();
expect(await screen.findByTestId('dummy-code-input')).toBeInTheDocument();
});
expect(props.datasource.languageProvider.fetchLabels).not.toHaveBeenCalled();