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

View file

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

View file

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

View file

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

View file

@ -28,7 +28,7 @@
"intl-messageformat": "^2.2.0", "intl-messageformat": "^2.2.0",
"intl-relativeformat": "^2.1.0", "intl-relativeformat": "^2.1.0",
"prop-types": "^15.6.2", "prop-types": "^15.6.2",
"react": "^16.8.6", "react": "^16.12.0",
"react-intl": "^2.8.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 currentRoute = nextProps.routes[1];
const nextRoute = this.props.getNextRoute(currentRoute.name); const nextRoute = this.props.getNextRoute(currentRoute.name);
const previousRoute = this.props.getPreviousRoute(currentRoute.name); const previousRoute = this.props.getPreviousRoute(currentRoute.name);

View file

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

View file

@ -36,7 +36,7 @@ export class GuideSection extends Component {
this.props.openCodeViewer(this.props.source, this.props.title); this.props.openCodeViewer(this.props.source, this.props.title);
} }
componentWillMount() { UNSAFE_componentWillMount() {
this.props.registerSection(this.getId(), this.props.title); 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. // Only force the chrome to be hidden if we're navigating from a non-sandbox to a sandbox.
if (!this.props.isSandbox && nextProps.isSandbox) { if (!this.props.isSandbox && nextProps.isSandbox) {
this.setState({ this.setState({

View file

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

View file

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

View file

@ -45,16 +45,6 @@ beforeEach(() => {
jest.clearAllMocks(); 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)); export const waitForPromises = () => new Promise(resolve => setTimeout(resolve, 0));
/** /**

View file

@ -16,20 +16,10 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * 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 { buildSearchBody, useEsDocSearch, ElasticRequestState } from './use_es_doc_search';
import { DocProps } from './doc'; 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', () => { describe('Test of <Doc /> helper / hook', () => {
test('buildSearchBody', () => { test('buildSearchBody', () => {
const indexPattern = { const indexPattern = {

View file

@ -67,7 +67,7 @@ class TutorialUi extends React.Component {
} }
} }
componentWillMount() { UNSAFE_componentWillMount() {
this._isMounted = true; 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); 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) { if (nextProps.indices.length !== this.props.indices.length) {
this.pager.setTotalItems(nextProps.indices.length); this.pager.setTotalItems(nextProps.indices.length);
this.resetPageTo0(); this.resetPageTo0();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -18,7 +18,7 @@
*/ */
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { PureComponent } from 'react';
import { import {
ColorWrap as colorWrap, 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 ChromePointerCircle from 'react-color/lib/components/chrome/ChromePointerCircle';
import CompactColor from 'react-color/lib/components/compact/CompactColor'; import CompactColor from 'react-color/lib/components/compact/CompactColor';
import color from 'react-color/lib/helpers/color'; 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) { constructor(props) {
super(props); super(props);
this.handleChange = this.handleChange.bind(this); this.handleChange = this.handleChange.bind(this);
} }
shouldComponentUpdate(nextProps, nextState) {
return shallowCompare(nextProps, nextState);
}
handleChange(data) { handleChange(data) {
this.props.onChange(data); this.props.onChange(data);
} }

View file

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

View file

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

View file

@ -51,7 +51,7 @@ export class TablePanelConfig extends Component {
this.state = { selectedTab: 'data' }; this.state = { selectedTab: 'data' };
} }
componentWillMount() { UNSAFE_componentWillMount() {
const { model } = this.props; const { model } = this.props;
const parts = {}; const parts = {};
if (!model.bar_color_rules || (model.bar_color_rules && model.bar_color_rules.length === 0)) { 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' }; this.state = { selectedTab: 'data' };
} }
componentWillMount() { UNSAFE_componentWillMount() {
const { model } = this.props; const { model } = this.props;
const parts = {}; const parts = {};
if (!model.bar_color_rules || (model.bar_color_rules && model.bar_color_rules.length === 0)) { 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 { export class Split extends Component {
componentWillReceiveProps(nextProps) { UNSAFE_componentWillReceiveProps(nextProps) {
const { model } = nextProps; const { model } = nextProps;
if (model.split_mode === 'filters' && !model.split_filters) { if (model.split_mode === 'filters' && !model.split_filters) {
this.props.onChange({ this.props.onChange({

View file

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

View file

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

View file

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

View file

@ -19,7 +19,7 @@
import React from 'react'; import React from 'react';
import { mount, ReactWrapper } from 'enzyme'; 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 { I18nProvider } from '@kbn/i18n/react';
import { EuiButtonGroup } from '@elastic/eui'; import { EuiButtonGroup } from '@elastic/eui';

View file

@ -88,7 +88,7 @@ export class IndexPatternSelect extends Component<IndexPatternSelectProps> {
this.fetchSelectedIndexPattern(this.props.indexPatternId); this.fetchSelectedIndexPattern(this.props.indexPatternId);
} }
componentWillReceiveProps(nextProps: IndexPatternSelectProps) { UNSAFE_componentWillReceiveProps(nextProps: IndexPatternSelectProps) {
if (nextProps.indexPatternId !== this.props.indexPatternId) { if (nextProps.indexPatternId !== this.props.indexPatternId) {
this.fetchSelectedIndexPattern(nextProps.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; this.mounted = true;
const { embeddable } = this.props; const { embeddable } = this.props;
const { parent } = embeddable; const { parent } = embeddable;

View file

@ -18,7 +18,7 @@
*/ */
import { BehaviorSubject } from 'rxjs'; 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 { EUI_CHARTS_THEME_DARK, EUI_CHARTS_THEME_LIGHT } from '@elastic/eui/dist/eui_charts_theme';
import { EuiUtils } from './eui_utils'; 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); 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; this._isMounted = true;
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -5,8 +5,7 @@
*/ */
import React from 'react'; import React from 'react';
import { render, wait, waitForElement } from 'react-testing-library'; import { render, wait, waitForElement } from '@testing-library/react';
import 'react-testing-library/cleanup-after-each';
import { ServiceOverview } from '..'; import { ServiceOverview } from '..';
import * as urlParamsHooks from '../../../../hooks/useUrlParams'; import * as urlParamsHooks from '../../../../hooks/useUrlParams';
import * as kibanaCore from '../../../../../../observability/public/context/kibana_core'; import * as kibanaCore from '../../../../../../observability/public/context/kibana_core';
@ -61,16 +60,6 @@ describe('Service Overview -> View', () => {
jest.resetAllMocks(); 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 () => { it('should render services, when list is not empty', async () => {
// mock rest requests // mock rest requests
coreMock.http.get.mockResolvedValueOnce({ coreMock.http.get.mockResolvedValueOnce({

View file

@ -8,12 +8,11 @@ import React from 'react';
import { import {
queryByLabelText, queryByLabelText,
render, render,
queryBySelectText,
getByText, getByText,
getByDisplayValue, getByDisplayValue,
queryByDisplayValue, queryByDisplayValue,
fireEvent fireEvent
} from 'react-testing-library'; } from '@testing-library/react';
import { omit } from 'lodash'; import { omit } from 'lodash';
import { history } from '../../../../utils/history'; import { history } from '../../../../utils/history';
import { TransactionOverview } from '..'; import { TransactionOverview } from '..';
@ -32,16 +31,6 @@ const coreMock = ({
notifications: { toasts: { addWarning: () => {} } } notifications: { toasts: { addWarning: () => {} } }
} as unknown) as LegacyCoreStart; } 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({ function setup({
urlParams, urlParams,
serviceTransactionTypes serviceTransactionTypes
@ -107,8 +96,8 @@ describe('TransactionOverview', () => {
}); });
// secondType is selected in the dropdown // secondType is selected in the dropdown
expect(queryBySelectText(container, 'secondType')).not.toBeNull(); expect(queryByDisplayValue(container, 'secondType')).not.toBeNull();
expect(queryBySelectText(container, 'firstType')).toBeNull(); expect(queryByDisplayValue(container, 'firstType')).toBeNull();
expect(getByText(container, 'firstType')).not.toBeNull(); expect(getByText(container, 'firstType')).not.toBeNull();
}); });

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -5,14 +5,12 @@
*/ */
import React from 'react'; import React from 'react';
import 'jest-dom/extend-expect'; import { render } from '@testing-library/react';
import { render, cleanup } from 'react-testing-library';
import { MetadataTable } from '..'; import { MetadataTable } from '..';
import { expectTextsInDocument } from '../../../../utils/testHelpers'; import { expectTextsInDocument } from '../../../../utils/testHelpers';
import { SectionsWithRows } from '../helper'; import { SectionsWithRows } from '../helper';
describe('MetadataTable', () => { describe('MetadataTable', () => {
afterEach(cleanup);
it('shows sections', () => { it('shows sections', () => {
const sectionsWithRows = ([ const sectionsWithRows = ([
{ key: 'foo', label: 'Foo', required: true }, { 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. * you may not use this file except in compliance with the Elastic License.
*/ */
import React from 'react'; import React from 'react';
import 'jest-dom/extend-expect'; import { render } from '@testing-library/react';
import { render } from 'react-testing-library';
import { Section } from '../Section'; import { Section } from '../Section';
import { expectTextsInDocument } from '../../../../utils/testHelpers'; import { expectTextsInDocument } from '../../../../utils/testHelpers';

View file

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

View file

@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License. * 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 theme from '@elastic/eui/dist/eui_theme_light.json';
import * as useFetcherModule from './useFetcher'; import * as useFetcherModule from './useFetcher';
import { useAvgDurationByBrowser } from './useAvgDurationByBrowser'; import { useAvgDurationByBrowser } from './useAvgDurationByBrowser';

View file

@ -5,22 +5,12 @@
*/ */
import React from 'react'; import React from 'react';
import { render } from 'react-testing-library'; import { render } from '@testing-library/react';
import { delay, tick } from '../utils/testHelpers'; import { delay, tick } from '../utils/testHelpers';
import { useFetcher } from './useFetcher'; import { useFetcher } from './useFetcher';
import { KibanaCoreContext } from '../../../observability/public/context/kibana_core'; import { KibanaCoreContext } from '../../../observability/public/context/kibana_core';
import { LegacyCoreStart } from 'kibana/public'; 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 // Wrap the hook with a provider so it can useKibanaCore
const wrapper = ({ children }: { children?: React.ReactNode }) => ( const wrapper = ({ children }: { children?: React.ReactNode }) => (
<KibanaCoreContext.Provider <KibanaCoreContext.Provider

View file

@ -4,25 +4,13 @@
* you may not use this file except in compliance with the Elastic License. * 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 { delay } from '../utils/testHelpers';
import { useFetcher } from './useFetcher'; import { useFetcher } from './useFetcher';
import { KibanaCoreContext } from '../../../observability/public/context/kibana_core'; import { KibanaCoreContext } from '../../../observability/public/context/kibana_core';
import { LegacyCoreStart } from 'kibana/public'; import { LegacyCoreStart } from 'kibana/public';
import React from 'react'; 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 // Wrap the hook with a provider so it can useKibanaCore
const wrapper = ({ children }: { children?: React.ReactNode }) => ( const wrapper = ({ children }: { children?: React.ReactNode }) => (
<KibanaCoreContext.Provider <KibanaCoreContext.Provider

View file

@ -12,7 +12,8 @@ import { Location } from 'history';
import moment from 'moment'; import moment from 'moment';
import { Moment } from 'moment-timezone'; import { Moment } from 'moment-timezone';
import React from 'react'; 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 { MemoryRouter } from 'react-router-dom';
import { APMConfig } from '../../../../../plugins/apm/server'; import { APMConfig } from '../../../../../plugins/apm/server';
import { LocationProvider } from '../context/LocationContext'; import { LocationProvider } from '../context/LocationContext';

View file

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

View file

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

View file

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

View file

@ -49,7 +49,7 @@ class FieldSelect extends Component<
} }
} }
public componentWillReceiveProps(nextProps: ComponentProps) { public UNSAFE_componentWillReceiveProps(nextProps: ComponentProps) {
if (nextProps.isFormSubmitted()) { if (nextProps.isFormSubmitted()) {
this.showError(); 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 tags = await this.props.libs.tags.getTagsWithIds(this.props.beat.tags);
const blocksResult = await this.props.libs.configBlocks.getForTags( const blocksResult = await this.props.libs.configBlocks.getForTags(
this.props.beat.tags, 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(); this.updateBeatsData();
} }

View file

@ -54,7 +54,7 @@ class TagEditPageComponent extends React.PureComponent<
}; };
} }
public componentWillMount() { public UNSAFE_componentWillMount() {
this.loadTag(); this.loadTag();
this.loadAttachedBeats(); this.loadAttachedBeats();
this.loadConfigBlocks(); 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) { if (this.state.loading === true) {
try { try {
await this.props.beatsContainer.reload(); 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 // 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) { if (from !== this.props.from || to !== this.props.to) {
this.setState({ this.setState({
range: { from, to }, range: { from, to },

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,10 +4,10 @@
* you may not use this file except in compliance with the Elastic License. * 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 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 once renovate completes the upgrade. Relevant code has been commented out
in the meantime. in the meantime.
*/ */
import { mount, ReactWrapper } from 'enzyme'; import { mount, ReactWrapper } from 'enzyme';

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -22,9 +22,7 @@ const removeWhiteSpaceOnArrayValues = (array: any[]) =>
jest.mock('ui/new_platform'); jest.mock('ui/new_platform');
// We need to skip the tests until react 16.9.0 is released describe('<IndexManagementHome />', () => {
// which supports asynchronous code inside act()
describe.skip('<IndexManagementHome />', () => {
const { server, httpRequestsMockHelpers } = setupEnvironment(); const { server, httpRequestsMockHelpers } = setupEnvironment();
let testBed: IdxMgmtHomeTestBed; let testBed: IdxMgmtHomeTestBed;
@ -38,7 +36,6 @@ describe.skip('<IndexManagementHome />', () => {
testBed = await setup(); testBed = await setup();
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
const { component } = testBed; const { component } = testBed;
@ -81,7 +78,6 @@ describe.skip('<IndexManagementHome />', () => {
actions.selectHomeTab('templatesTab'); actions.selectHomeTab('templatesTab');
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
await nextTick(); await nextTick();
component.update(); component.update();
@ -101,7 +97,6 @@ describe.skip('<IndexManagementHome />', () => {
actions.selectHomeTab('templatesTab'); actions.selectHomeTab('templatesTab');
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
await nextTick(); await nextTick();
component.update(); component.update();
@ -147,7 +142,6 @@ describe.skip('<IndexManagementHome />', () => {
actions.selectHomeTab('templatesTab'); actions.selectHomeTab('templatesTab');
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
await nextTick(); await nextTick();
component.update(); component.update();
@ -186,7 +180,6 @@ describe.skip('<IndexManagementHome />', () => {
expect(exists('reloadButton')).toBe(true); expect(exists('reloadButton')).toBe(true);
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
actions.clickReloadButton(); actions.clickReloadButton();
await nextTick(); await nextTick();
@ -214,7 +207,6 @@ describe.skip('<IndexManagementHome />', () => {
expect(exists('systemTemplatesSwitch')).toBe(true); expect(exists('systemTemplatesSwitch')).toBe(true);
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
form.toggleEuiSwitch('systemTemplatesSwitch'); form.toggleEuiSwitch('systemTemplatesSwitch');
await nextTick(); await nextTick();
@ -290,7 +282,6 @@ describe.skip('<IndexManagementHome />', () => {
test('should show a warning message when attempting to delete a system template', async () => { test('should show a warning message when attempting to delete a system template', async () => {
const { component, form, actions } = testBed; const { component, form, actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
form.toggleEuiSwitch('systemTemplatesSwitch'); form.toggleEuiSwitch('systemTemplatesSwitch');
await nextTick(); await nextTick();
@ -328,7 +319,6 @@ describe.skip('<IndexManagementHome />', () => {
}, },
}); });
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
confirmButton!.click(); confirmButton!.click();
await nextTick(); await nextTick();
@ -384,7 +374,6 @@ describe.skip('<IndexManagementHome />', () => {
actions.clickCloseDetailsButton(); actions.clickCloseDetailsButton();
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
await nextTick(); await nextTick();
component.update(); component.update();
@ -474,7 +463,6 @@ describe.skip('<IndexManagementHome />', () => {
await actions.clickTemplateAt(0); await actions.clickTemplateAt(0);
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
await nextTick(); await nextTick();
component.update(); 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 describe('<TemplateClone />', () => {
// which supports asynchronous code inside act()
describe.skip('<TemplateClone />', () => {
let testBed: TemplateFormTestBed; let testBed: TemplateFormTestBed;
const { server, httpRequestsMockHelpers } = setupEnvironment(); const { server, httpRequestsMockHelpers } = setupEnvironment();
@ -59,7 +57,6 @@ describe.skip('<TemplateClone />', () => {
testBed = await setup(); testBed = await setup();
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
await nextTick(); await nextTick();
testBed.component.update(); testBed.component.update();
@ -77,7 +74,6 @@ describe.skip('<TemplateClone />', () => {
beforeEach(async () => { beforeEach(async () => {
const { actions, component } = testBed; const { actions, component } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
// Complete step 1 (logistics) // Complete step 1 (logistics)
// Specify index patterns, but do not change name (keep default) // Specify index patterns, but do not change name (keep default)
@ -105,7 +101,6 @@ describe.skip('<TemplateClone />', () => {
it('should send the correct payload', async () => { it('should send the correct payload', async () => {
const { actions } = testBed; const { actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
actions.clickSubmitButton(); actions.clickSubmitButton();
await nextTick(); 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 describe('<TemplateCreate />', () => {
// which supports asynchronous code inside act()
describe.skip('<TemplateCreate />', () => {
let testBed: TemplateFormTestBed; let testBed: TemplateFormTestBed;
const { server, httpRequestsMockHelpers } = setupEnvironment(); const { server, httpRequestsMockHelpers } = setupEnvironment();
@ -71,7 +69,6 @@ describe.skip('<TemplateCreate />', () => {
expect(find('nextButton').props().disabled).toEqual(false); expect(find('nextButton').props().disabled).toEqual(false);
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
actions.clickNextButton(); actions.clickNextButton();
await nextTick(); await nextTick();
@ -90,7 +87,6 @@ describe.skip('<TemplateCreate />', () => {
beforeEach(async () => { beforeEach(async () => {
const { actions } = testBed; const { actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
// Complete step 1 (logistics) // Complete step 1 (logistics)
await actions.completeStepOne({ name: TEMPLATE_NAME, indexPatterns: ['index1'] }); await actions.completeStepOne({ name: TEMPLATE_NAME, indexPatterns: ['index1'] });
@ -107,7 +103,6 @@ describe.skip('<TemplateCreate />', () => {
it('should not allow invalid json', async () => { it('should not allow invalid json', async () => {
const { form, actions } = testBed; const { form, actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
actions.completeStepTwo('{ invalidJsonString '); actions.completeStepTwo('{ invalidJsonString ');
}); });
@ -120,7 +115,6 @@ describe.skip('<TemplateCreate />', () => {
beforeEach(async () => { beforeEach(async () => {
const { actions } = testBed; const { actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
// Complete step 1 (logistics) // Complete step 1 (logistics)
await actions.completeStepOne({ name: TEMPLATE_NAME, indexPatterns: ['index1'] }); await actions.completeStepOne({ name: TEMPLATE_NAME, indexPatterns: ['index1'] });
@ -140,7 +134,6 @@ describe.skip('<TemplateCreate />', () => {
it('should not allow invalid json', async () => { it('should not allow invalid json', async () => {
const { actions, form } = testBed; const { actions, form } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
// Complete step 3 (mappings) with invalid json // Complete step 3 (mappings) with invalid json
await actions.completeStepThree('{ invalidJsonString '); await actions.completeStepThree('{ invalidJsonString ');
@ -154,7 +147,6 @@ describe.skip('<TemplateCreate />', () => {
beforeEach(async () => { beforeEach(async () => {
const { actions } = testBed; const { actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
// Complete step 1 (logistics) // Complete step 1 (logistics)
await actions.completeStepOne({ name: TEMPLATE_NAME, indexPatterns: ['index1'] }); await actions.completeStepOne({ name: TEMPLATE_NAME, indexPatterns: ['index1'] });
@ -177,7 +169,6 @@ describe.skip('<TemplateCreate />', () => {
it('should not allow invalid json', async () => { it('should not allow invalid json', async () => {
const { actions, form } = testBed; const { actions, form } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
// Complete step 4 (aliases) with invalid json // Complete step 4 (aliases) with invalid json
await actions.completeStepFour('{ invalidJsonString '); await actions.completeStepFour('{ invalidJsonString ');
@ -194,7 +185,6 @@ describe.skip('<TemplateCreate />', () => {
const { actions } = testBed; const { actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
// Complete step 1 (logistics) // Complete step 1 (logistics)
await actions.completeStepOne({ await actions.completeStepOne({
@ -249,7 +239,6 @@ describe.skip('<TemplateCreate />', () => {
const { actions, exists, find } = testBed; const { actions, exists, find } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
// Complete step 1 (logistics) // Complete step 1 (logistics)
await actions.completeStepOne({ await actions.completeStepOne({
@ -280,7 +269,6 @@ describe.skip('<TemplateCreate />', () => {
const { actions } = testBed; const { actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
// Complete step 1 (logistics) // Complete step 1 (logistics)
await actions.completeStepOne({ await actions.completeStepOne({
@ -302,7 +290,6 @@ describe.skip('<TemplateCreate />', () => {
it('should send the correct payload', async () => { it('should send the correct payload', async () => {
const { actions } = testBed; const { actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
actions.clickSubmitButton(); actions.clickSubmitButton();
await nextTick(); await nextTick();
@ -333,7 +320,6 @@ describe.skip('<TemplateCreate />', () => {
httpRequestsMockHelpers.setCreateTemplateResponse(undefined, { body: error }); httpRequestsMockHelpers.setCreateTemplateResponse(undefined, { body: error });
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
actions.clickSubmitButton(); actions.clickSubmitButton();
await nextTick(); 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 describe('<TemplateEdit />', () => {
// which supports asynchronous code inside act()
describe.skip('<TemplateEdit />', () => {
let testBed: TemplateFormTestBed; let testBed: TemplateFormTestBed;
const { server, httpRequestsMockHelpers } = setupEnvironment(); const { server, httpRequestsMockHelpers } = setupEnvironment();
@ -61,7 +59,6 @@ describe.skip('<TemplateEdit />', () => {
testBed = await setup(); testBed = await setup();
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
await nextTick(); await nextTick();
testBed.component.update(); testBed.component.update();
@ -87,7 +84,6 @@ describe.skip('<TemplateEdit />', () => {
beforeEach(async () => { beforeEach(async () => {
const { actions } = testBed; const { actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
// Complete step 1 (logistics) // Complete step 1 (logistics)
await actions.completeStepOne({ await actions.completeStepOne({
@ -108,7 +104,6 @@ describe.skip('<TemplateEdit />', () => {
it('should send the correct payload with changed values', async () => { it('should send the correct payload with changed values', async () => {
const { actions } = testBed; const { actions } = testBed;
// @ts-ignore (remove when react 16.9.0 is released)
await act(async () => { await act(async () => {
actions.clickSubmitButton(); actions.clickSubmitButton();
await nextTick(); await nextTick();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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