Skip to content

Commit

Permalink
[Lens] remove test warnings from console (#91632) (#91669)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbondyra authored Feb 17, 2021
1 parent 2112c09 commit 147f3db
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
import { ReactWrapper, ShallowWrapper } from 'enzyme';
import React, { ChangeEvent, MouseEvent } from 'react';
import { act } from 'react-dom/test-utils';
import { EuiComboBox, EuiListGroupItemProps, EuiListGroup, EuiRange } from '@elastic/eui';
import {
EuiComboBox,
EuiListGroupItemProps,
EuiListGroup,
EuiRange,
EuiSelect,
EuiButtonIcon,
} from '@elastic/eui';
import { DataPublicPluginStart } from '../../../../../../src/plugins/data/public';
import {
IndexPatternDimensionEditorComponent,
Expand All @@ -24,8 +31,6 @@ import { OperationMetadata } from '../../types';
import { DateHistogramIndexPatternColumn } from '../operations/definitions/date_histogram';
import { getFieldByNameFactory } from '../pure_helpers';
import { TimeScaling } from './time_scaling';
import { EuiSelect } from '@elastic/eui';
import { EuiButtonIcon } from '@elastic/eui';
import { DimensionEditor } from './dimension_editor';

jest.mock('../loader');
Expand Down Expand Up @@ -742,6 +747,8 @@ describe('IndexPatternDimensionEditorPanel', () => {
});

it('should leave error state when switching from incomplete state to fieldless operation', () => {
// @ts-expect-error
window['__react-beautiful-dnd-disable-dev-warnings'] = true; // issue with enzyme & react-beautiful-dnd throwing errors: https://github.com/atlassian/react-beautiful-dnd/issues/1593
wrapper = mount(<IndexPatternDimensionEditorComponent {...defaultProps} />);

wrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ import { RangePopover } from './advanced_editor';
import { DragDropBuckets } from '../shared_components';
import { getFieldByNameFactory } from '../../../pure_helpers';

// mocking random id generator function
jest.mock('@elastic/eui', () => {
const original = jest.requireActual('@elastic/eui');

return {
...original,
htmlIdGenerator: (fn: unknown) => {
let counter = 0;
return () => counter++;
},
};
});

const dataPluginMockValue = dataPluginMock.createStartContract();
// need to overwrite the formatter field first
dataPluginMockValue.fieldFormats.deserialize = jest.fn().mockImplementation(({ params }) => {
Expand Down

0 comments on commit 147f3db

Please sign in to comment.