Tempo: Add waitFor in flaky test (#86277)

This commit is contained in:
Fabrizio
2024-04-17 12:32:22 +02:00
committed by GitHub
parent 6a5bdcafa2
commit bbae4af935

View File

@@ -1,4 +1,4 @@
import { render, screen } from '@testing-library/react';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
@@ -56,6 +56,12 @@ describe('TempoVariableQueryEditor', () => {
render(<TempoVariableQueryEditor {...props} onChange={onChange} />);
await selectOptionInTest(screen.getByLabelText('Query type'), 'Label values');
await userEvent.click(document.body);
// The Label field is rendered only after the query type has been selected.
// We wait for it to be displayed to avoid flakyness.
await waitFor(() => expect(screen.getByLabelText('Label')).toBeInTheDocument());
await selectOptionInTest(screen.getByLabelText('Label'), 'luna');
await userEvent.click(document.body);