Chore: Remove react-testing-lib from bundles (#50442)

* refactor(selectoptiontest): move helper function out of grafana/ui so testing-lib isn't in bundle

* test(selectoptionintest): update import location of helper function

* test(amroutes): put back missing selectOptionInTest helper

* test(selectoptionintest): clean up remaining file imports / exports

* test(queryeditor): fix failing import

* refactor(grafana-ui): reuse selectOptionInTest in SelectBase test
This commit is contained in:
Jack Westbrook 2022-06-09 11:10:48 +02:00 committed by GitHub
parent ab4171770e
commit ccd75d72f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 23 additions and 31 deletions

View File

@ -4,8 +4,9 @@ import React, { useState } from 'react';
import { SelectableValue } from '@grafana/data';
import { selectOptionInTest } from '../../../../../public/test/helpers/selectOptionInTest';
import { SelectBase } from './SelectBase';
import { selectOptionInTest } from './test-utils';
describe('SelectBase', () => {
const onChangeHandler = () => jest.fn();

View File

@ -205,7 +205,6 @@ export { FieldArray } from './Forms/FieldArray';
// Select
export { default as resetSelectStyles } from './Select/resetSelectStyles';
export { selectOptionInTest } from './Select/test-utils';
export * from './Select/Select';
export { DropdownIndicator } from './Select/DropdownIndicator';
export { getSelectStyles } from './Select/getSelectStyles';

View File

@ -3,10 +3,10 @@ import userEvent from '@testing-library/user-event';
import React from 'react';
import { Provider } from 'react-redux';
import { Router } from 'react-router-dom';
import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
import { byLabelText, byRole, byTestId, byText } from 'testing-library-selector';
import { locationService, setDataSourceSrv } from '@grafana/runtime';
import { selectOptionInTest } from '@grafana/ui';
import { contextSrv } from 'app/core/services/context_srv';
import {
AlertManagerCortexConfig,

View File

@ -3,10 +3,10 @@ import userEvent from '@testing-library/user-event';
import React from 'react';
import { Provider } from 'react-redux';
import { Router } from 'react-router-dom';
import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
import { byLabelText, byPlaceholderText, byRole, byTestId, byText } from 'testing-library-selector';
import { locationService, setDataSourceSrv } from '@grafana/runtime';
import { selectOptionInTest } from '@grafana/ui';
import { interceptLinkClicks } from 'app/core/navigation/patch/interceptLinkClicks';
import { contextSrv } from 'app/core/services/context_srv';
import store from 'app/core/store';

View File

@ -3,11 +3,11 @@ import userEvent, { PointerEventsCheckLevel } from '@testing-library/user-event'
import React from 'react';
import { Provider } from 'react-redux';
import { Route, Router } from 'react-router-dom';
import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
import { byLabelText, byRole, byTestId, byText } from 'testing-library-selector';
import { DataSourceInstanceSettings } from '@grafana/data';
import { BackendSrv, locationService, setBackendSrv, setDataSourceSrv } from '@grafana/runtime';
import { selectOptionInTest } from '@grafana/ui';
import { contextSrv } from 'app/core/services/context_srv';
import { DashboardSearchHit } from 'app/features/search/types';
import { configureStore } from 'app/store/configureStore';

View File

@ -1,10 +1,10 @@
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
import { byRole } from 'testing-library-selector';
import { selectors } from '@grafana/e2e-selectors';
import { selectOptionInTest } from '@grafana/ui';
import { DashboardModel } from '../../state';

View File

@ -1,9 +1,9 @@
import { fireEvent, render, screen } from '@testing-library/react';
import React from 'react';
import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
import { MappingType } from '@grafana/data';
import { selectors } from '@grafana/e2e-selectors';
import { selectOptionInTest } from '@grafana/ui';
import { ValueMappingsEditorModal, Props } from './ValueMappingsEditorModal';

View File

@ -1,9 +1,9 @@
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
import React from 'react';
import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
import { selectors } from '@grafana/e2e-selectors';
import { locationService, setEchoSrv } from '@grafana/runtime';
import { selectOptionInTest } from '@grafana/ui';
import * as MockSearchSrv from 'app/core/services/__mocks__/search_srv';
import { Echo } from 'app/core/services/echo/Echo';
import * as SearchSrv from 'app/core/services/search_srv';

View File

@ -1,7 +1,6 @@
import { fireEvent, render, screen } from '@testing-library/react';
import React from 'react';
import { selectOptionInTest } from '@grafana/ui';
import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
import { SearchLayout } from '../types';

View File

@ -1,8 +1,8 @@
import { fireEvent, render, screen } from '@testing-library/react';
import React from 'react';
import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
import { toDataFrame, FieldType } from '@grafana/data';
import { selectOptionInTest } from '@grafana/ui';
import { Props, ConfigFromQueryTransformerEditor } from './ConfigFromQueryTransformerEditor';

View File

@ -1,9 +1,9 @@
import { fireEvent, render, screen, getByText, getByLabelText } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
import { toDataFrame, FieldType } from '@grafana/data';
import { selectOptionInTest } from '@grafana/ui';
import { Props, FieldToConfigMappingEditor } from './FieldToConfigMappingEditor';

View File

@ -1,8 +1,8 @@
import { fireEvent, render, screen } from '@testing-library/react';
import React from 'react';
import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
import { toDataFrame, FieldType } from '@grafana/data';
import { selectOptionInTest } from '@grafana/ui';
import { Props, RowsToFieldsTransformerEditor } from './RowsToFieldsTransformerEditor';

View File

@ -1,8 +1,6 @@
import { render, screen } from '@testing-library/react';
import React from 'react';
import { selectOptionInTest } from '@grafana/ui';
import { getSelectParent } from '@grafana/ui/src/components/Select/test-utils';
import { selectOptionInTest, getSelectParent } from 'test/helpers/selectOptionInTest';
import { adHocBuilder } from '../shared/testing/builders';

View File

@ -1,8 +1,6 @@
import { render, screen, fireEvent } from '@testing-library/react';
import React from 'react';
import { selectOptionInTest } from '@grafana/ui';
import { getSelectParent } from '@grafana/ui/src/components/Select/test-utils';
import { selectOptionInTest, getSelectParent } from 'test/helpers/selectOptionInTest';
import { DataSourceVariableEditorUnConnected as DataSourceVariableEditor } from './DataSourceVariableEditor';
import { initialDataSourceVariableModelState } from './reducer';

View File

@ -1,7 +1,6 @@
import { act, render, screen } from '@testing-library/react';
import React from 'react';
import { selectOptionInTest } from '@grafana/ui';
import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
import { setupMockedDataSource } from '../../__mocks__/CloudWatchDataSource';
import { QueryEditorExpressionType, QueryEditorPropertyType } from '../../expressions';

View File

@ -2,8 +2,7 @@ import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
import { openMenu } from 'react-select-event';
import { selectOptionInTest } from '@grafana/ui';
import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
import createMockDatasource from '../../__mocks__/datasource';
import createMockPanelData from '../../__mocks__/panelData';

View File

@ -1,7 +1,6 @@
import { render, screen, waitFor } from '@testing-library/react';
import React from 'react';
import { selectOptionInTest } from '@grafana/ui';
import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
import createMockDatasource from '../../__mocks__/datasource';
import createMockPanelData from '../../__mocks__/panelData';

View File

@ -1,9 +1,9 @@
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
import { config } from '@grafana/runtime';
import { selectOptionInTest } from '@grafana/ui';
import createMockDatasource from '../../__mocks__/datasource';
import { createMockInstanceSetttings } from '../../__mocks__/instanceSettings';

View File

@ -1,5 +1,6 @@
import { render, screen, waitFor } from '@testing-library/react';
import React from 'react';
import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
import { config } from '@grafana/runtime';
import * as ui from '@grafana/ui';
@ -52,7 +53,7 @@ describe('Azure Monitor QueryEditor', () => {
await waitFor(() => expect(screen.getByTestId('azure-monitor-query-editor')).toBeInTheDocument());
const metrics = await screen.findByLabelText('Service');
await ui.selectOptionInTest(metrics, 'Logs');
await selectOptionInTest(metrics, 'Logs');
expect(onChange).toHaveBeenCalledWith({
...mockQuery,

View File

@ -1,8 +1,7 @@
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
import { selectOptionInTest } from '@grafana/ui';
import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
import { InfluxQuery } from '../types';

View File

@ -1,8 +1,8 @@
import { render, screen } from '@testing-library/react';
import React from 'react';
import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
import { CoreApp } from '@grafana/data';
import { selectOptionInTest } from '@grafana/ui';
import { PromQuery } from '../../types';
import { getQueryWithDefaults } from '../state';

View File

@ -1,8 +1,8 @@
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
import { selectOptionInTest } from '../../../../../../../packages/grafana-ui';
import { getLabelSelects } from '../testUtils';
import { LabelFilters } from './LabelFilters';