[Dependencies]: upgrade react to latest v16.12.0 (#51145)

This commit is contained in:
Sébastien Loix 2019-11-28 15:26:47 +05:30 committed by patrykkopycinski
parent 066613e2a6
commit 439708a6f9
217 changed files with 2668 additions and 2549 deletions

View file

@ -79,17 +79,16 @@
},
"resolutions": {
"**/@types/node": "10.12.27",
"**/@types/react": "16.8.3",
"**/@types/react": "^16.9.13",
"**/@types/hapi": "^17.0.18",
"**/@types/angular": "^1.6.56",
"**/typescript": "3.7.2",
"**/graphql-toolkit/lodash": "^4.17.13",
"**/isomorphic-git/**/base64-js": "^1.2.1",
"**/image-diff/gm/debug": "^2.6.9",
"**/deepmerge": "^4.2.2",
"**/react": "16.8.6",
"**/react-dom": "16.8.6",
"**/react-test-renderer": "16.8.6"
"**/react-dom": "^16.12.0",
"**/react-test-renderer": "^16.12.0",
"**/deepmerge": "^4.2.2"
},
"workspaces": {
"packages": [
@ -216,15 +215,13 @@
"pug": "^2.0.3",
"querystring-browser": "1.0.4",
"raw-loader": "3.1.0",
"react": "^16.8.6",
"react-addons-shallow-compare": "15.6.2",
"react": "^16.12.0",
"react-color": "^2.13.8",
"react-dom": "^16.8.6",
"react-dom": "^16.12.0",
"react-grid-layout": "^0.16.2",
"react-hooks-testing-library": "^0.5.0",
"react-input-range": "^1.3.0",
"react-markdown": "^3.4.1",
"react-redux": "^5.1.1",
"react-redux": "^5.1.2",
"react-router-dom": "^4.3.1",
"react-sizeme": "^2.3.6",
"reactcss": "1.2.3",
@ -287,6 +284,8 @@
"@microsoft/api-documenter": "7.4.3",
"@microsoft/api-extractor": "7.4.2",
"@percy/agent": "^0.11.0",
"@testing-library/react": "^9.3.2",
"@testing-library/react-hooks": "^3.2.1",
"@types/angular": "^1.6.56",
"@types/angular-mocks": "^1.7.0",
"@types/babel__core": "^7.1.2",
@ -312,7 +311,7 @@
"@types/has-ansi": "^3.0.0",
"@types/history": "^4.7.3",
"@types/hoek": "^4.1.3",
"@types/jest": "^24.0.18",
"@types/jest": "24.0.19",
"@types/joi": "^13.4.2",
"@types/jquery": "^3.3.31",
"@types/js-yaml": "^3.11.1",
@ -332,8 +331,8 @@
"@types/podium": "^1.0.0",
"@types/prop-types": "^15.5.3",
"@types/reach__router": "^1.2.6",
"@types/react": "^16.8.0",
"@types/react-dom": "^16.8.0",
"@types/react": "^16.9.11",
"@types/react-dom": "^16.9.4",
"@types/react-redux": "^6.0.6",
"@types/react-router-dom": "^4.3.1",
"@types/react-virtualized": "^9.18.7",
@ -347,6 +346,8 @@
"@types/styled-components": "^4.4.0",
"@types/supertest": "^2.0.5",
"@types/supertest-as-promised": "^2.0.38",
"@types/testing-library__react": "^9.1.2",
"@types/testing-library__react-hooks": "^3.1.0",
"@types/type-detect": "^4.0.1",
"@types/uuid": "^3.4.4",
"@types/vinyl-fs": "^2.4.11",
@ -410,7 +411,6 @@
"istanbul-instrumenter-loader": "3.0.1",
"jest": "^24.9.0",
"jest-cli": "^24.9.0",
"jest-dom": "^3.5.0",
"jest-raw-loader": "^1.0.1",
"jimp": "0.8.4",
"json5": "^1.0.1",

View file

@ -40,7 +40,7 @@ module.exports = {
rules: {
'block-scoped-var': 'error',
camelcase: [ 'error', { properties: 'never' } ],
camelcase: [ 'error', { properties: 'never', allow: ['^UNSAFE_'] } ],
'comma-dangle': 'off',
'comma-spacing': ['error', { before: false, after: true }],
'comma-style': [ 'error', 'last' ],

View file

@ -16,7 +16,7 @@ module.exports = {
rules: {
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'import/order': 'off'
'import/order': 'off',
},
}
]

View file

@ -94,7 +94,7 @@ module.exports = {
'@typescript-eslint/camelcase': ['error', {
'properties': 'never',
'ignoreDestructuring': true,
'allow': ['^[A-Z0-9_]+$']
'allow': ['^[A-Z0-9_]+$', '^UNSAFE_']
}],
'@typescript-eslint/class-name-casing': 'error',
'@typescript-eslint/explicit-member-accessibility': ['error',

View file

@ -28,7 +28,7 @@
"intl-messageformat": "^2.2.0",
"intl-relativeformat": "^2.1.0",
"prop-types": "^15.6.2",
"react": "^16.8.6",
"react": "^16.12.0",
"react-intl": "^2.8.0"
}
}

View file

@ -47,7 +47,7 @@ export class GuideNav extends Component {
});
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
const currentRoute = nextProps.routes[1];
const nextRoute = this.props.getNextRoute(currentRoute.name);
const previousRoute = this.props.getPreviousRoute(currentRoute.name);

View file

@ -49,7 +49,7 @@ function mapDispatchToProps(dispatch) {
}
class GuideSandboxComponent extends Component {
componentWillMount() {
UNSAFE_componentWillMount() {
this.props.openSandbox();
}

View file

@ -36,7 +36,7 @@ export class GuideSection extends Component {
this.props.openCodeViewer(this.props.source, this.props.title);
}
componentWillMount() {
UNSAFE_componentWillMount() {
this.props.registerSection(this.getId(), this.props.title);
}

View file

@ -81,7 +81,7 @@ export class AppView extends Component {
});
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
// Only force the chrome to be hidden if we're navigating from a non-sandbox to a sandbox.
if (!this.props.isSandbox && nextProps.isSandbox) {
this.setState({

View file

@ -19,7 +19,7 @@
"focus-trap-react": "^3.1.1",
"lodash": "npm:@elastic/lodash@3.10.1-kibana3",
"prop-types": "15.6.0",
"react": "^16.8.6",
"react": "^16.12.0",
"react-ace": "^5.9.0",
"react-color": "^2.13.8",
"tabbable": "1.1.3",
@ -57,8 +57,8 @@
"postcss": "^7.0.5",
"postcss-loader": "^3.0.0",
"raw-loader": "^3.1.0",
"react-dom": "^16.8.6",
"react-redux": "^5.0.6",
"react-dom": "^16.12.0",
"react-redux": "^5.1.2",
"react-router": "^3.2.0",
"react-router-redux": "^4.0.8",
"redux": "3.7.2",

View file

@ -49,7 +49,7 @@ class FieldSelectUi extends Component {
this.loadFields(this.state.indexPatternId);
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
if (this.props.indexPatternId !== nextProps.indexPatternId) {
this.loadFields(nextProps.indexPatternId);
}

View file

@ -45,16 +45,6 @@ beforeEach(() => {
jest.clearAllMocks();
});
// Suppress warnings about "act" until we use React 16.9
/* eslint-disable no-console */
const originalError = console.error;
beforeAll(() => {
console.error = jest.fn();
});
afterAll(() => {
console.error = originalError;
});
export const waitForPromises = () => new Promise(resolve => setTimeout(resolve, 0));
/**

View file

@ -16,20 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
import { renderHook, act } from 'react-hooks-testing-library';
import { renderHook, act } from '@testing-library/react-hooks';
import { buildSearchBody, useEsDocSearch, ElasticRequestState } from './use_es_doc_search';
import { DocProps } from './doc';
// Suppress warnings about "act" until we use React 16.9
/* eslint-disable no-console */
const originalError = console.error;
beforeAll(() => {
console.error = jest.fn();
});
afterAll(() => {
console.error = originalError;
});
describe('Test of <Doc /> helper / hook', () => {
test('buildSearchBody', () => {
const indexPattern = {

View file

@ -67,7 +67,7 @@ class TutorialUi extends React.Component {
}
}
componentWillMount() {
UNSAFE_componentWillMount() {
this._isMounted = true;
}

View file

@ -61,7 +61,7 @@ export class IndicesList extends Component {
this.pager = new Pager(props.indices.length, this.state.perPage, this.state.page);
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
if (nextProps.indices.length !== this.props.indices.length) {
this.pager.setTotalItems(nextProps.indices.length);
this.resetPageTo0();

View file

@ -75,7 +75,7 @@ export class StepIndexPattern extends Component {
this.lastQuery = null;
}
async componentWillMount() {
async UNSAFE_componentWillMount() {
this.fetchExistingIndexPatterns();
if (this.state.query) {
this.lastQuery = this.state.query;

View file

@ -65,7 +65,7 @@ export class CreateIndexPatternWizard extends Component {
};
}
async componentWillMount() {
async UNSAFE_componentWillMount() {
this.fetchData();
}

View file

@ -47,7 +47,7 @@ export class IndexedFieldsTable extends Component {
};
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
if (nextProps.fields !== this.props.fields) {
this.setState({
fields: this.mapFields(nextProps.fields)

View file

@ -59,7 +59,7 @@ export class ScriptedFieldsTable extends Component {
};
}
componentWillMount() {
UNSAFE_componentWillMount() {
this.fetchFields();
}

View file

@ -58,7 +58,7 @@ export class SourceFiltersTable extends Component {
};
}
componentWillMount() {
UNSAFE_componentWillMount() {
this.updateFilters();
}

View file

@ -58,11 +58,11 @@ export class Relationships extends Component {
};
}
componentWillMount() {
UNSAFE_componentWillMount() {
this.getRelationshipData();
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
if (nextProps.savedObject.id !== this.props.savedObject.id) {
this.getRelationshipData();
}

View file

@ -81,7 +81,7 @@ export class AdvancedSettings extends Component {
}, {});
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
const { config } = nextProps;
const { query } = this.state;

View file

@ -76,7 +76,7 @@ export class Field extends PureComponent {
this.changeImageForm = null;
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
const { unsavedValue } = this.state;
const { type, value, defVal } = nextProps.setting;
const editableValue = this.getEditableValue(type, value, defVal);

View file

@ -52,7 +52,7 @@ export class TelemetryForm extends Component {
queryMatches: null,
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
const {
query
} = nextProps;

View file

@ -42,7 +42,7 @@ import {
} from '@elastic/eui';
export class CalculationAgg extends Component {
componentWillMount() {
UNSAFE_componentWillMount() {
if (!this.props.model.variables) {
this.props.onChange(
_.assign({}, this.props.model, {

View file

@ -42,7 +42,7 @@ import {
import { FormattedMessage } from '@kbn/i18n/react';
export class MathAgg extends Component {
componentWillMount() {
UNSAFE_componentWillMount() {
if (!this.props.model.variables) {
this.props.onChange(
_.assign({}, this.props.model, {

View file

@ -42,7 +42,7 @@ const RESTRICT_FIELDS = [KBN_FIELD_TYPES.NUMBER];
export class PercentileAgg extends Component {
// eslint-disable-line react/no-multi-comp
componentWillMount() {
UNSAFE_componentWillMount() {
if (!this.props.model.percentiles) {
this.props.onChange(
_.assign({}, this.props.model, {

View file

@ -18,7 +18,7 @@
*/
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import {
ColorWrap as colorWrap,
@ -32,18 +32,13 @@ import ChromePointer from 'react-color/lib/components/chrome/ChromePointer';
import ChromePointerCircle from 'react-color/lib/components/chrome/ChromePointerCircle';
import CompactColor from 'react-color/lib/components/compact/CompactColor';
import color from 'react-color/lib/helpers/color';
import shallowCompare from 'react-addons-shallow-compare';
class CustomColorPickerUI extends Component {
class CustomColorPickerUI extends PureComponent {
constructor(props) {
super(props);
this.handleChange = this.handleChange.bind(this);
}
shouldComponentUpdate(nextProps, nextState) {
return shallowCompare(nextProps, nextState);
}
handleChange(data) {
this.props.onChange(data);
}

View file

@ -52,7 +52,7 @@ class GaugePanelConfigUi extends Component {
this.state = { selectedTab: 'data' };
}
componentWillMount() {
UNSAFE_componentWillMount() {
const { model } = this.props;
const parts = {};
if (

View file

@ -48,7 +48,7 @@ export class MetricPanelConfig extends Component {
this.state = { selectedTab: 'data' };
}
componentWillMount() {
UNSAFE_componentWillMount() {
const { model } = this.props;
if (
!model.background_color_rules ||

View file

@ -51,7 +51,7 @@ export class TablePanelConfig extends Component {
this.state = { selectedTab: 'data' };
}
componentWillMount() {
UNSAFE_componentWillMount() {
const { model } = this.props;
const parts = {};
if (!model.bar_color_rules || (model.bar_color_rules && model.bar_color_rules.length === 0)) {

View file

@ -51,7 +51,7 @@ export class TopNPanelConfig extends Component {
this.state = { selectedTab: 'data' };
}
componentWillMount() {
UNSAFE_componentWillMount() {
const { model } = this.props;
const parts = {};
if (!model.bar_color_rules || (model.bar_color_rules && model.bar_color_rules.length === 0)) {

View file

@ -37,7 +37,7 @@ const SPLIT_MODES = {
};
export class Split extends Component {
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
const { model } = nextProps;
if (model.split_mode === 'filters' && !model.split_filters) {
this.props.onChange({

View file

@ -44,7 +44,7 @@ import { getDefaultQueryLanguage } from '../../lib/get_default_query_language';
import { QueryBarWrapper } from '../../query_bar_wrapper';
class TableSeriesConfigUI extends Component {
componentWillMount() {
UNSAFE_componentWillMount() {
const { model } = this.props;
if (!model.color_rules || (model.color_rules && model.color_rules.length === 0)) {
this.props.onChange({

View file

@ -42,7 +42,7 @@ export class Gauge extends Component {
this.handleResize = this.handleResize.bind(this);
}
componentWillMount() {
UNSAFE_componentWillMount() {
const check = () => {
this.timeout = setTimeout(() => {
const newState = calculateCoordinates(this.inner, this.resize, this.state);

View file

@ -37,7 +37,7 @@ export class GaugeVis extends Component {
this.handleResize = this.handleResize.bind(this);
}
componentWillMount() {
UNSAFE_componentWillMount() {
const check = () => {
this.timeout = setTimeout(() => {
const newState = calculateCoordinates(this.inner, this.resize, this.state);

View file

@ -37,7 +37,7 @@ export class Metric extends Component {
this.handleResize = this.handleResize.bind(this);
}
componentWillMount() {
UNSAFE_componentWillMount() {
const check = () => {
this.timeout = setTimeout(() => {
const newState = calculateCoordinates(this.inner, this.resize, this.state);

View file

@ -31,7 +31,7 @@ interface Props {
}
export class ExitFullScreenButton extends PureComponent<Props> {
public componentWillMount() {
public UNSAFE_componentWillMount() {
chrome.setVisible(false);
}

View file

@ -19,7 +19,7 @@
import React from 'react';
import { mount, ReactWrapper } from 'enzyme';
import { act } from 'react-hooks-testing-library';
import { act } from '@testing-library/react-hooks';
import { I18nProvider } from '@kbn/i18n/react';
import { EuiButtonGroup } from '@elastic/eui';

View file

@ -88,7 +88,7 @@ export class IndexPatternSelect extends Component<IndexPatternSelectProps> {
this.fetchSelectedIndexPattern(this.props.indexPatternId);
}
componentWillReceiveProps(nextProps: IndexPatternSelectProps) {
UNSAFE_componentWillReceiveProps(nextProps: IndexPatternSelectProps) {
if (nextProps.indexPatternId !== this.props.indexPatternId) {
this.fetchSelectedIndexPattern(nextProps.indexPatternId);
}

View file

@ -102,7 +102,7 @@ export class EmbeddablePanel extends React.Component<Props, State> {
}
}
public componentWillMount() {
public UNSAFE_componentWillMount() {
this.mounted = true;
const { embeddable } = this.props;
const { parent } = embeddable;

View file

@ -18,7 +18,7 @@
*/
import { BehaviorSubject } from 'rxjs';
import { renderHook, act } from 'react-hooks-testing-library';
import { renderHook, act } from '@testing-library/react-hooks';
import { EUI_CHARTS_THEME_DARK, EUI_CHARTS_THEME_LIGHT } from '@elastic/eui/dist/eui_charts_theme';
import { EuiUtils } from './eui_utils';

View file

@ -35,7 +35,7 @@ class ExitFullScreenButtonUi extends PureComponent<ExitFullScreenButtonProps> {
}
};
public componentWillMount() {
public UNSAFE_componentWillMount() {
document.addEventListener('keydown', this.onKeyDown, false);
}

View file

@ -112,7 +112,7 @@ class TableListView extends React.Component<TableListViewProps, TableListViewSta
};
}
componentWillMount() {
UNSAFE_componentWillMount() {
this._isMounted = true;
}

View file

@ -17,7 +17,7 @@
* under the License.
*/
import { renderHook, act } from 'react-hooks-testing-library';
import { renderHook, act } from '@testing-library/react-hooks';
import { Subject } from 'rxjs';
import { useObservable } from './use_observable';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import { renderHook } from 'react-hooks-testing-library';
import { renderHook } from '@testing-library/react-hooks';
import { useShallowCompareEffect } from './use_shallow_compare_effect';
describe('useShallowCompareEffect', () => {

View file

@ -8,7 +8,7 @@
"license": "Apache-2.0",
"dependencies": {
"@elastic/eui": "16.0.0",
"react": "^16.8.6",
"react-dom": "^16.8.6"
"react": "^16.12.0",
"react-dom": "^16.12.0"
}
}

View file

@ -8,6 +8,6 @@
"license": "Apache-2.0",
"dependencies": {
"@elastic/eui": "16.0.0",
"react": "^16.8.6"
"react": "^16.12.0"
}
}

View file

@ -9,7 +9,7 @@
"license": "Apache-2.0",
"dependencies": {
"@elastic/eui": "16.0.0",
"react": "^16.8.6"
"react": "^16.12.0"
},
"scripts": {
"kbn": "node ../../../../scripts/kbn.js",

View file

@ -9,7 +9,7 @@
"license": "Apache-2.0",
"dependencies": {
"@elastic/eui": "16.0.0",
"react": "^16.8.6"
"react": "^16.12.0"
},
"scripts": {
"kbn": "node ../../../../scripts/kbn.js",

View file

@ -10,3 +10,4 @@
*/
import 'jest-styled-components';
import '@testing-library/jest-dom/extend-expect';

View file

@ -5,8 +5,7 @@
*/
import React from 'react';
import { render, wait, waitForElement } from 'react-testing-library';
import 'react-testing-library/cleanup-after-each';
import { render, wait, waitForElement } from '@testing-library/react';
import { ServiceOverview } from '..';
import * as urlParamsHooks from '../../../../hooks/useUrlParams';
import * as kibanaCore from '../../../../../../observability/public/context/kibana_core';
@ -61,16 +60,6 @@ describe('Service Overview -> View', () => {
jest.resetAllMocks();
});
// Suppress warnings about "act" until async/await syntax is supported: https://github.com/facebook/react/issues/14769
/* eslint-disable no-console */
const originalError = console.error;
beforeAll(() => {
console.error = jest.fn();
});
afterAll(() => {
console.error = originalError;
});
it('should render services, when list is not empty', async () => {
// mock rest requests
coreMock.http.get.mockResolvedValueOnce({

View file

@ -8,12 +8,11 @@ import React from 'react';
import {
queryByLabelText,
render,
queryBySelectText,
getByText,
getByDisplayValue,
queryByDisplayValue,
fireEvent
} from 'react-testing-library';
} from '@testing-library/react';
import { omit } from 'lodash';
import { history } from '../../../../utils/history';
import { TransactionOverview } from '..';
@ -32,16 +31,6 @@ const coreMock = ({
notifications: { toasts: { addWarning: () => {} } }
} as unknown) as LegacyCoreStart;
// Suppress warnings about "act" until async/await syntax is supported: https://github.com/facebook/react/issues/14769
/* eslint-disable no-console */
const originalError = console.error;
beforeAll(() => {
console.error = jest.fn();
});
afterAll(() => {
console.error = originalError;
});
function setup({
urlParams,
serviceTransactionTypes
@ -107,8 +96,8 @@ describe('TransactionOverview', () => {
});
// secondType is selected in the dropdown
expect(queryBySelectText(container, 'secondType')).not.toBeNull();
expect(queryBySelectText(container, 'firstType')).toBeNull();
expect(queryByDisplayValue(container, 'secondType')).not.toBeNull();
expect(queryByDisplayValue(container, 'firstType')).toBeNull();
expect(getByText(container, 'firstType')).not.toBeNull();
});

View file

@ -6,7 +6,7 @@
import React from 'react';
import { KeyValueTable } from '..';
import { cleanup, render } from 'react-testing-library';
import { render } from '@testing-library/react';
function getKeys(output: ReturnType<typeof render>) {
const keys = output.getAllByTestId('dot-key');
@ -19,8 +19,6 @@ function getValues(output: ReturnType<typeof render>) {
}
describe('KeyValueTable', () => {
afterEach(cleanup);
it('displays key and value table', () => {
const data = [
{ key: 'name.first', value: 'First Name' },

View file

@ -6,7 +6,7 @@
import { shallow } from 'enzyme';
import React from 'react';
import { ManagedTable } from '..';
import { UnoptimizedManagedTable } from '..';
describe('ManagedTable component', () => {
let people;
@ -31,14 +31,14 @@ describe('ManagedTable component', () => {
it('should render a page-full of items, with defaults', () => {
expect(
shallow(<ManagedTable columns={columns} items={people} />)
shallow(<UnoptimizedManagedTable columns={columns} items={people} />)
).toMatchSnapshot();
});
it('should render when specifying initial values', () => {
expect(
shallow(
<ManagedTable
<UnoptimizedManagedTable
columns={columns}
items={people}
initialSortField="age"

View file

@ -119,4 +119,4 @@ const ManagedTable = React.memo(
UnoptimizedManagedTable
) as typeof UnoptimizedManagedTable;
export { ManagedTable };
export { ManagedTable, UnoptimizedManagedTable };

View file

@ -6,9 +6,8 @@
import React from 'react';
import { ErrorMetadata } from '..';
import { render, cleanup } from 'react-testing-library';
import { render } from '@testing-library/react';
import { APMError } from '../../../../../../typings/es_schemas/ui/APMError';
import 'jest-dom/extend-expect';
import {
expectTextsInDocument,
expectTextsNotInDocument
@ -37,8 +36,6 @@ function getError() {
}
describe('ErrorMetadata', () => {
afterEach(cleanup);
it('should render a error with all sections', () => {
const error = getError();
const output = render(<ErrorMetadata error={error} />);

View file

@ -5,8 +5,7 @@
*/
import React from 'react';
import 'jest-dom/extend-expect';
import { render, cleanup } from 'react-testing-library';
import { render } from '@testing-library/react';
import { SpanMetadata } from '..';
import { Span } from '../../../../../../typings/es_schemas/ui/Span';
import {
@ -15,7 +14,6 @@ import {
} from '../../../../../utils/testHelpers';
describe('SpanMetadata', () => {
afterEach(cleanup);
describe('render', () => {
it('renders', () => {
const span = ({

View file

@ -6,9 +6,8 @@
import React from 'react';
import { TransactionMetadata } from '..';
import { render, cleanup } from 'react-testing-library';
import { render } from '@testing-library/react';
import { Transaction } from '../../../../../../typings/es_schemas/ui/Transaction';
import 'jest-dom/extend-expect';
import {
expectTextsInDocument,
expectTextsNotInDocument
@ -37,8 +36,6 @@ function getTransaction() {
}
describe('TransactionMetadata', () => {
afterEach(cleanup);
it('should render a transaction with all sections', () => {
const transaction = getTransaction();
const output = render(<TransactionMetadata transaction={transaction} />);

View file

@ -5,14 +5,12 @@
*/
import React from 'react';
import 'jest-dom/extend-expect';
import { render, cleanup } from 'react-testing-library';
import { render } from '@testing-library/react';
import { MetadataTable } from '..';
import { expectTextsInDocument } from '../../../../utils/testHelpers';
import { SectionsWithRows } from '../helper';
describe('MetadataTable', () => {
afterEach(cleanup);
it('shows sections', () => {
const sectionsWithRows = ([
{ key: 'foo', label: 'Foo', required: true },

View file

@ -4,8 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
import 'jest-dom/extend-expect';
import { render } from 'react-testing-library';
import { render } from '@testing-library/react';
import { Section } from '../Section';
import { expectTextsInDocument } from '../../../../utils/testHelpers';

View file

@ -5,8 +5,7 @@
*/
import React from 'react';
import { render, fireEvent, cleanup } from 'react-testing-library';
import 'react-testing-library/cleanup-after-each';
import { render, fireEvent } from '@testing-library/react';
import { TransactionActionMenu } from '../TransactionActionMenu';
import { Transaction } from '../../../../../typings/es_schemas/ui/Transaction';
import * as Transactions from './mockData';
@ -38,7 +37,6 @@ describe('TransactionActionMenu component', () => {
afterEach(() => {
jest.clearAllMocks();
cleanup();
});
it('should always render the discover link', async () => {

View file

@ -4,21 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { cleanup, renderHook } from 'react-hooks-testing-library';
import { renderHook } from '@testing-library/react-hooks';
import { useDelayedVisibility } from '.';
afterEach(cleanup);
// Suppress warnings about "act" until async/await syntax is supported: https://github.com/facebook/react/issues/14769
/* eslint-disable no-console */
const originalError = console.error;
beforeAll(() => {
console.error = jest.fn();
});
afterAll(() => {
console.error = originalError;
});
describe('useFetcher', () => {
let hook;
beforeEach(() => {

View file

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { renderHook } from 'react-hooks-testing-library';
import { renderHook } from '@testing-library/react-hooks';
import theme from '@elastic/eui/dist/eui_theme_light.json';
import * as useFetcherModule from './useFetcher';
import { useAvgDurationByBrowser } from './useAvgDurationByBrowser';

View file

@ -5,22 +5,12 @@
*/
import React from 'react';
import { render } from 'react-testing-library';
import { render } from '@testing-library/react';
import { delay, tick } from '../utils/testHelpers';
import { useFetcher } from './useFetcher';
import { KibanaCoreContext } from '../../../observability/public/context/kibana_core';
import { LegacyCoreStart } from 'kibana/public';
// Suppress warnings about "act" until async/await syntax is supported: https://github.com/facebook/react/issues/14769
/* eslint-disable no-console */
const originalError = console.error;
beforeAll(() => {
console.error = jest.fn();
});
afterAll(() => {
console.error = originalError;
});
// Wrap the hook with a provider so it can useKibanaCore
const wrapper = ({ children }: { children?: React.ReactNode }) => (
<KibanaCoreContext.Provider

View file

@ -4,25 +4,13 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { cleanup, renderHook } from 'react-hooks-testing-library';
import { renderHook } from '@testing-library/react-hooks';
import { delay } from '../utils/testHelpers';
import { useFetcher } from './useFetcher';
import { KibanaCoreContext } from '../../../observability/public/context/kibana_core';
import { LegacyCoreStart } from 'kibana/public';
import React from 'react';
afterEach(cleanup);
// Suppress warnings about "act" until async/await syntax is supported: https://github.com/facebook/react/issues/14769
/* eslint-disable no-console */
const originalError = console.error;
beforeAll(() => {
console.error = jest.fn();
});
afterAll(() => {
console.error = originalError;
});
// Wrap the hook with a provider so it can useKibanaCore
const wrapper = ({ children }: { children?: React.ReactNode }) => (
<KibanaCoreContext.Provider

View file

@ -12,7 +12,8 @@ import { Location } from 'history';
import moment from 'moment';
import { Moment } from 'moment-timezone';
import React from 'react';
import { render, waitForElement } from 'react-testing-library';
import { render, waitForElement } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import { MemoryRouter } from 'react-router-dom';
import { APMConfig } from '../../../../../plugins/apm/server';
import { LocationProvider } from '../context/LocationContext';

View file

@ -41,7 +41,7 @@ class CodeEditor extends Component<
setValue(defaultValue || '');
}
public componentWillReceiveProps(nextProps: ComponentProps) {
public UNSAFE_componentWillReceiveProps(nextProps: ComponentProps) {
if (nextProps.isFormSubmitted()) {
this.showError();
}

View file

@ -40,7 +40,7 @@ class FieldText extends Component<
}
}
public componentWillReceiveProps(nextProps: ComponentProps) {
public UNSAFE_componentWillReceiveProps(nextProps: ComponentProps) {
if (nextProps.isFormSubmitted()) {
this.showError();
}

View file

@ -42,7 +42,7 @@ class MultiFieldText extends Component<
}
}
public componentWillReceiveProps(nextProps: ComponentProps) {
public UNSAFE_componentWillReceiveProps(nextProps: ComponentProps) {
if (nextProps.isFormSubmitted()) {
this.showError();
}

View file

@ -49,7 +49,7 @@ class FieldSelect extends Component<
}
}
public componentWillReceiveProps(nextProps: ComponentProps) {
public UNSAFE_componentWillReceiveProps(nextProps: ComponentProps) {
if (nextProps.isFormSubmitted()) {
this.showError();
}

View file

@ -52,7 +52,7 @@ class BeatDetailPageUi extends React.PureComponent<PageProps, PageState> {
};
}
public async componentWillMount() {
public async UNSAFE_componentWillMount() {
const tags = await this.props.libs.tags.getTagsWithIds(this.props.beat.tags);
const blocksResult = await this.props.libs.configBlocks.getForTags(
this.props.beat.tags,

View file

@ -34,7 +34,7 @@ export class BeatTagsPage extends React.PureComponent<BeatTagsPageProps, BeatTag
};
}
public componentWillMount() {
public UNSAFE_componentWillMount() {
this.updateBeatsData();
}

View file

@ -54,7 +54,7 @@ class TagEditPageComponent extends React.PureComponent<
};
}
public componentWillMount() {
public UNSAFE_componentWillMount() {
this.loadTag();
this.loadAttachedBeats();
this.loadConfigBlocks();

View file

@ -32,7 +32,7 @@ export class AppRouter extends Component<RouterProps, RouterState> {
};
}
public async componentWillMount() {
public async UNSAFE_componentWillMount() {
if (this.state.loading === true) {
try {
await this.props.beatsContainer.reload();

View file

@ -48,7 +48,7 @@ export class TimePicker extends Component<Props, State> {
};
// TODO: Refactor to no longer use componentWillReceiveProps since it is being deprecated
componentWillReceiveProps({ from, to }: Props) {
UNSAFE_componentWillReceiveProps({ from, to }: Props) {
if (from !== this.props.from || to !== this.props.to) {
this.setState({
range: { from, to },

View file

@ -5,7 +5,7 @@
*/
import React from 'react';
import { render, cleanup } from 'react-testing-library';
import { render } from '@testing-library/react';
import {
withUnconnectedElementsLoadedTelemetry,
WorkpadLoadedMetric,
@ -63,8 +63,6 @@ describe('Elements Loaded Telemetry', () => {
trackMetric.mockReset();
});
afterEach(cleanup);
it('tracks when all resolvedArgs are completed', () => {
const { rerender } = render(
<Component

View file

@ -28,7 +28,7 @@ class ArgTemplateFormComponent extends React.Component {
errorTemplate: PropTypes.oneOfType([PropTypes.element, PropTypes.func]).isRequired,
};
componentWillUpdate(prevProps) {
UNSAFE_componentWillUpdate(prevProps) {
//see if error state changed
if (this.props.error !== prevProps.error) {
this.props.handlers.destroy();

View file

@ -20,7 +20,7 @@ export function createStatefulPropHoc(fieldname, updater = 'updateValue') {
};
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
this.setState({ value: nextProps[fieldname] });
}

View file

@ -20,7 +20,7 @@ export class Fullscreen extends React.Component {
height: 0,
};
componentWillMount() {
UNSAFE_componentWillMount() {
this.win = getWindow();
this.setState({
width: this.win.innerWidth,

View file

@ -20,7 +20,7 @@ export class FunctionFormContextPending extends React.PureComponent {
this.fetchContext(this.props);
}
componentWillReceiveProps(newProps) {
UNSAFE_componentWillReceiveProps(newProps) {
const oldContext = this.props.contextExpression;
const newContext = newProps.contextExpression;
const forceUpdate = newProps.expressionType.requiresContext && oldContext !== newContext;

View file

@ -42,7 +42,7 @@ export class RenderWithFn extends React.Component {
this.renderTarget = null;
}
componentWillReceiveProps({ renderFn }) {
UNSAFE_componentWillReceiveProps({ renderFn }) {
const newRenderFunction = renderFn !== this.props.renderFn;
if (newRenderFunction) {

View file

@ -37,7 +37,7 @@ export class Router extends React.PureComponent {
return { router };
}
componentWillMount() {
UNSAFE_componentWillMount() {
// routerProvider is a singleton, and will only ever return one instance
const { routes, onRouteChange, onLoad, onError } = this.props;
const router = routerProvider(routes);

View file

@ -70,7 +70,7 @@ export class WorkpadLoader extends React.PureComponent {
this._isMounted = true;
}
componentWillReceiveProps(newProps) {
UNSAFE_componentWillReceiveProps(newProps) {
// the workpadId prop will change when a is created or loaded, close the toolbar when it does
const { workpadId, onClose } = this.props;
if (workpadId !== newProps.workpadId) {

View file

@ -4,10 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/
/*
One test relies on react-dom at a version of 16.9... it can be enabled
once renovate completes the upgrade. Relevant code has been commented out
in the meantime.
/*
One test relies on react-dom at a version of 16.9... it can be enabled
once renovate completes the upgrade. Relevant code has been commented out
in the meantime.
*/
import { mount, ReactWrapper } from 'enzyme';

View file

@ -56,7 +56,7 @@ export class App extends Component {
};
}
componentWillMount() {
UNSAFE_componentWillMount() {
routing.userHasLeftApp = false;
}

View file

@ -24,6 +24,7 @@ import {
EuiForm,
EuiSpacer,
EuiIconTip,
EuiComboBoxOptionProps,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import classNames from 'classnames';
@ -221,7 +222,9 @@ export function FieldEditor({
}}
singleSelection={{ asPlainText: true }}
isClearable={false}
options={toOptions(allFields, initialField)}
options={
toOptions(allFields, initialField) as Array<EuiComboBoxOptionProps<string>>
}
selectedOptions={[
{
value: currentField.name,

View file

@ -9,7 +9,7 @@ import { EuiTab, EuiListGroupItem, EuiButton, EuiAccordion, EuiFieldText } from
import * as Rx from 'rxjs';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { Settings, AngularProps } from './settings';
import { act } from 'react-testing-library';
import { act } from '@testing-library/react';
import { ReactWrapper } from 'enzyme';
import { UrlTemplateForm } from './url_template_form';
import {

View file

@ -27,7 +27,7 @@ export class NodeAttrsDetails extends PureComponent {
selectedNodeAttrs: PropTypes.string.isRequired,
};
componentWillMount() {
UNSAFE_componentWillMount() {
this.props.fetchNodeDetails(this.props.selectedNodeAttrs);
}

View file

@ -105,7 +105,6 @@ export const setup = async (): Promise<IdxMgmtHomeTestBed> => {
const { rows } = table.getMetaData('templateTable');
const templateLink = findTestSubject(rows[index].reactWrapper, 'templateDetailsLink');
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
const { href } = templateLink.props();
router.navigateTo(href!);

View file

@ -22,9 +22,7 @@ const removeWhiteSpaceOnArrayValues = (array: any[]) =>
jest.mock('ui/new_platform');
// We need to skip the tests until react 16.9.0 is released
// which supports asynchronous code inside act()
describe.skip('<IndexManagementHome />', () => {
describe('<IndexManagementHome />', () => {
const { server, httpRequestsMockHelpers } = setupEnvironment();
let testBed: IdxMgmtHomeTestBed;
@ -38,7 +36,6 @@ describe.skip('<IndexManagementHome />', () => {
testBed = await setup();
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
const { component } = testBed;
@ -81,7 +78,6 @@ describe.skip('<IndexManagementHome />', () => {
actions.selectHomeTab('templatesTab');
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
await nextTick();
component.update();
@ -101,7 +97,6 @@ describe.skip('<IndexManagementHome />', () => {
actions.selectHomeTab('templatesTab');
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
await nextTick();
component.update();
@ -147,7 +142,6 @@ describe.skip('<IndexManagementHome />', () => {
actions.selectHomeTab('templatesTab');
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
await nextTick();
component.update();
@ -186,7 +180,6 @@ describe.skip('<IndexManagementHome />', () => {
expect(exists('reloadButton')).toBe(true);
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
actions.clickReloadButton();
await nextTick();
@ -214,7 +207,6 @@ describe.skip('<IndexManagementHome />', () => {
expect(exists('systemTemplatesSwitch')).toBe(true);
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
form.toggleEuiSwitch('systemTemplatesSwitch');
await nextTick();
@ -290,7 +282,6 @@ describe.skip('<IndexManagementHome />', () => {
test('should show a warning message when attempting to delete a system template', async () => {
const { component, form, actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
form.toggleEuiSwitch('systemTemplatesSwitch');
await nextTick();
@ -328,7 +319,6 @@ describe.skip('<IndexManagementHome />', () => {
},
});
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
confirmButton!.click();
await nextTick();
@ -384,7 +374,6 @@ describe.skip('<IndexManagementHome />', () => {
actions.clickCloseDetailsButton();
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
await nextTick();
component.update();
@ -474,7 +463,6 @@ describe.skip('<IndexManagementHome />', () => {
await actions.clickTemplateAt(0);
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
await nextTick();
component.update();

View file

@ -38,9 +38,7 @@ jest.mock('@elastic/eui', () => ({
),
}));
// We need to skip the tests until react 16.9.0 is released
// which supports asynchronous code inside act()
describe.skip('<TemplateClone />', () => {
describe('<TemplateClone />', () => {
let testBed: TemplateFormTestBed;
const { server, httpRequestsMockHelpers } = setupEnvironment();
@ -59,7 +57,6 @@ describe.skip('<TemplateClone />', () => {
testBed = await setup();
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
await nextTick();
testBed.component.update();
@ -77,7 +74,6 @@ describe.skip('<TemplateClone />', () => {
beforeEach(async () => {
const { actions, component } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
// Complete step 1 (logistics)
// Specify index patterns, but do not change name (keep default)
@ -105,7 +101,6 @@ describe.skip('<TemplateClone />', () => {
it('should send the correct payload', async () => {
const { actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
actions.clickSubmitButton();
await nextTick();

View file

@ -43,9 +43,7 @@ jest.mock('@elastic/eui', () => ({
),
}));
// We need to skip the tests until react 16.9.0 is released
// which supports asynchronous code inside act()
describe.skip('<TemplateCreate />', () => {
describe('<TemplateCreate />', () => {
let testBed: TemplateFormTestBed;
const { server, httpRequestsMockHelpers } = setupEnvironment();
@ -71,7 +69,6 @@ describe.skip('<TemplateCreate />', () => {
expect(find('nextButton').props().disabled).toEqual(false);
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
actions.clickNextButton();
await nextTick();
@ -90,7 +87,6 @@ describe.skip('<TemplateCreate />', () => {
beforeEach(async () => {
const { actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
// Complete step 1 (logistics)
await actions.completeStepOne({ name: TEMPLATE_NAME, indexPatterns: ['index1'] });
@ -107,7 +103,6 @@ describe.skip('<TemplateCreate />', () => {
it('should not allow invalid json', async () => {
const { form, actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
actions.completeStepTwo('{ invalidJsonString ');
});
@ -120,7 +115,6 @@ describe.skip('<TemplateCreate />', () => {
beforeEach(async () => {
const { actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
// Complete step 1 (logistics)
await actions.completeStepOne({ name: TEMPLATE_NAME, indexPatterns: ['index1'] });
@ -140,7 +134,6 @@ describe.skip('<TemplateCreate />', () => {
it('should not allow invalid json', async () => {
const { actions, form } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
// Complete step 3 (mappings) with invalid json
await actions.completeStepThree('{ invalidJsonString ');
@ -154,7 +147,6 @@ describe.skip('<TemplateCreate />', () => {
beforeEach(async () => {
const { actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
// Complete step 1 (logistics)
await actions.completeStepOne({ name: TEMPLATE_NAME, indexPatterns: ['index1'] });
@ -177,7 +169,6 @@ describe.skip('<TemplateCreate />', () => {
it('should not allow invalid json', async () => {
const { actions, form } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
// Complete step 4 (aliases) with invalid json
await actions.completeStepFour('{ invalidJsonString ');
@ -194,7 +185,6 @@ describe.skip('<TemplateCreate />', () => {
const { actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
// Complete step 1 (logistics)
await actions.completeStepOne({
@ -249,7 +239,6 @@ describe.skip('<TemplateCreate />', () => {
const { actions, exists, find } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
// Complete step 1 (logistics)
await actions.completeStepOne({
@ -280,7 +269,6 @@ describe.skip('<TemplateCreate />', () => {
const { actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
// Complete step 1 (logistics)
await actions.completeStepOne({
@ -302,7 +290,6 @@ describe.skip('<TemplateCreate />', () => {
it('should send the correct payload', async () => {
const { actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
actions.clickSubmitButton();
await nextTick();
@ -333,7 +320,6 @@ describe.skip('<TemplateCreate />', () => {
httpRequestsMockHelpers.setCreateTemplateResponse(undefined, { body: error });
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
actions.clickSubmitButton();
await nextTick();

View file

@ -40,9 +40,7 @@ jest.mock('@elastic/eui', () => ({
),
}));
// We need to skip the tests until react 16.9.0 is released
// which supports asynchronous code inside act()
describe.skip('<TemplateEdit />', () => {
describe('<TemplateEdit />', () => {
let testBed: TemplateFormTestBed;
const { server, httpRequestsMockHelpers } = setupEnvironment();
@ -61,7 +59,6 @@ describe.skip('<TemplateEdit />', () => {
testBed = await setup();
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
await nextTick();
testBed.component.update();
@ -87,7 +84,6 @@ describe.skip('<TemplateEdit />', () => {
beforeEach(async () => {
const { actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
// Complete step 1 (logistics)
await actions.completeStepOne({
@ -108,7 +104,6 @@ describe.skip('<TemplateEdit />', () => {
it('should send the correct payload with changed values', async () => {
const { actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => {
actions.clickSubmitButton();
await nextTick();

View file

@ -56,7 +56,7 @@ export class EditSettingsJson extends React.PureComponent {
}
return newSettings;
}
componentWillMount() {
UNSAFE_componentWillMount() {
const { indexName } = this.props;
this.props.loadIndexData({ dataType: TAB_SETTINGS, indexName });
}

View file

@ -10,10 +10,10 @@ import { EuiCodeEditor } from '@elastic/eui';
import 'brace/theme/textmate';
export class ShowJson extends React.PureComponent {
componentWillMount() {
UNSAFE_componentWillMount() {
this.props.loadIndexData(this.props);
}
componentWillUpdate(newProps) {
UNSAFE_componentWillUpdate(newProps) {
const { data, loadIndexData } = newProps;
if (!data) {
loadIndexData(newProps);

View file

@ -8,7 +8,7 @@ import { fetch } from '../../utils/fetch';
import { useMetricsExplorerData } from './use_metrics_explorer_data';
import { MetricsExplorerAggregation } from '../../../server/routes/metrics_explorer/types';
import { renderHook } from 'react-hooks-testing-library';
import { renderHook } from '@testing-library/react-hooks';
import {
options,

View file

@ -5,7 +5,7 @@
*/
import React from 'react';
import { renderHook, act } from 'react-hooks-testing-library';
import { renderHook, act } from '@testing-library/react-hooks';
import {
useMetricsExplorerOptions,
MetricsExplorerOptionsContainer,
@ -65,7 +65,7 @@ describe('useMetricExplorerOptions', () => {
});
it('should change the store when options update', () => {
const { result, waitForNextUpdate } = renderUseMetricsExplorerOptionsHook();
const { result, rerender } = renderUseMetricsExplorerOptionsHook();
const newOptions: MetricsExplorerOptions = {
...DEFAULT_OPTIONS,
metrics: [{ aggregation: MetricsExplorerAggregation.count }],
@ -73,13 +73,13 @@ describe('useMetricExplorerOptions', () => {
act(() => {
result.current.setOptions(newOptions);
});
waitForNextUpdate();
rerender();
expect(result.current.options).toEqual(newOptions);
expect(STORE.MetricsExplorerOptions).toEqual(JSON.stringify(newOptions));
});
it('should change the store when timerange update', () => {
const { result, waitForNextUpdate } = renderUseMetricsExplorerOptionsHook();
const { result, rerender } = renderUseMetricsExplorerOptionsHook();
const newTimeRange: MetricsExplorerTimeOptions = {
...DEFAULT_TIMERANGE,
from: 'now-15m',
@ -87,7 +87,7 @@ describe('useMetricExplorerOptions', () => {
act(() => {
result.current.setTimeRange(newTimeRange);
});
waitForNextUpdate();
rerender();
expect(result.current.currentTimerange).toEqual(newTimeRange);
expect(STORE.MetricsExplorerTimeRange).toEqual(JSON.stringify(newTimeRange));
});

View file

@ -5,7 +5,7 @@
*/
import { fetch } from '../../../utils/fetch';
import { renderHook } from 'react-hooks-testing-library';
import { renderHook } from '@testing-library/react-hooks';
import { useMetricsExplorerState } from './use_metric_explorer_state';
import { MetricsExplorerOptionsContainer } from '../../../containers/metrics_explorer/use_metrics_explorer_options';
import React from 'react';
@ -172,7 +172,7 @@ describe('useMetricsExplorerState', () => {
describe('handleLoadMore', () => {
it('should load more based on the afterKey', async () => {
const { result, waitForNextUpdate } = renderUseMetricsExplorerStateHook();
const { result, waitForNextUpdate, rerender } = renderUseMetricsExplorerStateHook();
expect(result.current.data).toBe(null);
expect(result.current.loading).toBe(true);
await waitForNextUpdate();
@ -189,7 +189,7 @@ describe('useMetricsExplorerState', () => {
} as any);
const { handleLoadMore } = result.current;
handleLoadMore(pageInfo.afterKey!);
await waitForNextUpdate();
await rerender();
expect(result.current.loading).toBe(true);
await waitForNextUpdate();
expect(result.current.loading).toBe(false);

View file

@ -6,7 +6,7 @@
import { useHostIpToName } from './use_host_ip_to_name';
import { fetch } from '../../utils/fetch';
import { renderHook } from 'react-hooks-testing-library';
import { renderHook } from '@testing-library/react-hooks';
const renderUseHostIpToNameHook = () =>
renderHook(props => useHostIpToName(props.ipAddress, props.indexPattern), {

Some files were not shown because too many files have changed in this diff Show more