mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki: Remove dependency in test files on selectOptionInTest (#80546)
* Loki: Remove dependecy in test files on selectOptionInTest * Remove await waitFor(() => where not needed
This commit is contained in:
parent
67d77e76be
commit
b97170b01e
@ -1,7 +1,7 @@
|
||||
import { act, render, screen, waitFor } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import React from 'react';
|
||||
import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
|
||||
import { select } from 'react-select-event';
|
||||
|
||||
import { LogRowModel, dateTime } from '@grafana/data';
|
||||
|
||||
@ -136,8 +136,8 @@ describe('LokiContextUi', () => {
|
||||
await waitFor(() => {
|
||||
expect(props.logContextProvider.getInitContextFilters).toHaveBeenCalled();
|
||||
});
|
||||
const select = await screen.findAllByRole('combobox');
|
||||
await selectOptionInTest(select[0], 'label1="value1"');
|
||||
const selects = await screen.findAllByRole('combobox');
|
||||
await select(selects[0], 'label1="value1"', { container: document.body });
|
||||
});
|
||||
|
||||
it('finds label3 as a parsed label', async () => {
|
||||
@ -146,8 +146,8 @@ describe('LokiContextUi', () => {
|
||||
await waitFor(() => {
|
||||
expect(props.logContextProvider.getInitContextFilters).toHaveBeenCalled();
|
||||
});
|
||||
const select = await screen.findAllByRole('combobox');
|
||||
await selectOptionInTest(select[1], 'label3="value3"');
|
||||
const selects = await screen.findAllByRole('combobox');
|
||||
await select(selects[1], 'label3="value3"', { container: document.body });
|
||||
});
|
||||
|
||||
it('calls updateFilter when selecting a label', async () => {
|
||||
@ -158,7 +158,7 @@ describe('LokiContextUi', () => {
|
||||
expect(props.logContextProvider.getInitContextFilters).toHaveBeenCalled();
|
||||
expect(screen.getAllByRole('combobox')).toHaveLength(2);
|
||||
});
|
||||
await selectOptionInTest(screen.getAllByRole('combobox')[1], 'label3="value3"');
|
||||
await select(screen.getAllByRole('combobox')[1], 'label3="value3"', { container: document.body });
|
||||
act(() => {
|
||||
jest.runAllTimers();
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { render, screen, waitFor } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import React from 'react';
|
||||
import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
|
||||
import { select } from 'react-select-event';
|
||||
|
||||
import { TemplateSrv } from '@grafana/runtime';
|
||||
|
||||
@ -34,8 +34,7 @@ describe('LokiVariableQueryEditor', () => {
|
||||
render(<LokiVariableQueryEditor {...props} onChange={onChange} />);
|
||||
|
||||
expect(onChange).not.toHaveBeenCalled();
|
||||
|
||||
await selectOptionInTest(screen.getByLabelText('Query type'), 'Label names');
|
||||
await select(screen.getByLabelText('Query type'), 'Label names', { container: document.body });
|
||||
|
||||
expect(onChange).toHaveBeenCalledWith({
|
||||
type: LokiVariableQueryType.LabelNames,
|
||||
@ -51,8 +50,8 @@ describe('LokiVariableQueryEditor', () => {
|
||||
|
||||
expect(onChange).not.toHaveBeenCalled();
|
||||
|
||||
await selectOptionInTest(screen.getByLabelText('Query type'), 'Label values');
|
||||
await selectOptionInTest(screen.getByLabelText('Label'), 'luna');
|
||||
await waitFor(() => select(screen.getByLabelText('Query type'), 'Label values', { container: document.body }));
|
||||
await select(screen.getByLabelText('Label'), 'luna', { container: document.body });
|
||||
await userEvent.type(screen.getByLabelText('Stream selector'), 'stream');
|
||||
|
||||
await waitFor(() => expect(screen.getByDisplayValue('stream')).toBeInTheDocument());
|
||||
@ -72,8 +71,8 @@ describe('LokiVariableQueryEditor', () => {
|
||||
render(<LokiVariableQueryEditor {...props} onChange={onChange} />);
|
||||
|
||||
expect(onChange).not.toHaveBeenCalled();
|
||||
await waitFor(() => select(screen.getByLabelText('Query type'), 'Label values', { container: document.body }));
|
||||
|
||||
await selectOptionInTest(screen.getByLabelText('Query type'), 'Label values');
|
||||
await userEvent.type(screen.getByLabelText('Label'), 'sol{enter}');
|
||||
await userEvent.type(screen.getByLabelText('Stream selector'), 'stream');
|
||||
|
||||
@ -120,9 +119,8 @@ describe('LokiVariableQueryEditor', () => {
|
||||
|
||||
test('Label options are not lost when selecting one', async () => {
|
||||
const { rerender } = render(<LokiVariableQueryEditor {...props} onChange={() => {}} />);
|
||||
|
||||
await selectOptionInTest(screen.getByLabelText('Query type'), 'Label values');
|
||||
await selectOptionInTest(screen.getByLabelText('Label'), 'luna');
|
||||
await waitFor(() => select(screen.getByLabelText('Query type'), 'Label values', { container: document.body }));
|
||||
await select(screen.getByLabelText('Label'), 'luna', { container: document.body });
|
||||
|
||||
const updatedQuery = {
|
||||
refId: 'test',
|
||||
@ -131,8 +129,8 @@ describe('LokiVariableQueryEditor', () => {
|
||||
};
|
||||
rerender(<LokiVariableQueryEditor {...props} query={updatedQuery} onChange={() => {}} />);
|
||||
|
||||
await selectOptionInTest(screen.getByLabelText('Label'), 'moon');
|
||||
await selectOptionInTest(screen.getByLabelText('Label'), 'luna');
|
||||
await select(screen.getByLabelText('Label'), 'moon', { container: document.body });
|
||||
await select(screen.getByLabelText('Label'), 'luna', { container: document.body });
|
||||
await screen.findByText('luna');
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { dateTime } from '@grafana/data';
|
||||
import { Monaco, monacoTypes } from '@grafana/ui/src';
|
||||
import { Monaco, monacoTypes } from '@grafana/ui';
|
||||
|
||||
import LokiLanguageProvider from '../../../LanguageProvider';
|
||||
import { createLokiDatasource } from '../../../__mocks__/datasource';
|
||||
|
Loading…
Reference in New Issue
Block a user