diff --git a/public/app/plugins/datasource/tempo/VariableQueryEditor.test.tsx b/public/app/plugins/datasource/tempo/VariableQueryEditor.test.tsx index 3b843ed7a81..3d5554775a5 100644 --- a/public/app/plugins/datasource/tempo/VariableQueryEditor.test.tsx +++ b/public/app/plugins/datasource/tempo/VariableQueryEditor.test.tsx @@ -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(); 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);