Loki: Fix failing test waiting for Loading... copy (#83547)

fix monaco tests
This commit is contained in:
Sven Grossmann 2024-02-27 21:59:38 +01:00 committed by GitHub
parent de75813d8d
commit d8b7992c0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 5 deletions

View File

@ -1,4 +1,4 @@
import { render, screen } from '@testing-library/react';
import { render, screen, waitFor } from '@testing-library/react';
import React, { ComponentProps } from 'react';
import { dateTime } from '@grafana/data';
@ -33,7 +33,9 @@ describe('LokiQueryField', () => {
it('refreshes metrics when time range changes over 1 minute', async () => {
const { rerender } = render(<LokiQueryField {...props} />);
expect(await screen.findByText('Loading...')).toBeInTheDocument();
await waitFor(async () => {
expect(await screen.findByText('Loading...')).toBeInTheDocument();
});
expect(props.datasource.languageProvider.fetchLabels).not.toHaveBeenCalled();
@ -55,7 +57,9 @@ describe('LokiQueryField', () => {
it('does not refreshes metrics when time range change by less than 1 minute', async () => {
const { rerender } = render(<LokiQueryField {...props} />);
expect(await screen.findByText('Loading...')).toBeInTheDocument();
await waitFor(async () => {
expect(await screen.findByText('Loading...')).toBeInTheDocument();
});
expect(props.datasource.languageProvider.fetchLabels).not.toHaveBeenCalled();

View File

@ -1,4 +1,4 @@
import { render, screen } from '@testing-library/react';
import { render, screen, waitFor } from '@testing-library/react';
import React from 'react';
import { createLokiDatasource } from '../../__mocks__/datasource';
@ -24,6 +24,8 @@ describe('MonacoFieldWrapper', () => {
test('Renders with no errors', async () => {
renderComponent();
expect(await screen.findByText('Loading...')).toBeInTheDocument();
await waitFor(async () => {
expect(await screen.findByText('Loading...')).toBeInTheDocument();
});
});
});