diff --git a/package.json b/package.json index 7315007edf93d..1a19b322bf655 100644 --- a/package.json +++ b/package.json @@ -295,7 +295,7 @@ "rison-node": "1.0.2", "rxjs": "^6.5.5", "seedrandom": "^3.0.5", - "semver": "^5.7.0", + "semver": "^7.3.2", "set-value": "^3.0.2", "source-map-support": "^0.5.19", "squel": "^5.13.0", @@ -536,7 +536,7 @@ "@types/request": "^2.48.2", "@types/seedrandom": ">=2.0.0 <4.0.0", "@types/selenium-webdriver": "^4.0.9", - "@types/semver": "^5.5.0", + "@types/semver": "^7", "@types/set-value": "^2.0.0", "@types/sinon": "^7.0.13", "@types/source-map-support": "^0.5.3", diff --git a/packages/kbn-es-archiver/package.json b/packages/kbn-es-archiver/package.json index 9e7ff757996b7..3cd07668635f1 100644 --- a/packages/kbn-es-archiver/package.json +++ b/packages/kbn-es-archiver/package.json @@ -11,6 +11,7 @@ "kbn:watch": "rm -rf target && ../../node_modules/.bin/tsc --watch" }, "dependencies": { - "@kbn/dev-utils": "link:../kbn-dev-utils" + "@kbn/dev-utils": "link:../kbn-dev-utils", + "@kbn/test": "link:../kbn-test" } } \ No newline at end of file diff --git a/packages/kbn-eslint-import-resolver-kibana/lib/get_webpack_config.js b/packages/kbn-eslint-import-resolver-kibana/lib/get_webpack_config.js index 60a03ae8a104e..65c432dd69b60 100755 --- a/packages/kbn-eslint-import-resolver-kibana/lib/get_webpack_config.js +++ b/packages/kbn-eslint-import-resolver-kibana/lib/get_webpack_config.js @@ -29,7 +29,6 @@ exports.getWebpackConfig = function (kibanaPath) { alias: { // Dev defaults for test bundle https://github.com/elastic/kibana/blob/6998f074542e8c7b32955db159d15661aca253d7/src/core_plugins/tests_bundle/index.js#L73-L78 fixtures: resolve(kibanaPath, 'src/fixtures'), - test_utils: resolve(kibanaPath, 'src/test_utils/public'), }, unsafeCache: true, }, diff --git a/packages/kbn-i18n/GUIDELINE.md b/packages/kbn-i18n/GUIDELINE.md index 45408dc6582b5..b7c1371d59ea4 100644 --- a/packages/kbn-i18n/GUIDELINE.md +++ b/packages/kbn-i18n/GUIDELINE.md @@ -391,7 +391,7 @@ Testing React component that uses the `injectI18n` higher-order component is mor With shallow rendering only top level component is rendered, that is a wrapper itself, not the original component. Since we want to test the rendering of the original component, we need to access it via the wrapper's `WrappedComponent` property. Its value will be the component we passed into `injectI18n()`. -When testing such component, use the `shallowWithIntl` helper function defined in `test_utils/enzyme_helpers` and pass the component's `WrappedComponent` property to render the wrapped component. This will shallow render the component with Enzyme and inject the necessary context and props to use the `intl` mock defined in `test_utils/mocks/intl`. +When testing such component, use the `shallowWithIntl` helper function defined in `@kbn/test/jest` and pass the component's `WrappedComponent` property to render the wrapped component. This will shallow render the component with Enzyme and inject the necessary context and props to use the `intl` mock defined in `test_utils/mocks/intl`. Use the `mountWithIntl` helper function to mount render the component. diff --git a/packages/kbn-pm/dist/index.js b/packages/kbn-pm/dist/index.js index f0ac050b128ff..cd8b1f674fa40 100644 --- a/packages/kbn-pm/dist/index.js +++ b/packages/kbn-pm/dist/index.js @@ -94,7 +94,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _cli__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "run", function() { return _cli__WEBPACK_IMPORTED_MODULE_0__["run"]; }); -/* harmony import */ var _production__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(505); +/* harmony import */ var _production__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(506); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "buildProductionProjects", function() { return _production__WEBPACK_IMPORTED_MODULE_1__["buildProductionProjects"]; }); /* harmony import */ var _utils_projects__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(248); @@ -106,7 +106,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _utils_package_json__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(251); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "transformDependencies", function() { return _utils_package_json__WEBPACK_IMPORTED_MODULE_4__["transformDependencies"]; }); -/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(504); +/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(505); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getProjectPaths", function() { return _config__WEBPACK_IMPORTED_MODULE_5__["getProjectPaths"]; }); /* @@ -150,7 +150,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _kbn_dev_utils_tooling_log__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5); /* harmony import */ var _kbn_dev_utils_tooling_log__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_kbn_dev_utils_tooling_log__WEBPACK_IMPORTED_MODULE_3__); /* harmony import */ var _commands__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(128); -/* harmony import */ var _run__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(498); +/* harmony import */ var _run__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(499); /* harmony import */ var _utils_log__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(246); /* * Licensed to Elasticsearch B.V. under one or more contributor @@ -8897,9 +8897,9 @@ exports.ToolingLogCollectingWriter = ToolingLogCollectingWriter; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commands", function() { return commands; }); /* harmony import */ var _bootstrap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(129); -/* harmony import */ var _clean__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(366); -/* harmony import */ var _run__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(397); -/* harmony import */ var _watch__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(398); +/* harmony import */ var _clean__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(367); +/* harmony import */ var _run__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(398); +/* harmony import */ var _watch__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(399); /* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with @@ -8942,10 +8942,10 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _utils_log__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(246); /* harmony import */ var _utils_parallelize__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(247); /* harmony import */ var _utils_projects__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(248); -/* harmony import */ var _utils_project_checksums__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(358); -/* harmony import */ var _utils_bootstrap_cache_file__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(363); -/* harmony import */ var _utils_yarn_lock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(360); -/* harmony import */ var _utils_validate_dependencies__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(364); +/* harmony import */ var _utils_project_checksums__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(359); +/* harmony import */ var _utils_bootstrap_cache_file__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(364); +/* harmony import */ var _utils_yarn_lock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(361); +/* harmony import */ var _utils_validate_dependencies__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(365); /* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with @@ -22997,7 +22997,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(249); /* harmony import */ var _log__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(246); /* harmony import */ var _package_json__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(251); -/* harmony import */ var _scripts__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(312); +/* harmony import */ var _scripts__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(313); function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } @@ -30996,7 +30996,7 @@ const writeFileAtomic = __webpack_require__(302); const sortKeys = __webpack_require__(307); const makeDir = __webpack_require__(309); const pify = __webpack_require__(310); -const detectIndent = __webpack_require__(311); +const detectIndent = __webpack_require__(312); const init = (fn, filePath, data, options) => { if (!filePath) { @@ -31767,7 +31767,7 @@ module.exports = function (x) { const fs = __webpack_require__(134); const path = __webpack_require__(4); const pify = __webpack_require__(310); -const semver = __webpack_require__(276); +const semver = __webpack_require__(311); const defaults = { mode: 0o777 & (~process.umask()), @@ -31981,6 +31981,1495 @@ module.exports = (input, options) => { /***/ }), /* 311 */ +/***/ (function(module, exports) { + +exports = module.exports = SemVer + +var debug +/* istanbul ignore next */ +if (typeof process === 'object' && + process.env && + process.env.NODE_DEBUG && + /\bsemver\b/i.test(process.env.NODE_DEBUG)) { + debug = function () { + var args = Array.prototype.slice.call(arguments, 0) + args.unshift('SEMVER') + console.log.apply(console, args) + } +} else { + debug = function () {} +} + +// Note: this is the semver.org version of the spec that it implements +// Not necessarily the package version of this code. +exports.SEMVER_SPEC_VERSION = '2.0.0' + +var MAX_LENGTH = 256 +var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || + /* istanbul ignore next */ 9007199254740991 + +// Max safe segment length for coercion. +var MAX_SAFE_COMPONENT_LENGTH = 16 + +// The actual regexps go on exports.re +var re = exports.re = [] +var src = exports.src = [] +var R = 0 + +// The following Regular Expressions can be used for tokenizing, +// validating, and parsing SemVer version strings. + +// ## Numeric Identifier +// A single `0`, or a non-zero digit followed by zero or more digits. + +var NUMERICIDENTIFIER = R++ +src[NUMERICIDENTIFIER] = '0|[1-9]\\d*' +var NUMERICIDENTIFIERLOOSE = R++ +src[NUMERICIDENTIFIERLOOSE] = '[0-9]+' + +// ## Non-numeric Identifier +// Zero or more digits, followed by a letter or hyphen, and then zero or +// more letters, digits, or hyphens. + +var NONNUMERICIDENTIFIER = R++ +src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*' + +// ## Main Version +// Three dot-separated numeric identifiers. + +var MAINVERSION = R++ +src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' + + '(' + src[NUMERICIDENTIFIER] + ')\\.' + + '(' + src[NUMERICIDENTIFIER] + ')' + +var MAINVERSIONLOOSE = R++ +src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + + '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + + '(' + src[NUMERICIDENTIFIERLOOSE] + ')' + +// ## Pre-release Version Identifier +// A numeric identifier, or a non-numeric identifier. + +var PRERELEASEIDENTIFIER = R++ +src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] + + '|' + src[NONNUMERICIDENTIFIER] + ')' + +var PRERELEASEIDENTIFIERLOOSE = R++ +src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] + + '|' + src[NONNUMERICIDENTIFIER] + ')' + +// ## Pre-release Version +// Hyphen, followed by one or more dot-separated pre-release version +// identifiers. + +var PRERELEASE = R++ +src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] + + '(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))' + +var PRERELEASELOOSE = R++ +src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] + + '(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))' + +// ## Build Metadata Identifier +// Any combination of digits, letters, or hyphens. + +var BUILDIDENTIFIER = R++ +src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+' + +// ## Build Metadata +// Plus sign, followed by one or more period-separated build metadata +// identifiers. + +var BUILD = R++ +src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] + + '(?:\\.' + src[BUILDIDENTIFIER] + ')*))' + +// ## Full Version String +// A main version, followed optionally by a pre-release version and +// build metadata. + +// Note that the only major, minor, patch, and pre-release sections of +// the version string are capturing groups. The build metadata is not a +// capturing group, because it should not ever be used in version +// comparison. + +var FULL = R++ +var FULLPLAIN = 'v?' + src[MAINVERSION] + + src[PRERELEASE] + '?' + + src[BUILD] + '?' + +src[FULL] = '^' + FULLPLAIN + '$' + +// like full, but allows v1.2.3 and =1.2.3, which people do sometimes. +// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty +// common in the npm registry. +var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] + + src[PRERELEASELOOSE] + '?' + + src[BUILD] + '?' + +var LOOSE = R++ +src[LOOSE] = '^' + LOOSEPLAIN + '$' + +var GTLT = R++ +src[GTLT] = '((?:<|>)?=?)' + +// Something like "2.*" or "1.2.x". +// Note that "x.x" is a valid xRange identifer, meaning "any version" +// Only the first item is strictly required. +var XRANGEIDENTIFIERLOOSE = R++ +src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*' +var XRANGEIDENTIFIER = R++ +src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*' + +var XRANGEPLAIN = R++ +src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' + + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + + '(?:' + src[PRERELEASE] + ')?' + + src[BUILD] + '?' + + ')?)?' + +var XRANGEPLAINLOOSE = R++ +src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' + + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + + '(?:' + src[PRERELEASELOOSE] + ')?' + + src[BUILD] + '?' + + ')?)?' + +var XRANGE = R++ +src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$' +var XRANGELOOSE = R++ +src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$' + +// Coercion. +// Extract anything that could conceivably be a part of a valid semver +var COERCE = R++ +src[COERCE] = '(?:^|[^\\d])' + + '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + + '(?:$|[^\\d])' + +// Tilde ranges. +// Meaning is "reasonably at or greater than" +var LONETILDE = R++ +src[LONETILDE] = '(?:~>?)' + +var TILDETRIM = R++ +src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+' +re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g') +var tildeTrimReplace = '$1~' + +var TILDE = R++ +src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$' +var TILDELOOSE = R++ +src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$' + +// Caret ranges. +// Meaning is "at least and backwards compatible with" +var LONECARET = R++ +src[LONECARET] = '(?:\\^)' + +var CARETTRIM = R++ +src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+' +re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g') +var caretTrimReplace = '$1^' + +var CARET = R++ +src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$' +var CARETLOOSE = R++ +src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$' + +// A simple gt/lt/eq thing, or just "" to indicate "any version" +var COMPARATORLOOSE = R++ +src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$' +var COMPARATOR = R++ +src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$' + +// An expression to strip any whitespace between the gtlt and the thing +// it modifies, so that `> 1.2.3` ==> `>1.2.3` +var COMPARATORTRIM = R++ +src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] + + '\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')' + +// this one has to use the /g flag +re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g') +var comparatorTrimReplace = '$1$2$3' + +// Something like `1.2.3 - 1.2.4` +// Note that these all use the loose form, because they'll be +// checked against either the strict or loose comparator form +// later. +var HYPHENRANGE = R++ +src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' + + '\\s+-\\s+' + + '(' + src[XRANGEPLAIN] + ')' + + '\\s*$' + +var HYPHENRANGELOOSE = R++ +src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' + + '\\s+-\\s+' + + '(' + src[XRANGEPLAINLOOSE] + ')' + + '\\s*$' + +// Star ranges basically just allow anything at all. +var STAR = R++ +src[STAR] = '(<|>)?=?\\s*\\*' + +// Compile to actual regexp objects. +// All are flag-free, unless they were created above with a flag. +for (var i = 0; i < R; i++) { + debug(i, src[i]) + if (!re[i]) { + re[i] = new RegExp(src[i]) + } +} + +exports.parse = parse +function parse (version, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + + if (version instanceof SemVer) { + return version + } + + if (typeof version !== 'string') { + return null + } + + if (version.length > MAX_LENGTH) { + return null + } + + var r = options.loose ? re[LOOSE] : re[FULL] + if (!r.test(version)) { + return null + } + + try { + return new SemVer(version, options) + } catch (er) { + return null + } +} + +exports.valid = valid +function valid (version, options) { + var v = parse(version, options) + return v ? v.version : null +} + +exports.clean = clean +function clean (version, options) { + var s = parse(version.trim().replace(/^[=v]+/, ''), options) + return s ? s.version : null +} + +exports.SemVer = SemVer + +function SemVer (version, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + if (version instanceof SemVer) { + if (version.loose === options.loose) { + return version + } else { + version = version.version + } + } else if (typeof version !== 'string') { + throw new TypeError('Invalid Version: ' + version) + } + + if (version.length > MAX_LENGTH) { + throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters') + } + + if (!(this instanceof SemVer)) { + return new SemVer(version, options) + } + + debug('SemVer', version, options) + this.options = options + this.loose = !!options.loose + + var m = version.trim().match(options.loose ? re[LOOSE] : re[FULL]) + + if (!m) { + throw new TypeError('Invalid Version: ' + version) + } + + this.raw = version + + // these are actually numbers + this.major = +m[1] + this.minor = +m[2] + this.patch = +m[3] + + if (this.major > MAX_SAFE_INTEGER || this.major < 0) { + throw new TypeError('Invalid major version') + } + + if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { + throw new TypeError('Invalid minor version') + } + + if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { + throw new TypeError('Invalid patch version') + } + + // numberify any prerelease numeric ids + if (!m[4]) { + this.prerelease = [] + } else { + this.prerelease = m[4].split('.').map(function (id) { + if (/^[0-9]+$/.test(id)) { + var num = +id + if (num >= 0 && num < MAX_SAFE_INTEGER) { + return num + } + } + return id + }) + } + + this.build = m[5] ? m[5].split('.') : [] + this.format() +} + +SemVer.prototype.format = function () { + this.version = this.major + '.' + this.minor + '.' + this.patch + if (this.prerelease.length) { + this.version += '-' + this.prerelease.join('.') + } + return this.version +} + +SemVer.prototype.toString = function () { + return this.version +} + +SemVer.prototype.compare = function (other) { + debug('SemVer.compare', this.version, this.options, other) + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + return this.compareMain(other) || this.comparePre(other) +} + +SemVer.prototype.compareMain = function (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + return compareIdentifiers(this.major, other.major) || + compareIdentifiers(this.minor, other.minor) || + compareIdentifiers(this.patch, other.patch) +} + +SemVer.prototype.comparePre = function (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + // NOT having a prerelease is > having one + if (this.prerelease.length && !other.prerelease.length) { + return -1 + } else if (!this.prerelease.length && other.prerelease.length) { + return 1 + } else if (!this.prerelease.length && !other.prerelease.length) { + return 0 + } + + var i = 0 + do { + var a = this.prerelease[i] + var b = other.prerelease[i] + debug('prerelease compare', i, a, b) + if (a === undefined && b === undefined) { + return 0 + } else if (b === undefined) { + return 1 + } else if (a === undefined) { + return -1 + } else if (a === b) { + continue + } else { + return compareIdentifiers(a, b) + } + } while (++i) +} + +// preminor will bump the version up to the next minor release, and immediately +// down to pre-release. premajor and prepatch work the same way. +SemVer.prototype.inc = function (release, identifier) { + switch (release) { + case 'premajor': + this.prerelease.length = 0 + this.patch = 0 + this.minor = 0 + this.major++ + this.inc('pre', identifier) + break + case 'preminor': + this.prerelease.length = 0 + this.patch = 0 + this.minor++ + this.inc('pre', identifier) + break + case 'prepatch': + // If this is already a prerelease, it will bump to the next version + // drop any prereleases that might already exist, since they are not + // relevant at this point. + this.prerelease.length = 0 + this.inc('patch', identifier) + this.inc('pre', identifier) + break + // If the input is a non-prerelease version, this acts the same as + // prepatch. + case 'prerelease': + if (this.prerelease.length === 0) { + this.inc('patch', identifier) + } + this.inc('pre', identifier) + break + + case 'major': + // If this is a pre-major version, bump up to the same major version. + // Otherwise increment major. + // 1.0.0-5 bumps to 1.0.0 + // 1.1.0 bumps to 2.0.0 + if (this.minor !== 0 || + this.patch !== 0 || + this.prerelease.length === 0) { + this.major++ + } + this.minor = 0 + this.patch = 0 + this.prerelease = [] + break + case 'minor': + // If this is a pre-minor version, bump up to the same minor version. + // Otherwise increment minor. + // 1.2.0-5 bumps to 1.2.0 + // 1.2.1 bumps to 1.3.0 + if (this.patch !== 0 || this.prerelease.length === 0) { + this.minor++ + } + this.patch = 0 + this.prerelease = [] + break + case 'patch': + // If this is not a pre-release version, it will increment the patch. + // If it is a pre-release it will bump up to the same patch version. + // 1.2.0-5 patches to 1.2.0 + // 1.2.0 patches to 1.2.1 + if (this.prerelease.length === 0) { + this.patch++ + } + this.prerelease = [] + break + // This probably shouldn't be used publicly. + // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction. + case 'pre': + if (this.prerelease.length === 0) { + this.prerelease = [0] + } else { + var i = this.prerelease.length + while (--i >= 0) { + if (typeof this.prerelease[i] === 'number') { + this.prerelease[i]++ + i = -2 + } + } + if (i === -1) { + // didn't increment anything + this.prerelease.push(0) + } + } + if (identifier) { + // 1.2.0-beta.1 bumps to 1.2.0-beta.2, + // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0 + if (this.prerelease[0] === identifier) { + if (isNaN(this.prerelease[1])) { + this.prerelease = [identifier, 0] + } + } else { + this.prerelease = [identifier, 0] + } + } + break + + default: + throw new Error('invalid increment argument: ' + release) + } + this.format() + this.raw = this.version + return this +} + +exports.inc = inc +function inc (version, release, loose, identifier) { + if (typeof (loose) === 'string') { + identifier = loose + loose = undefined + } + + try { + return new SemVer(version, loose).inc(release, identifier).version + } catch (er) { + return null + } +} + +exports.diff = diff +function diff (version1, version2) { + if (eq(version1, version2)) { + return null + } else { + var v1 = parse(version1) + var v2 = parse(version2) + var prefix = '' + if (v1.prerelease.length || v2.prerelease.length) { + prefix = 'pre' + var defaultResult = 'prerelease' + } + for (var key in v1) { + if (key === 'major' || key === 'minor' || key === 'patch') { + if (v1[key] !== v2[key]) { + return prefix + key + } + } + } + return defaultResult // may be undefined + } +} + +exports.compareIdentifiers = compareIdentifiers + +var numeric = /^[0-9]+$/ +function compareIdentifiers (a, b) { + var anum = numeric.test(a) + var bnum = numeric.test(b) + + if (anum && bnum) { + a = +a + b = +b + } + + return a === b ? 0 + : (anum && !bnum) ? -1 + : (bnum && !anum) ? 1 + : a < b ? -1 + : 1 +} + +exports.rcompareIdentifiers = rcompareIdentifiers +function rcompareIdentifiers (a, b) { + return compareIdentifiers(b, a) +} + +exports.major = major +function major (a, loose) { + return new SemVer(a, loose).major +} + +exports.minor = minor +function minor (a, loose) { + return new SemVer(a, loose).minor +} + +exports.patch = patch +function patch (a, loose) { + return new SemVer(a, loose).patch +} + +exports.compare = compare +function compare (a, b, loose) { + return new SemVer(a, loose).compare(new SemVer(b, loose)) +} + +exports.compareLoose = compareLoose +function compareLoose (a, b) { + return compare(a, b, true) +} + +exports.rcompare = rcompare +function rcompare (a, b, loose) { + return compare(b, a, loose) +} + +exports.sort = sort +function sort (list, loose) { + return list.sort(function (a, b) { + return exports.compare(a, b, loose) + }) +} + +exports.rsort = rsort +function rsort (list, loose) { + return list.sort(function (a, b) { + return exports.rcompare(a, b, loose) + }) +} + +exports.gt = gt +function gt (a, b, loose) { + return compare(a, b, loose) > 0 +} + +exports.lt = lt +function lt (a, b, loose) { + return compare(a, b, loose) < 0 +} + +exports.eq = eq +function eq (a, b, loose) { + return compare(a, b, loose) === 0 +} + +exports.neq = neq +function neq (a, b, loose) { + return compare(a, b, loose) !== 0 +} + +exports.gte = gte +function gte (a, b, loose) { + return compare(a, b, loose) >= 0 +} + +exports.lte = lte +function lte (a, b, loose) { + return compare(a, b, loose) <= 0 +} + +exports.cmp = cmp +function cmp (a, op, b, loose) { + switch (op) { + case '===': + if (typeof a === 'object') + a = a.version + if (typeof b === 'object') + b = b.version + return a === b + + case '!==': + if (typeof a === 'object') + a = a.version + if (typeof b === 'object') + b = b.version + return a !== b + + case '': + case '=': + case '==': + return eq(a, b, loose) + + case '!=': + return neq(a, b, loose) + + case '>': + return gt(a, b, loose) + + case '>=': + return gte(a, b, loose) + + case '<': + return lt(a, b, loose) + + case '<=': + return lte(a, b, loose) + + default: + throw new TypeError('Invalid operator: ' + op) + } +} + +exports.Comparator = Comparator +function Comparator (comp, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + + if (comp instanceof Comparator) { + if (comp.loose === !!options.loose) { + return comp + } else { + comp = comp.value + } + } + + if (!(this instanceof Comparator)) { + return new Comparator(comp, options) + } + + debug('comparator', comp, options) + this.options = options + this.loose = !!options.loose + this.parse(comp) + + if (this.semver === ANY) { + this.value = '' + } else { + this.value = this.operator + this.semver.version + } + + debug('comp', this) +} + +var ANY = {} +Comparator.prototype.parse = function (comp) { + var r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR] + var m = comp.match(r) + + if (!m) { + throw new TypeError('Invalid comparator: ' + comp) + } + + this.operator = m[1] + if (this.operator === '=') { + this.operator = '' + } + + // if it literally is just '>' or '' then allow anything. + if (!m[2]) { + this.semver = ANY + } else { + this.semver = new SemVer(m[2], this.options.loose) + } +} + +Comparator.prototype.toString = function () { + return this.value +} + +Comparator.prototype.test = function (version) { + debug('Comparator.test', version, this.options.loose) + + if (this.semver === ANY) { + return true + } + + if (typeof version === 'string') { + version = new SemVer(version, this.options) + } + + return cmp(version, this.operator, this.semver, this.options) +} + +Comparator.prototype.intersects = function (comp, options) { + if (!(comp instanceof Comparator)) { + throw new TypeError('a Comparator is required') + } + + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + + var rangeTmp + + if (this.operator === '') { + rangeTmp = new Range(comp.value, options) + return satisfies(this.value, rangeTmp, options) + } else if (comp.operator === '') { + rangeTmp = new Range(this.value, options) + return satisfies(comp.semver, rangeTmp, options) + } + + var sameDirectionIncreasing = + (this.operator === '>=' || this.operator === '>') && + (comp.operator === '>=' || comp.operator === '>') + var sameDirectionDecreasing = + (this.operator === '<=' || this.operator === '<') && + (comp.operator === '<=' || comp.operator === '<') + var sameSemVer = this.semver.version === comp.semver.version + var differentDirectionsInclusive = + (this.operator === '>=' || this.operator === '<=') && + (comp.operator === '>=' || comp.operator === '<=') + var oppositeDirectionsLessThan = + cmp(this.semver, '<', comp.semver, options) && + ((this.operator === '>=' || this.operator === '>') && + (comp.operator === '<=' || comp.operator === '<')) + var oppositeDirectionsGreaterThan = + cmp(this.semver, '>', comp.semver, options) && + ((this.operator === '<=' || this.operator === '<') && + (comp.operator === '>=' || comp.operator === '>')) + + return sameDirectionIncreasing || sameDirectionDecreasing || + (sameSemVer && differentDirectionsInclusive) || + oppositeDirectionsLessThan || oppositeDirectionsGreaterThan +} + +exports.Range = Range +function Range (range, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + + if (range instanceof Range) { + if (range.loose === !!options.loose && + range.includePrerelease === !!options.includePrerelease) { + return range + } else { + return new Range(range.raw, options) + } + } + + if (range instanceof Comparator) { + return new Range(range.value, options) + } + + if (!(this instanceof Range)) { + return new Range(range, options) + } + + this.options = options + this.loose = !!options.loose + this.includePrerelease = !!options.includePrerelease + + // First, split based on boolean or || + this.raw = range + this.set = range.split(/\s*\|\|\s*/).map(function (range) { + return this.parseRange(range.trim()) + }, this).filter(function (c) { + // throw out any that are not relevant for whatever reason + return c.length + }) + + if (!this.set.length) { + throw new TypeError('Invalid SemVer Range: ' + range) + } + + this.format() +} + +Range.prototype.format = function () { + this.range = this.set.map(function (comps) { + return comps.join(' ').trim() + }).join('||').trim() + return this.range +} + +Range.prototype.toString = function () { + return this.range +} + +Range.prototype.parseRange = function (range) { + var loose = this.options.loose + range = range.trim() + // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` + var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE] + range = range.replace(hr, hyphenReplace) + debug('hyphen replace', range) + // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` + range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace) + debug('comparator trim', range, re[COMPARATORTRIM]) + + // `~ 1.2.3` => `~1.2.3` + range = range.replace(re[TILDETRIM], tildeTrimReplace) + + // `^ 1.2.3` => `^1.2.3` + range = range.replace(re[CARETTRIM], caretTrimReplace) + + // normalize spaces + range = range.split(/\s+/).join(' ') + + // At this point, the range is completely trimmed and + // ready to be split into comparators. + + var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR] + var set = range.split(' ').map(function (comp) { + return parseComparator(comp, this.options) + }, this).join(' ').split(/\s+/) + if (this.options.loose) { + // in loose mode, throw out any that are not valid comparators + set = set.filter(function (comp) { + return !!comp.match(compRe) + }) + } + set = set.map(function (comp) { + return new Comparator(comp, this.options) + }, this) + + return set +} + +Range.prototype.intersects = function (range, options) { + if (!(range instanceof Range)) { + throw new TypeError('a Range is required') + } + + return this.set.some(function (thisComparators) { + return thisComparators.every(function (thisComparator) { + return range.set.some(function (rangeComparators) { + return rangeComparators.every(function (rangeComparator) { + return thisComparator.intersects(rangeComparator, options) + }) + }) + }) + }) +} + +// Mostly just for testing and legacy API reasons +exports.toComparators = toComparators +function toComparators (range, options) { + return new Range(range, options).set.map(function (comp) { + return comp.map(function (c) { + return c.value + }).join(' ').trim().split(' ') + }) +} + +// comprised of xranges, tildes, stars, and gtlt's at this point. +// already replaced the hyphen ranges +// turn into a set of JUST comparators. +function parseComparator (comp, options) { + debug('comp', comp, options) + comp = replaceCarets(comp, options) + debug('caret', comp) + comp = replaceTildes(comp, options) + debug('tildes', comp) + comp = replaceXRanges(comp, options) + debug('xrange', comp) + comp = replaceStars(comp, options) + debug('stars', comp) + return comp +} + +function isX (id) { + return !id || id.toLowerCase() === 'x' || id === '*' +} + +// ~, ~> --> * (any, kinda silly) +// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0 +// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0 +// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0 +// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0 +// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0 +function replaceTildes (comp, options) { + return comp.trim().split(/\s+/).map(function (comp) { + return replaceTilde(comp, options) + }).join(' ') +} + +function replaceTilde (comp, options) { + var r = options.loose ? re[TILDELOOSE] : re[TILDE] + return comp.replace(r, function (_, M, m, p, pr) { + debug('tilde', comp, _, M, m, p, pr) + var ret + + if (isX(M)) { + ret = '' + } else if (isX(m)) { + ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' + } else if (isX(p)) { + // ~1.2 == >=1.2.0 <1.3.0 + ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' + } else if (pr) { + debug('replaceTilde pr', pr) + ret = '>=' + M + '.' + m + '.' + p + '-' + pr + + ' <' + M + '.' + (+m + 1) + '.0' + } else { + // ~1.2.3 == >=1.2.3 <1.3.0 + ret = '>=' + M + '.' + m + '.' + p + + ' <' + M + '.' + (+m + 1) + '.0' + } + + debug('tilde return', ret) + return ret + }) +} + +// ^ --> * (any, kinda silly) +// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0 +// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0 +// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0 +// ^1.2.3 --> >=1.2.3 <2.0.0 +// ^1.2.0 --> >=1.2.0 <2.0.0 +function replaceCarets (comp, options) { + return comp.trim().split(/\s+/).map(function (comp) { + return replaceCaret(comp, options) + }).join(' ') +} + +function replaceCaret (comp, options) { + debug('caret', comp, options) + var r = options.loose ? re[CARETLOOSE] : re[CARET] + return comp.replace(r, function (_, M, m, p, pr) { + debug('caret', comp, _, M, m, p, pr) + var ret + + if (isX(M)) { + ret = '' + } else if (isX(m)) { + ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' + } else if (isX(p)) { + if (M === '0') { + ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' + } else { + ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0' + } + } else if (pr) { + debug('replaceCaret pr', pr) + if (M === '0') { + if (m === '0') { + ret = '>=' + M + '.' + m + '.' + p + '-' + pr + + ' <' + M + '.' + m + '.' + (+p + 1) + } else { + ret = '>=' + M + '.' + m + '.' + p + '-' + pr + + ' <' + M + '.' + (+m + 1) + '.0' + } + } else { + ret = '>=' + M + '.' + m + '.' + p + '-' + pr + + ' <' + (+M + 1) + '.0.0' + } + } else { + debug('no pr') + if (M === '0') { + if (m === '0') { + ret = '>=' + M + '.' + m + '.' + p + + ' <' + M + '.' + m + '.' + (+p + 1) + } else { + ret = '>=' + M + '.' + m + '.' + p + + ' <' + M + '.' + (+m + 1) + '.0' + } + } else { + ret = '>=' + M + '.' + m + '.' + p + + ' <' + (+M + 1) + '.0.0' + } + } + + debug('caret return', ret) + return ret + }) +} + +function replaceXRanges (comp, options) { + debug('replaceXRanges', comp, options) + return comp.split(/\s+/).map(function (comp) { + return replaceXRange(comp, options) + }).join(' ') +} + +function replaceXRange (comp, options) { + comp = comp.trim() + var r = options.loose ? re[XRANGELOOSE] : re[XRANGE] + return comp.replace(r, function (ret, gtlt, M, m, p, pr) { + debug('xRange', comp, ret, gtlt, M, m, p, pr) + var xM = isX(M) + var xm = xM || isX(m) + var xp = xm || isX(p) + var anyX = xp + + if (gtlt === '=' && anyX) { + gtlt = '' + } + + if (xM) { + if (gtlt === '>' || gtlt === '<') { + // nothing is allowed + ret = '<0.0.0' + } else { + // nothing is forbidden + ret = '*' + } + } else if (gtlt && anyX) { + // we know patch is an x, because we have any x at all. + // replace X with 0 + if (xm) { + m = 0 + } + p = 0 + + if (gtlt === '>') { + // >1 => >=2.0.0 + // >1.2 => >=1.3.0 + // >1.2.3 => >= 1.2.4 + gtlt = '>=' + if (xm) { + M = +M + 1 + m = 0 + p = 0 + } else { + m = +m + 1 + p = 0 + } + } else if (gtlt === '<=') { + // <=0.7.x is actually <0.8.0, since any 0.7.x should + // pass. Similarly, <=7.x is actually <8.0.0, etc. + gtlt = '<' + if (xm) { + M = +M + 1 + } else { + m = +m + 1 + } + } + + ret = gtlt + M + '.' + m + '.' + p + } else if (xm) { + ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' + } else if (xp) { + ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' + } + + debug('xRange return', ret) + + return ret + }) +} + +// Because * is AND-ed with everything else in the comparator, +// and '' means "any version", just remove the *s entirely. +function replaceStars (comp, options) { + debug('replaceStars', comp, options) + // Looseness is ignored here. star is always as loose as it gets! + return comp.trim().replace(re[STAR], '') +} + +// This function is passed to string.replace(re[HYPHENRANGE]) +// M, m, patch, prerelease, build +// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 +// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do +// 1.2 - 3.4 => >=1.2.0 <3.5.0 +function hyphenReplace ($0, + from, fM, fm, fp, fpr, fb, + to, tM, tm, tp, tpr, tb) { + if (isX(fM)) { + from = '' + } else if (isX(fm)) { + from = '>=' + fM + '.0.0' + } else if (isX(fp)) { + from = '>=' + fM + '.' + fm + '.0' + } else { + from = '>=' + from + } + + if (isX(tM)) { + to = '' + } else if (isX(tm)) { + to = '<' + (+tM + 1) + '.0.0' + } else if (isX(tp)) { + to = '<' + tM + '.' + (+tm + 1) + '.0' + } else if (tpr) { + to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr + } else { + to = '<=' + to + } + + return (from + ' ' + to).trim() +} + +// if ANY of the sets match ALL of its comparators, then pass +Range.prototype.test = function (version) { + if (!version) { + return false + } + + if (typeof version === 'string') { + version = new SemVer(version, this.options) + } + + for (var i = 0; i < this.set.length; i++) { + if (testSet(this.set[i], version, this.options)) { + return true + } + } + return false +} + +function testSet (set, version, options) { + for (var i = 0; i < set.length; i++) { + if (!set[i].test(version)) { + return false + } + } + + if (version.prerelease.length && !options.includePrerelease) { + // Find the set of versions that are allowed to have prereleases + // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0 + // That should allow `1.2.3-pr.2` to pass. + // However, `1.2.4-alpha.notready` should NOT be allowed, + // even though it's within the range set by the comparators. + for (i = 0; i < set.length; i++) { + debug(set[i].semver) + if (set[i].semver === ANY) { + continue + } + + if (set[i].semver.prerelease.length > 0) { + var allowed = set[i].semver + if (allowed.major === version.major && + allowed.minor === version.minor && + allowed.patch === version.patch) { + return true + } + } + } + + // Version has a -pre, but it's not one of the ones we like. + return false + } + + return true +} + +exports.satisfies = satisfies +function satisfies (version, range, options) { + try { + range = new Range(range, options) + } catch (er) { + return false + } + return range.test(version) +} + +exports.maxSatisfying = maxSatisfying +function maxSatisfying (versions, range, options) { + var max = null + var maxSV = null + try { + var rangeObj = new Range(range, options) + } catch (er) { + return null + } + versions.forEach(function (v) { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!max || maxSV.compare(v) === -1) { + // compare(max, v, true) + max = v + maxSV = new SemVer(max, options) + } + } + }) + return max +} + +exports.minSatisfying = minSatisfying +function minSatisfying (versions, range, options) { + var min = null + var minSV = null + try { + var rangeObj = new Range(range, options) + } catch (er) { + return null + } + versions.forEach(function (v) { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!min || minSV.compare(v) === 1) { + // compare(min, v, true) + min = v + minSV = new SemVer(min, options) + } + } + }) + return min +} + +exports.minVersion = minVersion +function minVersion (range, loose) { + range = new Range(range, loose) + + var minver = new SemVer('0.0.0') + if (range.test(minver)) { + return minver + } + + minver = new SemVer('0.0.0-0') + if (range.test(minver)) { + return minver + } + + minver = null + for (var i = 0; i < range.set.length; ++i) { + var comparators = range.set[i] + + comparators.forEach(function (comparator) { + // Clone to avoid manipulating the comparator's semver object. + var compver = new SemVer(comparator.semver.version) + switch (comparator.operator) { + case '>': + if (compver.prerelease.length === 0) { + compver.patch++ + } else { + compver.prerelease.push(0) + } + compver.raw = compver.format() + /* fallthrough */ + case '': + case '>=': + if (!minver || gt(minver, compver)) { + minver = compver + } + break + case '<': + case '<=': + /* Ignore maximum versions */ + break + /* istanbul ignore next */ + default: + throw new Error('Unexpected operation: ' + comparator.operator) + } + }) + } + + if (minver && range.test(minver)) { + return minver + } + + return null +} + +exports.validRange = validRange +function validRange (range, options) { + try { + // Return '*' instead of '' so that truthiness works. + // This will throw if it's invalid anyway + return new Range(range, options).range || '*' + } catch (er) { + return null + } +} + +// Determine if version is less than all the versions possible in the range +exports.ltr = ltr +function ltr (version, range, options) { + return outside(version, range, '<', options) +} + +// Determine if version is greater than all the versions possible in the range. +exports.gtr = gtr +function gtr (version, range, options) { + return outside(version, range, '>', options) +} + +exports.outside = outside +function outside (version, range, hilo, options) { + version = new SemVer(version, options) + range = new Range(range, options) + + var gtfn, ltefn, ltfn, comp, ecomp + switch (hilo) { + case '>': + gtfn = gt + ltefn = lte + ltfn = lt + comp = '>' + ecomp = '>=' + break + case '<': + gtfn = lt + ltefn = gte + ltfn = gt + comp = '<' + ecomp = '<=' + break + default: + throw new TypeError('Must provide a hilo val of "<" or ">"') + } + + // If it satisifes the range it is not outside + if (satisfies(version, range, options)) { + return false + } + + // From now on, variable terms are as if we're in "gtr" mode. + // but note that everything is flipped for the "ltr" function. + + for (var i = 0; i < range.set.length; ++i) { + var comparators = range.set[i] + + var high = null + var low = null + + comparators.forEach(function (comparator) { + if (comparator.semver === ANY) { + comparator = new Comparator('>=0.0.0') + } + high = high || comparator + low = low || comparator + if (gtfn(comparator.semver, high.semver, options)) { + high = comparator + } else if (ltfn(comparator.semver, low.semver, options)) { + low = comparator + } + }) + + // If the edge version comparator has a operator then our version + // isn't outside it + if (high.operator === comp || high.operator === ecomp) { + return false + } + + // If the lowest version comparator has an operator and our version + // is less than it then it isn't higher than the range + if ((!low.operator || low.operator === comp) && + ltefn(version, low.semver)) { + return false + } else if (low.operator === ecomp && ltfn(version, low.semver)) { + return false + } + } + return true +} + +exports.prerelease = prerelease +function prerelease (version, options) { + var parsed = parse(version, options) + return (parsed && parsed.prerelease.length) ? parsed.prerelease : null +} + +exports.intersects = intersects +function intersects (r1, r2, options) { + r1 = new Range(r1, options) + r2 = new Range(r2, options) + return r1.intersects(r2) +} + +exports.coerce = coerce +function coerce (version) { + if (version instanceof SemVer) { + return version + } + + if (typeof version !== 'string') { + return null + } + + var match = version.match(re[COERCE]) + + if (match == null) { + return null + } + + return parse(match[1] + + '.' + (match[2] || '0') + + '.' + (match[3] || '0')) +} + + +/***/ }), +/* 312 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -32109,7 +33598,7 @@ module.exports = str => { /***/ }), -/* 312 */ +/* 313 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -32117,7 +33606,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "installInDir", function() { return installInDir; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "runScriptInPackage", function() { return runScriptInPackage; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "runScriptInPackageStreaming", function() { return runScriptInPackageStreaming; }); -/* harmony import */ var _child_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(313); +/* harmony import */ var _child_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(314); /* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with @@ -32180,7 +33669,7 @@ function runScriptInPackageStreaming({ } /***/ }), -/* 313 */ +/* 314 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -32191,9 +33680,9 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var stream__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(stream__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(113); /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var execa__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(314); +/* harmony import */ var execa__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(315); /* harmony import */ var execa__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(execa__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var strong_log_transformer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(350); +/* harmony import */ var strong_log_transformer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(351); /* harmony import */ var strong_log_transformer__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(strong_log_transformer__WEBPACK_IMPORTED_MODULE_3__); /* harmony import */ var _log__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(246); function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } @@ -32281,23 +33770,23 @@ function spawnStreaming(command, args, opts, { } /***/ }), -/* 314 */ +/* 315 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const path = __webpack_require__(4); -const childProcess = __webpack_require__(315); -const crossSpawn = __webpack_require__(316); -const stripFinalNewline = __webpack_require__(329); -const npmRunPath = __webpack_require__(330); -const onetime = __webpack_require__(332); -const makeError = __webpack_require__(334); -const normalizeStdio = __webpack_require__(339); -const {spawnedKill, spawnedCancel, setupTimeout, setExitHandler} = __webpack_require__(340); -const {handleInput, getSpawnedResult, makeAllStream, validateInputSync} = __webpack_require__(341); -const {mergePromise, getSpawnedPromise} = __webpack_require__(348); -const {joinCommand, parseCommand} = __webpack_require__(349); +const childProcess = __webpack_require__(316); +const crossSpawn = __webpack_require__(317); +const stripFinalNewline = __webpack_require__(330); +const npmRunPath = __webpack_require__(331); +const onetime = __webpack_require__(333); +const makeError = __webpack_require__(335); +const normalizeStdio = __webpack_require__(340); +const {spawnedKill, spawnedCancel, setupTimeout, setExitHandler} = __webpack_require__(341); +const {handleInput, getSpawnedResult, makeAllStream, validateInputSync} = __webpack_require__(342); +const {mergePromise, getSpawnedPromise} = __webpack_require__(349); +const {joinCommand, parseCommand} = __webpack_require__(350); const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100; @@ -32544,21 +34033,21 @@ module.exports.node = (scriptPath, args, options = {}) => { /***/ }), -/* 315 */ +/* 316 */ /***/ (function(module, exports) { module.exports = require("child_process"); /***/ }), -/* 316 */ +/* 317 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const cp = __webpack_require__(315); -const parse = __webpack_require__(317); -const enoent = __webpack_require__(328); +const cp = __webpack_require__(316); +const parse = __webpack_require__(318); +const enoent = __webpack_require__(329); function spawn(command, args, options) { // Parse the arguments @@ -32596,16 +34085,16 @@ module.exports._enoent = enoent; /***/ }), -/* 317 */ +/* 318 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const path = __webpack_require__(4); -const resolveCommand = __webpack_require__(318); -const escape = __webpack_require__(324); -const readShebang = __webpack_require__(325); +const resolveCommand = __webpack_require__(319); +const escape = __webpack_require__(325); +const readShebang = __webpack_require__(326); const isWin = process.platform === 'win32'; const isExecutableRegExp = /\.(?:com|exe)$/i; @@ -32694,15 +34183,15 @@ module.exports = parse; /***/ }), -/* 318 */ +/* 319 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const path = __webpack_require__(4); -const which = __webpack_require__(319); -const pathKey = __webpack_require__(323)(); +const which = __webpack_require__(320); +const pathKey = __webpack_require__(324)(); function resolveCommandAttempt(parsed, withoutPathExt) { const cwd = process.cwd(); @@ -32752,7 +34241,7 @@ module.exports = resolveCommand; /***/ }), -/* 319 */ +/* 320 */ /***/ (function(module, exports, __webpack_require__) { const isWindows = process.platform === 'win32' || @@ -32761,7 +34250,7 @@ const isWindows = process.platform === 'win32' || const path = __webpack_require__(4) const COLON = isWindows ? ';' : ':' -const isexe = __webpack_require__(320) +const isexe = __webpack_require__(321) const getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' }) @@ -32883,15 +34372,15 @@ which.sync = whichSync /***/ }), -/* 320 */ +/* 321 */ /***/ (function(module, exports, __webpack_require__) { var fs = __webpack_require__(134) var core if (process.platform === 'win32' || global.TESTING_WINDOWS) { - core = __webpack_require__(321) -} else { core = __webpack_require__(322) +} else { + core = __webpack_require__(323) } module.exports = isexe @@ -32946,7 +34435,7 @@ function sync (path, options) { /***/ }), -/* 321 */ +/* 322 */ /***/ (function(module, exports, __webpack_require__) { module.exports = isexe @@ -32994,7 +34483,7 @@ function sync (path, options) { /***/ }), -/* 322 */ +/* 323 */ /***/ (function(module, exports, __webpack_require__) { module.exports = isexe @@ -33041,7 +34530,7 @@ function checkMode (stat, options) { /***/ }), -/* 323 */ +/* 324 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -33064,7 +34553,7 @@ module.exports.default = pathKey; /***/ }), -/* 324 */ +/* 325 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -33116,14 +34605,14 @@ module.exports.argument = escapeArgument; /***/ }), -/* 325 */ +/* 326 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const fs = __webpack_require__(134); -const shebangCommand = __webpack_require__(326); +const shebangCommand = __webpack_require__(327); function readShebang(command) { // Read the first 150 bytes from the file @@ -33146,12 +34635,12 @@ module.exports = readShebang; /***/ }), -/* 326 */ +/* 327 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const shebangRegex = __webpack_require__(327); +const shebangRegex = __webpack_require__(328); module.exports = (string = '') => { const match = string.match(shebangRegex); @@ -33172,7 +34661,7 @@ module.exports = (string = '') => { /***/ }), -/* 327 */ +/* 328 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -33181,7 +34670,7 @@ module.exports = /^#!(.*)/; /***/ }), -/* 328 */ +/* 329 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -33247,7 +34736,7 @@ module.exports = { /***/ }), -/* 329 */ +/* 330 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -33270,13 +34759,13 @@ module.exports = input => { /***/ }), -/* 330 */ +/* 331 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const path = __webpack_require__(4); -const pathKey = __webpack_require__(331); +const pathKey = __webpack_require__(332); const npmRunPath = options => { options = { @@ -33324,7 +34813,7 @@ module.exports.env = options => { /***/ }), -/* 331 */ +/* 332 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -33347,12 +34836,12 @@ module.exports.default = pathKey; /***/ }), -/* 332 */ +/* 333 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const mimicFn = __webpack_require__(333); +const mimicFn = __webpack_require__(334); const calledFunctions = new WeakMap(); @@ -33404,7 +34893,7 @@ module.exports.callCount = fn => { /***/ }), -/* 333 */ +/* 334 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -33424,12 +34913,12 @@ module.exports.default = mimicFn; /***/ }), -/* 334 */ +/* 335 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const {signalsByName} = __webpack_require__(335); +const {signalsByName} = __webpack_require__(336); const getErrorPrefix = ({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled}) => { if (timedOut) { @@ -33517,14 +35006,14 @@ module.exports = makeError; /***/ }), -/* 335 */ +/* 336 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports,"__esModule",{value:true});exports.signalsByNumber=exports.signalsByName=void 0;var _os=__webpack_require__(121); -var _signals=__webpack_require__(336); -var _realtime=__webpack_require__(338); +var _signals=__webpack_require__(337); +var _realtime=__webpack_require__(339); @@ -33594,14 +35083,14 @@ const signalsByNumber=getSignalsByNumber();exports.signalsByNumber=signalsByNumb //# sourceMappingURL=main.js.map /***/ }), -/* 336 */ +/* 337 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports,"__esModule",{value:true});exports.getSignals=void 0;var _os=__webpack_require__(121); -var _core=__webpack_require__(337); -var _realtime=__webpack_require__(338); +var _core=__webpack_require__(338); +var _realtime=__webpack_require__(339); @@ -33635,7 +35124,7 @@ return{name,number,description,supported,action,forced,standard}; //# sourceMappingURL=signals.js.map /***/ }), -/* 337 */ +/* 338 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -33914,7 +35403,7 @@ standard:"other"}];exports.SIGNALS=SIGNALS; //# sourceMappingURL=core.js.map /***/ }), -/* 338 */ +/* 339 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -33939,7 +35428,7 @@ const SIGRTMAX=64;exports.SIGRTMAX=SIGRTMAX; //# sourceMappingURL=realtime.js.map /***/ }), -/* 339 */ +/* 340 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -33998,7 +35487,7 @@ module.exports.node = opts => { /***/ }), -/* 340 */ +/* 341 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -34117,14 +35606,14 @@ module.exports = { /***/ }), -/* 341 */ +/* 342 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const isStream = __webpack_require__(342); -const getStream = __webpack_require__(343); -const mergeStream = __webpack_require__(347); +const isStream = __webpack_require__(343); +const getStream = __webpack_require__(344); +const mergeStream = __webpack_require__(348); // `input` option const handleInput = (spawned, input) => { @@ -34221,7 +35710,7 @@ module.exports = { /***/ }), -/* 342 */ +/* 343 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -34257,13 +35746,13 @@ module.exports = isStream; /***/ }), -/* 343 */ +/* 344 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const pump = __webpack_require__(344); -const bufferStream = __webpack_require__(346); +const pump = __webpack_require__(345); +const bufferStream = __webpack_require__(347); class MaxBufferError extends Error { constructor() { @@ -34322,11 +35811,11 @@ module.exports.MaxBufferError = MaxBufferError; /***/ }), -/* 344 */ +/* 345 */ /***/ (function(module, exports, __webpack_require__) { var once = __webpack_require__(162) -var eos = __webpack_require__(345) +var eos = __webpack_require__(346) var fs = __webpack_require__(134) // we only need fs to get the ReadStream and WriteStream prototypes var noop = function () {} @@ -34410,7 +35899,7 @@ module.exports = pump /***/ }), -/* 345 */ +/* 346 */ /***/ (function(module, exports, __webpack_require__) { var once = __webpack_require__(162); @@ -34510,7 +35999,7 @@ module.exports = eos; /***/ }), -/* 346 */ +/* 347 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -34569,7 +36058,7 @@ module.exports = options => { /***/ }), -/* 347 */ +/* 348 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -34617,7 +36106,7 @@ module.exports = function (/*streams...*/) { /***/ }), -/* 348 */ +/* 349 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -34670,7 +36159,7 @@ module.exports = { /***/ }), -/* 349 */ +/* 350 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -34715,7 +36204,7 @@ module.exports = { /***/ }), -/* 350 */ +/* 351 */ /***/ (function(module, exports, __webpack_require__) { // Copyright IBM Corp. 2014,2018. All Rights Reserved. @@ -34723,12 +36212,12 @@ module.exports = { // This file is licensed under the Apache License 2.0. // License text available at https://opensource.org/licenses/Apache-2.0 -module.exports = __webpack_require__(351); -module.exports.cli = __webpack_require__(355); +module.exports = __webpack_require__(352); +module.exports.cli = __webpack_require__(356); /***/ }), -/* 351 */ +/* 352 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -34743,9 +36232,9 @@ var stream = __webpack_require__(138); var util = __webpack_require__(112); var fs = __webpack_require__(134); -var through = __webpack_require__(352); -var duplexer = __webpack_require__(353); -var StringDecoder = __webpack_require__(354).StringDecoder; +var through = __webpack_require__(353); +var duplexer = __webpack_require__(354); +var StringDecoder = __webpack_require__(355).StringDecoder; module.exports = Logger; @@ -34934,7 +36423,7 @@ function lineMerger(host) { /***/ }), -/* 352 */ +/* 353 */ /***/ (function(module, exports, __webpack_require__) { var Stream = __webpack_require__(138) @@ -35048,7 +36537,7 @@ function through (write, end, opts) { /***/ }), -/* 353 */ +/* 354 */ /***/ (function(module, exports, __webpack_require__) { var Stream = __webpack_require__(138) @@ -35141,13 +36630,13 @@ function duplex(writer, reader) { /***/ }), -/* 354 */ +/* 355 */ /***/ (function(module, exports) { module.exports = require("string_decoder"); /***/ }), -/* 355 */ +/* 356 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -35158,11 +36647,11 @@ module.exports = require("string_decoder"); -var minimist = __webpack_require__(356); +var minimist = __webpack_require__(357); var path = __webpack_require__(4); -var Logger = __webpack_require__(351); -var pkg = __webpack_require__(357); +var Logger = __webpack_require__(352); +var pkg = __webpack_require__(358); module.exports = cli; @@ -35216,7 +36705,7 @@ function usage($0, p) { /***/ }), -/* 356 */ +/* 357 */ /***/ (function(module, exports) { module.exports = function (args, opts) { @@ -35467,13 +36956,13 @@ function isNumber (x) { /***/ }), -/* 357 */ +/* 358 */ /***/ (function(module) { module.exports = JSON.parse("{\"name\":\"strong-log-transformer\",\"version\":\"2.1.0\",\"description\":\"Stream transformer that prefixes lines with timestamps and other things.\",\"author\":\"Ryan Graham \",\"license\":\"Apache-2.0\",\"repository\":{\"type\":\"git\",\"url\":\"git://github.com/strongloop/strong-log-transformer\"},\"keywords\":[\"logging\",\"streams\"],\"bugs\":{\"url\":\"https://github.com/strongloop/strong-log-transformer/issues\"},\"homepage\":\"https://github.com/strongloop/strong-log-transformer\",\"directories\":{\"test\":\"test\"},\"bin\":{\"sl-log-transformer\":\"bin/sl-log-transformer.js\"},\"main\":\"index.js\",\"scripts\":{\"test\":\"tap --100 test/test-*\"},\"dependencies\":{\"duplexer\":\"^0.1.1\",\"minimist\":\"^1.2.0\",\"through\":\"^2.3.4\"},\"devDependencies\":{\"tap\":\"^12.0.1\"},\"engines\":{\"node\":\">=4\"}}"); /***/ }), -/* 358 */ +/* 359 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -35481,13 +36970,13 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getAllChecksums", function() { return getAllChecksums; }); /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(134); /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(359); +/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(360); /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(112); /* harmony import */ var util__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(util__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var execa__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(314); +/* harmony import */ var execa__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(315); /* harmony import */ var execa__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(execa__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var _yarn_lock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(360); +/* harmony import */ var _yarn_lock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(361); /* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with @@ -35686,20 +37175,20 @@ async function getAllChecksums(kbn, log, yarnLock) { } /***/ }), -/* 359 */ +/* 360 */ /***/ (function(module, exports) { module.exports = require("crypto"); /***/ }), -/* 360 */ +/* 361 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "readYarnLock", function() { return readYarnLock; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "resolveDepsForProject", function() { return resolveDepsForProject; }); -/* harmony import */ var _yarnpkg_lockfile__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(361); +/* harmony import */ var _yarnpkg_lockfile__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(362); /* harmony import */ var _yarnpkg_lockfile__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_yarnpkg_lockfile__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _utils_fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(131); /* @@ -35812,7 +37301,7 @@ function resolveDepsForProject({ } /***/ }), -/* 361 */ +/* 362 */ /***/ (function(module, exports, __webpack_require__) { module.exports = @@ -37371,7 +38860,7 @@ module.exports = invariant; /* 9 */ /***/ (function(module, exports) { -module.exports = __webpack_require__(359); +module.exports = __webpack_require__(360); /***/ }), /* 10 */, @@ -39695,7 +41184,7 @@ function onceStrict (fn) { /* 63 */ /***/ (function(module, exports) { -module.exports = __webpack_require__(362); +module.exports = __webpack_require__(363); /***/ }), /* 64 */, @@ -46090,13 +47579,13 @@ module.exports = process && support(supportLevel); /******/ ]); /***/ }), -/* 362 */ +/* 363 */ /***/ (function(module, exports) { module.exports = require("buffer"); /***/ }), -/* 363 */ +/* 364 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -46193,13 +47682,13 @@ class BootstrapCacheFile { } /***/ }), -/* 364 */ +/* 365 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "validateDependencies", function() { return validateDependencies; }); -/* harmony import */ var _yarnpkg_lockfile__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(361); +/* harmony import */ var _yarnpkg_lockfile__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(362); /* harmony import */ var _yarnpkg_lockfile__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_yarnpkg_lockfile__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var dedent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2); /* harmony import */ var dedent__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(dedent__WEBPACK_IMPORTED_MODULE_1__); @@ -46210,7 +47699,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _fs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(131); /* harmony import */ var _log__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(246); /* harmony import */ var _package_json__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(251); -/* harmony import */ var _projects_tree__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(365); +/* harmony import */ var _projects_tree__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(366); /* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with @@ -46402,7 +47891,7 @@ function getDevOnlyProductionDepsTree(kbn, projectName) { } /***/ }), -/* 365 */ +/* 366 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -46555,7 +48044,7 @@ function addProjectToTree(tree, pathParts, project) { } /***/ }), -/* 366 */ +/* 367 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -46563,7 +48052,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CleanCommand", function() { return CleanCommand; }); /* harmony import */ var del__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(143); /* harmony import */ var del__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(del__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var ora__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(367); +/* harmony import */ var ora__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(368); /* harmony import */ var ora__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ora__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4); /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_2__); @@ -46663,20 +48152,20 @@ const CleanCommand = { }; /***/ }), -/* 367 */ +/* 368 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const readline = __webpack_require__(368); -const chalk = __webpack_require__(369); -const cliCursor = __webpack_require__(376); -const cliSpinners = __webpack_require__(378); -const logSymbols = __webpack_require__(380); -const stripAnsi = __webpack_require__(389); -const wcwidth = __webpack_require__(391); -const isInteractive = __webpack_require__(395); -const MuteStream = __webpack_require__(396); +const readline = __webpack_require__(369); +const chalk = __webpack_require__(370); +const cliCursor = __webpack_require__(377); +const cliSpinners = __webpack_require__(379); +const logSymbols = __webpack_require__(381); +const stripAnsi = __webpack_require__(390); +const wcwidth = __webpack_require__(392); +const isInteractive = __webpack_require__(396); +const MuteStream = __webpack_require__(397); const TEXT = Symbol('text'); const PREFIX_TEXT = Symbol('prefixText'); @@ -47029,23 +48518,23 @@ module.exports.promise = (action, options) => { /***/ }), -/* 368 */ +/* 369 */ /***/ (function(module, exports) { module.exports = require("readline"); /***/ }), -/* 369 */ +/* 370 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const ansiStyles = __webpack_require__(370); +const ansiStyles = __webpack_require__(371); const {stdout: stdoutColor, stderr: stderrColor} = __webpack_require__(120); const { stringReplaceAll, stringEncaseCRLFWithFirstIndex -} = __webpack_require__(374); +} = __webpack_require__(375); // `supportsColor.level` → `ansiStyles.color[name]` mapping const levelMapping = [ @@ -47246,7 +48735,7 @@ const chalkTag = (chalk, ...strings) => { } if (template === undefined) { - template = __webpack_require__(375); + template = __webpack_require__(376); } return template(chalk, parts.join('')); @@ -47275,7 +48764,7 @@ module.exports = chalk; /***/ }), -/* 370 */ +/* 371 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -47321,7 +48810,7 @@ const setLazyProperty = (object, property, get) => { let colorConvert; const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => { if (colorConvert === undefined) { - colorConvert = __webpack_require__(371); + colorConvert = __webpack_require__(372); } const offset = isBackground ? 10 : 0; @@ -47446,11 +48935,11 @@ Object.defineProperty(module, 'exports', { /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(115)(module))) /***/ }), -/* 371 */ +/* 372 */ /***/ (function(module, exports, __webpack_require__) { -const conversions = __webpack_require__(372); -const route = __webpack_require__(373); +const conversions = __webpack_require__(373); +const route = __webpack_require__(374); const convert = {}; @@ -47533,7 +49022,7 @@ module.exports = convert; /***/ }), -/* 372 */ +/* 373 */ /***/ (function(module, exports, __webpack_require__) { /* MIT license */ @@ -48378,10 +49867,10 @@ convert.rgb.gray = function (rgb) { /***/ }), -/* 373 */ +/* 374 */ /***/ (function(module, exports, __webpack_require__) { -const conversions = __webpack_require__(372); +const conversions = __webpack_require__(373); /* This function routes a model to all other models. @@ -48481,7 +49970,7 @@ module.exports = function (fromModel) { /***/ }), -/* 374 */ +/* 375 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -48527,7 +50016,7 @@ module.exports = { /***/ }), -/* 375 */ +/* 376 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -48668,12 +50157,12 @@ module.exports = (chalk, temporary) => { /***/ }), -/* 376 */ +/* 377 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const restoreCursor = __webpack_require__(377); +const restoreCursor = __webpack_require__(378); let isHidden = false; @@ -48710,12 +50199,12 @@ exports.toggle = (force, writableStream) => { /***/ }), -/* 377 */ +/* 378 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const onetime = __webpack_require__(332); +const onetime = __webpack_require__(333); const signalExit = __webpack_require__(304); module.exports = onetime(() => { @@ -48726,13 +50215,13 @@ module.exports = onetime(() => { /***/ }), -/* 378 */ +/* 379 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const spinners = Object.assign({}, __webpack_require__(379)); +const spinners = Object.assign({}, __webpack_require__(380)); const spinnersList = Object.keys(spinners); @@ -48750,18 +50239,18 @@ module.exports.default = spinners; /***/ }), -/* 379 */ +/* 380 */ /***/ (function(module) { module.exports = JSON.parse("{\"dots\":{\"interval\":80,\"frames\":[\"⠋\",\"⠙\",\"⠹\",\"⠸\",\"⠼\",\"⠴\",\"⠦\",\"⠧\",\"⠇\",\"⠏\"]},\"dots2\":{\"interval\":80,\"frames\":[\"⣾\",\"⣽\",\"⣻\",\"⢿\",\"⡿\",\"⣟\",\"⣯\",\"⣷\"]},\"dots3\":{\"interval\":80,\"frames\":[\"⠋\",\"⠙\",\"⠚\",\"⠞\",\"⠖\",\"⠦\",\"⠴\",\"⠲\",\"⠳\",\"⠓\"]},\"dots4\":{\"interval\":80,\"frames\":[\"⠄\",\"⠆\",\"⠇\",\"⠋\",\"⠙\",\"⠸\",\"⠰\",\"⠠\",\"⠰\",\"⠸\",\"⠙\",\"⠋\",\"⠇\",\"⠆\"]},\"dots5\":{\"interval\":80,\"frames\":[\"⠋\",\"⠙\",\"⠚\",\"⠒\",\"⠂\",\"⠂\",\"⠒\",\"⠲\",\"⠴\",\"⠦\",\"⠖\",\"⠒\",\"⠐\",\"⠐\",\"⠒\",\"⠓\",\"⠋\"]},\"dots6\":{\"interval\":80,\"frames\":[\"⠁\",\"⠉\",\"⠙\",\"⠚\",\"⠒\",\"⠂\",\"⠂\",\"⠒\",\"⠲\",\"⠴\",\"⠤\",\"⠄\",\"⠄\",\"⠤\",\"⠴\",\"⠲\",\"⠒\",\"⠂\",\"⠂\",\"⠒\",\"⠚\",\"⠙\",\"⠉\",\"⠁\"]},\"dots7\":{\"interval\":80,\"frames\":[\"⠈\",\"⠉\",\"⠋\",\"⠓\",\"⠒\",\"⠐\",\"⠐\",\"⠒\",\"⠖\",\"⠦\",\"⠤\",\"⠠\",\"⠠\",\"⠤\",\"⠦\",\"⠖\",\"⠒\",\"⠐\",\"⠐\",\"⠒\",\"⠓\",\"⠋\",\"⠉\",\"⠈\"]},\"dots8\":{\"interval\":80,\"frames\":[\"⠁\",\"⠁\",\"⠉\",\"⠙\",\"⠚\",\"⠒\",\"⠂\",\"⠂\",\"⠒\",\"⠲\",\"⠴\",\"⠤\",\"⠄\",\"⠄\",\"⠤\",\"⠠\",\"⠠\",\"⠤\",\"⠦\",\"⠖\",\"⠒\",\"⠐\",\"⠐\",\"⠒\",\"⠓\",\"⠋\",\"⠉\",\"⠈\",\"⠈\"]},\"dots9\":{\"interval\":80,\"frames\":[\"⢹\",\"⢺\",\"⢼\",\"⣸\",\"⣇\",\"⡧\",\"⡗\",\"⡏\"]},\"dots10\":{\"interval\":80,\"frames\":[\"⢄\",\"⢂\",\"⢁\",\"⡁\",\"⡈\",\"⡐\",\"⡠\"]},\"dots11\":{\"interval\":100,\"frames\":[\"⠁\",\"⠂\",\"⠄\",\"⡀\",\"⢀\",\"⠠\",\"⠐\",\"⠈\"]},\"dots12\":{\"interval\":80,\"frames\":[\"⢀⠀\",\"⡀⠀\",\"⠄⠀\",\"⢂⠀\",\"⡂⠀\",\"⠅⠀\",\"⢃⠀\",\"⡃⠀\",\"⠍⠀\",\"⢋⠀\",\"⡋⠀\",\"⠍⠁\",\"⢋⠁\",\"⡋⠁\",\"⠍⠉\",\"⠋⠉\",\"⠋⠉\",\"⠉⠙\",\"⠉⠙\",\"⠉⠩\",\"⠈⢙\",\"⠈⡙\",\"⢈⠩\",\"⡀⢙\",\"⠄⡙\",\"⢂⠩\",\"⡂⢘\",\"⠅⡘\",\"⢃⠨\",\"⡃⢐\",\"⠍⡐\",\"⢋⠠\",\"⡋⢀\",\"⠍⡁\",\"⢋⠁\",\"⡋⠁\",\"⠍⠉\",\"⠋⠉\",\"⠋⠉\",\"⠉⠙\",\"⠉⠙\",\"⠉⠩\",\"⠈⢙\",\"⠈⡙\",\"⠈⠩\",\"⠀⢙\",\"⠀⡙\",\"⠀⠩\",\"⠀⢘\",\"⠀⡘\",\"⠀⠨\",\"⠀⢐\",\"⠀⡐\",\"⠀⠠\",\"⠀⢀\",\"⠀⡀\"]},\"dots8Bit\":{\"interval\":80,\"frames\":[\"⠀\",\"⠁\",\"⠂\",\"⠃\",\"⠄\",\"⠅\",\"⠆\",\"⠇\",\"⡀\",\"⡁\",\"⡂\",\"⡃\",\"⡄\",\"⡅\",\"⡆\",\"⡇\",\"⠈\",\"⠉\",\"⠊\",\"⠋\",\"⠌\",\"⠍\",\"⠎\",\"⠏\",\"⡈\",\"⡉\",\"⡊\",\"⡋\",\"⡌\",\"⡍\",\"⡎\",\"⡏\",\"⠐\",\"⠑\",\"⠒\",\"⠓\",\"⠔\",\"⠕\",\"⠖\",\"⠗\",\"⡐\",\"⡑\",\"⡒\",\"⡓\",\"⡔\",\"⡕\",\"⡖\",\"⡗\",\"⠘\",\"⠙\",\"⠚\",\"⠛\",\"⠜\",\"⠝\",\"⠞\",\"⠟\",\"⡘\",\"⡙\",\"⡚\",\"⡛\",\"⡜\",\"⡝\",\"⡞\",\"⡟\",\"⠠\",\"⠡\",\"⠢\",\"⠣\",\"⠤\",\"⠥\",\"⠦\",\"⠧\",\"⡠\",\"⡡\",\"⡢\",\"⡣\",\"⡤\",\"⡥\",\"⡦\",\"⡧\",\"⠨\",\"⠩\",\"⠪\",\"⠫\",\"⠬\",\"⠭\",\"⠮\",\"⠯\",\"⡨\",\"⡩\",\"⡪\",\"⡫\",\"⡬\",\"⡭\",\"⡮\",\"⡯\",\"⠰\",\"⠱\",\"⠲\",\"⠳\",\"⠴\",\"⠵\",\"⠶\",\"⠷\",\"⡰\",\"⡱\",\"⡲\",\"⡳\",\"⡴\",\"⡵\",\"⡶\",\"⡷\",\"⠸\",\"⠹\",\"⠺\",\"⠻\",\"⠼\",\"⠽\",\"⠾\",\"⠿\",\"⡸\",\"⡹\",\"⡺\",\"⡻\",\"⡼\",\"⡽\",\"⡾\",\"⡿\",\"⢀\",\"⢁\",\"⢂\",\"⢃\",\"⢄\",\"⢅\",\"⢆\",\"⢇\",\"⣀\",\"⣁\",\"⣂\",\"⣃\",\"⣄\",\"⣅\",\"⣆\",\"⣇\",\"⢈\",\"⢉\",\"⢊\",\"⢋\",\"⢌\",\"⢍\",\"⢎\",\"⢏\",\"⣈\",\"⣉\",\"⣊\",\"⣋\",\"⣌\",\"⣍\",\"⣎\",\"⣏\",\"⢐\",\"⢑\",\"⢒\",\"⢓\",\"⢔\",\"⢕\",\"⢖\",\"⢗\",\"⣐\",\"⣑\",\"⣒\",\"⣓\",\"⣔\",\"⣕\",\"⣖\",\"⣗\",\"⢘\",\"⢙\",\"⢚\",\"⢛\",\"⢜\",\"⢝\",\"⢞\",\"⢟\",\"⣘\",\"⣙\",\"⣚\",\"⣛\",\"⣜\",\"⣝\",\"⣞\",\"⣟\",\"⢠\",\"⢡\",\"⢢\",\"⢣\",\"⢤\",\"⢥\",\"⢦\",\"⢧\",\"⣠\",\"⣡\",\"⣢\",\"⣣\",\"⣤\",\"⣥\",\"⣦\",\"⣧\",\"⢨\",\"⢩\",\"⢪\",\"⢫\",\"⢬\",\"⢭\",\"⢮\",\"⢯\",\"⣨\",\"⣩\",\"⣪\",\"⣫\",\"⣬\",\"⣭\",\"⣮\",\"⣯\",\"⢰\",\"⢱\",\"⢲\",\"⢳\",\"⢴\",\"⢵\",\"⢶\",\"⢷\",\"⣰\",\"⣱\",\"⣲\",\"⣳\",\"⣴\",\"⣵\",\"⣶\",\"⣷\",\"⢸\",\"⢹\",\"⢺\",\"⢻\",\"⢼\",\"⢽\",\"⢾\",\"⢿\",\"⣸\",\"⣹\",\"⣺\",\"⣻\",\"⣼\",\"⣽\",\"⣾\",\"⣿\"]},\"line\":{\"interval\":130,\"frames\":[\"-\",\"\\\\\",\"|\",\"/\"]},\"line2\":{\"interval\":100,\"frames\":[\"⠂\",\"-\",\"–\",\"—\",\"–\",\"-\"]},\"pipe\":{\"interval\":100,\"frames\":[\"┤\",\"┘\",\"┴\",\"└\",\"├\",\"┌\",\"┬\",\"┐\"]},\"simpleDots\":{\"interval\":400,\"frames\":[\". \",\".. \",\"...\",\" \"]},\"simpleDotsScrolling\":{\"interval\":200,\"frames\":[\". \",\".. \",\"...\",\" ..\",\" .\",\" \"]},\"star\":{\"interval\":70,\"frames\":[\"✶\",\"✸\",\"✹\",\"✺\",\"✹\",\"✷\"]},\"star2\":{\"interval\":80,\"frames\":[\"+\",\"x\",\"*\"]},\"flip\":{\"interval\":70,\"frames\":[\"_\",\"_\",\"_\",\"-\",\"`\",\"`\",\"'\",\"´\",\"-\",\"_\",\"_\",\"_\"]},\"hamburger\":{\"interval\":100,\"frames\":[\"☱\",\"☲\",\"☴\"]},\"growVertical\":{\"interval\":120,\"frames\":[\"▁\",\"▃\",\"▄\",\"▅\",\"▆\",\"▇\",\"▆\",\"▅\",\"▄\",\"▃\"]},\"growHorizontal\":{\"interval\":120,\"frames\":[\"▏\",\"▎\",\"▍\",\"▌\",\"▋\",\"▊\",\"▉\",\"▊\",\"▋\",\"▌\",\"▍\",\"▎\"]},\"balloon\":{\"interval\":140,\"frames\":[\" \",\".\",\"o\",\"O\",\"@\",\"*\",\" \"]},\"balloon2\":{\"interval\":120,\"frames\":[\".\",\"o\",\"O\",\"°\",\"O\",\"o\",\".\"]},\"noise\":{\"interval\":100,\"frames\":[\"▓\",\"▒\",\"░\"]},\"bounce\":{\"interval\":120,\"frames\":[\"⠁\",\"⠂\",\"⠄\",\"⠂\"]},\"boxBounce\":{\"interval\":120,\"frames\":[\"▖\",\"▘\",\"▝\",\"▗\"]},\"boxBounce2\":{\"interval\":100,\"frames\":[\"▌\",\"▀\",\"▐\",\"▄\"]},\"triangle\":{\"interval\":50,\"frames\":[\"◢\",\"◣\",\"◤\",\"◥\"]},\"arc\":{\"interval\":100,\"frames\":[\"◜\",\"◠\",\"◝\",\"◞\",\"◡\",\"◟\"]},\"circle\":{\"interval\":120,\"frames\":[\"◡\",\"⊙\",\"◠\"]},\"squareCorners\":{\"interval\":180,\"frames\":[\"◰\",\"◳\",\"◲\",\"◱\"]},\"circleQuarters\":{\"interval\":120,\"frames\":[\"◴\",\"◷\",\"◶\",\"◵\"]},\"circleHalves\":{\"interval\":50,\"frames\":[\"◐\",\"◓\",\"◑\",\"◒\"]},\"squish\":{\"interval\":100,\"frames\":[\"╫\",\"╪\"]},\"toggle\":{\"interval\":250,\"frames\":[\"⊶\",\"⊷\"]},\"toggle2\":{\"interval\":80,\"frames\":[\"▫\",\"▪\"]},\"toggle3\":{\"interval\":120,\"frames\":[\"□\",\"■\"]},\"toggle4\":{\"interval\":100,\"frames\":[\"■\",\"□\",\"▪\",\"▫\"]},\"toggle5\":{\"interval\":100,\"frames\":[\"▮\",\"▯\"]},\"toggle6\":{\"interval\":300,\"frames\":[\"ဝ\",\"၀\"]},\"toggle7\":{\"interval\":80,\"frames\":[\"⦾\",\"⦿\"]},\"toggle8\":{\"interval\":100,\"frames\":[\"◍\",\"◌\"]},\"toggle9\":{\"interval\":100,\"frames\":[\"◉\",\"◎\"]},\"toggle10\":{\"interval\":100,\"frames\":[\"㊂\",\"㊀\",\"㊁\"]},\"toggle11\":{\"interval\":50,\"frames\":[\"⧇\",\"⧆\"]},\"toggle12\":{\"interval\":120,\"frames\":[\"☗\",\"☖\"]},\"toggle13\":{\"interval\":80,\"frames\":[\"=\",\"*\",\"-\"]},\"arrow\":{\"interval\":100,\"frames\":[\"←\",\"↖\",\"↑\",\"↗\",\"→\",\"↘\",\"↓\",\"↙\"]},\"arrow2\":{\"interval\":80,\"frames\":[\"⬆️ \",\"↗️ \",\"➡️ \",\"↘️ \",\"⬇️ \",\"↙️ \",\"⬅️ \",\"↖️ \"]},\"arrow3\":{\"interval\":120,\"frames\":[\"▹▹▹▹▹\",\"▸▹▹▹▹\",\"▹▸▹▹▹\",\"▹▹▸▹▹\",\"▹▹▹▸▹\",\"▹▹▹▹▸\"]},\"bouncingBar\":{\"interval\":80,\"frames\":[\"[ ]\",\"[= ]\",\"[== ]\",\"[=== ]\",\"[ ===]\",\"[ ==]\",\"[ =]\",\"[ ]\",\"[ =]\",\"[ ==]\",\"[ ===]\",\"[====]\",\"[=== ]\",\"[== ]\",\"[= ]\"]},\"bouncingBall\":{\"interval\":80,\"frames\":[\"( ● )\",\"( ● )\",\"( ● )\",\"( ● )\",\"( ●)\",\"( ● )\",\"( ● )\",\"( ● )\",\"( ● )\",\"(● )\"]},\"smiley\":{\"interval\":200,\"frames\":[\"😄 \",\"😝 \"]},\"monkey\":{\"interval\":300,\"frames\":[\"🙈 \",\"🙈 \",\"🙉 \",\"🙊 \"]},\"hearts\":{\"interval\":100,\"frames\":[\"💛 \",\"💙 \",\"💜 \",\"💚 \",\"❤️ \"]},\"clock\":{\"interval\":100,\"frames\":[\"🕛 \",\"🕐 \",\"🕑 \",\"🕒 \",\"🕓 \",\"🕔 \",\"🕕 \",\"🕖 \",\"🕗 \",\"🕘 \",\"🕙 \",\"🕚 \"]},\"earth\":{\"interval\":180,\"frames\":[\"🌍 \",\"🌎 \",\"🌏 \"]},\"material\":{\"interval\":17,\"frames\":[\"█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁\",\"██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁\",\"███▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁\",\"████▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁\",\"██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁\",\"██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁\",\"███████▁▁▁▁▁▁▁▁▁▁▁▁▁\",\"████████▁▁▁▁▁▁▁▁▁▁▁▁\",\"█████████▁▁▁▁▁▁▁▁▁▁▁\",\"█████████▁▁▁▁▁▁▁▁▁▁▁\",\"██████████▁▁▁▁▁▁▁▁▁▁\",\"███████████▁▁▁▁▁▁▁▁▁\",\"█████████████▁▁▁▁▁▁▁\",\"██████████████▁▁▁▁▁▁\",\"██████████████▁▁▁▁▁▁\",\"▁██████████████▁▁▁▁▁\",\"▁██████████████▁▁▁▁▁\",\"▁██████████████▁▁▁▁▁\",\"▁▁██████████████▁▁▁▁\",\"▁▁▁██████████████▁▁▁\",\"▁▁▁▁█████████████▁▁▁\",\"▁▁▁▁██████████████▁▁\",\"▁▁▁▁██████████████▁▁\",\"▁▁▁▁▁██████████████▁\",\"▁▁▁▁▁██████████████▁\",\"▁▁▁▁▁██████████████▁\",\"▁▁▁▁▁▁██████████████\",\"▁▁▁▁▁▁██████████████\",\"▁▁▁▁▁▁▁█████████████\",\"▁▁▁▁▁▁▁█████████████\",\"▁▁▁▁▁▁▁▁████████████\",\"▁▁▁▁▁▁▁▁████████████\",\"▁▁▁▁▁▁▁▁▁███████████\",\"▁▁▁▁▁▁▁▁▁███████████\",\"▁▁▁▁▁▁▁▁▁▁██████████\",\"▁▁▁▁▁▁▁▁▁▁██████████\",\"▁▁▁▁▁▁▁▁▁▁▁▁████████\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁███████\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁▁██████\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████\",\"█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████\",\"██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███\",\"██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███\",\"███▁▁▁▁▁▁▁▁▁▁▁▁▁▁███\",\"████▁▁▁▁▁▁▁▁▁▁▁▁▁▁██\",\"█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█\",\"█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█\",\"██████▁▁▁▁▁▁▁▁▁▁▁▁▁█\",\"████████▁▁▁▁▁▁▁▁▁▁▁▁\",\"█████████▁▁▁▁▁▁▁▁▁▁▁\",\"█████████▁▁▁▁▁▁▁▁▁▁▁\",\"█████████▁▁▁▁▁▁▁▁▁▁▁\",\"█████████▁▁▁▁▁▁▁▁▁▁▁\",\"███████████▁▁▁▁▁▁▁▁▁\",\"████████████▁▁▁▁▁▁▁▁\",\"████████████▁▁▁▁▁▁▁▁\",\"██████████████▁▁▁▁▁▁\",\"██████████████▁▁▁▁▁▁\",\"▁██████████████▁▁▁▁▁\",\"▁██████████████▁▁▁▁▁\",\"▁▁▁█████████████▁▁▁▁\",\"▁▁▁▁▁████████████▁▁▁\",\"▁▁▁▁▁████████████▁▁▁\",\"▁▁▁▁▁▁███████████▁▁▁\",\"▁▁▁▁▁▁▁▁█████████▁▁▁\",\"▁▁▁▁▁▁▁▁█████████▁▁▁\",\"▁▁▁▁▁▁▁▁▁█████████▁▁\",\"▁▁▁▁▁▁▁▁▁█████████▁▁\",\"▁▁▁▁▁▁▁▁▁▁█████████▁\",\"▁▁▁▁▁▁▁▁▁▁▁████████▁\",\"▁▁▁▁▁▁▁▁▁▁▁████████▁\",\"▁▁▁▁▁▁▁▁▁▁▁▁███████▁\",\"▁▁▁▁▁▁▁▁▁▁▁▁███████▁\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁███████\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁███████\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁\",\"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁\"]},\"moon\":{\"interval\":80,\"frames\":[\"🌑 \",\"🌒 \",\"🌓 \",\"🌔 \",\"🌕 \",\"🌖 \",\"🌗 \",\"🌘 \"]},\"runner\":{\"interval\":140,\"frames\":[\"🚶 \",\"🏃 \"]},\"pong\":{\"interval\":80,\"frames\":[\"▐⠂ ▌\",\"▐⠈ ▌\",\"▐ ⠂ ▌\",\"▐ ⠠ ▌\",\"▐ ⡀ ▌\",\"▐ ⠠ ▌\",\"▐ ⠂ ▌\",\"▐ ⠈ ▌\",\"▐ ⠂ ▌\",\"▐ ⠠ ▌\",\"▐ ⡀ ▌\",\"▐ ⠠ ▌\",\"▐ ⠂ ▌\",\"▐ ⠈ ▌\",\"▐ ⠂▌\",\"▐ ⠠▌\",\"▐ ⡀▌\",\"▐ ⠠ ▌\",\"▐ ⠂ ▌\",\"▐ ⠈ ▌\",\"▐ ⠂ ▌\",\"▐ ⠠ ▌\",\"▐ ⡀ ▌\",\"▐ ⠠ ▌\",\"▐ ⠂ ▌\",\"▐ ⠈ ▌\",\"▐ ⠂ ▌\",\"▐ ⠠ ▌\",\"▐ ⡀ ▌\",\"▐⠠ ▌\"]},\"shark\":{\"interval\":120,\"frames\":[\"▐|\\\\____________▌\",\"▐_|\\\\___________▌\",\"▐__|\\\\__________▌\",\"▐___|\\\\_________▌\",\"▐____|\\\\________▌\",\"▐_____|\\\\_______▌\",\"▐______|\\\\______▌\",\"▐_______|\\\\_____▌\",\"▐________|\\\\____▌\",\"▐_________|\\\\___▌\",\"▐__________|\\\\__▌\",\"▐___________|\\\\_▌\",\"▐____________|\\\\▌\",\"▐____________/|▌\",\"▐___________/|_▌\",\"▐__________/|__▌\",\"▐_________/|___▌\",\"▐________/|____▌\",\"▐_______/|_____▌\",\"▐______/|______▌\",\"▐_____/|_______▌\",\"▐____/|________▌\",\"▐___/|_________▌\",\"▐__/|__________▌\",\"▐_/|___________▌\",\"▐/|____________▌\"]},\"dqpb\":{\"interval\":100,\"frames\":[\"d\",\"q\",\"p\",\"b\"]},\"weather\":{\"interval\":100,\"frames\":[\"☀️ \",\"☀️ \",\"☀️ \",\"🌤 \",\"⛅️ \",\"🌥 \",\"☁️ \",\"🌧 \",\"🌨 \",\"🌧 \",\"🌨 \",\"🌧 \",\"🌨 \",\"⛈ \",\"🌨 \",\"🌧 \",\"🌨 \",\"☁️ \",\"🌥 \",\"⛅️ \",\"🌤 \",\"☀️ \",\"☀️ \"]},\"christmas\":{\"interval\":400,\"frames\":[\"🌲\",\"🎄\"]},\"grenade\":{\"interval\":80,\"frames\":[\"، \",\"′ \",\" ´ \",\" ‾ \",\" ⸌\",\" ⸊\",\" |\",\" ⁎\",\" ⁕\",\" ෴ \",\" ⁓\",\" \",\" \",\" \"]},\"point\":{\"interval\":125,\"frames\":[\"∙∙∙\",\"●∙∙\",\"∙●∙\",\"∙∙●\",\"∙∙∙\"]},\"layer\":{\"interval\":150,\"frames\":[\"-\",\"=\",\"≡\"]},\"betaWave\":{\"interval\":80,\"frames\":[\"ρββββββ\",\"βρβββββ\",\"ββρββββ\",\"βββρβββ\",\"ββββρββ\",\"βββββρβ\",\"ββββββρ\"]}}"); /***/ }), -/* 380 */ +/* 381 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const chalk = __webpack_require__(381); +const chalk = __webpack_require__(382); const isSupported = process.platform !== 'win32' || process.env.CI || process.env.TERM === 'xterm-256color'; @@ -48783,16 +50272,16 @@ module.exports = isSupported ? main : fallbacks; /***/ }), -/* 381 */ +/* 382 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const escapeStringRegexp = __webpack_require__(265); -const ansiStyles = __webpack_require__(382); -const stdoutColor = __webpack_require__(387).stdout; +const ansiStyles = __webpack_require__(383); +const stdoutColor = __webpack_require__(388).stdout; -const template = __webpack_require__(388); +const template = __webpack_require__(389); const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); @@ -49018,12 +50507,12 @@ module.exports.default = module.exports; // For TypeScript /***/ }), -/* 382 */ +/* 383 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(module) { -const colorConvert = __webpack_require__(383); +const colorConvert = __webpack_require__(384); const wrapAnsi16 = (fn, offset) => function () { const code = fn.apply(colorConvert, arguments); @@ -49191,11 +50680,11 @@ Object.defineProperty(module, 'exports', { /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(115)(module))) /***/ }), -/* 383 */ +/* 384 */ /***/ (function(module, exports, __webpack_require__) { -var conversions = __webpack_require__(384); -var route = __webpack_require__(386); +var conversions = __webpack_require__(385); +var route = __webpack_require__(387); var convert = {}; @@ -49275,11 +50764,11 @@ module.exports = convert; /***/ }), -/* 384 */ +/* 385 */ /***/ (function(module, exports, __webpack_require__) { /* MIT license */ -var cssKeywords = __webpack_require__(385); +var cssKeywords = __webpack_require__(386); // NOTE: conversions should only return primitive values (i.e. arrays, or // values that give correct `typeof` results). @@ -50149,7 +51638,7 @@ convert.rgb.gray = function (rgb) { /***/ }), -/* 385 */ +/* 386 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -50308,10 +51797,10 @@ module.exports = { /***/ }), -/* 386 */ +/* 387 */ /***/ (function(module, exports, __webpack_require__) { -var conversions = __webpack_require__(384); +var conversions = __webpack_require__(385); /* this function routes a model to all other models. @@ -50411,7 +51900,7 @@ module.exports = function (fromModel) { /***/ }), -/* 387 */ +/* 388 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -50549,7 +52038,7 @@ module.exports = { /***/ }), -/* 388 */ +/* 389 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -50684,18 +52173,18 @@ module.exports = (chalk, tmp) => { /***/ }), -/* 389 */ +/* 390 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const ansiRegex = __webpack_require__(390); +const ansiRegex = __webpack_require__(391); module.exports = string => typeof string === 'string' ? string.replace(ansiRegex(), '') : string; /***/ }), -/* 390 */ +/* 391 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -50712,14 +52201,14 @@ module.exports = ({onlyFirst = false} = {}) => { /***/ }), -/* 391 */ +/* 392 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var defaults = __webpack_require__(392) -var combining = __webpack_require__(394) +var defaults = __webpack_require__(393) +var combining = __webpack_require__(395) var DEFAULTS = { nul: 0, @@ -50818,10 +52307,10 @@ function bisearch(ucs) { /***/ }), -/* 392 */ +/* 393 */ /***/ (function(module, exports, __webpack_require__) { -var clone = __webpack_require__(393); +var clone = __webpack_require__(394); module.exports = function(options, defaults) { options = options || {}; @@ -50836,7 +52325,7 @@ module.exports = function(options, defaults) { }; /***/ }), -/* 393 */ +/* 394 */ /***/ (function(module, exports, __webpack_require__) { var clone = (function() { @@ -51008,7 +52497,7 @@ if ( true && module.exports) { /***/ }), -/* 394 */ +/* 395 */ /***/ (function(module, exports) { module.exports = [ @@ -51064,7 +52553,7 @@ module.exports = [ /***/ }), -/* 395 */ +/* 396 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -51080,7 +52569,7 @@ module.exports = ({stream = process.stdout} = {}) => { /***/ }), -/* 396 */ +/* 397 */ /***/ (function(module, exports, __webpack_require__) { var Stream = __webpack_require__(138) @@ -51231,7 +52720,7 @@ MuteStream.prototype.close = proxy('close') /***/ }), -/* 397 */ +/* 398 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -51292,7 +52781,7 @@ const RunCommand = { }; /***/ }), -/* 398 */ +/* 399 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -51302,7 +52791,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _utils_log__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(246); /* harmony import */ var _utils_parallelize__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(247); /* harmony import */ var _utils_projects__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(248); -/* harmony import */ var _utils_watch__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(399); +/* harmony import */ var _utils_watch__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(400); /* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with @@ -51388,14 +52877,14 @@ const WatchCommand = { }; /***/ }), -/* 399 */ +/* 400 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "waitUntilWatchIsReady", function() { return waitUntilWatchIsReady; }); /* harmony import */ var rxjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8); -/* harmony import */ var rxjs_operators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(400); +/* harmony import */ var rxjs_operators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(401); /* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with @@ -51462,141 +52951,141 @@ function waitUntilWatchIsReady(stream, opts = {}) { } /***/ }), -/* 400 */ +/* 401 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); -/* harmony import */ var _internal_operators_audit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(401); +/* harmony import */ var _internal_operators_audit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(402); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "audit", function() { return _internal_operators_audit__WEBPACK_IMPORTED_MODULE_0__["audit"]; }); -/* harmony import */ var _internal_operators_auditTime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(402); +/* harmony import */ var _internal_operators_auditTime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(403); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "auditTime", function() { return _internal_operators_auditTime__WEBPACK_IMPORTED_MODULE_1__["auditTime"]; }); -/* harmony import */ var _internal_operators_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(403); +/* harmony import */ var _internal_operators_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(404); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "buffer", function() { return _internal_operators_buffer__WEBPACK_IMPORTED_MODULE_2__["buffer"]; }); -/* harmony import */ var _internal_operators_bufferCount__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(404); +/* harmony import */ var _internal_operators_bufferCount__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(405); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "bufferCount", function() { return _internal_operators_bufferCount__WEBPACK_IMPORTED_MODULE_3__["bufferCount"]; }); -/* harmony import */ var _internal_operators_bufferTime__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(405); +/* harmony import */ var _internal_operators_bufferTime__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(406); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "bufferTime", function() { return _internal_operators_bufferTime__WEBPACK_IMPORTED_MODULE_4__["bufferTime"]; }); -/* harmony import */ var _internal_operators_bufferToggle__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(406); +/* harmony import */ var _internal_operators_bufferToggle__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(407); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "bufferToggle", function() { return _internal_operators_bufferToggle__WEBPACK_IMPORTED_MODULE_5__["bufferToggle"]; }); -/* harmony import */ var _internal_operators_bufferWhen__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(407); +/* harmony import */ var _internal_operators_bufferWhen__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(408); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "bufferWhen", function() { return _internal_operators_bufferWhen__WEBPACK_IMPORTED_MODULE_6__["bufferWhen"]; }); -/* harmony import */ var _internal_operators_catchError__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(408); +/* harmony import */ var _internal_operators_catchError__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(409); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "catchError", function() { return _internal_operators_catchError__WEBPACK_IMPORTED_MODULE_7__["catchError"]; }); -/* harmony import */ var _internal_operators_combineAll__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(409); +/* harmony import */ var _internal_operators_combineAll__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(410); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "combineAll", function() { return _internal_operators_combineAll__WEBPACK_IMPORTED_MODULE_8__["combineAll"]; }); -/* harmony import */ var _internal_operators_combineLatest__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(410); +/* harmony import */ var _internal_operators_combineLatest__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(411); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "combineLatest", function() { return _internal_operators_combineLatest__WEBPACK_IMPORTED_MODULE_9__["combineLatest"]; }); -/* harmony import */ var _internal_operators_concat__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(411); +/* harmony import */ var _internal_operators_concat__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(412); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "concat", function() { return _internal_operators_concat__WEBPACK_IMPORTED_MODULE_10__["concat"]; }); /* harmony import */ var _internal_operators_concatAll__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(80); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "concatAll", function() { return _internal_operators_concatAll__WEBPACK_IMPORTED_MODULE_11__["concatAll"]; }); -/* harmony import */ var _internal_operators_concatMap__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(412); +/* harmony import */ var _internal_operators_concatMap__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(413); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "concatMap", function() { return _internal_operators_concatMap__WEBPACK_IMPORTED_MODULE_12__["concatMap"]; }); -/* harmony import */ var _internal_operators_concatMapTo__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(413); +/* harmony import */ var _internal_operators_concatMapTo__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(414); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "concatMapTo", function() { return _internal_operators_concatMapTo__WEBPACK_IMPORTED_MODULE_13__["concatMapTo"]; }); -/* harmony import */ var _internal_operators_count__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(414); +/* harmony import */ var _internal_operators_count__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(415); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "count", function() { return _internal_operators_count__WEBPACK_IMPORTED_MODULE_14__["count"]; }); -/* harmony import */ var _internal_operators_debounce__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(415); +/* harmony import */ var _internal_operators_debounce__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(416); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "debounce", function() { return _internal_operators_debounce__WEBPACK_IMPORTED_MODULE_15__["debounce"]; }); -/* harmony import */ var _internal_operators_debounceTime__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(416); +/* harmony import */ var _internal_operators_debounceTime__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(417); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "debounceTime", function() { return _internal_operators_debounceTime__WEBPACK_IMPORTED_MODULE_16__["debounceTime"]; }); -/* harmony import */ var _internal_operators_defaultIfEmpty__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(417); +/* harmony import */ var _internal_operators_defaultIfEmpty__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(418); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "defaultIfEmpty", function() { return _internal_operators_defaultIfEmpty__WEBPACK_IMPORTED_MODULE_17__["defaultIfEmpty"]; }); -/* harmony import */ var _internal_operators_delay__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(418); +/* harmony import */ var _internal_operators_delay__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(419); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "delay", function() { return _internal_operators_delay__WEBPACK_IMPORTED_MODULE_18__["delay"]; }); -/* harmony import */ var _internal_operators_delayWhen__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(420); +/* harmony import */ var _internal_operators_delayWhen__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(421); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "delayWhen", function() { return _internal_operators_delayWhen__WEBPACK_IMPORTED_MODULE_19__["delayWhen"]; }); -/* harmony import */ var _internal_operators_dematerialize__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(421); +/* harmony import */ var _internal_operators_dematerialize__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(422); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "dematerialize", function() { return _internal_operators_dematerialize__WEBPACK_IMPORTED_MODULE_20__["dematerialize"]; }); -/* harmony import */ var _internal_operators_distinct__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(422); +/* harmony import */ var _internal_operators_distinct__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(423); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "distinct", function() { return _internal_operators_distinct__WEBPACK_IMPORTED_MODULE_21__["distinct"]; }); -/* harmony import */ var _internal_operators_distinctUntilChanged__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(423); +/* harmony import */ var _internal_operators_distinctUntilChanged__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(424); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "distinctUntilChanged", function() { return _internal_operators_distinctUntilChanged__WEBPACK_IMPORTED_MODULE_22__["distinctUntilChanged"]; }); -/* harmony import */ var _internal_operators_distinctUntilKeyChanged__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(424); +/* harmony import */ var _internal_operators_distinctUntilKeyChanged__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(425); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "distinctUntilKeyChanged", function() { return _internal_operators_distinctUntilKeyChanged__WEBPACK_IMPORTED_MODULE_23__["distinctUntilKeyChanged"]; }); -/* harmony import */ var _internal_operators_elementAt__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(425); +/* harmony import */ var _internal_operators_elementAt__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(426); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "elementAt", function() { return _internal_operators_elementAt__WEBPACK_IMPORTED_MODULE_24__["elementAt"]; }); -/* harmony import */ var _internal_operators_endWith__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(428); +/* harmony import */ var _internal_operators_endWith__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(429); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "endWith", function() { return _internal_operators_endWith__WEBPACK_IMPORTED_MODULE_25__["endWith"]; }); -/* harmony import */ var _internal_operators_every__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(429); +/* harmony import */ var _internal_operators_every__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(430); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "every", function() { return _internal_operators_every__WEBPACK_IMPORTED_MODULE_26__["every"]; }); -/* harmony import */ var _internal_operators_exhaust__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(430); +/* harmony import */ var _internal_operators_exhaust__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(431); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "exhaust", function() { return _internal_operators_exhaust__WEBPACK_IMPORTED_MODULE_27__["exhaust"]; }); -/* harmony import */ var _internal_operators_exhaustMap__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(431); +/* harmony import */ var _internal_operators_exhaustMap__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(432); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "exhaustMap", function() { return _internal_operators_exhaustMap__WEBPACK_IMPORTED_MODULE_28__["exhaustMap"]; }); -/* harmony import */ var _internal_operators_expand__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(432); +/* harmony import */ var _internal_operators_expand__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(433); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expand", function() { return _internal_operators_expand__WEBPACK_IMPORTED_MODULE_29__["expand"]; }); /* harmony import */ var _internal_operators_filter__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(105); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "filter", function() { return _internal_operators_filter__WEBPACK_IMPORTED_MODULE_30__["filter"]; }); -/* harmony import */ var _internal_operators_finalize__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(433); +/* harmony import */ var _internal_operators_finalize__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(434); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "finalize", function() { return _internal_operators_finalize__WEBPACK_IMPORTED_MODULE_31__["finalize"]; }); -/* harmony import */ var _internal_operators_find__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(434); +/* harmony import */ var _internal_operators_find__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(435); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "find", function() { return _internal_operators_find__WEBPACK_IMPORTED_MODULE_32__["find"]; }); -/* harmony import */ var _internal_operators_findIndex__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(435); +/* harmony import */ var _internal_operators_findIndex__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(436); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "findIndex", function() { return _internal_operators_findIndex__WEBPACK_IMPORTED_MODULE_33__["findIndex"]; }); -/* harmony import */ var _internal_operators_first__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(436); +/* harmony import */ var _internal_operators_first__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(437); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "first", function() { return _internal_operators_first__WEBPACK_IMPORTED_MODULE_34__["first"]; }); /* harmony import */ var _internal_operators_groupBy__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(31); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "groupBy", function() { return _internal_operators_groupBy__WEBPACK_IMPORTED_MODULE_35__["groupBy"]; }); -/* harmony import */ var _internal_operators_ignoreElements__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(437); +/* harmony import */ var _internal_operators_ignoreElements__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(438); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ignoreElements", function() { return _internal_operators_ignoreElements__WEBPACK_IMPORTED_MODULE_36__["ignoreElements"]; }); -/* harmony import */ var _internal_operators_isEmpty__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(438); +/* harmony import */ var _internal_operators_isEmpty__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(439); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "isEmpty", function() { return _internal_operators_isEmpty__WEBPACK_IMPORTED_MODULE_37__["isEmpty"]; }); -/* harmony import */ var _internal_operators_last__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(439); +/* harmony import */ var _internal_operators_last__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(440); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "last", function() { return _internal_operators_last__WEBPACK_IMPORTED_MODULE_38__["last"]; }); /* harmony import */ var _internal_operators_map__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(66); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "map", function() { return _internal_operators_map__WEBPACK_IMPORTED_MODULE_39__["map"]; }); -/* harmony import */ var _internal_operators_mapTo__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(441); +/* harmony import */ var _internal_operators_mapTo__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(442); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "mapTo", function() { return _internal_operators_mapTo__WEBPACK_IMPORTED_MODULE_40__["mapTo"]; }); -/* harmony import */ var _internal_operators_materialize__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(442); +/* harmony import */ var _internal_operators_materialize__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(443); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "materialize", function() { return _internal_operators_materialize__WEBPACK_IMPORTED_MODULE_41__["materialize"]; }); -/* harmony import */ var _internal_operators_max__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(443); +/* harmony import */ var _internal_operators_max__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(444); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "max", function() { return _internal_operators_max__WEBPACK_IMPORTED_MODULE_42__["max"]; }); -/* harmony import */ var _internal_operators_merge__WEBPACK_IMPORTED_MODULE_43__ = __webpack_require__(446); +/* harmony import */ var _internal_operators_merge__WEBPACK_IMPORTED_MODULE_43__ = __webpack_require__(447); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "merge", function() { return _internal_operators_merge__WEBPACK_IMPORTED_MODULE_43__["merge"]; }); /* harmony import */ var _internal_operators_mergeAll__WEBPACK_IMPORTED_MODULE_44__ = __webpack_require__(81); @@ -51607,175 +53096,175 @@ __webpack_require__.r(__webpack_exports__); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "flatMap", function() { return _internal_operators_mergeMap__WEBPACK_IMPORTED_MODULE_45__["flatMap"]; }); -/* harmony import */ var _internal_operators_mergeMapTo__WEBPACK_IMPORTED_MODULE_46__ = __webpack_require__(447); +/* harmony import */ var _internal_operators_mergeMapTo__WEBPACK_IMPORTED_MODULE_46__ = __webpack_require__(448); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "mergeMapTo", function() { return _internal_operators_mergeMapTo__WEBPACK_IMPORTED_MODULE_46__["mergeMapTo"]; }); -/* harmony import */ var _internal_operators_mergeScan__WEBPACK_IMPORTED_MODULE_47__ = __webpack_require__(448); +/* harmony import */ var _internal_operators_mergeScan__WEBPACK_IMPORTED_MODULE_47__ = __webpack_require__(449); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "mergeScan", function() { return _internal_operators_mergeScan__WEBPACK_IMPORTED_MODULE_47__["mergeScan"]; }); -/* harmony import */ var _internal_operators_min__WEBPACK_IMPORTED_MODULE_48__ = __webpack_require__(449); +/* harmony import */ var _internal_operators_min__WEBPACK_IMPORTED_MODULE_48__ = __webpack_require__(450); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "min", function() { return _internal_operators_min__WEBPACK_IMPORTED_MODULE_48__["min"]; }); -/* harmony import */ var _internal_operators_multicast__WEBPACK_IMPORTED_MODULE_49__ = __webpack_require__(450); +/* harmony import */ var _internal_operators_multicast__WEBPACK_IMPORTED_MODULE_49__ = __webpack_require__(451); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "multicast", function() { return _internal_operators_multicast__WEBPACK_IMPORTED_MODULE_49__["multicast"]; }); /* harmony import */ var _internal_operators_observeOn__WEBPACK_IMPORTED_MODULE_50__ = __webpack_require__(41); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "observeOn", function() { return _internal_operators_observeOn__WEBPACK_IMPORTED_MODULE_50__["observeOn"]; }); -/* harmony import */ var _internal_operators_onErrorResumeNext__WEBPACK_IMPORTED_MODULE_51__ = __webpack_require__(451); +/* harmony import */ var _internal_operators_onErrorResumeNext__WEBPACK_IMPORTED_MODULE_51__ = __webpack_require__(452); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "onErrorResumeNext", function() { return _internal_operators_onErrorResumeNext__WEBPACK_IMPORTED_MODULE_51__["onErrorResumeNext"]; }); -/* harmony import */ var _internal_operators_pairwise__WEBPACK_IMPORTED_MODULE_52__ = __webpack_require__(452); +/* harmony import */ var _internal_operators_pairwise__WEBPACK_IMPORTED_MODULE_52__ = __webpack_require__(453); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "pairwise", function() { return _internal_operators_pairwise__WEBPACK_IMPORTED_MODULE_52__["pairwise"]; }); -/* harmony import */ var _internal_operators_partition__WEBPACK_IMPORTED_MODULE_53__ = __webpack_require__(453); +/* harmony import */ var _internal_operators_partition__WEBPACK_IMPORTED_MODULE_53__ = __webpack_require__(454); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "partition", function() { return _internal_operators_partition__WEBPACK_IMPORTED_MODULE_53__["partition"]; }); -/* harmony import */ var _internal_operators_pluck__WEBPACK_IMPORTED_MODULE_54__ = __webpack_require__(454); +/* harmony import */ var _internal_operators_pluck__WEBPACK_IMPORTED_MODULE_54__ = __webpack_require__(455); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "pluck", function() { return _internal_operators_pluck__WEBPACK_IMPORTED_MODULE_54__["pluck"]; }); -/* harmony import */ var _internal_operators_publish__WEBPACK_IMPORTED_MODULE_55__ = __webpack_require__(455); +/* harmony import */ var _internal_operators_publish__WEBPACK_IMPORTED_MODULE_55__ = __webpack_require__(456); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "publish", function() { return _internal_operators_publish__WEBPACK_IMPORTED_MODULE_55__["publish"]; }); -/* harmony import */ var _internal_operators_publishBehavior__WEBPACK_IMPORTED_MODULE_56__ = __webpack_require__(456); +/* harmony import */ var _internal_operators_publishBehavior__WEBPACK_IMPORTED_MODULE_56__ = __webpack_require__(457); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "publishBehavior", function() { return _internal_operators_publishBehavior__WEBPACK_IMPORTED_MODULE_56__["publishBehavior"]; }); -/* harmony import */ var _internal_operators_publishLast__WEBPACK_IMPORTED_MODULE_57__ = __webpack_require__(457); +/* harmony import */ var _internal_operators_publishLast__WEBPACK_IMPORTED_MODULE_57__ = __webpack_require__(458); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "publishLast", function() { return _internal_operators_publishLast__WEBPACK_IMPORTED_MODULE_57__["publishLast"]; }); -/* harmony import */ var _internal_operators_publishReplay__WEBPACK_IMPORTED_MODULE_58__ = __webpack_require__(458); +/* harmony import */ var _internal_operators_publishReplay__WEBPACK_IMPORTED_MODULE_58__ = __webpack_require__(459); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "publishReplay", function() { return _internal_operators_publishReplay__WEBPACK_IMPORTED_MODULE_58__["publishReplay"]; }); -/* harmony import */ var _internal_operators_race__WEBPACK_IMPORTED_MODULE_59__ = __webpack_require__(459); +/* harmony import */ var _internal_operators_race__WEBPACK_IMPORTED_MODULE_59__ = __webpack_require__(460); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "race", function() { return _internal_operators_race__WEBPACK_IMPORTED_MODULE_59__["race"]; }); -/* harmony import */ var _internal_operators_reduce__WEBPACK_IMPORTED_MODULE_60__ = __webpack_require__(444); +/* harmony import */ var _internal_operators_reduce__WEBPACK_IMPORTED_MODULE_60__ = __webpack_require__(445); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "reduce", function() { return _internal_operators_reduce__WEBPACK_IMPORTED_MODULE_60__["reduce"]; }); -/* harmony import */ var _internal_operators_repeat__WEBPACK_IMPORTED_MODULE_61__ = __webpack_require__(460); +/* harmony import */ var _internal_operators_repeat__WEBPACK_IMPORTED_MODULE_61__ = __webpack_require__(461); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "repeat", function() { return _internal_operators_repeat__WEBPACK_IMPORTED_MODULE_61__["repeat"]; }); -/* harmony import */ var _internal_operators_repeatWhen__WEBPACK_IMPORTED_MODULE_62__ = __webpack_require__(461); +/* harmony import */ var _internal_operators_repeatWhen__WEBPACK_IMPORTED_MODULE_62__ = __webpack_require__(462); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "repeatWhen", function() { return _internal_operators_repeatWhen__WEBPACK_IMPORTED_MODULE_62__["repeatWhen"]; }); -/* harmony import */ var _internal_operators_retry__WEBPACK_IMPORTED_MODULE_63__ = __webpack_require__(462); +/* harmony import */ var _internal_operators_retry__WEBPACK_IMPORTED_MODULE_63__ = __webpack_require__(463); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "retry", function() { return _internal_operators_retry__WEBPACK_IMPORTED_MODULE_63__["retry"]; }); -/* harmony import */ var _internal_operators_retryWhen__WEBPACK_IMPORTED_MODULE_64__ = __webpack_require__(463); +/* harmony import */ var _internal_operators_retryWhen__WEBPACK_IMPORTED_MODULE_64__ = __webpack_require__(464); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "retryWhen", function() { return _internal_operators_retryWhen__WEBPACK_IMPORTED_MODULE_64__["retryWhen"]; }); /* harmony import */ var _internal_operators_refCount__WEBPACK_IMPORTED_MODULE_65__ = __webpack_require__(30); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "refCount", function() { return _internal_operators_refCount__WEBPACK_IMPORTED_MODULE_65__["refCount"]; }); -/* harmony import */ var _internal_operators_sample__WEBPACK_IMPORTED_MODULE_66__ = __webpack_require__(464); +/* harmony import */ var _internal_operators_sample__WEBPACK_IMPORTED_MODULE_66__ = __webpack_require__(465); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "sample", function() { return _internal_operators_sample__WEBPACK_IMPORTED_MODULE_66__["sample"]; }); -/* harmony import */ var _internal_operators_sampleTime__WEBPACK_IMPORTED_MODULE_67__ = __webpack_require__(465); +/* harmony import */ var _internal_operators_sampleTime__WEBPACK_IMPORTED_MODULE_67__ = __webpack_require__(466); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "sampleTime", function() { return _internal_operators_sampleTime__WEBPACK_IMPORTED_MODULE_67__["sampleTime"]; }); -/* harmony import */ var _internal_operators_scan__WEBPACK_IMPORTED_MODULE_68__ = __webpack_require__(445); +/* harmony import */ var _internal_operators_scan__WEBPACK_IMPORTED_MODULE_68__ = __webpack_require__(446); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "scan", function() { return _internal_operators_scan__WEBPACK_IMPORTED_MODULE_68__["scan"]; }); -/* harmony import */ var _internal_operators_sequenceEqual__WEBPACK_IMPORTED_MODULE_69__ = __webpack_require__(466); +/* harmony import */ var _internal_operators_sequenceEqual__WEBPACK_IMPORTED_MODULE_69__ = __webpack_require__(467); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "sequenceEqual", function() { return _internal_operators_sequenceEqual__WEBPACK_IMPORTED_MODULE_69__["sequenceEqual"]; }); -/* harmony import */ var _internal_operators_share__WEBPACK_IMPORTED_MODULE_70__ = __webpack_require__(467); +/* harmony import */ var _internal_operators_share__WEBPACK_IMPORTED_MODULE_70__ = __webpack_require__(468); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "share", function() { return _internal_operators_share__WEBPACK_IMPORTED_MODULE_70__["share"]; }); -/* harmony import */ var _internal_operators_shareReplay__WEBPACK_IMPORTED_MODULE_71__ = __webpack_require__(468); +/* harmony import */ var _internal_operators_shareReplay__WEBPACK_IMPORTED_MODULE_71__ = __webpack_require__(469); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "shareReplay", function() { return _internal_operators_shareReplay__WEBPACK_IMPORTED_MODULE_71__["shareReplay"]; }); -/* harmony import */ var _internal_operators_single__WEBPACK_IMPORTED_MODULE_72__ = __webpack_require__(469); +/* harmony import */ var _internal_operators_single__WEBPACK_IMPORTED_MODULE_72__ = __webpack_require__(470); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "single", function() { return _internal_operators_single__WEBPACK_IMPORTED_MODULE_72__["single"]; }); -/* harmony import */ var _internal_operators_skip__WEBPACK_IMPORTED_MODULE_73__ = __webpack_require__(470); +/* harmony import */ var _internal_operators_skip__WEBPACK_IMPORTED_MODULE_73__ = __webpack_require__(471); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "skip", function() { return _internal_operators_skip__WEBPACK_IMPORTED_MODULE_73__["skip"]; }); -/* harmony import */ var _internal_operators_skipLast__WEBPACK_IMPORTED_MODULE_74__ = __webpack_require__(471); +/* harmony import */ var _internal_operators_skipLast__WEBPACK_IMPORTED_MODULE_74__ = __webpack_require__(472); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "skipLast", function() { return _internal_operators_skipLast__WEBPACK_IMPORTED_MODULE_74__["skipLast"]; }); -/* harmony import */ var _internal_operators_skipUntil__WEBPACK_IMPORTED_MODULE_75__ = __webpack_require__(472); +/* harmony import */ var _internal_operators_skipUntil__WEBPACK_IMPORTED_MODULE_75__ = __webpack_require__(473); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "skipUntil", function() { return _internal_operators_skipUntil__WEBPACK_IMPORTED_MODULE_75__["skipUntil"]; }); -/* harmony import */ var _internal_operators_skipWhile__WEBPACK_IMPORTED_MODULE_76__ = __webpack_require__(473); +/* harmony import */ var _internal_operators_skipWhile__WEBPACK_IMPORTED_MODULE_76__ = __webpack_require__(474); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "skipWhile", function() { return _internal_operators_skipWhile__WEBPACK_IMPORTED_MODULE_76__["skipWhile"]; }); -/* harmony import */ var _internal_operators_startWith__WEBPACK_IMPORTED_MODULE_77__ = __webpack_require__(474); +/* harmony import */ var _internal_operators_startWith__WEBPACK_IMPORTED_MODULE_77__ = __webpack_require__(475); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "startWith", function() { return _internal_operators_startWith__WEBPACK_IMPORTED_MODULE_77__["startWith"]; }); -/* harmony import */ var _internal_operators_subscribeOn__WEBPACK_IMPORTED_MODULE_78__ = __webpack_require__(475); +/* harmony import */ var _internal_operators_subscribeOn__WEBPACK_IMPORTED_MODULE_78__ = __webpack_require__(476); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "subscribeOn", function() { return _internal_operators_subscribeOn__WEBPACK_IMPORTED_MODULE_78__["subscribeOn"]; }); -/* harmony import */ var _internal_operators_switchAll__WEBPACK_IMPORTED_MODULE_79__ = __webpack_require__(477); +/* harmony import */ var _internal_operators_switchAll__WEBPACK_IMPORTED_MODULE_79__ = __webpack_require__(478); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "switchAll", function() { return _internal_operators_switchAll__WEBPACK_IMPORTED_MODULE_79__["switchAll"]; }); -/* harmony import */ var _internal_operators_switchMap__WEBPACK_IMPORTED_MODULE_80__ = __webpack_require__(478); +/* harmony import */ var _internal_operators_switchMap__WEBPACK_IMPORTED_MODULE_80__ = __webpack_require__(479); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "switchMap", function() { return _internal_operators_switchMap__WEBPACK_IMPORTED_MODULE_80__["switchMap"]; }); -/* harmony import */ var _internal_operators_switchMapTo__WEBPACK_IMPORTED_MODULE_81__ = __webpack_require__(479); +/* harmony import */ var _internal_operators_switchMapTo__WEBPACK_IMPORTED_MODULE_81__ = __webpack_require__(480); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "switchMapTo", function() { return _internal_operators_switchMapTo__WEBPACK_IMPORTED_MODULE_81__["switchMapTo"]; }); -/* harmony import */ var _internal_operators_take__WEBPACK_IMPORTED_MODULE_82__ = __webpack_require__(427); +/* harmony import */ var _internal_operators_take__WEBPACK_IMPORTED_MODULE_82__ = __webpack_require__(428); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "take", function() { return _internal_operators_take__WEBPACK_IMPORTED_MODULE_82__["take"]; }); -/* harmony import */ var _internal_operators_takeLast__WEBPACK_IMPORTED_MODULE_83__ = __webpack_require__(440); +/* harmony import */ var _internal_operators_takeLast__WEBPACK_IMPORTED_MODULE_83__ = __webpack_require__(441); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "takeLast", function() { return _internal_operators_takeLast__WEBPACK_IMPORTED_MODULE_83__["takeLast"]; }); -/* harmony import */ var _internal_operators_takeUntil__WEBPACK_IMPORTED_MODULE_84__ = __webpack_require__(480); +/* harmony import */ var _internal_operators_takeUntil__WEBPACK_IMPORTED_MODULE_84__ = __webpack_require__(481); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "takeUntil", function() { return _internal_operators_takeUntil__WEBPACK_IMPORTED_MODULE_84__["takeUntil"]; }); -/* harmony import */ var _internal_operators_takeWhile__WEBPACK_IMPORTED_MODULE_85__ = __webpack_require__(481); +/* harmony import */ var _internal_operators_takeWhile__WEBPACK_IMPORTED_MODULE_85__ = __webpack_require__(482); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "takeWhile", function() { return _internal_operators_takeWhile__WEBPACK_IMPORTED_MODULE_85__["takeWhile"]; }); -/* harmony import */ var _internal_operators_tap__WEBPACK_IMPORTED_MODULE_86__ = __webpack_require__(482); +/* harmony import */ var _internal_operators_tap__WEBPACK_IMPORTED_MODULE_86__ = __webpack_require__(483); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "tap", function() { return _internal_operators_tap__WEBPACK_IMPORTED_MODULE_86__["tap"]; }); -/* harmony import */ var _internal_operators_throttle__WEBPACK_IMPORTED_MODULE_87__ = __webpack_require__(483); +/* harmony import */ var _internal_operators_throttle__WEBPACK_IMPORTED_MODULE_87__ = __webpack_require__(484); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "throttle", function() { return _internal_operators_throttle__WEBPACK_IMPORTED_MODULE_87__["throttle"]; }); -/* harmony import */ var _internal_operators_throttleTime__WEBPACK_IMPORTED_MODULE_88__ = __webpack_require__(484); +/* harmony import */ var _internal_operators_throttleTime__WEBPACK_IMPORTED_MODULE_88__ = __webpack_require__(485); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "throttleTime", function() { return _internal_operators_throttleTime__WEBPACK_IMPORTED_MODULE_88__["throttleTime"]; }); -/* harmony import */ var _internal_operators_throwIfEmpty__WEBPACK_IMPORTED_MODULE_89__ = __webpack_require__(426); +/* harmony import */ var _internal_operators_throwIfEmpty__WEBPACK_IMPORTED_MODULE_89__ = __webpack_require__(427); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "throwIfEmpty", function() { return _internal_operators_throwIfEmpty__WEBPACK_IMPORTED_MODULE_89__["throwIfEmpty"]; }); -/* harmony import */ var _internal_operators_timeInterval__WEBPACK_IMPORTED_MODULE_90__ = __webpack_require__(485); +/* harmony import */ var _internal_operators_timeInterval__WEBPACK_IMPORTED_MODULE_90__ = __webpack_require__(486); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "timeInterval", function() { return _internal_operators_timeInterval__WEBPACK_IMPORTED_MODULE_90__["timeInterval"]; }); -/* harmony import */ var _internal_operators_timeout__WEBPACK_IMPORTED_MODULE_91__ = __webpack_require__(486); +/* harmony import */ var _internal_operators_timeout__WEBPACK_IMPORTED_MODULE_91__ = __webpack_require__(487); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "timeout", function() { return _internal_operators_timeout__WEBPACK_IMPORTED_MODULE_91__["timeout"]; }); -/* harmony import */ var _internal_operators_timeoutWith__WEBPACK_IMPORTED_MODULE_92__ = __webpack_require__(487); +/* harmony import */ var _internal_operators_timeoutWith__WEBPACK_IMPORTED_MODULE_92__ = __webpack_require__(488); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "timeoutWith", function() { return _internal_operators_timeoutWith__WEBPACK_IMPORTED_MODULE_92__["timeoutWith"]; }); -/* harmony import */ var _internal_operators_timestamp__WEBPACK_IMPORTED_MODULE_93__ = __webpack_require__(488); +/* harmony import */ var _internal_operators_timestamp__WEBPACK_IMPORTED_MODULE_93__ = __webpack_require__(489); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "timestamp", function() { return _internal_operators_timestamp__WEBPACK_IMPORTED_MODULE_93__["timestamp"]; }); -/* harmony import */ var _internal_operators_toArray__WEBPACK_IMPORTED_MODULE_94__ = __webpack_require__(489); +/* harmony import */ var _internal_operators_toArray__WEBPACK_IMPORTED_MODULE_94__ = __webpack_require__(490); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "toArray", function() { return _internal_operators_toArray__WEBPACK_IMPORTED_MODULE_94__["toArray"]; }); -/* harmony import */ var _internal_operators_window__WEBPACK_IMPORTED_MODULE_95__ = __webpack_require__(490); +/* harmony import */ var _internal_operators_window__WEBPACK_IMPORTED_MODULE_95__ = __webpack_require__(491); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "window", function() { return _internal_operators_window__WEBPACK_IMPORTED_MODULE_95__["window"]; }); -/* harmony import */ var _internal_operators_windowCount__WEBPACK_IMPORTED_MODULE_96__ = __webpack_require__(491); +/* harmony import */ var _internal_operators_windowCount__WEBPACK_IMPORTED_MODULE_96__ = __webpack_require__(492); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "windowCount", function() { return _internal_operators_windowCount__WEBPACK_IMPORTED_MODULE_96__["windowCount"]; }); -/* harmony import */ var _internal_operators_windowTime__WEBPACK_IMPORTED_MODULE_97__ = __webpack_require__(492); +/* harmony import */ var _internal_operators_windowTime__WEBPACK_IMPORTED_MODULE_97__ = __webpack_require__(493); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "windowTime", function() { return _internal_operators_windowTime__WEBPACK_IMPORTED_MODULE_97__["windowTime"]; }); -/* harmony import */ var _internal_operators_windowToggle__WEBPACK_IMPORTED_MODULE_98__ = __webpack_require__(493); +/* harmony import */ var _internal_operators_windowToggle__WEBPACK_IMPORTED_MODULE_98__ = __webpack_require__(494); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "windowToggle", function() { return _internal_operators_windowToggle__WEBPACK_IMPORTED_MODULE_98__["windowToggle"]; }); -/* harmony import */ var _internal_operators_windowWhen__WEBPACK_IMPORTED_MODULE_99__ = __webpack_require__(494); +/* harmony import */ var _internal_operators_windowWhen__WEBPACK_IMPORTED_MODULE_99__ = __webpack_require__(495); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "windowWhen", function() { return _internal_operators_windowWhen__WEBPACK_IMPORTED_MODULE_99__["windowWhen"]; }); -/* harmony import */ var _internal_operators_withLatestFrom__WEBPACK_IMPORTED_MODULE_100__ = __webpack_require__(495); +/* harmony import */ var _internal_operators_withLatestFrom__WEBPACK_IMPORTED_MODULE_100__ = __webpack_require__(496); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "withLatestFrom", function() { return _internal_operators_withLatestFrom__WEBPACK_IMPORTED_MODULE_100__["withLatestFrom"]; }); -/* harmony import */ var _internal_operators_zip__WEBPACK_IMPORTED_MODULE_101__ = __webpack_require__(496); +/* harmony import */ var _internal_operators_zip__WEBPACK_IMPORTED_MODULE_101__ = __webpack_require__(497); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "zip", function() { return _internal_operators_zip__WEBPACK_IMPORTED_MODULE_101__["zip"]; }); -/* harmony import */ var _internal_operators_zipAll__WEBPACK_IMPORTED_MODULE_102__ = __webpack_require__(497); +/* harmony import */ var _internal_operators_zipAll__WEBPACK_IMPORTED_MODULE_102__ = __webpack_require__(498); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "zipAll", function() { return _internal_operators_zipAll__WEBPACK_IMPORTED_MODULE_102__["zipAll"]; }); /** PURE_IMPORTS_START PURE_IMPORTS_END */ @@ -51886,7 +53375,7 @@ __webpack_require__.r(__webpack_exports__); /***/ }), -/* 401 */ +/* 402 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -51965,14 +53454,14 @@ var AuditSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 402 */ +/* 403 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "auditTime", function() { return auditTime; }); /* harmony import */ var _scheduler_async__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(55); -/* harmony import */ var _audit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(401); +/* harmony import */ var _audit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(402); /* harmony import */ var _observable_timer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(108); /** PURE_IMPORTS_START _scheduler_async,_audit,_observable_timer PURE_IMPORTS_END */ @@ -51988,7 +53477,7 @@ function auditTime(duration, scheduler) { /***/ }), -/* 403 */ +/* 404 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -52035,7 +53524,7 @@ var BufferSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 404 */ +/* 405 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -52136,7 +53625,7 @@ var BufferSkipCountSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 405 */ +/* 406 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -52297,7 +53786,7 @@ function dispatchBufferClose(arg) { /***/ }), -/* 406 */ +/* 407 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -52416,7 +53905,7 @@ var BufferToggleSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 407 */ +/* 408 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -52509,7 +53998,7 @@ var BufferWhenSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 408 */ +/* 409 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -52569,7 +54058,7 @@ var CatchSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 409 */ +/* 410 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -52585,7 +54074,7 @@ function combineAll(project) { /***/ }), -/* 410 */ +/* 411 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -52617,7 +54106,7 @@ function combineLatest() { /***/ }), -/* 411 */ +/* 412 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -52637,7 +54126,7 @@ function concat() { /***/ }), -/* 412 */ +/* 413 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -52653,13 +54142,13 @@ function concatMap(project, resultSelector) { /***/ }), -/* 413 */ +/* 414 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "concatMapTo", function() { return concatMapTo; }); -/* harmony import */ var _concatMap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(412); +/* harmony import */ var _concatMap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(413); /** PURE_IMPORTS_START _concatMap PURE_IMPORTS_END */ function concatMapTo(innerObservable, resultSelector) { @@ -52669,7 +54158,7 @@ function concatMapTo(innerObservable, resultSelector) { /***/ }), -/* 414 */ +/* 415 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -52734,7 +54223,7 @@ var CountSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 415 */ +/* 416 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -52819,7 +54308,7 @@ var DebounceSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 416 */ +/* 417 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -52895,7 +54384,7 @@ function dispatchNext(subscriber) { /***/ }), -/* 417 */ +/* 418 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -52945,7 +54434,7 @@ var DefaultIfEmptySubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 418 */ +/* 419 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -52953,7 +54442,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "delay", function() { return delay; }); /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(12); /* harmony import */ var _scheduler_async__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(55); -/* harmony import */ var _util_isDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(419); +/* harmony import */ var _util_isDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(420); /* harmony import */ var _Subscriber__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(11); /* harmony import */ var _Notification__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(42); /** PURE_IMPORTS_START tslib,_scheduler_async,_util_isDate,_Subscriber,_Notification PURE_IMPORTS_END */ @@ -53052,7 +54541,7 @@ var DelayMessage = /*@__PURE__*/ (function () { /***/ }), -/* 419 */ +/* 420 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -53066,7 +54555,7 @@ function isDate(value) { /***/ }), -/* 420 */ +/* 421 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -53212,7 +54701,7 @@ var SubscriptionDelaySubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 421 */ +/* 422 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -53250,7 +54739,7 @@ var DeMaterializeSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 422 */ +/* 423 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -53326,7 +54815,7 @@ var DistinctSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 423 */ +/* 424 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -53397,13 +54886,13 @@ var DistinctUntilChangedSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 424 */ +/* 425 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "distinctUntilKeyChanged", function() { return distinctUntilKeyChanged; }); -/* harmony import */ var _distinctUntilChanged__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(423); +/* harmony import */ var _distinctUntilChanged__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(424); /** PURE_IMPORTS_START _distinctUntilChanged PURE_IMPORTS_END */ function distinctUntilKeyChanged(key, compare) { @@ -53413,7 +54902,7 @@ function distinctUntilKeyChanged(key, compare) { /***/ }), -/* 425 */ +/* 426 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -53421,9 +54910,9 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "elementAt", function() { return elementAt; }); /* harmony import */ var _util_ArgumentOutOfRangeError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(62); /* harmony import */ var _filter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(105); -/* harmony import */ var _throwIfEmpty__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(426); -/* harmony import */ var _defaultIfEmpty__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(417); -/* harmony import */ var _take__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(427); +/* harmony import */ var _throwIfEmpty__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(427); +/* harmony import */ var _defaultIfEmpty__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(418); +/* harmony import */ var _take__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(428); /** PURE_IMPORTS_START _util_ArgumentOutOfRangeError,_filter,_throwIfEmpty,_defaultIfEmpty,_take PURE_IMPORTS_END */ @@ -53445,7 +54934,7 @@ function elementAt(index, defaultValue) { /***/ }), -/* 426 */ +/* 427 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -53511,7 +55000,7 @@ function defaultErrorFactory() { /***/ }), -/* 427 */ +/* 428 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -53573,7 +55062,7 @@ var TakeSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 428 */ +/* 429 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -53595,7 +55084,7 @@ function endWith() { /***/ }), -/* 429 */ +/* 430 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -53657,7 +55146,7 @@ var EverySubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 430 */ +/* 431 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -53711,7 +55200,7 @@ var SwitchFirstSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 431 */ +/* 432 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -53805,7 +55294,7 @@ var ExhaustMapSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 432 */ +/* 433 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -53917,7 +55406,7 @@ var ExpandSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 433 */ +/* 434 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -53955,7 +55444,7 @@ var FinallySubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 434 */ +/* 435 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -54027,13 +55516,13 @@ var FindValueSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 435 */ +/* 436 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "findIndex", function() { return findIndex; }); -/* harmony import */ var _operators_find__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(434); +/* harmony import */ var _operators_find__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(435); /** PURE_IMPORTS_START _operators_find PURE_IMPORTS_END */ function findIndex(predicate, thisArg) { @@ -54043,7 +55532,7 @@ function findIndex(predicate, thisArg) { /***/ }), -/* 436 */ +/* 437 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -54051,9 +55540,9 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "first", function() { return first; }); /* harmony import */ var _util_EmptyError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(63); /* harmony import */ var _filter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(105); -/* harmony import */ var _take__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(427); -/* harmony import */ var _defaultIfEmpty__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(417); -/* harmony import */ var _throwIfEmpty__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(426); +/* harmony import */ var _take__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(428); +/* harmony import */ var _defaultIfEmpty__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(418); +/* harmony import */ var _throwIfEmpty__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(427); /* harmony import */ var _util_identity__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(25); /** PURE_IMPORTS_START _util_EmptyError,_filter,_take,_defaultIfEmpty,_throwIfEmpty,_util_identity PURE_IMPORTS_END */ @@ -54070,7 +55559,7 @@ function first(predicate, defaultValue) { /***/ }), -/* 437 */ +/* 438 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -54107,7 +55596,7 @@ var IgnoreElementsSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 438 */ +/* 439 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -54151,7 +55640,7 @@ var IsEmptySubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 439 */ +/* 440 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -54159,9 +55648,9 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "last", function() { return last; }); /* harmony import */ var _util_EmptyError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(63); /* harmony import */ var _filter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(105); -/* harmony import */ var _takeLast__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(440); -/* harmony import */ var _throwIfEmpty__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(426); -/* harmony import */ var _defaultIfEmpty__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(417); +/* harmony import */ var _takeLast__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(441); +/* harmony import */ var _throwIfEmpty__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(427); +/* harmony import */ var _defaultIfEmpty__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(418); /* harmony import */ var _util_identity__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(25); /** PURE_IMPORTS_START _util_EmptyError,_filter,_takeLast,_throwIfEmpty,_defaultIfEmpty,_util_identity PURE_IMPORTS_END */ @@ -54178,7 +55667,7 @@ function last(predicate, defaultValue) { /***/ }), -/* 440 */ +/* 441 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -54255,7 +55744,7 @@ var TakeLastSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 441 */ +/* 442 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -54294,7 +55783,7 @@ var MapToSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 442 */ +/* 443 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -54344,13 +55833,13 @@ var MaterializeSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 443 */ +/* 444 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "max", function() { return max; }); -/* harmony import */ var _reduce__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(444); +/* harmony import */ var _reduce__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(445); /** PURE_IMPORTS_START _reduce PURE_IMPORTS_END */ function max(comparer) { @@ -54363,15 +55852,15 @@ function max(comparer) { /***/ }), -/* 444 */ +/* 445 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reduce", function() { return reduce; }); -/* harmony import */ var _scan__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(445); -/* harmony import */ var _takeLast__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(440); -/* harmony import */ var _defaultIfEmpty__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(417); +/* harmony import */ var _scan__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(446); +/* harmony import */ var _takeLast__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(441); +/* harmony import */ var _defaultIfEmpty__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(418); /* harmony import */ var _util_pipe__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(24); /** PURE_IMPORTS_START _scan,_takeLast,_defaultIfEmpty,_util_pipe PURE_IMPORTS_END */ @@ -54392,7 +55881,7 @@ function reduce(accumulator, seed) { /***/ }), -/* 445 */ +/* 446 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -54474,7 +55963,7 @@ var ScanSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 446 */ +/* 447 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -54494,7 +55983,7 @@ function merge() { /***/ }), -/* 447 */ +/* 448 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -54519,7 +56008,7 @@ function mergeMapTo(innerObservable, resultSelector, concurrent) { /***/ }), -/* 448 */ +/* 449 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -54628,13 +56117,13 @@ var MergeScanSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 449 */ +/* 450 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "min", function() { return min; }); -/* harmony import */ var _reduce__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(444); +/* harmony import */ var _reduce__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(445); /** PURE_IMPORTS_START _reduce PURE_IMPORTS_END */ function min(comparer) { @@ -54647,7 +56136,7 @@ function min(comparer) { /***/ }), -/* 450 */ +/* 451 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -54696,7 +56185,7 @@ var MulticastOperator = /*@__PURE__*/ (function () { /***/ }), -/* 451 */ +/* 452 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -54786,7 +56275,7 @@ var OnErrorResumeNextSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 452 */ +/* 453 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -54834,7 +56323,7 @@ var PairwiseSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 453 */ +/* 454 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -54857,7 +56346,7 @@ function partition(predicate, thisArg) { /***/ }), -/* 454 */ +/* 455 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -54897,14 +56386,14 @@ function plucker(props, length) { /***/ }), -/* 455 */ +/* 456 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "publish", function() { return publish; }); /* harmony import */ var _Subject__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(27); -/* harmony import */ var _multicast__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(450); +/* harmony import */ var _multicast__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(451); /** PURE_IMPORTS_START _Subject,_multicast PURE_IMPORTS_END */ @@ -54917,14 +56406,14 @@ function publish(selector) { /***/ }), -/* 456 */ +/* 457 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "publishBehavior", function() { return publishBehavior; }); /* harmony import */ var _BehaviorSubject__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(32); -/* harmony import */ var _multicast__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(450); +/* harmony import */ var _multicast__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(451); /** PURE_IMPORTS_START _BehaviorSubject,_multicast PURE_IMPORTS_END */ @@ -54935,14 +56424,14 @@ function publishBehavior(value) { /***/ }), -/* 457 */ +/* 458 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "publishLast", function() { return publishLast; }); /* harmony import */ var _AsyncSubject__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(50); -/* harmony import */ var _multicast__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(450); +/* harmony import */ var _multicast__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(451); /** PURE_IMPORTS_START _AsyncSubject,_multicast PURE_IMPORTS_END */ @@ -54953,14 +56442,14 @@ function publishLast() { /***/ }), -/* 458 */ +/* 459 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "publishReplay", function() { return publishReplay; }); /* harmony import */ var _ReplaySubject__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(33); -/* harmony import */ var _multicast__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(450); +/* harmony import */ var _multicast__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(451); /** PURE_IMPORTS_START _ReplaySubject,_multicast PURE_IMPORTS_END */ @@ -54976,7 +56465,7 @@ function publishReplay(bufferSize, windowTime, selectorOrScheduler, scheduler) { /***/ }), -/* 459 */ +/* 460 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -55003,7 +56492,7 @@ function race() { /***/ }), -/* 460 */ +/* 461 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -55068,7 +56557,7 @@ var RepeatSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 461 */ +/* 462 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -55162,7 +56651,7 @@ var RepeatWhenSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 462 */ +/* 463 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -55215,7 +56704,7 @@ var RetrySubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 463 */ +/* 464 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -55301,7 +56790,7 @@ var RetryWhenSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 464 */ +/* 465 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -55356,7 +56845,7 @@ var SampleSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 465 */ +/* 466 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -55416,7 +56905,7 @@ function dispatchNotification(state) { /***/ }), -/* 466 */ +/* 467 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -55539,13 +57028,13 @@ var SequenceEqualCompareToSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 467 */ +/* 468 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "share", function() { return share; }); -/* harmony import */ var _multicast__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(450); +/* harmony import */ var _multicast__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(451); /* harmony import */ var _refCount__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(30); /* harmony import */ var _Subject__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(27); /** PURE_IMPORTS_START _multicast,_refCount,_Subject PURE_IMPORTS_END */ @@ -55562,7 +57051,7 @@ function share() { /***/ }), -/* 468 */ +/* 469 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -55631,7 +57120,7 @@ function shareReplayOperator(_a) { /***/ }), -/* 469 */ +/* 470 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -55711,7 +57200,7 @@ var SingleSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 470 */ +/* 471 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -55753,7 +57242,7 @@ var SkipSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 471 */ +/* 472 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -55815,7 +57304,7 @@ var SkipLastSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 472 */ +/* 473 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -55872,7 +57361,7 @@ var SkipUntilSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 473 */ +/* 474 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -55928,7 +57417,7 @@ var SkipWhileSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 474 */ +/* 475 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -55957,13 +57446,13 @@ function startWith() { /***/ }), -/* 475 */ +/* 476 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "subscribeOn", function() { return subscribeOn; }); -/* harmony import */ var _observable_SubscribeOnObservable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(476); +/* harmony import */ var _observable_SubscribeOnObservable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(477); /** PURE_IMPORTS_START _observable_SubscribeOnObservable PURE_IMPORTS_END */ function subscribeOn(scheduler, delay) { @@ -55988,7 +57477,7 @@ var SubscribeOnOperator = /*@__PURE__*/ (function () { /***/ }), -/* 476 */ +/* 477 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -56052,13 +57541,13 @@ var SubscribeOnObservable = /*@__PURE__*/ (function (_super) { /***/ }), -/* 477 */ +/* 478 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "switchAll", function() { return switchAll; }); -/* harmony import */ var _switchMap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(478); +/* harmony import */ var _switchMap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(479); /* harmony import */ var _util_identity__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(25); /** PURE_IMPORTS_START _switchMap,_util_identity PURE_IMPORTS_END */ @@ -56070,7 +57559,7 @@ function switchAll() { /***/ }), -/* 478 */ +/* 479 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -56158,13 +57647,13 @@ var SwitchMapSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 479 */ +/* 480 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "switchMapTo", function() { return switchMapTo; }); -/* harmony import */ var _switchMap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(478); +/* harmony import */ var _switchMap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(479); /** PURE_IMPORTS_START _switchMap PURE_IMPORTS_END */ function switchMapTo(innerObservable, resultSelector) { @@ -56174,7 +57663,7 @@ function switchMapTo(innerObservable, resultSelector) { /***/ }), -/* 480 */ +/* 481 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -56222,7 +57711,7 @@ var TakeUntilSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 481 */ +/* 482 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -56290,7 +57779,7 @@ var TakeWhileSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 482 */ +/* 483 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -56378,7 +57867,7 @@ var TapSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 483 */ +/* 484 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -56480,7 +57969,7 @@ var ThrottleSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 484 */ +/* 485 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -56489,7 +57978,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(12); /* harmony import */ var _Subscriber__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(11); /* harmony import */ var _scheduler_async__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(55); -/* harmony import */ var _throttle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(483); +/* harmony import */ var _throttle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(484); /** PURE_IMPORTS_START tslib,_Subscriber,_scheduler_async,_throttle PURE_IMPORTS_END */ @@ -56578,7 +58067,7 @@ function dispatchNext(arg) { /***/ }), -/* 485 */ +/* 486 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -56586,7 +58075,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "timeInterval", function() { return timeInterval; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TimeInterval", function() { return TimeInterval; }); /* harmony import */ var _scheduler_async__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(55); -/* harmony import */ var _scan__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(445); +/* harmony import */ var _scan__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(446); /* harmony import */ var _observable_defer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(91); /* harmony import */ var _map__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(66); /** PURE_IMPORTS_START _scheduler_async,_scan,_observable_defer,_map PURE_IMPORTS_END */ @@ -56622,7 +58111,7 @@ var TimeInterval = /*@__PURE__*/ (function () { /***/ }), -/* 486 */ +/* 487 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -56630,7 +58119,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "timeout", function() { return timeout; }); /* harmony import */ var _scheduler_async__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(55); /* harmony import */ var _util_TimeoutError__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(64); -/* harmony import */ var _timeoutWith__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(487); +/* harmony import */ var _timeoutWith__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(488); /* harmony import */ var _observable_throwError__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(49); /** PURE_IMPORTS_START _scheduler_async,_util_TimeoutError,_timeoutWith,_observable_throwError PURE_IMPORTS_END */ @@ -56647,7 +58136,7 @@ function timeout(due, scheduler) { /***/ }), -/* 487 */ +/* 488 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -56655,7 +58144,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "timeoutWith", function() { return timeoutWith; }); /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(12); /* harmony import */ var _scheduler_async__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(55); -/* harmony import */ var _util_isDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(419); +/* harmony import */ var _util_isDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(420); /* harmony import */ var _innerSubscribe__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(90); /** PURE_IMPORTS_START tslib,_scheduler_async,_util_isDate,_innerSubscribe PURE_IMPORTS_END */ @@ -56726,7 +58215,7 @@ var TimeoutWithSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 488 */ +/* 489 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -56756,13 +58245,13 @@ var Timestamp = /*@__PURE__*/ (function () { /***/ }), -/* 489 */ +/* 490 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toArray", function() { return toArray; }); -/* harmony import */ var _reduce__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(444); +/* harmony import */ var _reduce__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(445); /** PURE_IMPORTS_START _reduce PURE_IMPORTS_END */ function toArrayReducer(arr, item, index) { @@ -56779,7 +58268,7 @@ function toArray() { /***/ }), -/* 490 */ +/* 491 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -56857,7 +58346,7 @@ var WindowSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 491 */ +/* 492 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -56947,7 +58436,7 @@ var WindowCountSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 492 */ +/* 493 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -57117,7 +58606,7 @@ function dispatchWindowClose(state) { /***/ }), -/* 493 */ +/* 494 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -57260,7 +58749,7 @@ var WindowToggleSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 494 */ +/* 495 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -57357,7 +58846,7 @@ var WindowSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 495 */ +/* 496 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -57452,7 +58941,7 @@ var WithLatestFromSubscriber = /*@__PURE__*/ (function (_super) { /***/ }), -/* 496 */ +/* 497 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -57474,7 +58963,7 @@ function zip() { /***/ }), -/* 497 */ +/* 498 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -57490,7 +58979,7 @@ function zipAll(project) { /***/ }), -/* 498 */ +/* 499 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -57499,8 +58988,8 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _utils_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(249); /* harmony import */ var _utils_log__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(246); /* harmony import */ var _utils_projects__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(248); -/* harmony import */ var _utils_projects_tree__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(365); -/* harmony import */ var _utils_kibana__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(499); +/* harmony import */ var _utils_projects_tree__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(366); +/* harmony import */ var _utils_kibana__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(500); function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } @@ -57582,7 +59071,7 @@ function toArray(value) { } /***/ }), -/* 499 */ +/* 500 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -57590,13 +59079,13 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Kibana", function() { return Kibana; }); /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4); /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var multimatch__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(500); +/* harmony import */ var multimatch__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(501); /* harmony import */ var multimatch__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(multimatch__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var is_path_inside__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(239); /* harmony import */ var is_path_inside__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(is_path_inside__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var _yarn_lock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(360); +/* harmony import */ var _yarn_lock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(361); /* harmony import */ var _projects__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(248); -/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(504); +/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(505); function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } @@ -57758,15 +59247,15 @@ class Kibana { } /***/ }), -/* 500 */ +/* 501 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const minimatch = __webpack_require__(150); -const arrayUnion = __webpack_require__(501); -const arrayDiffer = __webpack_require__(502); -const arrify = __webpack_require__(503); +const arrayUnion = __webpack_require__(502); +const arrayDiffer = __webpack_require__(503); +const arrify = __webpack_require__(504); module.exports = (list, patterns, options = {}) => { list = arrify(list); @@ -57790,7 +59279,7 @@ module.exports = (list, patterns, options = {}) => { /***/ }), -/* 501 */ +/* 502 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -57802,7 +59291,7 @@ module.exports = (...arguments_) => { /***/ }), -/* 502 */ +/* 503 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -57817,7 +59306,7 @@ module.exports = arrayDiffer; /***/ }), -/* 503 */ +/* 504 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -57847,7 +59336,7 @@ module.exports = arrify; /***/ }), -/* 504 */ +/* 505 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -57917,12 +59406,12 @@ function getProjectPaths({ } /***/ }), -/* 505 */ +/* 506 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); -/* harmony import */ var _build_production_projects__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(506); +/* harmony import */ var _build_production_projects__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(507); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "buildProductionProjects", function() { return _build_production_projects__WEBPACK_IMPORTED_MODULE_0__["buildProductionProjects"]; }); /* @@ -57946,19 +59435,19 @@ __webpack_require__.r(__webpack_exports__); /***/ }), -/* 506 */ +/* 507 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "buildProductionProjects", function() { return buildProductionProjects; }); -/* harmony import */ var cpy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(507); +/* harmony import */ var cpy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(508); /* harmony import */ var cpy__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(cpy__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var del__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(143); /* harmony import */ var del__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(del__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4); /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(504); +/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(505); /* harmony import */ var _utils_fs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(131); /* harmony import */ var _utils_log__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(246); /* harmony import */ var _utils_package_json__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(251); @@ -58095,7 +59584,7 @@ async function copyToBuild(project, kibanaRoot, buildRoot) { } /***/ }), -/* 507 */ +/* 508 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -58103,14 +59592,14 @@ async function copyToBuild(project, kibanaRoot, buildRoot) { const EventEmitter = __webpack_require__(156); const path = __webpack_require__(4); const os = __webpack_require__(121); -const pMap = __webpack_require__(508); -const arrify = __webpack_require__(503); -const globby = __webpack_require__(509); -const hasGlob = __webpack_require__(705); -const cpFile = __webpack_require__(707); -const junk = __webpack_require__(717); -const pFilter = __webpack_require__(718); -const CpyError = __webpack_require__(720); +const pMap = __webpack_require__(509); +const arrify = __webpack_require__(504); +const globby = __webpack_require__(510); +const hasGlob = __webpack_require__(706); +const cpFile = __webpack_require__(708); +const junk = __webpack_require__(718); +const pFilter = __webpack_require__(719); +const CpyError = __webpack_require__(721); const defaultOptions = { ignoreJunk: true @@ -58261,7 +59750,7 @@ module.exports = (source, destination, { /***/ }), -/* 508 */ +/* 509 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -58349,17 +59838,17 @@ module.exports = async ( /***/ }), -/* 509 */ +/* 510 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const fs = __webpack_require__(134); -const arrayUnion = __webpack_require__(510); +const arrayUnion = __webpack_require__(511); const glob = __webpack_require__(147); -const fastGlob = __webpack_require__(512); -const dirGlob = __webpack_require__(698); -const gitignore = __webpack_require__(701); +const fastGlob = __webpack_require__(513); +const dirGlob = __webpack_require__(699); +const gitignore = __webpack_require__(702); const DEFAULT_FILTER = () => false; @@ -58504,12 +59993,12 @@ module.exports.gitignore = gitignore; /***/ }), -/* 510 */ +/* 511 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var arrayUniq = __webpack_require__(511); +var arrayUniq = __webpack_require__(512); module.exports = function () { return arrayUniq([].concat.apply([], arguments)); @@ -58517,7 +60006,7 @@ module.exports = function () { /***/ }), -/* 511 */ +/* 512 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -58586,10 +60075,10 @@ if ('Set' in global) { /***/ }), -/* 512 */ +/* 513 */ /***/ (function(module, exports, __webpack_require__) { -const pkg = __webpack_require__(513); +const pkg = __webpack_require__(514); module.exports = pkg.async; module.exports.default = pkg.async; @@ -58602,19 +60091,19 @@ module.exports.generateTasks = pkg.generateTasks; /***/ }), -/* 513 */ +/* 514 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var optionsManager = __webpack_require__(514); -var taskManager = __webpack_require__(515); -var reader_async_1 = __webpack_require__(669); -var reader_stream_1 = __webpack_require__(693); -var reader_sync_1 = __webpack_require__(694); -var arrayUtils = __webpack_require__(696); -var streamUtils = __webpack_require__(697); +var optionsManager = __webpack_require__(515); +var taskManager = __webpack_require__(516); +var reader_async_1 = __webpack_require__(670); +var reader_stream_1 = __webpack_require__(694); +var reader_sync_1 = __webpack_require__(695); +var arrayUtils = __webpack_require__(697); +var streamUtils = __webpack_require__(698); /** * Synchronous API. */ @@ -58680,7 +60169,7 @@ function isString(source) { /***/ }), -/* 514 */ +/* 515 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -58718,13 +60207,13 @@ exports.prepare = prepare; /***/ }), -/* 515 */ +/* 516 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var patternUtils = __webpack_require__(516); +var patternUtils = __webpack_require__(517); /** * Generate tasks based on parent directory of each pattern. */ @@ -58815,16 +60304,16 @@ exports.convertPatternGroupToTask = convertPatternGroupToTask; /***/ }), -/* 516 */ +/* 517 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var path = __webpack_require__(4); -var globParent = __webpack_require__(517); +var globParent = __webpack_require__(518); var isGlob = __webpack_require__(172); -var micromatch = __webpack_require__(520); +var micromatch = __webpack_require__(521); var GLOBSTAR = '**'; /** * Return true for static pattern. @@ -58970,15 +60459,15 @@ exports.matchAny = matchAny; /***/ }), -/* 517 */ +/* 518 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var path = __webpack_require__(4); -var isglob = __webpack_require__(518); -var pathDirname = __webpack_require__(519); +var isglob = __webpack_require__(519); +var pathDirname = __webpack_require__(520); var isWin32 = __webpack_require__(121).platform() === 'win32'; module.exports = function globParent(str) { @@ -59001,7 +60490,7 @@ module.exports = function globParent(str) { /***/ }), -/* 518 */ +/* 519 */ /***/ (function(module, exports, __webpack_require__) { /*! @@ -59032,7 +60521,7 @@ module.exports = function isGlob(str) { /***/ }), -/* 519 */ +/* 520 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -59182,7 +60671,7 @@ module.exports.win32 = win32; /***/ }), -/* 520 */ +/* 521 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -59193,18 +60682,18 @@ module.exports.win32 = win32; */ var util = __webpack_require__(112); -var braces = __webpack_require__(521); -var toRegex = __webpack_require__(522); -var extend = __webpack_require__(635); +var braces = __webpack_require__(522); +var toRegex = __webpack_require__(523); +var extend = __webpack_require__(636); /** * Local dependencies */ -var compilers = __webpack_require__(637); -var parsers = __webpack_require__(664); -var cache = __webpack_require__(665); -var utils = __webpack_require__(666); +var compilers = __webpack_require__(638); +var parsers = __webpack_require__(665); +var cache = __webpack_require__(666); +var utils = __webpack_require__(667); var MAX_LENGTH = 1024 * 64; /** @@ -60066,7 +61555,7 @@ module.exports = micromatch; /***/ }), -/* 521 */ +/* 522 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -60076,18 +61565,18 @@ module.exports = micromatch; * Module dependencies */ -var toRegex = __webpack_require__(522); -var unique = __webpack_require__(544); -var extend = __webpack_require__(545); +var toRegex = __webpack_require__(523); +var unique = __webpack_require__(545); +var extend = __webpack_require__(546); /** * Local dependencies */ -var compilers = __webpack_require__(547); -var parsers = __webpack_require__(560); -var Braces = __webpack_require__(564); -var utils = __webpack_require__(548); +var compilers = __webpack_require__(548); +var parsers = __webpack_require__(561); +var Braces = __webpack_require__(565); +var utils = __webpack_require__(549); var MAX_LENGTH = 1024 * 64; var cache = {}; @@ -60391,16 +61880,16 @@ module.exports = braces; /***/ }), -/* 522 */ +/* 523 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var safe = __webpack_require__(523); -var define = __webpack_require__(529); -var extend = __webpack_require__(537); -var not = __webpack_require__(541); +var safe = __webpack_require__(524); +var define = __webpack_require__(530); +var extend = __webpack_require__(538); +var not = __webpack_require__(542); var MAX_LENGTH = 1024 * 64; /** @@ -60553,10 +62042,10 @@ module.exports.makeRe = makeRe; /***/ }), -/* 523 */ +/* 524 */ /***/ (function(module, exports, __webpack_require__) { -var parse = __webpack_require__(524); +var parse = __webpack_require__(525); var types = parse.types; module.exports = function (re, opts) { @@ -60602,13 +62091,13 @@ function isRegExp (x) { /***/ }), -/* 524 */ +/* 525 */ /***/ (function(module, exports, __webpack_require__) { -var util = __webpack_require__(525); -var types = __webpack_require__(526); -var sets = __webpack_require__(527); -var positions = __webpack_require__(528); +var util = __webpack_require__(526); +var types = __webpack_require__(527); +var sets = __webpack_require__(528); +var positions = __webpack_require__(529); module.exports = function(regexpStr) { @@ -60890,11 +62379,11 @@ module.exports.types = types; /***/ }), -/* 525 */ +/* 526 */ /***/ (function(module, exports, __webpack_require__) { -var types = __webpack_require__(526); -var sets = __webpack_require__(527); +var types = __webpack_require__(527); +var sets = __webpack_require__(528); // All of these are private and only used by randexp. @@ -61007,7 +62496,7 @@ exports.error = function(regexp, msg) { /***/ }), -/* 526 */ +/* 527 */ /***/ (function(module, exports) { module.exports = { @@ -61023,10 +62512,10 @@ module.exports = { /***/ }), -/* 527 */ +/* 528 */ /***/ (function(module, exports, __webpack_require__) { -var types = __webpack_require__(526); +var types = __webpack_require__(527); var INTS = function() { return [{ type: types.RANGE , from: 48, to: 57 }]; @@ -61111,10 +62600,10 @@ exports.anyChar = function() { /***/ }), -/* 528 */ +/* 529 */ /***/ (function(module, exports, __webpack_require__) { -var types = __webpack_require__(526); +var types = __webpack_require__(527); exports.wordBoundary = function() { return { type: types.POSITION, value: 'b' }; @@ -61134,7 +62623,7 @@ exports.end = function() { /***/ }), -/* 529 */ +/* 530 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -61147,8 +62636,8 @@ exports.end = function() { -var isobject = __webpack_require__(530); -var isDescriptor = __webpack_require__(531); +var isobject = __webpack_require__(531); +var isDescriptor = __webpack_require__(532); var define = (typeof Reflect !== 'undefined' && Reflect.defineProperty) ? Reflect.defineProperty : Object.defineProperty; @@ -61179,7 +62668,7 @@ module.exports = function defineProperty(obj, key, val) { /***/ }), -/* 530 */ +/* 531 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -61198,7 +62687,7 @@ module.exports = function isObject(val) { /***/ }), -/* 531 */ +/* 532 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -61211,9 +62700,9 @@ module.exports = function isObject(val) { -var typeOf = __webpack_require__(532); -var isAccessor = __webpack_require__(533); -var isData = __webpack_require__(535); +var typeOf = __webpack_require__(533); +var isAccessor = __webpack_require__(534); +var isData = __webpack_require__(536); module.exports = function isDescriptor(obj, key) { if (typeOf(obj) !== 'object') { @@ -61227,7 +62716,7 @@ module.exports = function isDescriptor(obj, key) { /***/ }), -/* 532 */ +/* 533 */ /***/ (function(module, exports) { var toString = Object.prototype.toString; @@ -61362,7 +62851,7 @@ function isBuffer(val) { /***/ }), -/* 533 */ +/* 534 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -61375,7 +62864,7 @@ function isBuffer(val) { -var typeOf = __webpack_require__(534); +var typeOf = __webpack_require__(535); // accessor descriptor properties var accessor = { @@ -61438,7 +62927,7 @@ module.exports = isAccessorDescriptor; /***/ }), -/* 534 */ +/* 535 */ /***/ (function(module, exports) { var toString = Object.prototype.toString; @@ -61573,7 +63062,7 @@ function isBuffer(val) { /***/ }), -/* 535 */ +/* 536 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -61586,7 +63075,7 @@ function isBuffer(val) { -var typeOf = __webpack_require__(536); +var typeOf = __webpack_require__(537); module.exports = function isDataDescriptor(obj, prop) { // data descriptor properties @@ -61629,7 +63118,7 @@ module.exports = function isDataDescriptor(obj, prop) { /***/ }), -/* 536 */ +/* 537 */ /***/ (function(module, exports) { var toString = Object.prototype.toString; @@ -61764,14 +63253,14 @@ function isBuffer(val) { /***/ }), -/* 537 */ +/* 538 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var isExtendable = __webpack_require__(538); -var assignSymbols = __webpack_require__(540); +var isExtendable = __webpack_require__(539); +var assignSymbols = __webpack_require__(541); module.exports = Object.assign || function(obj/*, objects*/) { if (obj === null || typeof obj === 'undefined') { @@ -61831,7 +63320,7 @@ function isEnum(obj, key) { /***/ }), -/* 538 */ +/* 539 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -61844,7 +63333,7 @@ function isEnum(obj, key) { -var isPlainObject = __webpack_require__(539); +var isPlainObject = __webpack_require__(540); module.exports = function isExtendable(val) { return isPlainObject(val) || typeof val === 'function' || Array.isArray(val); @@ -61852,7 +63341,7 @@ module.exports = function isExtendable(val) { /***/ }), -/* 539 */ +/* 540 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -61865,7 +63354,7 @@ module.exports = function isExtendable(val) { -var isObject = __webpack_require__(530); +var isObject = __webpack_require__(531); function isObjectObject(o) { return isObject(o) === true @@ -61896,7 +63385,7 @@ module.exports = function isPlainObject(o) { /***/ }), -/* 540 */ +/* 541 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -61943,14 +63432,14 @@ module.exports = function(receiver, objects) { /***/ }), -/* 541 */ +/* 542 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var extend = __webpack_require__(542); -var safe = __webpack_require__(523); +var extend = __webpack_require__(543); +var safe = __webpack_require__(524); /** * The main export is a function that takes a `pattern` string and an `options` object. @@ -62022,14 +63511,14 @@ module.exports = toRegex; /***/ }), -/* 542 */ +/* 543 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var isExtendable = __webpack_require__(543); -var assignSymbols = __webpack_require__(540); +var isExtendable = __webpack_require__(544); +var assignSymbols = __webpack_require__(541); module.exports = Object.assign || function(obj/*, objects*/) { if (obj === null || typeof obj === 'undefined') { @@ -62089,7 +63578,7 @@ function isEnum(obj, key) { /***/ }), -/* 543 */ +/* 544 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -62102,7 +63591,7 @@ function isEnum(obj, key) { -var isPlainObject = __webpack_require__(539); +var isPlainObject = __webpack_require__(540); module.exports = function isExtendable(val) { return isPlainObject(val) || typeof val === 'function' || Array.isArray(val); @@ -62110,7 +63599,7 @@ module.exports = function isExtendable(val) { /***/ }), -/* 544 */ +/* 545 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -62160,13 +63649,13 @@ module.exports.immutable = function uniqueImmutable(arr) { /***/ }), -/* 545 */ +/* 546 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var isObject = __webpack_require__(546); +var isObject = __webpack_require__(547); module.exports = function extend(o/*, objects*/) { if (!isObject(o)) { o = {}; } @@ -62200,7 +63689,7 @@ function hasOwn(obj, key) { /***/ }), -/* 546 */ +/* 547 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -62220,13 +63709,13 @@ module.exports = function isExtendable(val) { /***/ }), -/* 547 */ +/* 548 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var utils = __webpack_require__(548); +var utils = __webpack_require__(549); module.exports = function(braces, options) { braces.compiler @@ -62509,25 +63998,25 @@ function hasQueue(node) { /***/ }), -/* 548 */ +/* 549 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var splitString = __webpack_require__(549); +var splitString = __webpack_require__(550); var utils = module.exports; /** * Module dependencies */ -utils.extend = __webpack_require__(545); -utils.flatten = __webpack_require__(552); -utils.isObject = __webpack_require__(530); -utils.fillRange = __webpack_require__(553); -utils.repeat = __webpack_require__(559); -utils.unique = __webpack_require__(544); +utils.extend = __webpack_require__(546); +utils.flatten = __webpack_require__(553); +utils.isObject = __webpack_require__(531); +utils.fillRange = __webpack_require__(554); +utils.repeat = __webpack_require__(560); +utils.unique = __webpack_require__(545); utils.define = function(obj, key, val) { Object.defineProperty(obj, key, { @@ -62859,7 +64348,7 @@ utils.escapeRegex = function(str) { /***/ }), -/* 549 */ +/* 550 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -62872,7 +64361,7 @@ utils.escapeRegex = function(str) { -var extend = __webpack_require__(550); +var extend = __webpack_require__(551); module.exports = function(str, options, fn) { if (typeof str !== 'string') { @@ -63037,14 +64526,14 @@ function keepEscaping(opts, str, idx) { /***/ }), -/* 550 */ +/* 551 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var isExtendable = __webpack_require__(551); -var assignSymbols = __webpack_require__(540); +var isExtendable = __webpack_require__(552); +var assignSymbols = __webpack_require__(541); module.exports = Object.assign || function(obj/*, objects*/) { if (obj === null || typeof obj === 'undefined') { @@ -63104,7 +64593,7 @@ function isEnum(obj, key) { /***/ }), -/* 551 */ +/* 552 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -63117,7 +64606,7 @@ function isEnum(obj, key) { -var isPlainObject = __webpack_require__(539); +var isPlainObject = __webpack_require__(540); module.exports = function isExtendable(val) { return isPlainObject(val) || typeof val === 'function' || Array.isArray(val); @@ -63125,7 +64614,7 @@ module.exports = function isExtendable(val) { /***/ }), -/* 552 */ +/* 553 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -63154,7 +64643,7 @@ function flat(arr, res) { /***/ }), -/* 553 */ +/* 554 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -63168,10 +64657,10 @@ function flat(arr, res) { var util = __webpack_require__(112); -var isNumber = __webpack_require__(554); -var extend = __webpack_require__(545); -var repeat = __webpack_require__(557); -var toRegex = __webpack_require__(558); +var isNumber = __webpack_require__(555); +var extend = __webpack_require__(546); +var repeat = __webpack_require__(558); +var toRegex = __webpack_require__(559); /** * Return a range of numbers or letters. @@ -63369,7 +64858,7 @@ module.exports = fillRange; /***/ }), -/* 554 */ +/* 555 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -63382,7 +64871,7 @@ module.exports = fillRange; -var typeOf = __webpack_require__(555); +var typeOf = __webpack_require__(556); module.exports = function isNumber(num) { var type = typeOf(num); @@ -63398,10 +64887,10 @@ module.exports = function isNumber(num) { /***/ }), -/* 555 */ +/* 556 */ /***/ (function(module, exports, __webpack_require__) { -var isBuffer = __webpack_require__(556); +var isBuffer = __webpack_require__(557); var toString = Object.prototype.toString; /** @@ -63520,7 +65009,7 @@ module.exports = function kindOf(val) { /***/ }), -/* 556 */ +/* 557 */ /***/ (function(module, exports) { /*! @@ -63547,7 +65036,7 @@ function isSlowBuffer (obj) { /***/ }), -/* 557 */ +/* 558 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -63624,7 +65113,7 @@ function repeat(str, num) { /***/ }), -/* 558 */ +/* 559 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -63637,8 +65126,8 @@ function repeat(str, num) { -var repeat = __webpack_require__(557); -var isNumber = __webpack_require__(554); +var repeat = __webpack_require__(558); +var isNumber = __webpack_require__(555); var cache = {}; function toRegexRange(min, max, options) { @@ -63925,7 +65414,7 @@ module.exports = toRegexRange; /***/ }), -/* 559 */ +/* 560 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -63950,14 +65439,14 @@ module.exports = function repeat(ele, num) { /***/ }), -/* 560 */ +/* 561 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var Node = __webpack_require__(561); -var utils = __webpack_require__(548); +var Node = __webpack_require__(562); +var utils = __webpack_require__(549); /** * Braces parsers @@ -64317,15 +65806,15 @@ function concatNodes(pos, node, parent, options) { /***/ }), -/* 561 */ +/* 562 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var isObject = __webpack_require__(530); -var define = __webpack_require__(562); -var utils = __webpack_require__(563); +var isObject = __webpack_require__(531); +var define = __webpack_require__(563); +var utils = __webpack_require__(564); var ownNames; /** @@ -64816,7 +66305,7 @@ exports = module.exports = Node; /***/ }), -/* 562 */ +/* 563 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -64829,7 +66318,7 @@ exports = module.exports = Node; -var isDescriptor = __webpack_require__(531); +var isDescriptor = __webpack_require__(532); module.exports = function defineProperty(obj, prop, val) { if (typeof obj !== 'object' && typeof obj !== 'function') { @@ -64854,13 +66343,13 @@ module.exports = function defineProperty(obj, prop, val) { /***/ }), -/* 563 */ +/* 564 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var typeOf = __webpack_require__(555); +var typeOf = __webpack_require__(556); var utils = module.exports; /** @@ -65880,17 +67369,17 @@ function assert(val, message) { /***/ }), -/* 564 */ +/* 565 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var extend = __webpack_require__(545); -var Snapdragon = __webpack_require__(565); -var compilers = __webpack_require__(547); -var parsers = __webpack_require__(560); -var utils = __webpack_require__(548); +var extend = __webpack_require__(546); +var Snapdragon = __webpack_require__(566); +var compilers = __webpack_require__(548); +var parsers = __webpack_require__(561); +var utils = __webpack_require__(549); /** * Customize Snapdragon parser and renderer @@ -65991,17 +67480,17 @@ module.exports = Braces; /***/ }), -/* 565 */ +/* 566 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var Base = __webpack_require__(566); -var define = __webpack_require__(593); -var Compiler = __webpack_require__(603); -var Parser = __webpack_require__(632); -var utils = __webpack_require__(612); +var Base = __webpack_require__(567); +var define = __webpack_require__(594); +var Compiler = __webpack_require__(604); +var Parser = __webpack_require__(633); +var utils = __webpack_require__(613); var regexCache = {}; var cache = {}; @@ -66172,20 +67661,20 @@ module.exports.Parser = Parser; /***/ }), -/* 566 */ +/* 567 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var util = __webpack_require__(112); -var define = __webpack_require__(567); -var CacheBase = __webpack_require__(568); -var Emitter = __webpack_require__(569); -var isObject = __webpack_require__(530); -var merge = __webpack_require__(587); -var pascal = __webpack_require__(590); -var cu = __webpack_require__(591); +var define = __webpack_require__(568); +var CacheBase = __webpack_require__(569); +var Emitter = __webpack_require__(570); +var isObject = __webpack_require__(531); +var merge = __webpack_require__(588); +var pascal = __webpack_require__(591); +var cu = __webpack_require__(592); /** * Optionally define a custom `cache` namespace to use. @@ -66614,7 +68103,7 @@ module.exports.namespace = namespace; /***/ }), -/* 567 */ +/* 568 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -66627,7 +68116,7 @@ module.exports.namespace = namespace; -var isDescriptor = __webpack_require__(531); +var isDescriptor = __webpack_require__(532); module.exports = function defineProperty(obj, prop, val) { if (typeof obj !== 'object' && typeof obj !== 'function') { @@ -66652,21 +68141,21 @@ module.exports = function defineProperty(obj, prop, val) { /***/ }), -/* 568 */ +/* 569 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var isObject = __webpack_require__(530); -var Emitter = __webpack_require__(569); -var visit = __webpack_require__(570); -var toPath = __webpack_require__(573); -var union = __webpack_require__(574); -var del = __webpack_require__(578); -var get = __webpack_require__(576); -var has = __webpack_require__(583); -var set = __webpack_require__(586); +var isObject = __webpack_require__(531); +var Emitter = __webpack_require__(570); +var visit = __webpack_require__(571); +var toPath = __webpack_require__(574); +var union = __webpack_require__(575); +var del = __webpack_require__(579); +var get = __webpack_require__(577); +var has = __webpack_require__(584); +var set = __webpack_require__(587); /** * Create a `Cache` constructor that when instantiated will @@ -66920,7 +68409,7 @@ module.exports.namespace = namespace; /***/ }), -/* 569 */ +/* 570 */ /***/ (function(module, exports, __webpack_require__) { @@ -67089,7 +68578,7 @@ Emitter.prototype.hasListeners = function(event){ /***/ }), -/* 570 */ +/* 571 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -67102,8 +68591,8 @@ Emitter.prototype.hasListeners = function(event){ -var visit = __webpack_require__(571); -var mapVisit = __webpack_require__(572); +var visit = __webpack_require__(572); +var mapVisit = __webpack_require__(573); module.exports = function(collection, method, val) { var result; @@ -67126,7 +68615,7 @@ module.exports = function(collection, method, val) { /***/ }), -/* 571 */ +/* 572 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -67139,7 +68628,7 @@ module.exports = function(collection, method, val) { -var isObject = __webpack_require__(530); +var isObject = __webpack_require__(531); module.exports = function visit(thisArg, method, target, val) { if (!isObject(thisArg) && typeof thisArg !== 'function') { @@ -67166,14 +68655,14 @@ module.exports = function visit(thisArg, method, target, val) { /***/ }), -/* 572 */ +/* 573 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var util = __webpack_require__(112); -var visit = __webpack_require__(571); +var visit = __webpack_require__(572); /** * Map `visit` over an array of objects. @@ -67210,7 +68699,7 @@ function isObject(val) { /***/ }), -/* 573 */ +/* 574 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -67223,7 +68712,7 @@ function isObject(val) { -var typeOf = __webpack_require__(555); +var typeOf = __webpack_require__(556); module.exports = function toPath(args) { if (typeOf(args) !== 'arguments') { @@ -67250,16 +68739,16 @@ function filter(arr) { /***/ }), -/* 574 */ +/* 575 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var isObject = __webpack_require__(546); -var union = __webpack_require__(575); -var get = __webpack_require__(576); -var set = __webpack_require__(577); +var isObject = __webpack_require__(547); +var union = __webpack_require__(576); +var get = __webpack_require__(577); +var set = __webpack_require__(578); module.exports = function unionValue(obj, prop, value) { if (!isObject(obj)) { @@ -67287,7 +68776,7 @@ function arrayify(val) { /***/ }), -/* 575 */ +/* 576 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -67323,7 +68812,7 @@ module.exports = function union(init) { /***/ }), -/* 576 */ +/* 577 */ /***/ (function(module, exports) { /*! @@ -67379,7 +68868,7 @@ function toString(val) { /***/ }), -/* 577 */ +/* 578 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -67392,10 +68881,10 @@ function toString(val) { -var split = __webpack_require__(549); -var extend = __webpack_require__(545); -var isPlainObject = __webpack_require__(539); -var isObject = __webpack_require__(546); +var split = __webpack_require__(550); +var extend = __webpack_require__(546); +var isPlainObject = __webpack_require__(540); +var isObject = __webpack_require__(547); module.exports = function(obj, prop, val) { if (!isObject(obj)) { @@ -67441,7 +68930,7 @@ function isValidKey(key) { /***/ }), -/* 578 */ +/* 579 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -67454,8 +68943,8 @@ function isValidKey(key) { -var isObject = __webpack_require__(530); -var has = __webpack_require__(579); +var isObject = __webpack_require__(531); +var has = __webpack_require__(580); module.exports = function unset(obj, prop) { if (!isObject(obj)) { @@ -67480,7 +68969,7 @@ module.exports = function unset(obj, prop) { /***/ }), -/* 579 */ +/* 580 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -67493,9 +68982,9 @@ module.exports = function unset(obj, prop) { -var isObject = __webpack_require__(580); -var hasValues = __webpack_require__(582); -var get = __webpack_require__(576); +var isObject = __webpack_require__(581); +var hasValues = __webpack_require__(583); +var get = __webpack_require__(577); module.exports = function(obj, prop, noZero) { if (isObject(obj)) { @@ -67506,7 +68995,7 @@ module.exports = function(obj, prop, noZero) { /***/ }), -/* 580 */ +/* 581 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -67519,7 +69008,7 @@ module.exports = function(obj, prop, noZero) { -var isArray = __webpack_require__(581); +var isArray = __webpack_require__(582); module.exports = function isObject(val) { return val != null && typeof val === 'object' && isArray(val) === false; @@ -67527,7 +69016,7 @@ module.exports = function isObject(val) { /***/ }), -/* 581 */ +/* 582 */ /***/ (function(module, exports) { var toString = {}.toString; @@ -67538,7 +69027,7 @@ module.exports = Array.isArray || function (arr) { /***/ }), -/* 582 */ +/* 583 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -67581,7 +69070,7 @@ module.exports = function hasValue(o, noZero) { /***/ }), -/* 583 */ +/* 584 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -67594,9 +69083,9 @@ module.exports = function hasValue(o, noZero) { -var isObject = __webpack_require__(530); -var hasValues = __webpack_require__(584); -var get = __webpack_require__(576); +var isObject = __webpack_require__(531); +var hasValues = __webpack_require__(585); +var get = __webpack_require__(577); module.exports = function(val, prop) { return hasValues(isObject(val) && prop ? get(val, prop) : val); @@ -67604,7 +69093,7 @@ module.exports = function(val, prop) { /***/ }), -/* 584 */ +/* 585 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -67617,8 +69106,8 @@ module.exports = function(val, prop) { -var typeOf = __webpack_require__(585); -var isNumber = __webpack_require__(554); +var typeOf = __webpack_require__(586); +var isNumber = __webpack_require__(555); module.exports = function hasValue(val) { // is-number checks for NaN and other edge cases @@ -67671,10 +69160,10 @@ module.exports = function hasValue(val) { /***/ }), -/* 585 */ +/* 586 */ /***/ (function(module, exports, __webpack_require__) { -var isBuffer = __webpack_require__(556); +var isBuffer = __webpack_require__(557); var toString = Object.prototype.toString; /** @@ -67796,7 +69285,7 @@ module.exports = function kindOf(val) { /***/ }), -/* 586 */ +/* 587 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -67809,10 +69298,10 @@ module.exports = function kindOf(val) { -var split = __webpack_require__(549); -var extend = __webpack_require__(545); -var isPlainObject = __webpack_require__(539); -var isObject = __webpack_require__(546); +var split = __webpack_require__(550); +var extend = __webpack_require__(546); +var isPlainObject = __webpack_require__(540); +var isObject = __webpack_require__(547); module.exports = function(obj, prop, val) { if (!isObject(obj)) { @@ -67858,14 +69347,14 @@ function isValidKey(key) { /***/ }), -/* 587 */ +/* 588 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var isExtendable = __webpack_require__(588); -var forIn = __webpack_require__(589); +var isExtendable = __webpack_require__(589); +var forIn = __webpack_require__(590); function mixinDeep(target, objects) { var len = arguments.length, i = 0; @@ -67929,7 +69418,7 @@ module.exports = mixinDeep; /***/ }), -/* 588 */ +/* 589 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -67942,7 +69431,7 @@ module.exports = mixinDeep; -var isPlainObject = __webpack_require__(539); +var isPlainObject = __webpack_require__(540); module.exports = function isExtendable(val) { return isPlainObject(val) || typeof val === 'function' || Array.isArray(val); @@ -67950,7 +69439,7 @@ module.exports = function isExtendable(val) { /***/ }), -/* 589 */ +/* 590 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -67973,7 +69462,7 @@ module.exports = function forIn(obj, fn, thisArg) { /***/ }), -/* 590 */ +/* 591 */ /***/ (function(module, exports) { /*! @@ -68000,14 +69489,14 @@ module.exports = pascalcase; /***/ }), -/* 591 */ +/* 592 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var util = __webpack_require__(112); -var utils = __webpack_require__(592); +var utils = __webpack_require__(593); /** * Expose class utils @@ -68372,7 +69861,7 @@ cu.bubble = function(Parent, events) { /***/ }), -/* 592 */ +/* 593 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -68386,10 +69875,10 @@ var utils = {}; * Lazily required module dependencies */ -utils.union = __webpack_require__(575); -utils.define = __webpack_require__(593); -utils.isObj = __webpack_require__(530); -utils.staticExtend = __webpack_require__(600); +utils.union = __webpack_require__(576); +utils.define = __webpack_require__(594); +utils.isObj = __webpack_require__(531); +utils.staticExtend = __webpack_require__(601); /** @@ -68400,7 +69889,7 @@ module.exports = utils; /***/ }), -/* 593 */ +/* 594 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -68413,7 +69902,7 @@ module.exports = utils; -var isDescriptor = __webpack_require__(594); +var isDescriptor = __webpack_require__(595); module.exports = function defineProperty(obj, prop, val) { if (typeof obj !== 'object' && typeof obj !== 'function') { @@ -68438,7 +69927,7 @@ module.exports = function defineProperty(obj, prop, val) { /***/ }), -/* 594 */ +/* 595 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -68451,9 +69940,9 @@ module.exports = function defineProperty(obj, prop, val) { -var typeOf = __webpack_require__(595); -var isAccessor = __webpack_require__(596); -var isData = __webpack_require__(598); +var typeOf = __webpack_require__(596); +var isAccessor = __webpack_require__(597); +var isData = __webpack_require__(599); module.exports = function isDescriptor(obj, key) { if (typeOf(obj) !== 'object') { @@ -68467,7 +69956,7 @@ module.exports = function isDescriptor(obj, key) { /***/ }), -/* 595 */ +/* 596 */ /***/ (function(module, exports) { var toString = Object.prototype.toString; @@ -68620,7 +70109,7 @@ function isBuffer(val) { /***/ }), -/* 596 */ +/* 597 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -68633,7 +70122,7 @@ function isBuffer(val) { -var typeOf = __webpack_require__(597); +var typeOf = __webpack_require__(598); // accessor descriptor properties var accessor = { @@ -68696,10 +70185,10 @@ module.exports = isAccessorDescriptor; /***/ }), -/* 597 */ +/* 598 */ /***/ (function(module, exports, __webpack_require__) { -var isBuffer = __webpack_require__(556); +var isBuffer = __webpack_require__(557); var toString = Object.prototype.toString; /** @@ -68818,7 +70307,7 @@ module.exports = function kindOf(val) { /***/ }), -/* 598 */ +/* 599 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -68831,7 +70320,7 @@ module.exports = function kindOf(val) { -var typeOf = __webpack_require__(599); +var typeOf = __webpack_require__(600); // data descriptor properties var data = { @@ -68880,10 +70369,10 @@ module.exports = isDataDescriptor; /***/ }), -/* 599 */ +/* 600 */ /***/ (function(module, exports, __webpack_require__) { -var isBuffer = __webpack_require__(556); +var isBuffer = __webpack_require__(557); var toString = Object.prototype.toString; /** @@ -69002,7 +70491,7 @@ module.exports = function kindOf(val) { /***/ }), -/* 600 */ +/* 601 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -69015,8 +70504,8 @@ module.exports = function kindOf(val) { -var copy = __webpack_require__(601); -var define = __webpack_require__(593); +var copy = __webpack_require__(602); +var define = __webpack_require__(594); var util = __webpack_require__(112); /** @@ -69099,15 +70588,15 @@ module.exports = extend; /***/ }), -/* 601 */ +/* 602 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var typeOf = __webpack_require__(555); -var copyDescriptor = __webpack_require__(602); -var define = __webpack_require__(593); +var typeOf = __webpack_require__(556); +var copyDescriptor = __webpack_require__(603); +var define = __webpack_require__(594); /** * Copy static properties, prototype properties, and descriptors from one object to another. @@ -69280,7 +70769,7 @@ module.exports.has = has; /***/ }), -/* 602 */ +/* 603 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -69368,16 +70857,16 @@ function isObject(val) { /***/ }), -/* 603 */ +/* 604 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var use = __webpack_require__(604); -var define = __webpack_require__(593); -var debug = __webpack_require__(606)('snapdragon:compiler'); -var utils = __webpack_require__(612); +var use = __webpack_require__(605); +var define = __webpack_require__(594); +var debug = __webpack_require__(607)('snapdragon:compiler'); +var utils = __webpack_require__(613); /** * Create a new `Compiler` with the given `options`. @@ -69531,7 +71020,7 @@ Compiler.prototype = { // source map support if (opts.sourcemap) { - var sourcemaps = __webpack_require__(631); + var sourcemaps = __webpack_require__(632); sourcemaps(this); this.mapVisit(this.ast.nodes); this.applySourceMaps(); @@ -69552,7 +71041,7 @@ module.exports = Compiler; /***/ }), -/* 604 */ +/* 605 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -69565,7 +71054,7 @@ module.exports = Compiler; -var utils = __webpack_require__(605); +var utils = __webpack_require__(606); module.exports = function base(app, opts) { if (!utils.isObject(app) && typeof app !== 'function') { @@ -69680,7 +71169,7 @@ module.exports = function base(app, opts) { /***/ }), -/* 605 */ +/* 606 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -69694,8 +71183,8 @@ var utils = {}; * Lazily required module dependencies */ -utils.define = __webpack_require__(593); -utils.isObject = __webpack_require__(530); +utils.define = __webpack_require__(594); +utils.isObject = __webpack_require__(531); utils.isString = function(val) { @@ -69710,7 +71199,7 @@ module.exports = utils; /***/ }), -/* 606 */ +/* 607 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -69719,14 +71208,14 @@ module.exports = utils; */ if (typeof process !== 'undefined' && process.type === 'renderer') { - module.exports = __webpack_require__(607); + module.exports = __webpack_require__(608); } else { - module.exports = __webpack_require__(610); + module.exports = __webpack_require__(611); } /***/ }), -/* 607 */ +/* 608 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -69735,7 +71224,7 @@ if (typeof process !== 'undefined' && process.type === 'renderer') { * Expose `debug()` as the module. */ -exports = module.exports = __webpack_require__(608); +exports = module.exports = __webpack_require__(609); exports.log = log; exports.formatArgs = formatArgs; exports.save = save; @@ -69917,7 +71406,7 @@ function localstorage() { /***/ }), -/* 608 */ +/* 609 */ /***/ (function(module, exports, __webpack_require__) { @@ -69933,7 +71422,7 @@ exports.coerce = coerce; exports.disable = disable; exports.enable = enable; exports.enabled = enabled; -exports.humanize = __webpack_require__(609); +exports.humanize = __webpack_require__(610); /** * The currently active debug mode names, and names to skip. @@ -70125,7 +71614,7 @@ function coerce(val) { /***/ }), -/* 609 */ +/* 610 */ /***/ (function(module, exports) { /** @@ -70283,7 +71772,7 @@ function plural(ms, n, name) { /***/ }), -/* 610 */ +/* 611 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -70299,7 +71788,7 @@ var util = __webpack_require__(112); * Expose `debug()` as the module. */ -exports = module.exports = __webpack_require__(608); +exports = module.exports = __webpack_require__(609); exports.init = init; exports.log = log; exports.formatArgs = formatArgs; @@ -70478,7 +71967,7 @@ function createWritableStdioStream (fd) { case 'PIPE': case 'TCP': - var net = __webpack_require__(611); + var net = __webpack_require__(612); stream = new net.Socket({ fd: fd, readable: false, @@ -70537,13 +72026,13 @@ exports.enable(load()); /***/ }), -/* 611 */ +/* 612 */ /***/ (function(module, exports) { module.exports = require("net"); /***/ }), -/* 612 */ +/* 613 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -70553,9 +72042,9 @@ module.exports = require("net"); * Module dependencies */ -exports.extend = __webpack_require__(545); -exports.SourceMap = __webpack_require__(613); -exports.sourceMapResolve = __webpack_require__(624); +exports.extend = __webpack_require__(546); +exports.SourceMap = __webpack_require__(614); +exports.sourceMapResolve = __webpack_require__(625); /** * Convert backslash in the given string to forward slashes @@ -70598,7 +72087,7 @@ exports.last = function(arr, n) { /***/ }), -/* 613 */ +/* 614 */ /***/ (function(module, exports, __webpack_require__) { /* @@ -70606,13 +72095,13 @@ exports.last = function(arr, n) { * Licensed under the New BSD license. See LICENSE.txt or: * http://opensource.org/licenses/BSD-3-Clause */ -exports.SourceMapGenerator = __webpack_require__(614).SourceMapGenerator; -exports.SourceMapConsumer = __webpack_require__(620).SourceMapConsumer; -exports.SourceNode = __webpack_require__(623).SourceNode; +exports.SourceMapGenerator = __webpack_require__(615).SourceMapGenerator; +exports.SourceMapConsumer = __webpack_require__(621).SourceMapConsumer; +exports.SourceNode = __webpack_require__(624).SourceNode; /***/ }), -/* 614 */ +/* 615 */ /***/ (function(module, exports, __webpack_require__) { /* -*- Mode: js; js-indent-level: 2; -*- */ @@ -70622,10 +72111,10 @@ exports.SourceNode = __webpack_require__(623).SourceNode; * http://opensource.org/licenses/BSD-3-Clause */ -var base64VLQ = __webpack_require__(615); -var util = __webpack_require__(617); -var ArraySet = __webpack_require__(618).ArraySet; -var MappingList = __webpack_require__(619).MappingList; +var base64VLQ = __webpack_require__(616); +var util = __webpack_require__(618); +var ArraySet = __webpack_require__(619).ArraySet; +var MappingList = __webpack_require__(620).MappingList; /** * An instance of the SourceMapGenerator represents a source map which is @@ -71034,7 +72523,7 @@ exports.SourceMapGenerator = SourceMapGenerator; /***/ }), -/* 615 */ +/* 616 */ /***/ (function(module, exports, __webpack_require__) { /* -*- Mode: js; js-indent-level: 2; -*- */ @@ -71074,7 +72563,7 @@ exports.SourceMapGenerator = SourceMapGenerator; * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -var base64 = __webpack_require__(616); +var base64 = __webpack_require__(617); // A single base 64 digit can contain 6 bits of data. For the base 64 variable // length quantities we use in the source map spec, the first bit is the sign, @@ -71180,7 +72669,7 @@ exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) { /***/ }), -/* 616 */ +/* 617 */ /***/ (function(module, exports) { /* -*- Mode: js; js-indent-level: 2; -*- */ @@ -71253,7 +72742,7 @@ exports.decode = function (charCode) { /***/ }), -/* 617 */ +/* 618 */ /***/ (function(module, exports) { /* -*- Mode: js; js-indent-level: 2; -*- */ @@ -71676,7 +73165,7 @@ exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflate /***/ }), -/* 618 */ +/* 619 */ /***/ (function(module, exports, __webpack_require__) { /* -*- Mode: js; js-indent-level: 2; -*- */ @@ -71686,7 +73175,7 @@ exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflate * http://opensource.org/licenses/BSD-3-Clause */ -var util = __webpack_require__(617); +var util = __webpack_require__(618); var has = Object.prototype.hasOwnProperty; var hasNativeMap = typeof Map !== "undefined"; @@ -71803,7 +73292,7 @@ exports.ArraySet = ArraySet; /***/ }), -/* 619 */ +/* 620 */ /***/ (function(module, exports, __webpack_require__) { /* -*- Mode: js; js-indent-level: 2; -*- */ @@ -71813,7 +73302,7 @@ exports.ArraySet = ArraySet; * http://opensource.org/licenses/BSD-3-Clause */ -var util = __webpack_require__(617); +var util = __webpack_require__(618); /** * Determine whether mappingB is after mappingA with respect to generated @@ -71888,7 +73377,7 @@ exports.MappingList = MappingList; /***/ }), -/* 620 */ +/* 621 */ /***/ (function(module, exports, __webpack_require__) { /* -*- Mode: js; js-indent-level: 2; -*- */ @@ -71898,11 +73387,11 @@ exports.MappingList = MappingList; * http://opensource.org/licenses/BSD-3-Clause */ -var util = __webpack_require__(617); -var binarySearch = __webpack_require__(621); -var ArraySet = __webpack_require__(618).ArraySet; -var base64VLQ = __webpack_require__(615); -var quickSort = __webpack_require__(622).quickSort; +var util = __webpack_require__(618); +var binarySearch = __webpack_require__(622); +var ArraySet = __webpack_require__(619).ArraySet; +var base64VLQ = __webpack_require__(616); +var quickSort = __webpack_require__(623).quickSort; function SourceMapConsumer(aSourceMap) { var sourceMap = aSourceMap; @@ -72976,7 +74465,7 @@ exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer; /***/ }), -/* 621 */ +/* 622 */ /***/ (function(module, exports) { /* -*- Mode: js; js-indent-level: 2; -*- */ @@ -73093,7 +74582,7 @@ exports.search = function search(aNeedle, aHaystack, aCompare, aBias) { /***/ }), -/* 622 */ +/* 623 */ /***/ (function(module, exports) { /* -*- Mode: js; js-indent-level: 2; -*- */ @@ -73213,7 +74702,7 @@ exports.quickSort = function (ary, comparator) { /***/ }), -/* 623 */ +/* 624 */ /***/ (function(module, exports, __webpack_require__) { /* -*- Mode: js; js-indent-level: 2; -*- */ @@ -73223,8 +74712,8 @@ exports.quickSort = function (ary, comparator) { * http://opensource.org/licenses/BSD-3-Clause */ -var SourceMapGenerator = __webpack_require__(614).SourceMapGenerator; -var util = __webpack_require__(617); +var SourceMapGenerator = __webpack_require__(615).SourceMapGenerator; +var util = __webpack_require__(618); // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other // operating systems these days (capturing the result). @@ -73632,17 +75121,17 @@ exports.SourceNode = SourceNode; /***/ }), -/* 624 */ +/* 625 */ /***/ (function(module, exports, __webpack_require__) { // Copyright 2014, 2015, 2016, 2017 Simon Lydell // X11 (“MIT”) Licensed. (See LICENSE.) -var sourceMappingURL = __webpack_require__(625) -var resolveUrl = __webpack_require__(626) -var decodeUriComponent = __webpack_require__(627) -var urix = __webpack_require__(629) -var atob = __webpack_require__(630) +var sourceMappingURL = __webpack_require__(626) +var resolveUrl = __webpack_require__(627) +var decodeUriComponent = __webpack_require__(628) +var urix = __webpack_require__(630) +var atob = __webpack_require__(631) @@ -73940,7 +75429,7 @@ module.exports = { /***/ }), -/* 625 */ +/* 626 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;// Copyright 2014 Simon Lydell @@ -74003,7 +75492,7 @@ void (function(root, factory) { /***/ }), -/* 626 */ +/* 627 */ /***/ (function(module, exports, __webpack_require__) { // Copyright 2014 Simon Lydell @@ -74021,13 +75510,13 @@ module.exports = resolveUrl /***/ }), -/* 627 */ +/* 628 */ /***/ (function(module, exports, __webpack_require__) { // Copyright 2017 Simon Lydell // X11 (“MIT”) Licensed. (See LICENSE.) -var decodeUriComponent = __webpack_require__(628) +var decodeUriComponent = __webpack_require__(629) function customDecodeUriComponent(string) { // `decodeUriComponent` turns `+` into ` `, but that's not wanted. @@ -74038,7 +75527,7 @@ module.exports = customDecodeUriComponent /***/ }), -/* 628 */ +/* 629 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -74139,7 +75628,7 @@ module.exports = function (encodedURI) { /***/ }), -/* 629 */ +/* 630 */ /***/ (function(module, exports, __webpack_require__) { // Copyright 2014 Simon Lydell @@ -74162,7 +75651,7 @@ module.exports = urix /***/ }), -/* 630 */ +/* 631 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -74176,7 +75665,7 @@ module.exports = atob.atob = atob; /***/ }), -/* 631 */ +/* 632 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -74184,8 +75673,8 @@ module.exports = atob.atob = atob; var fs = __webpack_require__(134); var path = __webpack_require__(4); -var define = __webpack_require__(593); -var utils = __webpack_require__(612); +var define = __webpack_require__(594); +var utils = __webpack_require__(613); /** * Expose `mixin()`. @@ -74328,19 +75817,19 @@ exports.comment = function(node) { /***/ }), -/* 632 */ +/* 633 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var use = __webpack_require__(604); +var use = __webpack_require__(605); var util = __webpack_require__(112); -var Cache = __webpack_require__(633); -var define = __webpack_require__(593); -var debug = __webpack_require__(606)('snapdragon:parser'); -var Position = __webpack_require__(634); -var utils = __webpack_require__(612); +var Cache = __webpack_require__(634); +var define = __webpack_require__(594); +var debug = __webpack_require__(607)('snapdragon:parser'); +var Position = __webpack_require__(635); +var utils = __webpack_require__(613); /** * Create a new `Parser` with the given `input` and `options`. @@ -74868,7 +76357,7 @@ module.exports = Parser; /***/ }), -/* 633 */ +/* 634 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -74975,13 +76464,13 @@ MapCache.prototype.del = function mapDelete(key) { /***/ }), -/* 634 */ +/* 635 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var define = __webpack_require__(593); +var define = __webpack_require__(594); /** * Store position for a node @@ -74996,14 +76485,14 @@ module.exports = function Position(start, parser) { /***/ }), -/* 635 */ +/* 636 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var isExtendable = __webpack_require__(636); -var assignSymbols = __webpack_require__(540); +var isExtendable = __webpack_require__(637); +var assignSymbols = __webpack_require__(541); module.exports = Object.assign || function(obj/*, objects*/) { if (obj === null || typeof obj === 'undefined') { @@ -75063,7 +76552,7 @@ function isEnum(obj, key) { /***/ }), -/* 636 */ +/* 637 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -75076,7 +76565,7 @@ function isEnum(obj, key) { -var isPlainObject = __webpack_require__(539); +var isPlainObject = __webpack_require__(540); module.exports = function isExtendable(val) { return isPlainObject(val) || typeof val === 'function' || Array.isArray(val); @@ -75084,14 +76573,14 @@ module.exports = function isExtendable(val) { /***/ }), -/* 637 */ +/* 638 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var nanomatch = __webpack_require__(638); -var extglob = __webpack_require__(653); +var nanomatch = __webpack_require__(639); +var extglob = __webpack_require__(654); module.exports = function(snapdragon) { var compilers = snapdragon.compiler.compilers; @@ -75168,7 +76657,7 @@ function escapeExtglobs(compiler) { /***/ }), -/* 638 */ +/* 639 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -75179,17 +76668,17 @@ function escapeExtglobs(compiler) { */ var util = __webpack_require__(112); -var toRegex = __webpack_require__(522); -var extend = __webpack_require__(639); +var toRegex = __webpack_require__(523); +var extend = __webpack_require__(640); /** * Local dependencies */ -var compilers = __webpack_require__(641); -var parsers = __webpack_require__(642); -var cache = __webpack_require__(645); -var utils = __webpack_require__(647); +var compilers = __webpack_require__(642); +var parsers = __webpack_require__(643); +var cache = __webpack_require__(646); +var utils = __webpack_require__(648); var MAX_LENGTH = 1024 * 64; /** @@ -76013,14 +77502,14 @@ module.exports = nanomatch; /***/ }), -/* 639 */ +/* 640 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var isExtendable = __webpack_require__(640); -var assignSymbols = __webpack_require__(540); +var isExtendable = __webpack_require__(641); +var assignSymbols = __webpack_require__(541); module.exports = Object.assign || function(obj/*, objects*/) { if (obj === null || typeof obj === 'undefined') { @@ -76080,7 +77569,7 @@ function isEnum(obj, key) { /***/ }), -/* 640 */ +/* 641 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -76093,7 +77582,7 @@ function isEnum(obj, key) { -var isPlainObject = __webpack_require__(539); +var isPlainObject = __webpack_require__(540); module.exports = function isExtendable(val) { return isPlainObject(val) || typeof val === 'function' || Array.isArray(val); @@ -76101,7 +77590,7 @@ module.exports = function isExtendable(val) { /***/ }), -/* 641 */ +/* 642 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -76447,15 +77936,15 @@ module.exports = function(nanomatch, options) { /***/ }), -/* 642 */ +/* 643 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var regexNot = __webpack_require__(541); -var toRegex = __webpack_require__(522); -var isOdd = __webpack_require__(643); +var regexNot = __webpack_require__(542); +var toRegex = __webpack_require__(523); +var isOdd = __webpack_require__(644); /** * Characters to use in negation regex (we want to "not" match @@ -76841,7 +78330,7 @@ module.exports.not = NOT_REGEX; /***/ }), -/* 643 */ +/* 644 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -76854,7 +78343,7 @@ module.exports.not = NOT_REGEX; -var isNumber = __webpack_require__(644); +var isNumber = __webpack_require__(645); module.exports = function isOdd(i) { if (!isNumber(i)) { @@ -76868,7 +78357,7 @@ module.exports = function isOdd(i) { /***/ }), -/* 644 */ +/* 645 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -76896,14 +78385,14 @@ module.exports = function isNumber(num) { /***/ }), -/* 645 */ +/* 646 */ /***/ (function(module, exports, __webpack_require__) { -module.exports = new (__webpack_require__(646))(); +module.exports = new (__webpack_require__(647))(); /***/ }), -/* 646 */ +/* 647 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -76916,7 +78405,7 @@ module.exports = new (__webpack_require__(646))(); -var MapCache = __webpack_require__(633); +var MapCache = __webpack_require__(634); /** * Create a new `FragmentCache` with an optional object to use for `caches`. @@ -77038,7 +78527,7 @@ exports = module.exports = FragmentCache; /***/ }), -/* 647 */ +/* 648 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -77051,14 +78540,14 @@ var path = __webpack_require__(4); * Module dependencies */ -var isWindows = __webpack_require__(648)(); -var Snapdragon = __webpack_require__(565); -utils.define = __webpack_require__(649); -utils.diff = __webpack_require__(650); -utils.extend = __webpack_require__(639); -utils.pick = __webpack_require__(651); -utils.typeOf = __webpack_require__(652); -utils.unique = __webpack_require__(544); +var isWindows = __webpack_require__(649)(); +var Snapdragon = __webpack_require__(566); +utils.define = __webpack_require__(650); +utils.diff = __webpack_require__(651); +utils.extend = __webpack_require__(640); +utils.pick = __webpack_require__(652); +utils.typeOf = __webpack_require__(653); +utils.unique = __webpack_require__(545); /** * Returns true if the given value is effectively an empty string @@ -77424,7 +78913,7 @@ utils.unixify = function(options) { /***/ }), -/* 648 */ +/* 649 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! @@ -77452,7 +78941,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ /***/ }), -/* 649 */ +/* 650 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -77465,8 +78954,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ -var isobject = __webpack_require__(530); -var isDescriptor = __webpack_require__(531); +var isobject = __webpack_require__(531); +var isDescriptor = __webpack_require__(532); var define = (typeof Reflect !== 'undefined' && Reflect.defineProperty) ? Reflect.defineProperty : Object.defineProperty; @@ -77497,7 +78986,7 @@ module.exports = function defineProperty(obj, key, val) { /***/ }), -/* 650 */ +/* 651 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -77551,7 +79040,7 @@ function diffArray(one, two) { /***/ }), -/* 651 */ +/* 652 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -77564,7 +79053,7 @@ function diffArray(one, two) { -var isObject = __webpack_require__(530); +var isObject = __webpack_require__(531); module.exports = function pick(obj, keys) { if (!isObject(obj) && typeof obj !== 'function') { @@ -77593,7 +79082,7 @@ module.exports = function pick(obj, keys) { /***/ }), -/* 652 */ +/* 653 */ /***/ (function(module, exports) { var toString = Object.prototype.toString; @@ -77728,7 +79217,7 @@ function isBuffer(val) { /***/ }), -/* 653 */ +/* 654 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -77738,18 +79227,18 @@ function isBuffer(val) { * Module dependencies */ -var extend = __webpack_require__(545); -var unique = __webpack_require__(544); -var toRegex = __webpack_require__(522); +var extend = __webpack_require__(546); +var unique = __webpack_require__(545); +var toRegex = __webpack_require__(523); /** * Local dependencies */ -var compilers = __webpack_require__(654); -var parsers = __webpack_require__(660); -var Extglob = __webpack_require__(663); -var utils = __webpack_require__(662); +var compilers = __webpack_require__(655); +var parsers = __webpack_require__(661); +var Extglob = __webpack_require__(664); +var utils = __webpack_require__(663); var MAX_LENGTH = 1024 * 64; /** @@ -78066,13 +79555,13 @@ module.exports = extglob; /***/ }), -/* 654 */ +/* 655 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var brackets = __webpack_require__(655); +var brackets = __webpack_require__(656); /** * Extglob compilers @@ -78242,7 +79731,7 @@ module.exports = function(extglob) { /***/ }), -/* 655 */ +/* 656 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -78252,17 +79741,17 @@ module.exports = function(extglob) { * Local dependencies */ -var compilers = __webpack_require__(656); -var parsers = __webpack_require__(658); +var compilers = __webpack_require__(657); +var parsers = __webpack_require__(659); /** * Module dependencies */ -var debug = __webpack_require__(606)('expand-brackets'); -var extend = __webpack_require__(545); -var Snapdragon = __webpack_require__(565); -var toRegex = __webpack_require__(522); +var debug = __webpack_require__(607)('expand-brackets'); +var extend = __webpack_require__(546); +var Snapdragon = __webpack_require__(566); +var toRegex = __webpack_require__(523); /** * Parses the given POSIX character class `pattern` and returns a @@ -78460,13 +79949,13 @@ module.exports = brackets; /***/ }), -/* 656 */ +/* 657 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var posix = __webpack_require__(657); +var posix = __webpack_require__(658); module.exports = function(brackets) { brackets.compiler @@ -78554,7 +80043,7 @@ module.exports = function(brackets) { /***/ }), -/* 657 */ +/* 658 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -78583,14 +80072,14 @@ module.exports = { /***/ }), -/* 658 */ +/* 659 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var utils = __webpack_require__(659); -var define = __webpack_require__(593); +var utils = __webpack_require__(660); +var define = __webpack_require__(594); /** * Text regex @@ -78809,14 +80298,14 @@ module.exports.TEXT_REGEX = TEXT_REGEX; /***/ }), -/* 659 */ +/* 660 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var toRegex = __webpack_require__(522); -var regexNot = __webpack_require__(541); +var toRegex = __webpack_require__(523); +var regexNot = __webpack_require__(542); var cached; /** @@ -78850,15 +80339,15 @@ exports.createRegex = function(pattern, include) { /***/ }), -/* 660 */ +/* 661 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var brackets = __webpack_require__(655); -var define = __webpack_require__(661); -var utils = __webpack_require__(662); +var brackets = __webpack_require__(656); +var define = __webpack_require__(662); +var utils = __webpack_require__(663); /** * Characters to use in text regex (we want to "not" match @@ -79013,7 +80502,7 @@ module.exports = parsers; /***/ }), -/* 661 */ +/* 662 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -79026,7 +80515,7 @@ module.exports = parsers; -var isDescriptor = __webpack_require__(531); +var isDescriptor = __webpack_require__(532); module.exports = function defineProperty(obj, prop, val) { if (typeof obj !== 'object' && typeof obj !== 'function') { @@ -79051,14 +80540,14 @@ module.exports = function defineProperty(obj, prop, val) { /***/ }), -/* 662 */ +/* 663 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var regex = __webpack_require__(541); -var Cache = __webpack_require__(646); +var regex = __webpack_require__(542); +var Cache = __webpack_require__(647); /** * Utils @@ -79127,7 +80616,7 @@ utils.createRegex = function(str) { /***/ }), -/* 663 */ +/* 664 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -79137,16 +80626,16 @@ utils.createRegex = function(str) { * Module dependencies */ -var Snapdragon = __webpack_require__(565); -var define = __webpack_require__(661); -var extend = __webpack_require__(545); +var Snapdragon = __webpack_require__(566); +var define = __webpack_require__(662); +var extend = __webpack_require__(546); /** * Local dependencies */ -var compilers = __webpack_require__(654); -var parsers = __webpack_require__(660); +var compilers = __webpack_require__(655); +var parsers = __webpack_require__(661); /** * Customize Snapdragon parser and renderer @@ -79212,16 +80701,16 @@ module.exports = Extglob; /***/ }), -/* 664 */ +/* 665 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var extglob = __webpack_require__(653); -var nanomatch = __webpack_require__(638); -var regexNot = __webpack_require__(541); -var toRegex = __webpack_require__(522); +var extglob = __webpack_require__(654); +var nanomatch = __webpack_require__(639); +var regexNot = __webpack_require__(542); +var toRegex = __webpack_require__(523); var not; /** @@ -79302,14 +80791,14 @@ function textRegex(pattern) { /***/ }), -/* 665 */ +/* 666 */ /***/ (function(module, exports, __webpack_require__) { -module.exports = new (__webpack_require__(646))(); +module.exports = new (__webpack_require__(647))(); /***/ }), -/* 666 */ +/* 667 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -79322,13 +80811,13 @@ var path = __webpack_require__(4); * Module dependencies */ -var Snapdragon = __webpack_require__(565); -utils.define = __webpack_require__(667); -utils.diff = __webpack_require__(650); -utils.extend = __webpack_require__(635); -utils.pick = __webpack_require__(651); -utils.typeOf = __webpack_require__(668); -utils.unique = __webpack_require__(544); +var Snapdragon = __webpack_require__(566); +utils.define = __webpack_require__(668); +utils.diff = __webpack_require__(651); +utils.extend = __webpack_require__(636); +utils.pick = __webpack_require__(652); +utils.typeOf = __webpack_require__(669); +utils.unique = __webpack_require__(545); /** * Returns true if the platform is windows, or `path.sep` is `\\`. @@ -79625,7 +81114,7 @@ utils.unixify = function(options) { /***/ }), -/* 667 */ +/* 668 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -79638,8 +81127,8 @@ utils.unixify = function(options) { -var isobject = __webpack_require__(530); -var isDescriptor = __webpack_require__(531); +var isobject = __webpack_require__(531); +var isDescriptor = __webpack_require__(532); var define = (typeof Reflect !== 'undefined' && Reflect.defineProperty) ? Reflect.defineProperty : Object.defineProperty; @@ -79670,7 +81159,7 @@ module.exports = function defineProperty(obj, key, val) { /***/ }), -/* 668 */ +/* 669 */ /***/ (function(module, exports) { var toString = Object.prototype.toString; @@ -79805,7 +81294,7 @@ function isBuffer(val) { /***/ }), -/* 669 */ +/* 670 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -79824,9 +81313,9 @@ var __extends = (this && this.__extends) || (function () { }; })(); Object.defineProperty(exports, "__esModule", { value: true }); -var readdir = __webpack_require__(670); -var reader_1 = __webpack_require__(683); -var fs_stream_1 = __webpack_require__(687); +var readdir = __webpack_require__(671); +var reader_1 = __webpack_require__(684); +var fs_stream_1 = __webpack_require__(688); var ReaderAsync = /** @class */ (function (_super) { __extends(ReaderAsync, _super); function ReaderAsync() { @@ -79887,15 +81376,15 @@ exports.default = ReaderAsync; /***/ }), -/* 670 */ +/* 671 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const readdirSync = __webpack_require__(671); -const readdirAsync = __webpack_require__(679); -const readdirStream = __webpack_require__(682); +const readdirSync = __webpack_require__(672); +const readdirAsync = __webpack_require__(680); +const readdirStream = __webpack_require__(683); module.exports = exports = readdirAsyncPath; exports.readdir = exports.readdirAsync = exports.async = readdirAsyncPath; @@ -79979,7 +81468,7 @@ function readdirStreamStat (dir, options) { /***/ }), -/* 671 */ +/* 672 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -79987,11 +81476,11 @@ function readdirStreamStat (dir, options) { module.exports = readdirSync; -const DirectoryReader = __webpack_require__(672); +const DirectoryReader = __webpack_require__(673); let syncFacade = { - fs: __webpack_require__(677), - forEach: __webpack_require__(678), + fs: __webpack_require__(678), + forEach: __webpack_require__(679), sync: true }; @@ -80020,7 +81509,7 @@ function readdirSync (dir, options, internalOptions) { /***/ }), -/* 672 */ +/* 673 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -80029,9 +81518,9 @@ function readdirSync (dir, options, internalOptions) { const Readable = __webpack_require__(138).Readable; const EventEmitter = __webpack_require__(156).EventEmitter; const path = __webpack_require__(4); -const normalizeOptions = __webpack_require__(673); -const stat = __webpack_require__(675); -const call = __webpack_require__(676); +const normalizeOptions = __webpack_require__(674); +const stat = __webpack_require__(676); +const call = __webpack_require__(677); /** * Asynchronously reads the contents of a directory and streams the results @@ -80407,14 +81896,14 @@ module.exports = DirectoryReader; /***/ }), -/* 673 */ +/* 674 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const path = __webpack_require__(4); -const globToRegExp = __webpack_require__(674); +const globToRegExp = __webpack_require__(675); module.exports = normalizeOptions; @@ -80591,7 +82080,7 @@ function normalizeOptions (options, internalOptions) { /***/ }), -/* 674 */ +/* 675 */ /***/ (function(module, exports) { module.exports = function (glob, opts) { @@ -80728,13 +82217,13 @@ module.exports = function (glob, opts) { /***/ }), -/* 675 */ +/* 676 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const call = __webpack_require__(676); +const call = __webpack_require__(677); module.exports = stat; @@ -80809,7 +82298,7 @@ function symlinkStat (fs, path, lstats, callback) { /***/ }), -/* 676 */ +/* 677 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -80870,14 +82359,14 @@ function callOnce (fn) { /***/ }), -/* 677 */ +/* 678 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const fs = __webpack_require__(134); -const call = __webpack_require__(676); +const call = __webpack_require__(677); /** * A facade around {@link fs.readdirSync} that allows it to be called @@ -80941,7 +82430,7 @@ exports.lstat = function (path, callback) { /***/ }), -/* 678 */ +/* 679 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -80970,7 +82459,7 @@ function syncForEach (array, iterator, done) { /***/ }), -/* 679 */ +/* 680 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -80978,12 +82467,12 @@ function syncForEach (array, iterator, done) { module.exports = readdirAsync; -const maybe = __webpack_require__(680); -const DirectoryReader = __webpack_require__(672); +const maybe = __webpack_require__(681); +const DirectoryReader = __webpack_require__(673); let asyncFacade = { fs: __webpack_require__(134), - forEach: __webpack_require__(681), + forEach: __webpack_require__(682), async: true }; @@ -81025,7 +82514,7 @@ function readdirAsync (dir, options, callback, internalOptions) { /***/ }), -/* 680 */ +/* 681 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -81052,7 +82541,7 @@ module.exports = function maybe (cb, promise) { /***/ }), -/* 681 */ +/* 682 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -81088,7 +82577,7 @@ function asyncForEach (array, iterator, done) { /***/ }), -/* 682 */ +/* 683 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -81096,11 +82585,11 @@ function asyncForEach (array, iterator, done) { module.exports = readdirStream; -const DirectoryReader = __webpack_require__(672); +const DirectoryReader = __webpack_require__(673); let streamFacade = { fs: __webpack_require__(134), - forEach: __webpack_require__(681), + forEach: __webpack_require__(682), async: true }; @@ -81120,16 +82609,16 @@ function readdirStream (dir, options, internalOptions) { /***/ }), -/* 683 */ +/* 684 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var path = __webpack_require__(4); -var deep_1 = __webpack_require__(684); -var entry_1 = __webpack_require__(686); -var pathUtil = __webpack_require__(685); +var deep_1 = __webpack_require__(685); +var entry_1 = __webpack_require__(687); +var pathUtil = __webpack_require__(686); var Reader = /** @class */ (function () { function Reader(options) { this.options = options; @@ -81195,14 +82684,14 @@ exports.default = Reader; /***/ }), -/* 684 */ +/* 685 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var pathUtils = __webpack_require__(685); -var patternUtils = __webpack_require__(516); +var pathUtils = __webpack_require__(686); +var patternUtils = __webpack_require__(517); var DeepFilter = /** @class */ (function () { function DeepFilter(options, micromatchOptions) { this.options = options; @@ -81285,7 +82774,7 @@ exports.default = DeepFilter; /***/ }), -/* 685 */ +/* 686 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -81316,14 +82805,14 @@ exports.makeAbsolute = makeAbsolute; /***/ }), -/* 686 */ +/* 687 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var pathUtils = __webpack_require__(685); -var patternUtils = __webpack_require__(516); +var pathUtils = __webpack_require__(686); +var patternUtils = __webpack_require__(517); var EntryFilter = /** @class */ (function () { function EntryFilter(options, micromatchOptions) { this.options = options; @@ -81408,7 +82897,7 @@ exports.default = EntryFilter; /***/ }), -/* 687 */ +/* 688 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -81428,8 +82917,8 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); var stream = __webpack_require__(138); -var fsStat = __webpack_require__(688); -var fs_1 = __webpack_require__(692); +var fsStat = __webpack_require__(689); +var fs_1 = __webpack_require__(693); var FileSystemStream = /** @class */ (function (_super) { __extends(FileSystemStream, _super); function FileSystemStream() { @@ -81479,14 +82968,14 @@ exports.default = FileSystemStream; /***/ }), -/* 688 */ +/* 689 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const optionsManager = __webpack_require__(689); -const statProvider = __webpack_require__(691); +const optionsManager = __webpack_require__(690); +const statProvider = __webpack_require__(692); /** * Asynchronous API. */ @@ -81517,13 +83006,13 @@ exports.statSync = statSync; /***/ }), -/* 689 */ +/* 690 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const fsAdapter = __webpack_require__(690); +const fsAdapter = __webpack_require__(691); function prepare(opts) { const options = Object.assign({ fs: fsAdapter.getFileSystemAdapter(opts ? opts.fs : undefined), @@ -81536,7 +83025,7 @@ exports.prepare = prepare; /***/ }), -/* 690 */ +/* 691 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -81559,7 +83048,7 @@ exports.getFileSystemAdapter = getFileSystemAdapter; /***/ }), -/* 691 */ +/* 692 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -81611,7 +83100,7 @@ exports.isFollowedSymlink = isFollowedSymlink; /***/ }), -/* 692 */ +/* 693 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -81642,7 +83131,7 @@ exports.default = FileSystem; /***/ }), -/* 693 */ +/* 694 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -81662,9 +83151,9 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); var stream = __webpack_require__(138); -var readdir = __webpack_require__(670); -var reader_1 = __webpack_require__(683); -var fs_stream_1 = __webpack_require__(687); +var readdir = __webpack_require__(671); +var reader_1 = __webpack_require__(684); +var fs_stream_1 = __webpack_require__(688); var TransformStream = /** @class */ (function (_super) { __extends(TransformStream, _super); function TransformStream(reader) { @@ -81732,7 +83221,7 @@ exports.default = ReaderStream; /***/ }), -/* 694 */ +/* 695 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -81751,9 +83240,9 @@ var __extends = (this && this.__extends) || (function () { }; })(); Object.defineProperty(exports, "__esModule", { value: true }); -var readdir = __webpack_require__(670); -var reader_1 = __webpack_require__(683); -var fs_sync_1 = __webpack_require__(695); +var readdir = __webpack_require__(671); +var reader_1 = __webpack_require__(684); +var fs_sync_1 = __webpack_require__(696); var ReaderSync = /** @class */ (function (_super) { __extends(ReaderSync, _super); function ReaderSync() { @@ -81813,7 +83302,7 @@ exports.default = ReaderSync; /***/ }), -/* 695 */ +/* 696 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -81832,8 +83321,8 @@ var __extends = (this && this.__extends) || (function () { }; })(); Object.defineProperty(exports, "__esModule", { value: true }); -var fsStat = __webpack_require__(688); -var fs_1 = __webpack_require__(692); +var fsStat = __webpack_require__(689); +var fs_1 = __webpack_require__(693); var FileSystemSync = /** @class */ (function (_super) { __extends(FileSystemSync, _super); function FileSystemSync() { @@ -81879,7 +83368,7 @@ exports.default = FileSystemSync; /***/ }), -/* 696 */ +/* 697 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -81895,7 +83384,7 @@ exports.flatten = flatten; /***/ }), -/* 697 */ +/* 698 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -81916,13 +83405,13 @@ exports.merge = merge; /***/ }), -/* 698 */ +/* 699 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const path = __webpack_require__(4); -const pathType = __webpack_require__(699); +const pathType = __webpack_require__(700); const getExtensions = extensions => extensions.length > 1 ? `{${extensions.join(',')}}` : extensions[0]; @@ -81988,13 +83477,13 @@ module.exports.sync = (input, opts) => { /***/ }), -/* 699 */ +/* 700 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const fs = __webpack_require__(134); -const pify = __webpack_require__(700); +const pify = __webpack_require__(701); function type(fn, fn2, fp) { if (typeof fp !== 'string') { @@ -82037,7 +83526,7 @@ exports.symlinkSync = typeSync.bind(null, 'lstatSync', 'isSymbolicLink'); /***/ }), -/* 700 */ +/* 701 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -82128,17 +83617,17 @@ module.exports = (obj, opts) => { /***/ }), -/* 701 */ +/* 702 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const fs = __webpack_require__(134); const path = __webpack_require__(4); -const fastGlob = __webpack_require__(512); -const gitIgnore = __webpack_require__(702); -const pify = __webpack_require__(703); -const slash = __webpack_require__(704); +const fastGlob = __webpack_require__(513); +const gitIgnore = __webpack_require__(703); +const pify = __webpack_require__(704); +const slash = __webpack_require__(705); const DEFAULT_IGNORE = [ '**/node_modules/**', @@ -82236,7 +83725,7 @@ module.exports.sync = options => { /***/ }), -/* 702 */ +/* 703 */ /***/ (function(module, exports) { // A simple implementation of make-array @@ -82705,7 +84194,7 @@ module.exports = options => new IgnoreBase(options) /***/ }), -/* 703 */ +/* 704 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -82780,7 +84269,7 @@ module.exports = (input, options) => { /***/ }), -/* 704 */ +/* 705 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -82798,7 +84287,7 @@ module.exports = input => { /***/ }), -/* 705 */ +/* 706 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -82811,7 +84300,7 @@ module.exports = input => { -var isGlob = __webpack_require__(706); +var isGlob = __webpack_require__(707); module.exports = function hasGlob(val) { if (val == null) return false; @@ -82831,7 +84320,7 @@ module.exports = function hasGlob(val) { /***/ }), -/* 706 */ +/* 707 */ /***/ (function(module, exports, __webpack_require__) { /*! @@ -82862,17 +84351,17 @@ module.exports = function isGlob(str) { /***/ }), -/* 707 */ +/* 708 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const path = __webpack_require__(4); const {constants: fsConstants} = __webpack_require__(134); -const pEvent = __webpack_require__(708); -const CpFileError = __webpack_require__(711); -const fs = __webpack_require__(713); -const ProgressEmitter = __webpack_require__(716); +const pEvent = __webpack_require__(709); +const CpFileError = __webpack_require__(712); +const fs = __webpack_require__(714); +const ProgressEmitter = __webpack_require__(717); const cpFileAsync = async (source, destination, options, progressEmitter) => { let readError; @@ -82986,12 +84475,12 @@ module.exports.sync = (source, destination, options) => { /***/ }), -/* 708 */ +/* 709 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const pTimeout = __webpack_require__(709); +const pTimeout = __webpack_require__(710); const symbolAsyncIterator = Symbol.asyncIterator || '@@asyncIterator'; @@ -83282,12 +84771,12 @@ module.exports.iterator = (emitter, event, options) => { /***/ }), -/* 709 */ +/* 710 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const pFinally = __webpack_require__(710); +const pFinally = __webpack_require__(711); class TimeoutError extends Error { constructor(message) { @@ -83333,7 +84822,7 @@ module.exports.TimeoutError = TimeoutError; /***/ }), -/* 710 */ +/* 711 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -83355,12 +84844,12 @@ module.exports = (promise, onFinally) => { /***/ }), -/* 711 */ +/* 712 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const NestedError = __webpack_require__(712); +const NestedError = __webpack_require__(713); class CpFileError extends NestedError { constructor(message, nested) { @@ -83374,7 +84863,7 @@ module.exports = CpFileError; /***/ }), -/* 712 */ +/* 713 */ /***/ (function(module, exports, __webpack_require__) { var inherits = __webpack_require__(112).inherits; @@ -83430,16 +84919,16 @@ module.exports = NestedError; /***/ }), -/* 713 */ +/* 714 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; const {promisify} = __webpack_require__(112); const fs = __webpack_require__(133); -const makeDir = __webpack_require__(714); -const pEvent = __webpack_require__(708); -const CpFileError = __webpack_require__(711); +const makeDir = __webpack_require__(715); +const pEvent = __webpack_require__(709); +const CpFileError = __webpack_require__(712); const stat = promisify(fs.stat); const lstat = promisify(fs.lstat); @@ -83536,7 +85025,7 @@ exports.copyFileSync = (source, destination, flags) => { /***/ }), -/* 714 */ +/* 715 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -83544,7 +85033,7 @@ exports.copyFileSync = (source, destination, flags) => { const fs = __webpack_require__(134); const path = __webpack_require__(4); const {promisify} = __webpack_require__(112); -const semver = __webpack_require__(715); +const semver = __webpack_require__(716); const useNativeRecursiveOption = semver.satisfies(process.version, '>=10.12.0'); @@ -83699,7 +85188,7 @@ module.exports.sync = (input, options) => { /***/ }), -/* 715 */ +/* 716 */ /***/ (function(module, exports) { exports = module.exports = SemVer @@ -85301,7 +86790,7 @@ function coerce (version, options) { /***/ }), -/* 716 */ +/* 717 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -85342,7 +86831,7 @@ module.exports = ProgressEmitter; /***/ }), -/* 717 */ +/* 718 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -85388,12 +86877,12 @@ exports.default = module.exports; /***/ }), -/* 718 */ +/* 719 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const pMap = __webpack_require__(719); +const pMap = __webpack_require__(720); const pFilter = async (iterable, filterer, options) => { const values = await pMap( @@ -85410,7 +86899,7 @@ module.exports.default = pFilter; /***/ }), -/* 719 */ +/* 720 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -85489,12 +86978,12 @@ module.exports.default = pMap; /***/ }), -/* 720 */ +/* 721 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -const NestedError = __webpack_require__(712); +const NestedError = __webpack_require__(713); class CpyError extends NestedError { constructor(message, nested) { diff --git a/packages/kbn-test/jest-preset.js b/packages/kbn-test/jest-preset.js new file mode 100644 index 0000000000000..4a85eca206c96 --- /dev/null +++ b/packages/kbn-test/jest-preset.js @@ -0,0 +1,111 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +// For a detailed explanation regarding each configuration property, visit: +// https://jestjs.io/docs/en/configuration.html + +const { resolve } = require('path'); + +module.exports = { + // The directory where Jest should output its coverage files + coverageDirectory: '/target/kibana-coverage/jest', + + // An array of regexp pattern strings used to skip coverage collection + coveragePathIgnorePatterns: ['/node_modules/', '.*\\.d\\.ts'], + + // A list of reporter names that Jest uses when writing coverage reports + coverageReporters: !!process.env.CODE_COVERAGE ? ['json'] : ['html', 'text'], + + // An array of file extensions your modules use + moduleFileExtensions: ['js', 'mjs', 'json', 'ts', 'tsx', 'node'], + + // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module + moduleNameMapper: { + '@elastic/eui/lib/(.*)?': '/node_modules/@elastic/eui/test-env/$1', + '@elastic/eui$': '/node_modules/@elastic/eui/test-env', + '\\.module.(css|scss)$': '/packages/kbn-test/target/jest/mocks/css_module_mock.js', + '\\.(css|less|scss)$': '/packages/kbn-test/target/jest/mocks/style_mock.js', + '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': + '/packages/kbn-test/target/jest/mocks/file_mock.js', + '\\.ace\\.worker.js$': '/packages/kbn-test/target/jest/mocks/worker_module_mock.js', + '\\.editor\\.worker.js$': '/packages/kbn-test/target/jest/mocks/worker_module_mock.js', + '^(!!)?file-loader!': '/packages/kbn-test/target/jest/mocks/file_mock.js', + '^fixtures/(.*)': '/src/fixtures/$1', + '^src/core/(.*)': '/src/core/$1', + '^src/legacy/(.*)': '/src/legacy/$1', + '^src/plugins/(.*)': '/src/plugins/$1', + }, + + // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader + modulePathIgnorePatterns: ['__fixtures__/', 'target/'], + + // Use this configuration option to add custom reporters to Jest + reporters: ['default', resolve(__dirname, './target/jest/junit_reporter')], + + // The paths to modules that run some code to configure or set up the testing environment before each test + setupFiles: [ + '/packages/kbn-test/target/jest/setup/babel_polyfill.js', + '/packages/kbn-test/target/jest/setup/polyfills.js', + '/packages/kbn-test/target/jest/setup/enzyme.js', + ], + + // A list of paths to modules that run some code to configure or set up the testing framework before each test + setupFilesAfterEnv: [ + '/packages/kbn-test/target/jest/setup/setup_test.js', + '/packages/kbn-test/target/jest/setup/mocks.js', + '/packages/kbn-test/target/jest/setup/react_testing_library.js', + ], + + // A list of paths to snapshot serializer modules Jest should use for snapshot testing + snapshotSerializers: [ + '/src/plugins/kibana_react/public/util/test_helpers/react_mount_serializer.ts', + '/node_modules/enzyme-to-json/serializer', + ], + + // The test environment that will be used for testing + testEnvironment: 'jest-environment-jsdom-thirteen', + + // The glob patterns Jest uses to detect test files + testMatch: ['**/*.test.{js,mjs,ts,tsx}'], + + // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped + testPathIgnorePatterns: [ + '/packages/kbn-ui-framework/(dist|doc_site|generator-kui)/', + '/packages/kbn-pm/dist/', + `integration_tests/`, + ], + + // This option allows use of a custom test runner + testRunner: 'jest-circus/runner', + + // A map from regular expressions to paths to transformers + transform: { + '^.+\\.(js|tsx?)$': '/packages/kbn-test/target/jest/babel_transform.js', + '^.+\\.txt?$': 'jest-raw-loader', + '^.+\\.html?$': 'jest-raw-loader', + }, + + // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation + transformIgnorePatterns: [ + // ignore all node_modules except monaco-editor which requires babel transforms to handle dynamic import() + // since ESM modules are not natively supported in Jest yet (https://github.com/facebook/jest/issues/4842) + '[/\\\\]node_modules(?![\\/\\\\]monaco-editor)[/\\\\].+\\.js$', + 'packages/kbn-pm/dist/index.js', + ], +}; diff --git a/packages/kbn-test/jest/package.json b/packages/kbn-test/jest/package.json new file mode 100644 index 0000000000000..c8b50f7b1b5ba --- /dev/null +++ b/packages/kbn-test/jest/package.json @@ -0,0 +1,4 @@ +{ + "main": "../target/jest", + "types": "../target/types/jest/index.d.ts" +} diff --git a/packages/kbn-test/package.json b/packages/kbn-test/package.json index 550294dba1f23..a64acdaefdc88 100644 --- a/packages/kbn-test/package.json +++ b/packages/kbn-test/package.json @@ -5,16 +5,22 @@ "license": "Apache-2.0", "main": "./target/index.js", "scripts": { - "build": "../../node_modules/.bin/babel src --out-dir target --delete-dir-on-start --extensions .ts,.js,.tsx --ignore *.test.js,**/__tests__/** --source-maps=inline", - "kbn:bootstrap": "yarn build", - "kbn:watch": "yarn build --watch" + "build": "node scripts/build", + "kbn:bootstrap": "node scripts/build --source-maps", + "kbn:watch": "node scripts/build --watch --source-maps" }, "kibana": { "devOnly": true }, + "dependencies": { + "@kbn/es": "link:../kbn-es", + "@kbn/i18n": "link:../kbn-i18n", + "@kbn/optimizer": "link:../kbn-optimizer" + }, "devDependencies": { "@kbn/babel-preset": "link:../kbn-babel-preset", "@kbn/dev-utils": "link:../kbn-dev-utils", + "@kbn/expect": "link:../kbn-expect", "@kbn/utils": "link:../kbn-utils" } } \ No newline at end of file diff --git a/packages/kbn-test/scripts/build.js b/packages/kbn-test/scripts/build.js new file mode 100644 index 0000000000000..4ded402ab4439 --- /dev/null +++ b/packages/kbn-test/scripts/build.js @@ -0,0 +1,91 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +const { resolve } = require('path'); + +const del = require('del'); +const supportsColor = require('supports-color'); +const { run, withProcRunner } = require('@kbn/dev-utils'); + +const ROOT_DIR = resolve(__dirname, '..'); +const BUILD_DIR = resolve(ROOT_DIR, 'target'); + +const padRight = (width, str) => + str.length >= width ? str : `${str}${' '.repeat(width - str.length)}`; + +run( + async ({ log, flags }) => { + await withProcRunner(log, async (proc) => { + log.info('Deleting old output'); + await del(BUILD_DIR); + + const cwd = ROOT_DIR; + const env = { ...process.env }; + if (supportsColor.stdout) { + env.FORCE_COLOR = 'true'; + } + + log.info(`Starting babel and typescript${flags.watch ? ' in watch mode' : ''}`); + await Promise.all([ + proc.run(padRight(10, `babel`), { + cmd: 'babel', + args: [ + 'src', + '--config-file', + require.resolve('../babel.config.js'), + '--out-dir', + BUILD_DIR, + '--extensions', + '.ts,.js,.tsx', + ...(flags.watch ? ['--watch'] : ['--quiet']), + ...(!flags['source-maps'] || !!process.env.CODE_COVERAGE + ? [] + : ['--source-maps', 'inline']), + ], + wait: true, + env, + cwd, + }), + + proc.run(padRight(10, 'tsc'), { + cmd: 'tsc', + args: [ + ...(flags.watch ? ['--watch', '--preserveWatchOutput', 'true'] : []), + ...(flags['source-maps'] ? ['--declarationMap', 'true'] : []), + ], + wait: true, + env, + cwd, + }), + ]); + + log.success('Complete'); + }); + }, + { + description: 'Simple build tool for @kbn/i18n package', + flags: { + boolean: ['watch', 'source-maps'], + help: ` + --watch Run in watch mode + --source-maps Include sourcemaps + `, + }, + } +); diff --git a/packages/kbn-test/src/index.ts b/packages/kbn-test/src/index.ts index a57b92fbdde25..3e4a62387d1bf 100644 --- a/packages/kbn-test/src/index.ts +++ b/packages/kbn-test/src/index.ts @@ -58,5 +58,3 @@ export { runFailedTestsReporterCli } from './failed_tests_reporter'; export { CI_PARALLEL_PROCESS_PREFIX } from './ci_parallel_process_prefix'; export * from './functional_test_runner'; - -export * from './jest'; diff --git a/src/dev/jest/babel_transform.js b/packages/kbn-test/src/jest/babel_transform.js similarity index 100% rename from src/dev/jest/babel_transform.js rename to packages/kbn-test/src/jest/babel_transform.js diff --git a/packages/kbn-test/src/jest/index.ts b/packages/kbn-test/src/jest/index.ts index c6d680863d9c4..8604973f9f4be 100644 --- a/packages/kbn-test/src/jest/index.ts +++ b/packages/kbn-test/src/jest/index.ts @@ -17,6 +17,4 @@ * under the License. */ -export * from './junit_reporter'; - -export * from './report_path'; +export * from './utils'; diff --git a/packages/kbn-test/src/jest/integration_tests/junit_reporter.test.ts b/packages/kbn-test/src/jest/integration_tests/junit_reporter.test.ts index a95215a0044f1..1842d577bd797 100644 --- a/packages/kbn-test/src/jest/integration_tests/junit_reporter.test.ts +++ b/packages/kbn-test/src/jest/integration_tests/junit_reporter.test.ts @@ -24,7 +24,7 @@ import { readFileSync } from 'fs'; import del from 'del'; import execa from 'execa'; import xml2js from 'xml2js'; -import { getUniqueJunitReportPath } from '@kbn/test'; +import { getUniqueJunitReportPath } from '../../report_path'; import { REPO_ROOT } from '@kbn/utils'; const MINUTE = 1000 * 60; diff --git a/packages/kbn-test/src/jest/junit_reporter.ts b/packages/kbn-test/src/jest/junit_reporter.ts index b6e964c22adfc..234b15724f498 100644 --- a/packages/kbn-test/src/jest/junit_reporter.ts +++ b/packages/kbn-test/src/jest/junit_reporter.ts @@ -27,7 +27,7 @@ import type { Config } from '@jest/types'; import { AggregatedResult, Test, BaseReporter } from '@jest/reporters'; import { escapeCdata } from '../mocha/xml'; -import { getUniqueJunitReportPath } from './report_path'; +import { getUniqueJunitReportPath } from '../report_path'; interface ReporterOptions { reportName?: string; diff --git a/src/dev/jest/mocks/css_module_mock.js b/packages/kbn-test/src/jest/mocks/css_module_mock.js similarity index 100% rename from src/dev/jest/mocks/css_module_mock.js rename to packages/kbn-test/src/jest/mocks/css_module_mock.js diff --git a/src/dev/jest/mocks/file_mock.js b/packages/kbn-test/src/jest/mocks/file_mock.js similarity index 100% rename from src/dev/jest/mocks/file_mock.js rename to packages/kbn-test/src/jest/mocks/file_mock.js diff --git a/src/dev/jest/mocks/style_mock.js b/packages/kbn-test/src/jest/mocks/style_mock.js similarity index 100% rename from src/dev/jest/mocks/style_mock.js rename to packages/kbn-test/src/jest/mocks/style_mock.js diff --git a/src/dev/jest/mocks/worker_module_mock.js b/packages/kbn-test/src/jest/mocks/worker_module_mock.js similarity index 100% rename from src/dev/jest/mocks/worker_module_mock.js rename to packages/kbn-test/src/jest/mocks/worker_module_mock.js diff --git a/src/dev/jest/setup/after_env.integration.js b/packages/kbn-test/src/jest/setup/after_env.integration.js similarity index 100% rename from src/dev/jest/setup/after_env.integration.js rename to packages/kbn-test/src/jest/setup/after_env.integration.js diff --git a/src/dev/jest/setup/babel_polyfill.js b/packages/kbn-test/src/jest/setup/babel_polyfill.js similarity index 100% rename from src/dev/jest/setup/babel_polyfill.js rename to packages/kbn-test/src/jest/setup/babel_polyfill.js diff --git a/src/dev/jest/setup/enzyme.js b/packages/kbn-test/src/jest/setup/enzyme.js similarity index 100% rename from src/dev/jest/setup/enzyme.js rename to packages/kbn-test/src/jest/setup/enzyme.js diff --git a/src/dev/jest/setup/mocks.js b/packages/kbn-test/src/jest/setup/mocks.js similarity index 100% rename from src/dev/jest/setup/mocks.js rename to packages/kbn-test/src/jest/setup/mocks.js diff --git a/src/dev/jest/setup/polyfills.js b/packages/kbn-test/src/jest/setup/polyfills.js similarity index 83% rename from src/dev/jest/setup/polyfills.js rename to packages/kbn-test/src/jest/setup/polyfills.js index 9e4f1db9ac289..2c1f7333d8126 100644 --- a/src/dev/jest/setup/polyfills.js +++ b/packages/kbn-test/src/jest/setup/polyfills.js @@ -28,3 +28,11 @@ const MutationObserver = require('mutation-observer'); Object.defineProperty(window, 'MutationObserver', { value: MutationObserver }); require('whatwg-fetch'); + +if (!global.URL.hasOwnProperty('createObjectURL')) { + Object.defineProperty(global.URL, 'createObjectURL', { value: () => '' }); +} + +// Will be replaced with a better solution in EUI +// https://github.com/elastic/eui/issues/3713 +global._isJest = true; diff --git a/src/test_utils/public/helpers/index.ts b/packages/kbn-test/src/jest/setup/react_mount_serializer.ts similarity index 67% rename from src/test_utils/public/helpers/index.ts rename to packages/kbn-test/src/jest/setup/react_mount_serializer.ts index fcc0102c76683..45ad4cb407175 100644 --- a/src/test_utils/public/helpers/index.ts +++ b/packages/kbn-test/src/jest/setup/react_mount_serializer.ts @@ -17,17 +17,14 @@ * under the License. */ -export { findTestSubject } from './find_test_subject'; +export function test(value: any) { + return value && value.__reactMount__; +} -export { WithStore } from './redux_helpers'; - -export { WithMemoryRouter, WithRoute, reactRouterMock } from './router_helpers'; - -export * from './utils'; - -export { - setSVGElementGetBBox, - setHTMLElementOffset, - setHTMLElementClientSizes, - setSVGElementGetComputedTextLength, -} from './jsdom_svg_mocks'; +export function print(value: any, serialize: any) { + // there is no proper way to correctly indent multiline values + // so the trick here is to use the Object representation and rewriting the root object name + return serialize({ + reactNode: value.__reactMount__, + }).replace('Object', 'MountPoint'); +} diff --git a/src/dev/jest/setup/react_testing_library.js b/packages/kbn-test/src/jest/setup/react_testing_library.js similarity index 100% rename from src/dev/jest/setup/react_testing_library.js rename to packages/kbn-test/src/jest/setup/react_testing_library.js diff --git a/src/test_utils/public/index.ts b/packages/kbn-test/src/jest/setup/setup_test.js similarity index 77% rename from src/test_utils/public/index.ts rename to packages/kbn-test/src/jest/setup/setup_test.js index e57f1ae8ea7a9..94a4db0594504 100644 --- a/src/test_utils/public/index.ts +++ b/packages/kbn-test/src/jest/setup/setup_test.js @@ -17,9 +17,10 @@ * under the License. */ -export { - setSVGElementGetBBox, - setHTMLElementOffset, - setHTMLElementClientSizes, - setSVGElementGetComputedTextLength, -} from './helpers'; +/* + Global import, so we don't need to remember to import the lib in each file + https://www.npmjs.com/package/jest-styled-components#global-installation +*/ + +import 'jest-styled-components'; +import '@testing-library/jest-dom'; diff --git a/x-pack/test_utils/enzyme_helpers.tsx b/packages/kbn-test/src/jest/utils/enzyme_helpers.tsx similarity index 81% rename from x-pack/test_utils/enzyme_helpers.tsx rename to packages/kbn-test/src/jest/utils/enzyme_helpers.tsx index 6e2c0144a9f0e..d23a496e7c675 100644 --- a/x-pack/test_utils/enzyme_helpers.tsx +++ b/packages/kbn-test/src/jest/utils/enzyme_helpers.tsx @@ -1,7 +1,20 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ /** @@ -192,4 +205,14 @@ export const mountHook = ( }; }; -export const nextTick = () => new Promise((res) => process.nextTick(res)); +export function shallowWithI18nProvider(child: ReactElement) { + const wrapped = shallow({child}); + const name = typeof child.type === 'string' ? child.type : child.type.name; + return wrapped.find(name).dive(); +} + +export function mountWithI18nProvider(child: ReactElement) { + const wrapped = mount({child}); + const name = typeof child.type === 'string' ? child.type : child.type.name; + return wrapped.find(name); +} diff --git a/src/test_utils/public/helpers/find_test_subject.ts b/packages/kbn-test/src/jest/utils/find_test_subject.ts similarity index 100% rename from src/test_utils/public/helpers/find_test_subject.ts rename to packages/kbn-test/src/jest/utils/find_test_subject.ts diff --git a/packages/kbn-test/src/jest/utils/get_url.test.ts b/packages/kbn-test/src/jest/utils/get_url.test.ts new file mode 100644 index 0000000000000..cc54efa4fe725 --- /dev/null +++ b/packages/kbn-test/src/jest/utils/get_url.test.ts @@ -0,0 +1,66 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { getUrl } from './get_url'; + +describe('getUrl', function () { + it('should convert to a url', function () { + const url = getUrl( + { + protocol: 'http', + hostname: 'localhost', + }, + { + pathname: 'foo', + } + ); + + expect(url).toBe('http://localhost/foo'); + }); + + it('should convert to a url with port', function () { + const url = getUrl( + { + protocol: 'http', + hostname: 'localhost', + port: 9220, + }, + { + pathname: 'foo', + } + ); + + expect(url).toBe('http://localhost:9220/foo'); + }); + + it('should convert to a secure hashed url', function () { + expect( + getUrl( + { + protocol: 'https', + hostname: 'localhost', + }, + { + pathname: 'foo', + hash: 'bar', + } + ) + ).toBe('https://localhost/foo#bar'); + }); +}); diff --git a/packages/kbn-test/src/jest/utils/get_url.ts b/packages/kbn-test/src/jest/utils/get_url.ts new file mode 100644 index 0000000000000..0bf70307d9236 --- /dev/null +++ b/packages/kbn-test/src/jest/utils/get_url.ts @@ -0,0 +1,75 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import _ from 'lodash'; +import url from 'url'; + +interface UrlParam { + hash?: string; + host?: string; + hostname?: string; + href?: string; + password?: string; + pathname?: string; + port?: number; + protocol?: string; + search?: string; + username?: string; +} + +interface App { + pathname?: string; + hash?: string; +} + +/** + * Converts a config and a pathname to a url + * @param {object} config A url config + * example: + * { + * protocol: 'http', + * hostname: 'localhost', + * port: 9220, + * auth: kibanaTestUser.username + ':' + kibanaTestUser.password + * } + * @param {object} app The params to append + * example: + * { + * pathname: 'app/kibana', + * hash: '/discover' + * } + * @return {string} + */ + +function getUrl(config: UrlParam, app: App) { + return url.format(_.assign({}, config, app)); +} + +getUrl.noAuth = function getUrlNoAuth(config: UrlParam, app: App) { + config = _.pickBy(config, function (val, param) { + return param !== 'auth'; + }); + return getUrl(config, app); +}; + +getUrl.baseUrl = function getBaseUrl(config: UrlParam) { + return url.format(_.pick(config, 'protocol', 'hostname', 'port')); +}; + +export { getUrl }; diff --git a/packages/kbn-test/src/jest/utils/index.ts b/packages/kbn-test/src/jest/utils/index.ts new file mode 100644 index 0000000000000..f85160652828b --- /dev/null +++ b/packages/kbn-test/src/jest/utils/index.ts @@ -0,0 +1,40 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export * from './enzyme_helpers'; + +export * from './find_test_subject'; + +export * from './jsdom_svg_mocks'; + +export * from './random'; + +export * from './redux_helpers'; + +export * from './router_helpers'; + +export * from './stub_browser_storage'; + +export * from './stub_web_worker'; + +export * from './testbed'; + +export const nextTick = () => new Promise((res) => process.nextTick(res)); + +export const delay = (time = 0) => new Promise((resolve) => setTimeout(resolve, time)); diff --git a/src/test_utils/public/helpers/jsdom_svg_mocks.ts b/packages/kbn-test/src/jest/utils/jsdom_svg_mocks.ts similarity index 100% rename from src/test_utils/public/helpers/jsdom_svg_mocks.ts rename to packages/kbn-test/src/jest/utils/jsdom_svg_mocks.ts diff --git a/src/test_utils/public/helpers/utils.ts b/packages/kbn-test/src/jest/utils/random.ts similarity index 92% rename from src/test_utils/public/helpers/utils.ts rename to packages/kbn-test/src/jest/utils/random.ts index 90788c4f4e521..3b4418b7120c1 100644 --- a/src/test_utils/public/helpers/utils.ts +++ b/packages/kbn-test/src/jest/utils/random.ts @@ -22,8 +22,6 @@ import Chance from 'chance'; const chance = new Chance(); const CHARS_POOL = 'abcdefghijklmnopqrstuvwxyz'; -export const nextTick = (time = 0) => new Promise((resolve) => setTimeout(resolve, time)); - export const getRandomNumber = (range: { min: number; max: number } = { min: 1, max: 20 }) => chance.integer(range); diff --git a/src/test_utils/public/helpers/redux_helpers.tsx b/packages/kbn-test/src/jest/utils/redux_helpers.tsx similarity index 100% rename from src/test_utils/public/helpers/redux_helpers.tsx rename to packages/kbn-test/src/jest/utils/redux_helpers.tsx diff --git a/src/test_utils/public/helpers/router_helpers.tsx b/packages/kbn-test/src/jest/utils/router_helpers.tsx similarity index 93% rename from src/test_utils/public/helpers/router_helpers.tsx rename to packages/kbn-test/src/jest/utils/router_helpers.tsx index 94ff4798d0226..acc63758cd957 100644 --- a/src/test_utils/public/helpers/router_helpers.tsx +++ b/packages/kbn-test/src/jest/utils/router_helpers.tsx @@ -29,9 +29,10 @@ export const WithMemoryRouter = (initialEntries: string[] = ['/'], initialIndex: ); -export const WithRoute = (componentRoutePath = '/', onRouter = (router: any) => {}) => ( - WrappedComponent: ComponentType -) => { +export const WithRoute = ( + componentRoutePath: string | string[] = '/', + onRouter = (router: any) => {} +) => (WrappedComponent: ComponentType) => { // Create a class component that will catch the router // and forward it to our "onRouter()" handler. const CatchRouter = withRouter( diff --git a/src/test_utils/public/stub_browser_storage.test.ts b/packages/kbn-test/src/jest/utils/stub_browser_storage.test.ts similarity index 100% rename from src/test_utils/public/stub_browser_storage.test.ts rename to packages/kbn-test/src/jest/utils/stub_browser_storage.test.ts diff --git a/src/test_utils/public/stub_browser_storage.ts b/packages/kbn-test/src/jest/utils/stub_browser_storage.ts similarity index 100% rename from src/test_utils/public/stub_browser_storage.ts rename to packages/kbn-test/src/jest/utils/stub_browser_storage.ts diff --git a/packages/kbn-test/src/jest/utils/stub_web_worker.ts b/packages/kbn-test/src/jest/utils/stub_web_worker.ts new file mode 100644 index 0000000000000..170b641b235a4 --- /dev/null +++ b/packages/kbn-test/src/jest/utils/stub_web_worker.ts @@ -0,0 +1,36 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +function stubWebWorker() { + if (!window.Worker) { + // @ts-ignore we aren't honoring the real Worker spec here + window.Worker = function Worker() { + this.postMessage = jest.fn(); + + // @ts-ignore TypeScript doesn't think this exists on the Worker interface + // https://developer.mozilla.org/en-US/docs/Web/API/Worker/terminate + this.terminate = jest.fn(); + }; + } +} + +stubWebWorker(); + +// Add an export to avoid TS complaining "stub_web_worker.ts" is not a module. +export { stubWebWorker }; diff --git a/x-pack/test_utils/README.md b/packages/kbn-test/src/jest/utils/testbed/README.md similarity index 92% rename from x-pack/test_utils/README.md rename to packages/kbn-test/src/jest/utils/testbed/README.md index a6ca1a5d86866..5a05ba3750d3c 100644 --- a/x-pack/test_utils/README.md +++ b/packages/kbn-test/src/jest/utils/testbed/README.md @@ -138,25 +138,6 @@ In order to prevent flakiness in component integration tests, please consider th component.update(); ``` -## Chrome extension - -There is a small Chrome extension that you can install in order to track the test subjects on the current page. As it is meant to be used -during development, the extension is only active when navigating to a `localhost` URL. - -You will find the "Test subjects finder" extension in the `x-pack/test_utils/chrome_extension` folder. - -### Install the extension - -- open the "extensions" window in Chrome -- activate the "Developer mode" (top right corner) -- drag and drop the `test_subjects_finder` folder on the window. - -You can specify a DOM node (the tree "root") from which the test subjects will be found. If you don't specify any, the document `` will be used. The output format can either be `Typescript` (to export a string union type) or `List`. - -### Output - -Once you start tracking the test subjects on the page, the output will be printed in the **Chrome dev console**. - ## API ## `registerTestBed(Component [, testBedConfig])` diff --git a/src/test_utils/public/testbed/index.ts b/packages/kbn-test/src/jest/utils/testbed/index.ts similarity index 100% rename from src/test_utils/public/testbed/index.ts rename to packages/kbn-test/src/jest/utils/testbed/index.ts diff --git a/src/test_utils/public/testbed/mount_component.tsx b/packages/kbn-test/src/jest/utils/testbed/mount_component.tsx similarity index 95% rename from src/test_utils/public/testbed/mount_component.tsx rename to packages/kbn-test/src/jest/utils/testbed/mount_component.tsx index 9cebca8eda7d8..bc0748e1d18ac 100644 --- a/src/test_utils/public/testbed/mount_component.tsx +++ b/packages/kbn-test/src/jest/utils/testbed/mount_component.tsx @@ -23,7 +23,8 @@ import { ReactWrapper } from 'enzyme'; import { act } from 'react-dom/test-utils'; import { mountWithIntl } from '../enzyme_helpers'; -import { WithMemoryRouter, WithRoute, WithStore } from '../helpers'; +import { WithMemoryRouter, WithRoute } from '../router_helpers'; +import { WithStore } from '../redux_helpers'; import { MemoryRouterConfig } from './types'; interface Config { diff --git a/x-pack/test_utils/testbed/testbed.ts b/packages/kbn-test/src/jest/utils/testbed/testbed.ts similarity index 92% rename from x-pack/test_utils/testbed/testbed.ts rename to packages/kbn-test/src/jest/utils/testbed/testbed.ts index e981d0b6918a3..0e0ed4e09d31e 100644 --- a/x-pack/test_utils/testbed/testbed.ts +++ b/packages/kbn-test/src/jest/utils/testbed/testbed.ts @@ -1,7 +1,20 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ import { ComponentType, ReactWrapper } from 'enzyme'; @@ -31,7 +44,7 @@ const defaultConfig: TestBedConfig = { * * @example ```typescript - import { registerTestBed } from '../../../../test_utils'; + import { registerTestBed } from '@kbn/test/jest'; import { RemoteClusterList } from '../../app/sections/remote_cluster_list'; import { remoteClustersStore } from '../../app/store'; diff --git a/src/test_utils/public/testbed/types.ts b/packages/kbn-test/src/jest/utils/testbed/types.ts similarity index 98% rename from src/test_utils/public/testbed/types.ts rename to packages/kbn-test/src/jest/utils/testbed/types.ts index 39422fa68081b..1ebdf8f28b5f5 100644 --- a/src/test_utils/public/testbed/types.ts +++ b/packages/kbn-test/src/jest/utils/testbed/types.ts @@ -74,6 +74,7 @@ export interface TestBed { * and we need to wait for the data to be fetched (and bypass any "loading" state). */ waitFor: (testSubject: T, count?: number) => Promise; + waitForFn: (predicate: () => Promise, errMessage: string) => Promise; form: { /** * Set the value of a form text input. @@ -175,7 +176,7 @@ export interface MemoryRouterConfig { /** The React Router **initial index** setting ([see documentation](https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/api/MemoryRouter.md)) */ initialIndex?: number; /** The route **path** for the mounted component (defaults to `"/"`) */ - componentRoutePath?: string; + componentRoutePath?: string | string[]; /** A callBack that will be called with the React Router instance once mounted */ onRouter?: (router: any) => void; } diff --git a/packages/kbn-test/src/mocha/__tests__/junit_report_generation.js b/packages/kbn-test/src/mocha/__tests__/junit_report_generation.js index dc7d161eca5a3..407ab37123d5d 100644 --- a/packages/kbn-test/src/mocha/__tests__/junit_report_generation.js +++ b/packages/kbn-test/src/mocha/__tests__/junit_report_generation.js @@ -25,7 +25,7 @@ import { parseString } from 'xml2js'; import del from 'del'; import Mocha from 'mocha'; import expect from '@kbn/expect'; -import { getUniqueJunitReportPath } from '@kbn/test'; +import { getUniqueJunitReportPath } from '../../report_path'; import { setupJUnitReportGeneration } from '../junit_report_generation'; diff --git a/packages/kbn-test/src/mocha/junit_report_generation.js b/packages/kbn-test/src/mocha/junit_report_generation.js index 9ac9bd18548f4..84d488bd8b5a1 100644 --- a/packages/kbn-test/src/mocha/junit_report_generation.js +++ b/packages/kbn-test/src/mocha/junit_report_generation.js @@ -22,7 +22,7 @@ import { writeFileSync, mkdirSync } from 'fs'; import { inspect } from 'util'; import xmlBuilder from 'xmlbuilder'; -import { getUniqueJunitReportPath } from '@kbn/test'; +import { getUniqueJunitReportPath } from '../report_path'; import { getSnapshotOfRunnableLogs } from './log_cache'; import { escapeCdata } from '../'; diff --git a/packages/kbn-test/src/jest/report_path.ts b/packages/kbn-test/src/report_path.ts similarity index 94% rename from packages/kbn-test/src/jest/report_path.ts rename to packages/kbn-test/src/report_path.ts index c9cf3ce454e6a..8843204097e85 100644 --- a/packages/kbn-test/src/jest/report_path.ts +++ b/packages/kbn-test/src/report_path.ts @@ -20,7 +20,7 @@ import Fs from 'fs'; import Path from 'path'; -import { CI_PARALLEL_PROCESS_PREFIX } from '../ci_parallel_process_prefix'; +import { CI_PARALLEL_PROCESS_PREFIX } from './ci_parallel_process_prefix'; export function getUniqueJunitReportPath( rootDirectory: string, diff --git a/packages/kbn-test/tsconfig.json b/packages/kbn-test/tsconfig.json index fec35e45b2a15..3219e6cf3d6ee 100644 --- a/packages/kbn-test/tsconfig.json +++ b/packages/kbn-test/tsconfig.json @@ -1,11 +1,19 @@ { "extends": "../../tsconfig.base.json", - "compilerOptions": { - "tsBuildInfoFile": "../../build/tsbuildinfo/packages/kbn-test" - }, "include": [ "types/**/*", "src/**/*", "index.d.ts" - ] + ], + "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "./target/types", + "types": [ + "jest", + "node" + ], + "stripInternal": true, + "declarationMap": true + } } diff --git a/src/core/public/chrome/ui/header/collapsible_nav.test.tsx b/src/core/public/chrome/ui/header/collapsible_nav.test.tsx index 267e17dc0a9d0..7fd79fa76635c 100644 --- a/src/core/public/chrome/ui/header/collapsible_nav.test.tsx +++ b/src/core/public/chrome/ui/header/collapsible_nav.test.tsx @@ -21,7 +21,7 @@ import { mount, ReactWrapper } from 'enzyme'; import React from 'react'; import { BehaviorSubject } from 'rxjs'; import sinon from 'sinon'; -import { StubBrowserStorage } from 'test_utils/stub_browser_storage'; +import { StubBrowserStorage } from '@kbn/test/jest'; import { ChromeNavLink, DEFAULT_APP_CATEGORIES } from '../../..'; import { httpServiceMock } from '../../../http/http_service.mock'; import { ChromeRecentlyAccessedHistoryItem } from '../../recently_accessed'; diff --git a/src/core/public/chrome/ui/header/header.test.tsx b/src/core/public/chrome/ui/header/header.test.tsx index 868d7f29f34e4..722b2a209c88f 100644 --- a/src/core/public/chrome/ui/header/header.test.tsx +++ b/src/core/public/chrome/ui/header/header.test.tsx @@ -20,11 +20,10 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; import { BehaviorSubject } from 'rxjs'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { StubBrowserStorage, mountWithIntl } from '@kbn/test/jest'; import { httpServiceMock } from '../../../http/http_service.mock'; import { applicationServiceMock } from '../../../mocks'; import { Header } from './header'; -import { StubBrowserStorage } from 'test_utils/stub_browser_storage'; jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => ({ htmlIdGenerator: () => () => 'mockId', diff --git a/src/core/public/fatal_errors/fatal_errors_screen.test.tsx b/src/core/public/fatal_errors/fatal_errors_screen.test.tsx index 35a9cbc48f6c1..94896f42c5693 100644 --- a/src/core/public/fatal_errors/fatal_errors_screen.test.tsx +++ b/src/core/public/fatal_errors/fatal_errors_screen.test.tsx @@ -21,7 +21,7 @@ import { EuiCallOut } from '@elastic/eui'; import testSubjSelector from '@kbn/test-subj-selector'; import React from 'react'; import * as Rx from 'rxjs'; -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { FatalErrorsScreen } from './fatal_errors_screen'; diff --git a/src/core/public/notifications/toasts/error_toast.test.tsx b/src/core/public/notifications/toasts/error_toast.test.tsx index b497be526093d..07ba5e23c2175 100644 --- a/src/core/public/notifications/toasts/error_toast.test.tsx +++ b/src/core/public/notifications/toasts/error_toast.test.tsx @@ -19,7 +19,7 @@ import { shallow } from 'enzyme'; import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { ErrorToast } from './error_toast'; diff --git a/src/dev/jest/config.integration.js b/src/dev/jest/config.integration.js index 970c00bb68b98..9e7bbc34ac711 100644 --- a/src/dev/jest/config.integration.js +++ b/src/dev/jest/config.integration.js @@ -17,6 +17,7 @@ * under the License. */ +import preset from '@kbn/test/jest-preset'; import config from './config'; export default { @@ -26,7 +27,7 @@ export default { '**/integration_tests/**/*.test.ts', '**/integration_tests/**/*.test.tsx', ], - testPathIgnorePatterns: config.testPathIgnorePatterns.filter( + testPathIgnorePatterns: preset.testPathIgnorePatterns.filter( (pattern) => !pattern.includes('integration_tests') ), reporters: [ @@ -36,5 +37,5 @@ export default { { reportName: 'Jest Integration Tests' }, ], ], - setupFilesAfterEnv: ['/src/dev/jest/setup/after_env.integration.js'], + setupFilesAfterEnv: ['/packages/kbn-test/target/jest/setup/after_env.integration.js'], }; diff --git a/src/dev/jest/config.js b/src/dev/jest/config.js index f582a8f3d4410..9f445b0c05be9 100644 --- a/src/dev/jest/config.js +++ b/src/dev/jest/config.js @@ -17,9 +17,8 @@ * under the License. */ -import { RESERVED_DIR_JEST_INTEGRATION_TESTS } from '../constants'; - export default { + preset: '@kbn/test', rootDir: '../../..', roots: [ '/src/plugins', @@ -51,53 +50,5 @@ export default { '!packages/kbn-ui-framework/src/services/index.js', '!packages/kbn-ui-framework/src/services/**/*/index.js', ], - moduleNameMapper: { - '@elastic/eui$': '/node_modules/@elastic/eui/test-env', - '@elastic/eui/lib/(.*)?': '/node_modules/@elastic/eui/test-env/$1', - '^src/plugins/(.*)': '/src/plugins/$1', - '^test_utils/(.*)': '/src/test_utils/public/$1', - '^fixtures/(.*)': '/src/fixtures/$1', - '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': - '/src/dev/jest/mocks/file_mock.js', - '\\.(css|less|scss)$': '/src/dev/jest/mocks/style_mock.js', - '\\.ace\\.worker.js$': '/src/dev/jest/mocks/worker_module_mock.js', - '\\.editor\\.worker.js$': '/src/dev/jest/mocks/worker_module_mock.js', - '^(!!)?file-loader!': '/src/dev/jest/mocks/file_mock.js', - }, - setupFiles: [ - '/src/dev/jest/setup/babel_polyfill.js', - '/src/dev/jest/setup/polyfills.js', - '/src/dev/jest/setup/enzyme.js', - ], - setupFilesAfterEnv: [ - '/src/dev/jest/setup/mocks.js', - '/src/dev/jest/setup/react_testing_library.js', - ], - coverageDirectory: '/target/kibana-coverage/jest', - coverageReporters: !!process.env.CODE_COVERAGE ? ['json'] : ['html', 'text'], - moduleFileExtensions: ['js', 'mjs', 'json', 'ts', 'tsx', 'node'], - modulePathIgnorePatterns: ['__fixtures__/', 'target/'], - testEnvironment: 'jest-environment-jsdom-thirteen', - testMatch: ['**/*.test.{js,mjs,ts,tsx}'], - testPathIgnorePatterns: [ - '/packages/kbn-ui-framework/(dist|doc_site|generator-kui)/', - '/packages/kbn-pm/dist/', - `${RESERVED_DIR_JEST_INTEGRATION_TESTS}/`, - ], - transform: { - '^.+\\.(js|tsx?)$': '/src/dev/jest/babel_transform.js', - '^.+\\.txt?$': 'jest-raw-loader', - '^.+\\.html?$': 'jest-raw-loader', - }, - transformIgnorePatterns: [ - // ignore all node_modules except monaco-editor which requires babel transforms to handle dynamic import() - // since ESM modules are not natively supported in Jest yet (https://github.com/facebook/jest/issues/4842) - '[/\\\\]node_modules(?![\\/\\\\]monaco-editor)[/\\\\].+\\.js$', - 'packages/kbn-pm/dist/index.js', - ], - snapshotSerializers: [ - '/src/plugins/kibana_react/public/util/test_helpers/react_mount_serializer.ts', - '/node_modules/enzyme-to-json/serializer', - ], - reporters: ['default', '/packages/kbn-test/target/jest/junit_reporter'], + testRunner: 'jasmine2', }; diff --git a/src/dev/precommit_hook/casing_check_config.js b/src/dev/precommit_hook/casing_check_config.js index 94ebc53b17ec1..d859c7e45fa20 100644 --- a/src/dev/precommit_hook/casing_check_config.js +++ b/src/dev/precommit_hook/casing_check_config.js @@ -49,6 +49,7 @@ export const IGNORE_FILE_GLOBS = [ 'Dockerfile*', 'vars/*', '.ci/pipeline-library/**/*', + 'packages/kbn-test/jest-preset.js', // filename must match language code which requires capital letters '**/translations/*.json', diff --git a/src/plugins/advanced_settings/public/component_registry/page_footer/page_footer.test.tsx b/src/plugins/advanced_settings/public/component_registry/page_footer/page_footer.test.tsx index cde2f47e7c180..6d63789b367b8 100644 --- a/src/plugins/advanced_settings/public/component_registry/page_footer/page_footer.test.tsx +++ b/src/plugins/advanced_settings/public/component_registry/page_footer/page_footer.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider } from '@kbn/test/jest'; import { PageFooter } from './page_footer'; diff --git a/src/plugins/advanced_settings/public/component_registry/page_subtitle/page_subtitle.test.tsx b/src/plugins/advanced_settings/public/component_registry/page_subtitle/page_subtitle.test.tsx index 0703706a50101..1b50bce36bf76 100644 --- a/src/plugins/advanced_settings/public/component_registry/page_subtitle/page_subtitle.test.tsx +++ b/src/plugins/advanced_settings/public/component_registry/page_subtitle/page_subtitle.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider } from '@kbn/test/jest'; import { PageSubtitle } from './page_subtitle'; diff --git a/src/plugins/advanced_settings/public/component_registry/page_title/page_title.test.tsx b/src/plugins/advanced_settings/public/component_registry/page_title/page_title.test.tsx index 54244909a668a..ff6211d960979 100644 --- a/src/plugins/advanced_settings/public/component_registry/page_title/page_title.test.tsx +++ b/src/plugins/advanced_settings/public/component_registry/page_title/page_title.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider } from '@kbn/test/jest'; import { PageTitle } from './page_title'; diff --git a/src/plugins/advanced_settings/public/management_app/advanced_settings.test.tsx b/src/plugins/advanced_settings/public/management_app/advanced_settings.test.tsx index 68a21c6a1587c..03a6fc1d30305 100644 --- a/src/plugins/advanced_settings/public/management_app/advanced_settings.test.tsx +++ b/src/plugins/advanced_settings/public/management_app/advanced_settings.test.tsx @@ -20,7 +20,7 @@ import React from 'react'; import { Observable } from 'rxjs'; import { ReactWrapper } from 'enzyme'; -import { mountWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { mountWithI18nProvider } from '@kbn/test/jest'; import dedent from 'dedent'; import { PublicUiSettingsParams, diff --git a/src/plugins/advanced_settings/public/management_app/components/field/field.test.tsx b/src/plugins/advanced_settings/public/management_app/components/field/field.test.tsx index 5b33b0e0ea120..d9b63f2e5334f 100644 --- a/src/plugins/advanced_settings/public/management_app/components/field/field.test.tsx +++ b/src/plugins/advanced_settings/public/management_app/components/field/field.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { I18nProvider } from '@kbn/i18n/react'; -import { shallowWithI18nProvider, mountWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider, mountWithI18nProvider } from '@kbn/test/jest'; import { mount, ReactWrapper } from 'enzyme'; import { FieldSetting } from '../../types'; import { UiSettingsType, StringValidation } from '../../../../../../core/public'; diff --git a/src/plugins/advanced_settings/public/management_app/components/form/form.test.tsx b/src/plugins/advanced_settings/public/management_app/components/form/form.test.tsx index a691af4a22bef..f7461242220d8 100644 --- a/src/plugins/advanced_settings/public/management_app/components/form/form.test.tsx +++ b/src/plugins/advanced_settings/public/management_app/components/form/form.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider, mountWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider, mountWithI18nProvider } from '@kbn/test/jest'; import { UiSettingsType } from '../../../../../../core/public'; import { findTestSubject } from '@elastic/eui/lib/test'; diff --git a/src/plugins/advanced_settings/public/management_app/components/search/search.test.tsx b/src/plugins/advanced_settings/public/management_app/components/search/search.test.tsx index 01f54cce60319..58a31c3960f5b 100644 --- a/src/plugins/advanced_settings/public/management_app/components/search/search.test.tsx +++ b/src/plugins/advanced_settings/public/management_app/components/search/search.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider, mountWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider, mountWithI18nProvider } from '@kbn/test/jest'; import { findTestSubject } from '@elastic/eui/lib/test'; diff --git a/src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.test.tsx b/src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.test.tsx index 3e188ce591e9a..bb9f0a80e344f 100644 --- a/src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.test.tsx +++ b/src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.test.tsx @@ -27,7 +27,7 @@ import * as sinon from 'sinon'; import { serviceContextMock } from '../../../../contexts/services_context.mock'; -import { nextTick } from 'test_utils/enzyme_helpers'; +import { nextTick } from '@kbn/test/jest'; import { ServicesContextProvider, EditorContextProvider, diff --git a/src/plugins/dashboard/common/migrate_to_730_panels.ts b/src/plugins/dashboard/common/migrate_to_730_panels.ts index d870e3c87d6ab..163f4242d12e6 100644 --- a/src/plugins/dashboard/common/migrate_to_730_panels.ts +++ b/src/plugins/dashboard/common/migrate_to_730_panels.ts @@ -17,7 +17,7 @@ * under the License. */ import { i18n } from '@kbn/i18n'; -import semver from 'semver'; +import semverSatisfies from 'semver/functions/satisfies'; import uuid from 'uuid'; import { GridData, @@ -60,23 +60,23 @@ function isPre61Panel( } function is61Panel(panel: unknown | RawSavedDashboardPanel610): panel is RawSavedDashboardPanel610 { - return semver.satisfies((panel as RawSavedDashboardPanel610).version, '6.1.x'); + return semverSatisfies((panel as RawSavedDashboardPanel610).version, '6.1.x'); } function is62Panel(panel: unknown | RawSavedDashboardPanel620): panel is RawSavedDashboardPanel620 { - return semver.satisfies((panel as RawSavedDashboardPanel620).version, '6.2.x'); + return semverSatisfies((panel as RawSavedDashboardPanel620).version, '6.2.x'); } function is63Panel(panel: unknown | RawSavedDashboardPanel630): panel is RawSavedDashboardPanel630 { - return semver.satisfies((panel as RawSavedDashboardPanel630).version, '6.3.x'); + return semverSatisfies((panel as RawSavedDashboardPanel630).version, '6.3.x'); } function is640To720Panel( panel: unknown | RawSavedDashboardPanel640To720 ): panel is RawSavedDashboardPanel640To720 { return ( - semver.satisfies((panel as RawSavedDashboardPanel630).version, '>6.3') && - semver.satisfies((panel as RawSavedDashboardPanel630).version, '<7.3') + semverSatisfies((panel as RawSavedDashboardPanel630).version, '>6.3') && + semverSatisfies((panel as RawSavedDashboardPanel630).version, '<7.3') ); } diff --git a/src/plugins/dashboard/public/application/actions/library_notification_popover.test.tsx b/src/plugins/dashboard/public/application/actions/library_notification_popover.test.tsx index c6f223fa45c23..22795a4cbf9e3 100644 --- a/src/plugins/dashboard/public/application/actions/library_notification_popover.test.tsx +++ b/src/plugins/dashboard/public/application/actions/library_notification_popover.test.tsx @@ -20,7 +20,7 @@ import React from 'react'; import { DashboardContainer } from '..'; import { isErrorEmbeddable } from '../../embeddable_plugin'; -import { mountWithIntl } from '../../../../../test_utils/public/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { embeddablePluginMock } from '../../../../embeddable/public/mocks'; import { getSampleDashboardInput } from '../test_helpers'; import { diff --git a/src/plugins/dashboard/public/application/dashboard_empty_screen.test.tsx b/src/plugins/dashboard/public/application/dashboard_empty_screen.test.tsx index 0a49e524d3350..c2162a931daf8 100644 --- a/src/plugins/dashboard/public/application/dashboard_empty_screen.test.tsx +++ b/src/plugins/dashboard/public/application/dashboard_empty_screen.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { DashboardEmptyScreen, DashboardEmptyScreenProps } from './dashboard_empty_screen'; import { findTestSubject } from '@elastic/eui/lib/test'; import { coreMock } from '../../../../core/public/mocks'; diff --git a/src/plugins/dashboard/public/application/embeddable/dashboard_container.test.tsx b/src/plugins/dashboard/public/application/embeddable/dashboard_container.test.tsx index caa8321d7b8b2..9c337ef1259a9 100644 --- a/src/plugins/dashboard/public/application/embeddable/dashboard_container.test.tsx +++ b/src/plugins/dashboard/public/application/embeddable/dashboard_container.test.tsx @@ -17,7 +17,7 @@ * under the License. */ -import { nextTick } from 'test_utils/enzyme_helpers'; +import { nextTick } from '@kbn/test/jest'; import { isErrorEmbeddable, ViewMode } from '../../embeddable_plugin'; import { DashboardContainer, DashboardContainerOptions } from './dashboard_container'; import { getSampleDashboardInput, getSampleDashboardPanel } from '../test_helpers'; diff --git a/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid.test.tsx b/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid.test.tsx index 42d8f92de80aa..5c4b976b15225 100644 --- a/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid.test.tsx +++ b/src/plugins/dashboard/public/application/embeddable/grid/dashboard_grid.test.tsx @@ -21,7 +21,7 @@ import sizeMe from 'react-sizeme'; import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { skip } from 'rxjs/operators'; import { DashboardGrid, DashboardGridProps } from './dashboard_grid'; import { DashboardContainer, DashboardContainerOptions } from '../dashboard_container'; diff --git a/src/plugins/dashboard/public/application/embeddable/viewport/dashboard_viewport.test.tsx b/src/plugins/dashboard/public/application/embeddable/viewport/dashboard_viewport.test.tsx index 60395bce678c2..94d0f8890c494 100644 --- a/src/plugins/dashboard/public/application/embeddable/viewport/dashboard_viewport.test.tsx +++ b/src/plugins/dashboard/public/application/embeddable/viewport/dashboard_viewport.test.tsx @@ -22,7 +22,7 @@ import React from 'react'; import { skip } from 'rxjs/operators'; import { mount } from 'enzyme'; import { I18nProvider } from '@kbn/i18n/react'; -import { nextTick } from 'test_utils/enzyme_helpers'; +import { nextTick } from '@kbn/test/jest'; import { DashboardViewport, DashboardViewportProps } from './dashboard_viewport'; import { DashboardContainer, DashboardContainerOptions } from '../dashboard_container'; import { getSampleDashboardInput } from '../../test_helpers'; diff --git a/src/plugins/dashboard/public/application/lib/migrate_app_state.ts b/src/plugins/dashboard/public/application/lib/migrate_app_state.ts index e2b32b1dbdad0..b5b96e4ced678 100644 --- a/src/plugins/dashboard/public/application/lib/migrate_app_state.ts +++ b/src/plugins/dashboard/public/application/lib/migrate_app_state.ts @@ -17,7 +17,7 @@ * under the License. */ -import semver from 'semver'; +import semverSatisfies from 'semver/functions/satisfies'; import { i18n } from '@kbn/i18n'; import { METRIC_TYPE } from '@kbn/analytics'; @@ -68,7 +68,7 @@ export function migrateAppState( usageCollection.reportUiStats('DashboardPanelVersionInUrl', METRIC_TYPE.LOADED, `${version}`); } - return semver.satisfies(version, '<7.3'); + return semverSatisfies(version, '<7.3'); }); if (panelNeedsMigration) { diff --git a/src/plugins/dashboard/public/application/tests/dashboard_container.test.tsx b/src/plugins/dashboard/public/application/tests/dashboard_container.test.tsx index 24075e0a634ba..f8f7226d23454 100644 --- a/src/plugins/dashboard/public/application/tests/dashboard_container.test.tsx +++ b/src/plugins/dashboard/public/application/tests/dashboard_container.test.tsx @@ -20,7 +20,7 @@ import { findTestSubject } from '@elastic/eui/lib/test'; import React from 'react'; import { mount } from 'enzyme'; -import { nextTick } from 'test_utils/enzyme_helpers'; +import { nextTick } from '@kbn/test/jest'; import { I18nProvider } from '@kbn/i18n/react'; import { ViewMode, CONTEXT_MENU_TRIGGER, EmbeddablePanel } from '../../embeddable_plugin'; import { DashboardContainer, DashboardContainerOptions } from '../embeddable/dashboard_container'; diff --git a/src/plugins/dashboard/public/application/top_nav/clone_modal.test.js b/src/plugins/dashboard/public/application/top_nav/clone_modal.test.js index ac3bf7ed2d794..a696e8f2265dc 100644 --- a/src/plugins/dashboard/public/application/top_nav/clone_modal.test.js +++ b/src/plugins/dashboard/public/application/top_nav/clone_modal.test.js @@ -19,7 +19,7 @@ import React from 'react'; import sinon from 'sinon'; -import { shallowWithI18nProvider, mountWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider, mountWithI18nProvider } from '@kbn/test/jest'; import { findTestSubject } from '@elastic/eui/lib/test'; import { DashboardCloneModal } from './clone_modal'; diff --git a/src/plugins/dashboard/public/application/top_nav/save_modal.test.js b/src/plugins/dashboard/public/application/top_nav/save_modal.test.js index 3eb7cb995ab19..ea12c55aecee9 100644 --- a/src/plugins/dashboard/public/application/top_nav/save_modal.test.js +++ b/src/plugins/dashboard/public/application/top_nav/save_modal.test.js @@ -18,7 +18,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider } from '@kbn/test/jest'; jest.mock('../../../../saved_objects/public', () => ({ SavedObjectSaveModal: () => null, diff --git a/src/plugins/data/public/query/query_string/query_string_manager.test.ts b/src/plugins/data/public/query/query_string/query_string_manager.test.ts index aa1556480452a..5f4315b19648f 100644 --- a/src/plugins/data/public/query/query_string/query_string_manager.test.ts +++ b/src/plugins/data/public/query/query_string/query_string_manager.test.ts @@ -19,7 +19,7 @@ import { QueryStringManager } from './query_string_manager'; import { Storage } from '../../../../kibana_utils/public/storage'; -import { StubBrowserStorage } from 'test_utils/stub_browser_storage'; +import { StubBrowserStorage } from '@kbn/test/jest'; import { coreMock } from '../../../../../core/public/mocks'; import { Query } from '../../../common/query'; diff --git a/src/plugins/data/public/query/state_sync/connect_to_query_state.test.ts b/src/plugins/data/public/query/state_sync/connect_to_query_state.test.ts index 2053e0b94b21a..c970dd521c142 100644 --- a/src/plugins/data/public/query/state_sync/connect_to_query_state.test.ts +++ b/src/plugins/data/public/query/state_sync/connect_to_query_state.test.ts @@ -24,7 +24,7 @@ import { Filter, FilterStateStore, UI_SETTINGS } from '../../../common'; import { coreMock } from '../../../../../core/public/mocks'; import { BaseStateContainer, createStateContainer, Storage } from '../../../../kibana_utils/public'; import { QueryService, QueryStart } from '../query_service'; -import { StubBrowserStorage } from '../../../../../test_utils/public/stub_browser_storage'; +import { StubBrowserStorage } from '@kbn/test/jest'; import { connectToQueryState } from './connect_to_query_state'; import { TimefilterContract } from '../timefilter'; import { QueryState } from './types'; diff --git a/src/plugins/data/public/query/state_sync/sync_state_with_url.test.ts b/src/plugins/data/public/query/state_sync/sync_state_with_url.test.ts index 0b4a3f663eb6b..47af09bfc7c0e 100644 --- a/src/plugins/data/public/query/state_sync/sync_state_with_url.test.ts +++ b/src/plugins/data/public/query/state_sync/sync_state_with_url.test.ts @@ -29,7 +29,7 @@ import { Storage, } from '../../../../kibana_utils/public'; import { QueryService, QueryStart } from '../query_service'; -import { StubBrowserStorage } from 'test_utils/stub_browser_storage'; +import { StubBrowserStorage } from '@kbn/test/jest'; import { TimefilterContract } from '../timefilter'; import { syncQueryStateWithUrl } from './sync_state_with_url'; import { QueryState } from './types'; diff --git a/src/plugins/data/public/ui/query_string_input/language_switcher.test.tsx b/src/plugins/data/public/ui/query_string_input/language_switcher.test.tsx index f8f576c4b6e97..bcc35b4f2971d 100644 --- a/src/plugins/data/public/ui/query_string_input/language_switcher.test.tsx +++ b/src/plugins/data/public/ui/query_string_input/language_switcher.test.tsx @@ -21,7 +21,7 @@ import React from 'react'; import { QueryLanguageSwitcher } from './language_switcher'; import { KibanaContextProvider } from 'src/plugins/kibana_react/public'; import { coreMock } from '../../../../../core/public/mocks'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { EuiButtonEmpty, EuiPopover } from '@elastic/eui'; const startMock = coreMock.createStart(); diff --git a/src/plugins/data/public/ui/query_string_input/no_data_popover.test.tsx b/src/plugins/data/public/ui/query_string_input/no_data_popover.test.tsx index 27f924d98e6eb..e46b4918db040 100644 --- a/src/plugins/data/public/ui/query_string_input/no_data_popover.test.tsx +++ b/src/plugins/data/public/ui/query_string_input/no_data_popover.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { mountWithIntl as mount } from 'test_utils/enzyme_helpers'; +import { mountWithIntl as mount } from '@kbn/test/jest'; import { NoDataPopover } from './no_data_popover'; import { EuiTourStep } from '@elastic/eui'; import { act } from 'react-dom/test-utils'; diff --git a/src/plugins/data/public/ui/shard_failure_modal/shard_failure_description.test.tsx b/src/plugins/data/public/ui/shard_failure_modal/shard_failure_description.test.tsx index d40770fb74ef1..c509c8ffa25d6 100644 --- a/src/plugins/data/public/ui/shard_failure_modal/shard_failure_description.test.tsx +++ b/src/plugins/data/public/ui/shard_failure_modal/shard_failure_description.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { ShardFailureDescription } from './shard_failure_description'; import { shardFailureResponse } from './__mocks__/shard_failure_response'; import { ShardFailure } from './shard_failure_types'; diff --git a/src/plugins/data/public/ui/shard_failure_modal/shard_failure_modal.test.tsx b/src/plugins/data/public/ui/shard_failure_modal/shard_failure_modal.test.tsx index 245ff8b7bdbfc..d740e6c2a9617 100644 --- a/src/plugins/data/public/ui/shard_failure_modal/shard_failure_modal.test.tsx +++ b/src/plugins/data/public/ui/shard_failure_modal/shard_failure_modal.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { ShardFailureModal } from './shard_failure_modal'; import { shardFailureRequest } from './__mocks__/shard_failure_request'; import { shardFailureResponse } from './__mocks__/shard_failure_response'; diff --git a/src/plugins/data/public/ui/shard_failure_modal/shard_failure_open_modal_button.test.tsx b/src/plugins/data/public/ui/shard_failure_modal/shard_failure_open_modal_button.test.tsx index 7a4ca80e6192f..8878e90073d8e 100644 --- a/src/plugins/data/public/ui/shard_failure_modal/shard_failure_open_modal_button.test.tsx +++ b/src/plugins/data/public/ui/shard_failure_modal/shard_failure_open_modal_button.test.tsx @@ -18,7 +18,7 @@ */ import { openModal } from './shard_failure_open_modal_button.test.mocks'; import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import ShardFailureOpenModalButton from './shard_failure_open_modal_button'; import { shardFailureRequest } from './__mocks__/shard_failure_request'; import { shardFailureResponse } from './__mocks__/shard_failure_response'; diff --git a/src/plugins/data/public/ui/shard_failure_modal/shard_failure_table.test.tsx b/src/plugins/data/public/ui/shard_failure_modal/shard_failure_table.test.tsx index 22478ebd57393..ca277e304a8c2 100644 --- a/src/plugins/data/public/ui/shard_failure_modal/shard_failure_table.test.tsx +++ b/src/plugins/data/public/ui/shard_failure_modal/shard_failure_table.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { ShardFailureTable } from './shard_failure_table'; import { shardFailureResponse } from './__mocks__/shard_failure_response'; import { ShardFailure } from './shard_failure_types'; diff --git a/src/plugins/discover/public/application/angular/context/components/action_bar/action_bar.test.tsx b/src/plugins/discover/public/application/angular/context/components/action_bar/action_bar.test.tsx index ab7adba193d87..bddd399701984 100644 --- a/src/plugins/discover/public/application/angular/context/components/action_bar/action_bar.test.tsx +++ b/src/plugins/discover/public/application/angular/context/components/action_bar/action_bar.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { ActionBar, ActionBarProps } from './action_bar'; import { findTestSubject } from '@elastic/eui/lib/test'; import { MAX_CONTEXT_SIZE, MIN_CONTEXT_SIZE } from '../../query_parameters/constants'; diff --git a/src/plugins/discover/public/application/angular/doc_table/components/pager/tool_bar_pager_buttons.test.tsx b/src/plugins/discover/public/application/angular/doc_table/components/pager/tool_bar_pager_buttons.test.tsx index 2cd829d89f78e..f591386e9047d 100644 --- a/src/plugins/discover/public/application/angular/doc_table/components/pager/tool_bar_pager_buttons.test.tsx +++ b/src/plugins/discover/public/application/angular/doc_table/components/pager/tool_bar_pager_buttons.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { ToolBarPagerButtons } from './tool_bar_pager_buttons'; import { findTestSubject } from '@elastic/eui/lib/test'; diff --git a/src/plugins/discover/public/application/angular/doc_table/components/pager/tool_bar_pager_text.test.tsx b/src/plugins/discover/public/application/angular/doc_table/components/pager/tool_bar_pager_text.test.tsx index 4085c22057c84..e63507b0d6e21 100644 --- a/src/plugins/discover/public/application/angular/doc_table/components/pager/tool_bar_pager_text.test.tsx +++ b/src/plugins/discover/public/application/angular/doc_table/components/pager/tool_bar_pager_text.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { renderWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl } from '@kbn/test/jest'; import { ToolBarPagerText } from './tool_bar_pager_text'; test('it renders ToolBarPagerText without crashing', () => { diff --git a/src/plugins/discover/public/application/angular/doc_table/components/table_header/table_header.test.tsx b/src/plugins/discover/public/application/angular/doc_table/components/table_header/table_header.test.tsx index 224e249a274cd..3d5698e2e0d96 100644 --- a/src/plugins/discover/public/application/angular/doc_table/components/table_header/table_header.test.tsx +++ b/src/plugins/discover/public/application/angular/doc_table/components/table_header/table_header.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { TableHeader } from './table_header'; import { findTestSubject } from '@elastic/eui/lib/test'; import { SortOrder } from './helpers'; diff --git a/src/plugins/discover/public/application/components/context_app/context_app_legacy.test.tsx b/src/plugins/discover/public/application/components/context_app/context_app_legacy.test.tsx index 77dd0a6d647c6..f76e0178e98b0 100644 --- a/src/plugins/discover/public/application/components/context_app/context_app_legacy.test.tsx +++ b/src/plugins/discover/public/application/components/context_app/context_app_legacy.test.tsx @@ -20,7 +20,7 @@ import React from 'react'; import { ContextAppLegacy } from './context_app_legacy'; import { IIndexPattern } from '../../../../../data/common/index_patterns'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { DocTableLegacy } from '../../angular/doc_table/create_doc_table_react'; import { findTestSubject } from '@elastic/eui/lib/test'; import { ActionBar } from '../../angular/context/components/action_bar/action_bar'; diff --git a/src/plugins/discover/public/application/components/context_error_message/context_error_message.test.tsx b/src/plugins/discover/public/application/components/context_error_message/context_error_message.test.tsx index 1cc8247957512..a99d5c04f47eb 100644 --- a/src/plugins/discover/public/application/components/context_error_message/context_error_message.test.tsx +++ b/src/plugins/discover/public/application/components/context_error_message/context_error_message.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { ReactWrapper } from 'enzyme'; import { ContextErrorMessage } from './context_error_message'; // @ts-ignore diff --git a/src/plugins/discover/public/application/components/doc/doc.test.tsx b/src/plugins/discover/public/application/components/doc/doc.test.tsx index d562291db46ac..9e22f481a95a5 100644 --- a/src/plugins/discover/public/application/components/doc/doc.test.tsx +++ b/src/plugins/discover/public/application/components/doc/doc.test.tsx @@ -19,7 +19,7 @@ import { throwError, of } from 'rxjs'; import React from 'react'; import { act } from 'react-dom/test-utils'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { ReactWrapper } from 'enzyme'; import { findTestSubject } from '@elastic/eui/lib/test'; import { Doc, DocProps } from './doc'; diff --git a/src/plugins/discover/public/application/components/hits_counter/hits_counter.test.tsx b/src/plugins/discover/public/application/components/hits_counter/hits_counter.test.tsx index c2eb4f08cf549..534947ea72148 100644 --- a/src/plugins/discover/public/application/components/hits_counter/hits_counter.test.tsx +++ b/src/plugins/discover/public/application/components/hits_counter/hits_counter.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { ReactWrapper } from 'enzyme'; import { HitsCounter, HitsCounterProps } from './hits_counter'; import { findTestSubject } from '@elastic/eui/lib/test'; diff --git a/src/plugins/discover/public/application/components/loading_spinner/loading_spinner.test.tsx b/src/plugins/discover/public/application/components/loading_spinner/loading_spinner.test.tsx index e996da5fe0e3c..845ece0455830 100644 --- a/src/plugins/discover/public/application/components/loading_spinner/loading_spinner.test.tsx +++ b/src/plugins/discover/public/application/components/loading_spinner/loading_spinner.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { ReactWrapper } from 'enzyme'; import { LoadingSpinner } from './loading_spinner'; import { findTestSubject } from '@elastic/eui/lib/test'; diff --git a/src/plugins/discover/public/application/components/no_results/no_results.test.tsx b/src/plugins/discover/public/application/components/no_results/no_results.test.tsx index dde75236eb15e..4b17a5aa797d0 100644 --- a/src/plugins/discover/public/application/components/no_results/no_results.test.tsx +++ b/src/plugins/discover/public/application/components/no_results/no_results.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { findTestSubject } from '@elastic/eui/lib/test'; import { DiscoverNoResults, DiscoverNoResultsProps } from './no_results'; diff --git a/src/plugins/discover/public/application/components/sidebar/discover_field.test.tsx b/src/plugins/discover/public/application/components/sidebar/discover_field.test.tsx index 8ab296bf1af4f..02ed17cd01f07 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_field.test.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_field.test.tsx @@ -21,7 +21,7 @@ import React from 'react'; import { findTestSubject } from '@elastic/eui/lib/test'; // @ts-ignore import stubbedLogstashFields from 'fixtures/logstash_fields'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { DiscoverField } from './discover_field'; import { coreMock } from '../../../../../../core/public/mocks'; import { IndexPatternField } from '../../../../../data/public'; diff --git a/src/plugins/discover/public/application/components/sidebar/discover_field_details.test.tsx b/src/plugins/discover/public/application/components/sidebar/discover_field_details.test.tsx index 2cf626d182eeb..8607873b98d3d 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_field_details.test.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_field_details.test.tsx @@ -21,7 +21,7 @@ import React from 'react'; import { findTestSubject } from '@elastic/eui/lib/test'; // @ts-ignore import stubbedLogstashFields from 'fixtures/logstash_fields'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { DiscoverFieldDetails } from './discover_field_details'; import { coreMock } from '../../../../../../core/public/mocks'; import { IndexPatternField } from '../../../../../data/public'; diff --git a/src/plugins/discover/public/application/components/sidebar/discover_field_search.test.tsx b/src/plugins/discover/public/application/components/sidebar/discover_field_search.test.tsx index 625d6833406eb..527be8cff9f0c 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_field_search.test.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_field_search.test.tsx @@ -18,7 +18,7 @@ */ import React, { EventHandler, MouseEvent as ReactMouseEvent } from 'react'; import { act } from 'react-dom/test-utils'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { findTestSubject } from '@elastic/eui/lib/test'; import { DiscoverFieldSearch, Props } from './discover_field_search'; import { EuiButtonGroupProps, EuiPopover } from '@elastic/eui'; diff --git a/src/plugins/discover/public/application/components/sidebar/discover_index_pattern.test.tsx b/src/plugins/discover/public/application/components/sidebar/discover_index_pattern.test.tsx index a1b231c2d4479..9109262e639da 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_index_pattern.test.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_index_pattern.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { shallowWithIntl as shallow } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl as shallow } from '@kbn/test/jest'; // @ts-ignore import { ShallowWrapper } from 'enzyme'; diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.test.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.test.tsx index 3d2c20109a264..7504d181d82b2 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.test.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.test.tsx @@ -24,7 +24,7 @@ import { findTestSubject } from '@elastic/eui/lib/test'; import realHits from 'fixtures/real_hits.js'; // @ts-ignore import stubbedLogstashFields from 'fixtures/logstash_fields'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { DiscoverSidebar, DiscoverSidebarProps } from './discover_sidebar'; import { coreMock } from '../../../../../../core/public/mocks'; diff --git a/src/plugins/discover/public/application/components/skip_bottom_button/skip_bottom_button.test.tsx b/src/plugins/discover/public/application/components/skip_bottom_button/skip_bottom_button.test.tsx index fdb0ff973dcf0..4fce196ed0b19 100644 --- a/src/plugins/discover/public/application/components/skip_bottom_button/skip_bottom_button.test.tsx +++ b/src/plugins/discover/public/application/components/skip_bottom_button/skip_bottom_button.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { ReactWrapper } from 'enzyme'; import { SkipBottomButton, SkipBottomButtonProps } from './skip_bottom_button'; diff --git a/src/plugins/discover/public/application/components/timechart_header/timechart_header.test.tsx b/src/plugins/discover/public/application/components/timechart_header/timechart_header.test.tsx index 7889b05a88415..39e7bfdc864ac 100644 --- a/src/plugins/discover/public/application/components/timechart_header/timechart_header.test.tsx +++ b/src/plugins/discover/public/application/components/timechart_header/timechart_header.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { ReactWrapper } from 'enzyme'; import { TimechartHeader, TimechartHeaderProps } from './timechart_header'; import { EuiIconTip } from '@elastic/eui'; diff --git a/src/plugins/embeddable/public/lib/containers/embeddable_child_panel.test.tsx b/src/plugins/embeddable/public/lib/containers/embeddable_child_panel.test.tsx index aa0b504b63fbe..7ef605c7dab70 100644 --- a/src/plugins/embeddable/public/lib/containers/embeddable_child_panel.test.tsx +++ b/src/plugins/embeddable/public/lib/containers/embeddable_child_panel.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { nextTick } from 'test_utils/enzyme_helpers'; +import { nextTick } from '@kbn/test/jest'; import { EmbeddableChildPanel } from './embeddable_child_panel'; import { CONTACT_CARD_EMBEDDABLE } from '../test_samples/embeddables/contact_card/contact_card_embeddable_factory'; import { SlowContactCardEmbeddableFactory } from '../test_samples/embeddables/contact_card/slow_contact_card_embeddable_factory'; diff --git a/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx b/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx index c717e4370231e..2104d93da9ad8 100644 --- a/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx +++ b/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { mount } from 'enzyme'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { findTestSubject } from '@elastic/eui/lib/test'; import { I18nProvider } from '@kbn/i18n/react'; diff --git a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.test.tsx b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.test.tsx index 95aee3d9cb335..7c65041e74d36 100644 --- a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.test.tsx +++ b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/add_panel_flyout.test.tsx @@ -27,7 +27,7 @@ import { import { HelloWorldContainer } from '../../../../test_samples/embeddables/hello_world_container'; import { ContactCardEmbeddable } from '../../../../test_samples/embeddables/contact_card/contact_card_embeddable'; import { ContainerInput } from '../../../../containers'; -import { mountWithIntl as mount } from 'test_utils/enzyme_helpers'; +import { mountWithIntl as mount } from '@kbn/test/jest'; import { ReactWrapper } from 'enzyme'; import { coreMock } from '../../../../../../../../core/public/mocks'; import { findTestSubject } from '@elastic/eui/lib/test'; diff --git a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/tests/saved_object_finder_create_new.test.tsx b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/tests/saved_object_finder_create_new.test.tsx index a4c80e1d86a80..9af4b80c7c885 100644 --- a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/tests/saved_object_finder_create_new.test.tsx +++ b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/add_panel/tests/saved_object_finder_create_new.test.tsx @@ -20,7 +20,7 @@ import React from 'react'; import { SavedObjectFinderCreateNew } from '../saved_object_finder_create_new'; import { shallow } from 'enzyme'; import { EuiButton, EuiContextMenuItem, EuiContextMenuPanel, EuiPopover } from '@elastic/eui'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; describe('SavedObjectFinderCreateNew', () => { test('renders correctly with no items', () => { diff --git a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/customize_title/customize_panel_action.test.ts b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/customize_title/customize_panel_action.test.ts index dbfa55a4e0f13..1ca62d2170b71 100644 --- a/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/customize_title/customize_panel_action.test.ts +++ b/src/plugins/embeddable/public/lib/panel/panel_header/panel_actions/customize_title/customize_panel_action.test.ts @@ -18,7 +18,7 @@ */ import { Container, isErrorEmbeddable } from '../../../..'; -import { nextTick } from 'test_utils/enzyme_helpers'; +import { nextTick } from '@kbn/test/jest'; import { CustomizePanelTitleAction } from './customize_panel_action'; import { ContactCardEmbeddable, diff --git a/src/plugins/embeddable/public/tests/customize_panel_modal.test.tsx b/src/plugins/embeddable/public/tests/customize_panel_modal.test.tsx index 24d94020af4dc..4014d4aa83735 100644 --- a/src/plugins/embeddable/public/tests/customize_panel_modal.test.tsx +++ b/src/plugins/embeddable/public/tests/customize_panel_modal.test.tsx @@ -35,7 +35,7 @@ import { testPlugin } from './test_plugin'; import { CustomizePanelModal } from '../lib/panel/panel_header/panel_actions/customize_title/customize_panel_modal'; import { EmbeddableStart } from '../plugin'; import { createEmbeddablePanelMock } from '../mocks'; -import { mountWithIntl } from '../../../../test_utils/public/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; let api: EmbeddableStart; let container: Container; diff --git a/src/plugins/es_ui_shared/static/forms/hook_form_lib/shared_imports.ts b/src/plugins/es_ui_shared/static/forms/hook_form_lib/shared_imports.ts index f9f718b8b2f33..734bede78e033 100644 --- a/src/plugins/es_ui_shared/static/forms/hook_form_lib/shared_imports.ts +++ b/src/plugins/es_ui_shared/static/forms/hook_form_lib/shared_imports.ts @@ -17,6 +17,6 @@ * under the License. */ -export { registerTestBed, TestBed } from '../../../../../test_utils/public/testbed'; +export { registerTestBed, TestBed } from '@kbn/test/jest'; -export { getRandomString } from '../../../../../test_utils/public/helpers'; +export { getRandomString } from '@kbn/test/jest'; diff --git a/src/plugins/home/public/application/components/add_data/add_data.test.tsx b/src/plugins/home/public/application/components/add_data/add_data.test.tsx index 9ba554dd2c222..e9ac686df83d1 100644 --- a/src/plugins/home/public/application/components/add_data/add_data.test.tsx +++ b/src/plugins/home/public/application/components/add_data/add_data.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { AddData } from './add_data'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; jest.mock('../app_navigation_handler', () => { return { diff --git a/src/plugins/home/public/application/components/manage_data/manage_data.test.tsx b/src/plugins/home/public/application/components/manage_data/manage_data.test.tsx index 69c7ec46a7a2c..25e8c1306bced 100644 --- a/src/plugins/home/public/application/components/manage_data/manage_data.test.tsx +++ b/src/plugins/home/public/application/components/manage_data/manage_data.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { ManageData } from './manage_data'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; jest.mock('../app_navigation_handler', () => { return { diff --git a/src/plugins/home/public/application/components/recently_accessed.test.js b/src/plugins/home/public/application/components/recently_accessed.test.js index f3ce6eb17e632..2b8a5f1c96d01 100644 --- a/src/plugins/home/public/application/components/recently_accessed.test.js +++ b/src/plugins/home/public/application/components/recently_accessed.test.js @@ -21,7 +21,7 @@ import React from 'react'; import { shallow } from 'enzyme'; import { RecentlyAccessed, NUM_LONG_LINKS } from './recently_accessed'; import { findTestSubject } from '@elastic/eui/lib/test'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; const createRecentlyAccessed = (length) => { const recentlyAccessed = []; diff --git a/src/plugins/home/public/application/components/tutorial/instruction_set.test.js b/src/plugins/home/public/application/components/tutorial/instruction_set.test.js index 6c9ce530f6b20..e446552fb4322 100644 --- a/src/plugins/home/public/application/components/tutorial/instruction_set.test.js +++ b/src/plugins/home/public/application/components/tutorial/instruction_set.test.js @@ -18,7 +18,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { InstructionSet } from './instruction_set'; import * as StatusCheckStates from './status_check_states'; diff --git a/src/plugins/home/public/application/components/tutorial/introduction.test.js b/src/plugins/home/public/application/components/tutorial/introduction.test.js index ae87bc6030c9a..bb81875e12021 100644 --- a/src/plugins/home/public/application/components/tutorial/introduction.test.js +++ b/src/plugins/home/public/application/components/tutorial/introduction.test.js @@ -18,7 +18,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { Introduction } from './introduction'; diff --git a/src/plugins/home/public/application/components/tutorial/saved_objects_installer.test.js b/src/plugins/home/public/application/components/tutorial/saved_objects_installer.test.js index e7b7d8ed1d7fd..77c625a226ac0 100644 --- a/src/plugins/home/public/application/components/tutorial/saved_objects_installer.test.js +++ b/src/plugins/home/public/application/components/tutorial/saved_objects_installer.test.js @@ -19,7 +19,7 @@ import React from 'react'; import { findTestSubject } from '@elastic/eui/lib/test'; -import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; import { SavedObjectsInstaller } from './saved_objects_installer'; diff --git a/src/plugins/home/public/application/components/tutorial/tutorial.test.js b/src/plugins/home/public/application/components/tutorial/tutorial.test.js index 65e11170e0e42..316d4a08384ea 100644 --- a/src/plugins/home/public/application/components/tutorial/tutorial.test.js +++ b/src/plugins/home/public/application/components/tutorial/tutorial.test.js @@ -18,7 +18,7 @@ */ import React from 'react'; -import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; import { Tutorial } from './tutorial'; diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.test.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.test.tsx index acc133a4dd649..a760e5918cea8 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.test.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_index_pattern/components/header/header.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { Header } from '../header'; -import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider } from '@kbn/test/jest'; describe('Header', () => { it('should render normally', () => { diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.test.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.test.tsx index ffb3779d47c89..612218fd711f3 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.test.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/advanced_options/advanced_options.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { AdvancedOptions } from '../advanced_options'; -import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider } from '@kbn/test/jest'; describe('AdvancedOptions', () => { it('should render normally', () => { diff --git a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.test.tsx b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.test.tsx index 8994ffd79b6e4..20a861809f4fd 100644 --- a/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.test.tsx +++ b/src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { TimeField } from '../time_field'; -import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider } from '@kbn/test/jest'; describe('TimeField', () => { it('should render normally', () => { diff --git a/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/color/color.test.tsx b/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/color/color.test.tsx index f13cb0975c8d2..9bcdcfde639c2 100644 --- a/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/color/color.test.tsx +++ b/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/color/color.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider } from '@kbn/test/jest'; import { FieldFormat } from 'src/plugins/data/public'; import { ColorFormatEditor } from './color'; diff --git a/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.test.tsx b/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.test.tsx index a8356923eb381..9fa9dda808f7b 100644 --- a/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.test.tsx +++ b/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider } from '../../../../../../../../../test_utils/public/enzyme_helpers'; +import { shallowWithI18nProvider } from '@kbn/test/jest'; import { StaticLookupFormatEditorFormatParams } from './static_lookup'; import { FieldFormat } from '../../../../../../../../data/public'; diff --git a/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/url/label_template_flyout.test.tsx b/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/url/label_template_flyout.test.tsx index 637b35911d369..8a42ed0bd0dbc 100644 --- a/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/url/label_template_flyout.test.tsx +++ b/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/url/label_template_flyout.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider } from '@kbn/test/jest'; import { LabelTemplateFlyout } from './label_template_flyout'; diff --git a/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/url/url_template_flyout.test.tsx b/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/url/url_template_flyout.test.tsx index d7e74bbec2bf7..db1a530863c50 100644 --- a/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/url/url_template_flyout.test.tsx +++ b/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/editors/url/url_template_flyout.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider } from '@kbn/test/jest'; import { UrlTemplateFlyout } from './url_template_flyout'; diff --git a/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/samples/samples.test.tsx b/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/samples/samples.test.tsx index 01f405e9aff1f..b244a4f728080 100644 --- a/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/samples/samples.test.tsx +++ b/src/plugins/index_pattern_management/public/components/field_editor/components/field_format_editor/samples/samples.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider } from '@kbn/test/jest'; import { FormatEditorSamples } from './samples'; diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx index 83eb803333afc..333bb73678362 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { EmptyIndexPatternPrompt } from '../empty_index_pattern_prompt'; -import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider } from '@kbn/test/jest'; describe('EmptyIndexPatternPrompt', () => { it('should render normally', () => { diff --git a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx index 9a4a04af0354e..23d11ffc7a671 100644 --- a/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx +++ b/src/plugins/index_pattern_management/public/components/index_pattern_table/empty_state/empty_state.test.tsx @@ -22,7 +22,7 @@ import { EmptyState } from '../empty_state'; import { shallow } from 'enzyme'; import sinon from 'sinon'; import { findTestSubject } from '@elastic/eui/lib/test'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { docLinksServiceMock } from '../../../../../../core/public/mocks'; import { MlCardState } from '../../../types'; diff --git a/src/plugins/input_control_vis/public/components/editor/controls_tab.test.tsx b/src/plugins/input_control_vis/public/components/editor/controls_tab.test.tsx index 0a7f6fc244a91..a85f98c7b89ba 100644 --- a/src/plugins/input_control_vis/public/components/editor/controls_tab.test.tsx +++ b/src/plugins/input_control_vis/public/components/editor/controls_tab.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; import { findTestSubject } from '@elastic/eui/lib/test'; import { getDepsMock, getIndexPatternMock } from '../../test_utils'; import { ControlsTab, ControlsTabUiProps } from './controls_tab'; diff --git a/src/plugins/input_control_vis/public/components/editor/list_control_editor.test.tsx b/src/plugins/input_control_vis/public/components/editor/list_control_editor.test.tsx index 0c0d94f0cf631..fa9f9222ab186 100644 --- a/src/plugins/input_control_vis/public/components/editor/list_control_editor.test.tsx +++ b/src/plugins/input_control_vis/public/components/editor/list_control_editor.test.tsx @@ -23,7 +23,7 @@ import { shallow } from 'enzyme'; import { findTestSubject } from '@elastic/eui/lib/test'; -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { getIndexPatternMock } from '../../test_utils/get_index_pattern_mock'; import { ListControlEditor } from './list_control_editor'; import { ControlParams } from '../../editor_utils'; diff --git a/src/plugins/input_control_vis/public/components/editor/options_tab.test.tsx b/src/plugins/input_control_vis/public/components/editor/options_tab.test.tsx index c53d7abc4d659..0f126e915a68c 100644 --- a/src/plugins/input_control_vis/public/components/editor/options_tab.test.tsx +++ b/src/plugins/input_control_vis/public/components/editor/options_tab.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { shallow } from 'enzyme'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { Vis } from '../../../../visualizations/public'; import { OptionsTab, OptionsTabProps } from './options_tab'; diff --git a/src/plugins/input_control_vis/public/components/editor/range_control_editor.test.tsx b/src/plugins/input_control_vis/public/components/editor/range_control_editor.test.tsx index 1ff03d555739e..b7afe45e8e0de 100644 --- a/src/plugins/input_control_vis/public/components/editor/range_control_editor.test.tsx +++ b/src/plugins/input_control_vis/public/components/editor/range_control_editor.test.tsx @@ -20,7 +20,7 @@ import React from 'react'; import { shallow } from 'enzyme'; import { SinonSpy, spy, assert } from 'sinon'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { findTestSubject } from '@elastic/eui/lib/test'; diff --git a/src/plugins/input_control_vis/public/components/vis/input_control_vis.test.tsx b/src/plugins/input_control_vis/public/components/vis/input_control_vis.test.tsx index 0b5f36acd2fc3..560daf14bd085 100644 --- a/src/plugins/input_control_vis/public/components/vis/input_control_vis.test.tsx +++ b/src/plugins/input_control_vis/public/components/vis/input_control_vis.test.tsx @@ -20,7 +20,7 @@ import React from 'react'; import sinon from 'sinon'; import { shallow } from 'enzyme'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { findTestSubject } from '@elastic/eui/lib/test'; import { InputControlVis } from './input_control_vis'; diff --git a/src/plugins/input_control_vis/public/components/vis/list_control.test.tsx b/src/plugins/input_control_vis/public/components/vis/list_control.test.tsx index 4944a9dacfed6..d8b3c4ce707d6 100644 --- a/src/plugins/input_control_vis/public/components/vis/list_control.test.tsx +++ b/src/plugins/input_control_vis/public/components/vis/list_control.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import sinon from 'sinon'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { ListControl } from './list_control'; diff --git a/src/plugins/input_control_vis/public/components/vis/range_control.test.tsx b/src/plugins/input_control_vis/public/components/vis/range_control.test.tsx index 569d115c9dbda..085e834285f52 100644 --- a/src/plugins/input_control_vis/public/components/vis/range_control.test.tsx +++ b/src/plugins/input_control_vis/public/components/vis/range_control.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { RangeControl, ceilWithPrecision, floorWithPrecision } from './range_control'; import { RangeControl as RangeControlClass } from '../../control/range_control_factory'; diff --git a/src/plugins/inspector/public/ui/inspector_panel.test.tsx b/src/plugins/inspector/public/ui/inspector_panel.test.tsx index 67e197abe7134..731ccef551448 100644 --- a/src/plugins/inspector/public/ui/inspector_panel.test.tsx +++ b/src/plugins/inspector/public/ui/inspector_panel.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { InspectorPanel } from './inspector_panel'; import { InspectorViewDescription } from '../types'; import { Adapters } from '../../common'; diff --git a/src/plugins/inspector/public/views/data/components/data_view.test.tsx b/src/plugins/inspector/public/views/data/components/data_view.test.tsx index 6a7f878ef807e..82bec5ee3fe8c 100644 --- a/src/plugins/inspector/public/views/data/components/data_view.test.tsx +++ b/src/plugins/inspector/public/views/data/components/data_view.test.tsx @@ -20,7 +20,7 @@ import React, { Suspense } from 'react'; import { getDataViewDescription } from '../index'; import { DataAdapter } from '../../../../common/adapters/data'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; jest.mock('../lib/export_csv', () => ({ exportAsCsv: jest.fn(), diff --git a/src/plugins/kibana_overview/public/components/add_data/add_data.test.tsx b/src/plugins/kibana_overview/public/components/add_data/add_data.test.tsx index f5cdbd9e27e28..c04aa9db87ace 100644 --- a/src/plugins/kibana_overview/public/components/add_data/add_data.test.tsx +++ b/src/plugins/kibana_overview/public/components/add_data/add_data.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { AddData } from './add_data'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { FeatureCatalogueCategory } from 'src/plugins/home/public'; const mockFeatures = [ diff --git a/src/plugins/kibana_overview/public/components/getting_started/getting_started.test.tsx b/src/plugins/kibana_overview/public/components/getting_started/getting_started.test.tsx index 7d40c4174f39b..856966732d405 100644 --- a/src/plugins/kibana_overview/public/components/getting_started/getting_started.test.tsx +++ b/src/plugins/kibana_overview/public/components/getting_started/getting_started.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { GettingStarted } from './getting_started'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { FeatureCatalogueCategory } from 'src/plugins/home/public'; const addBasePathMock = jest.fn((path: string) => (path ? path : 'path')); diff --git a/src/plugins/kibana_overview/public/components/manage_data/manage_data.test.tsx b/src/plugins/kibana_overview/public/components/manage_data/manage_data.test.tsx index 3ce2364c96083..69ef12f217738 100644 --- a/src/plugins/kibana_overview/public/components/manage_data/manage_data.test.tsx +++ b/src/plugins/kibana_overview/public/components/manage_data/manage_data.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { ManageData } from './manage_data'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { FeatureCatalogueCategory } from 'src/plugins/home/public'; const mockFeatures = [ diff --git a/src/plugins/kibana_overview/public/components/news_feed/news_feed.test.tsx b/src/plugins/kibana_overview/public/components/news_feed/news_feed.test.tsx index 6716c28b1f682..88fc717b97543 100644 --- a/src/plugins/kibana_overview/public/components/news_feed/news_feed.test.tsx +++ b/src/plugins/kibana_overview/public/components/news_feed/news_feed.test.tsx @@ -20,7 +20,7 @@ import moment from 'moment'; import React from 'react'; import { NewsFeed } from './news_feed'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; const mockNewsFetchResult = { error: null, diff --git a/src/plugins/kibana_overview/public/components/overview/overview.test.tsx b/src/plugins/kibana_overview/public/components/overview/overview.test.tsx index efef0a8a1f0a4..07c3a6e69c15c 100644 --- a/src/plugins/kibana_overview/public/components/overview/overview.test.tsx +++ b/src/plugins/kibana_overview/public/components/overview/overview.test.tsx @@ -20,7 +20,7 @@ import moment from 'moment'; import React from 'react'; import { Overview } from './overview'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { FeatureCatalogueCategory } from 'src/plugins/home/public'; jest.mock('../../../../../../src/plugins/kibana_react/public', () => ({ diff --git a/src/plugins/kibana_react/public/overview_page/overview_page_footer/overview_page_footer.test.tsx b/src/plugins/kibana_react/public/overview_page/overview_page_footer/overview_page_footer.test.tsx index ac28211d5032a..f90ecdda93242 100644 --- a/src/plugins/kibana_react/public/overview_page/overview_page_footer/overview_page_footer.test.tsx +++ b/src/plugins/kibana_react/public/overview_page/overview_page_footer/overview_page_footer.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { OverviewPageFooter } from './overview_page_footer'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; jest.mock('../../app_links', () => ({ RedirectAppLinks: jest.fn((element: JSX.Element) => element), diff --git a/src/plugins/kibana_react/public/overview_page/overview_page_header/overview_page_header.test.tsx b/src/plugins/kibana_react/public/overview_page/overview_page_header/overview_page_header.test.tsx index 73e5dada02d09..fd03c9d53aac2 100644 --- a/src/plugins/kibana_react/public/overview_page/overview_page_header/overview_page_header.test.tsx +++ b/src/plugins/kibana_react/public/overview_page/overview_page_header/overview_page_header.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { OverviewPageHeader } from './overview_page_header'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; jest.mock('../../app_links', () => ({ RedirectAppLinks: jest.fn((element: JSX.Element) => element), diff --git a/src/plugins/kibana_react/public/use_url_tracker/use_url_tracker.test.tsx b/src/plugins/kibana_react/public/use_url_tracker/use_url_tracker.test.tsx index d1425a09b2f9c..695c8fc29c0c2 100644 --- a/src/plugins/kibana_react/public/use_url_tracker/use_url_tracker.test.tsx +++ b/src/plugins/kibana_react/public/use_url_tracker/use_url_tracker.test.tsx @@ -19,7 +19,7 @@ import { renderHook } from '@testing-library/react-hooks'; import { useUrlTracker } from './use_url_tracker'; -import { StubBrowserStorage } from 'test_utils/stub_browser_storage'; +import { StubBrowserStorage } from '@kbn/test/jest'; import { createMemoryHistory } from 'history'; describe('useUrlTracker', () => { diff --git a/src/plugins/kibana_utils/public/state_management/url/kbn_url_tracker.test.ts b/src/plugins/kibana_utils/public/state_management/url/kbn_url_tracker.test.ts index e50469546417c..2a50fa7a70247 100644 --- a/src/plugins/kibana_utils/public/state_management/url/kbn_url_tracker.test.ts +++ b/src/plugins/kibana_utils/public/state_management/url/kbn_url_tracker.test.ts @@ -17,7 +17,7 @@ * under the License. */ -import { StubBrowserStorage } from 'test_utils/stub_browser_storage'; +import { StubBrowserStorage } from '@kbn/test/jest'; import { createMemoryHistory, History } from 'history'; import { createKbnUrlTracker, KbnUrlTracker } from './kbn_url_tracker'; import { BehaviorSubject, Subject } from 'rxjs'; diff --git a/src/plugins/kibana_utils/public/state_management/url/url_tracker.test.ts b/src/plugins/kibana_utils/public/state_management/url/url_tracker.test.ts index d7e5f99ffb700..0301cff83799f 100644 --- a/src/plugins/kibana_utils/public/state_management/url/url_tracker.test.ts +++ b/src/plugins/kibana_utils/public/state_management/url/url_tracker.test.ts @@ -18,7 +18,7 @@ */ import { createUrlTracker, IUrlTracker } from './url_tracker'; -import { StubBrowserStorage } from 'test_utils/stub_browser_storage'; +import { StubBrowserStorage } from '@kbn/test/jest'; import { createMemoryHistory, History } from 'history'; describe('urlTracker', () => { diff --git a/src/plugins/kibana_utils/public/state_sync/state_sync.test.ts b/src/plugins/kibana_utils/public/state_sync/state_sync.test.ts index 0450f420784dd..4b2b2bd99911b 100644 --- a/src/plugins/kibana_utils/public/state_sync/state_sync.test.ts +++ b/src/plugins/kibana_utils/public/state_sync/state_sync.test.ts @@ -33,7 +33,7 @@ import { IKbnUrlStateStorage, ISessionStorageStateStorage, } from './state_sync_state_storage'; -import { StubBrowserStorage } from 'test_utils/stub_browser_storage'; +import { StubBrowserStorage } from '@kbn/test/jest'; import { createBrowserHistory, History } from 'history'; import { INullableBaseStateContainer } from './types'; diff --git a/src/plugins/kibana_utils/public/state_sync/state_sync_state_storage/create_session_storage_state_storage.test.ts b/src/plugins/kibana_utils/public/state_sync/state_sync_state_storage/create_session_storage_state_storage.test.ts index f69629e755008..d38f19b0f09b6 100644 --- a/src/plugins/kibana_utils/public/state_sync/state_sync_state_storage/create_session_storage_state_storage.test.ts +++ b/src/plugins/kibana_utils/public/state_sync/state_sync_state_storage/create_session_storage_state_storage.test.ts @@ -21,7 +21,7 @@ import { createSessionStorageStateStorage, ISessionStorageStateStorage, } from './create_session_storage_state_storage'; -import { StubBrowserStorage } from 'test_utils/stub_browser_storage'; +import { StubBrowserStorage } from '@kbn/test/jest'; describe('SessionStorageStateStorage', () => { let browserStorage: StubBrowserStorage; diff --git a/src/plugins/kibana_utils/public/storage/hashed_item_store/hashed_item_store.test.ts b/src/plugins/kibana_utils/public/storage/hashed_item_store/hashed_item_store.test.ts index f0ff77d516270..c1e4b0e6261ba 100644 --- a/src/plugins/kibana_utils/public/storage/hashed_item_store/hashed_item_store.test.ts +++ b/src/plugins/kibana_utils/public/storage/hashed_item_store/hashed_item_store.test.ts @@ -17,7 +17,7 @@ * under the License. */ -import { StubBrowserStorage } from 'test_utils/stub_browser_storage'; +import { StubBrowserStorage } from '@kbn/test/jest'; import { HashedItemStore } from './hashed_item_store'; describe('hashedItemStore', () => { diff --git a/src/plugins/kibana_utils/public/storage/hashed_item_store/mock.ts b/src/plugins/kibana_utils/public/storage/hashed_item_store/mock.ts index 43a8856176c42..4d722a818fe12 100644 --- a/src/plugins/kibana_utils/public/storage/hashed_item_store/mock.ts +++ b/src/plugins/kibana_utils/public/storage/hashed_item_store/mock.ts @@ -17,7 +17,7 @@ * under the License. */ -import { StubBrowserStorage } from 'test_utils/stub_browser_storage'; +import { StubBrowserStorage } from '@kbn/test/jest'; import { HashedItemStore } from './hashed_item_store'; /** diff --git a/src/plugins/navigation/public/top_nav_menu/top_nav_menu.test.tsx b/src/plugins/navigation/public/top_nav_menu/top_nav_menu.test.tsx index 147feee3cd472..0cd00ae5d6478 100644 --- a/src/plugins/navigation/public/top_nav_menu/top_nav_menu.test.tsx +++ b/src/plugins/navigation/public/top_nav_menu/top_nav_menu.test.tsx @@ -23,7 +23,7 @@ import { act } from 'react-dom/test-utils'; import { MountPoint } from 'kibana/public'; import { TopNavMenu } from './top_nav_menu'; import { TopNavMenuData } from './top_nav_menu_data'; -import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; const dataShim = { ui: { diff --git a/src/plugins/navigation/public/top_nav_menu/top_nav_menu_item.test.tsx b/src/plugins/navigation/public/top_nav_menu/top_nav_menu_item.test.tsx index 9ba58379c5ce1..3e82421bc7901 100644 --- a/src/plugins/navigation/public/top_nav_menu/top_nav_menu_item.test.tsx +++ b/src/plugins/navigation/public/top_nav_menu/top_nav_menu_item.test.tsx @@ -20,7 +20,7 @@ import React from 'react'; import { TopNavMenuItem } from './top_nav_menu_item'; import { TopNavMenuData } from './top_nav_menu_data'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; describe('TopNavMenu', () => { const ensureMenuItemDisabled = (data: TopNavMenuData) => { diff --git a/src/plugins/saved_objects/public/save_modal/saved_object_save_modal.test.tsx b/src/plugins/saved_objects/public/save_modal/saved_object_save_modal.test.tsx index 15400087c2641..9701d46c55513 100644 --- a/src/plugins/saved_objects/public/save_modal/saved_object_save_modal.test.tsx +++ b/src/plugins/saved_objects/public/save_modal/saved_object_save_modal.test.tsx @@ -20,7 +20,7 @@ import { shallow } from 'enzyme'; import React from 'react'; import { SavedObjectSaveModal } from './saved_object_save_modal'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; describe('SavedObjectSaveModal', () => { it('should render matching snapshot', () => { diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/flyout.test.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/components/flyout.test.tsx index 37da411a1e96b..0994f704464e5 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/flyout.test.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/flyout.test.tsx @@ -28,7 +28,7 @@ import { } from './flyout.test.mocks'; import React from 'react'; -import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider } from '@kbn/test/jest'; import { coreMock } from '../../../../../../core/public/mocks'; import { serviceRegistryMock } from '../../../services/service_registry.mock'; import { Flyout, FlyoutProps, FlyoutState } from './flyout'; diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/import_mode_control.test.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/components/import_mode_control.test.tsx index 467347d95d1d7..61400bd3ebe16 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/import_mode_control.test.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/import_mode_control.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { ReactWrapper } from 'enzyme'; -import { shallowWithI18nProvider, mountWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider, mountWithIntl } from '@kbn/test/jest'; import { ImportModeControl, ImportModeControlProps } from './import_mode_control'; describe('ImportModeControl', () => { diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/import_summary.test.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/components/import_summary.test.tsx index 20ac5a903ef22..d1224a03af98e 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/import_summary.test.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/import_summary.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { ShallowWrapper } from 'enzyme'; -import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider } from '@kbn/test/jest'; import { ImportSummary, ImportSummaryProps } from './import_summary'; import { FailedImport } from '../../../lib'; diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/overwrite_modal.test.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/components/overwrite_modal.test.tsx index 7576b62552aa2..6d93a8c164bcf 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/overwrite_modal.test.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/overwrite_modal.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider, mountWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider, mountWithIntl } from '@kbn/test/jest'; import { OverwriteModalProps, OverwriteModal } from './overwrite_modal'; import { findTestSubject } from '@elastic/eui/lib/test'; diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/relationships.test.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/components/relationships.test.tsx index ead2738973074..3bea827022285 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/relationships.test.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/relationships.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider } from '@kbn/test/jest'; import { httpServiceMock } from '../../../../../../core/public/mocks'; import { Relationships, RelationshipsProps } from './relationships'; diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/table.test.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/components/table.test.tsx index f83536d2c5ea0..b4d4f55b0fb5c 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/table.test.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/table.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider, mountWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider, mountWithI18nProvider } from '@kbn/test/jest'; import { findTestSubject } from '@elastic/eui/lib/test'; import { keys } from '@elastic/eui'; import { httpServiceMock } from '../../../../../../core/public/mocks'; diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.test.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.test.tsx index 63aefde6fd233..0171c13fd974b 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.test.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.test.tsx @@ -30,7 +30,7 @@ import { import React from 'react'; import { Query } from '@elastic/eui'; import { ShallowWrapper } from 'enzyme'; -import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { shallowWithI18nProvider } from '@kbn/test/jest'; import { httpServiceMock, overlayServiceMock, diff --git a/src/plugins/security_oss/public/insecure_cluster_service/insecure_cluster_service.test.tsx b/src/plugins/security_oss/public/insecure_cluster_service/insecure_cluster_service.test.tsx index a81f361689743..7bd2d9c4e5a0a 100644 --- a/src/plugins/security_oss/public/insecure_cluster_service/insecure_cluster_service.test.tsx +++ b/src/plugins/security_oss/public/insecure_cluster_service/insecure_cluster_service.test.tsx @@ -20,7 +20,7 @@ import { InsecureClusterService } from './insecure_cluster_service'; import { ConfigType } from '../config'; import { coreMock } from '../../../../core/public/mocks'; -import { nextTick } from 'test_utils/enzyme_helpers'; +import { nextTick } from '@kbn/test/jest'; let mockOnDismissCallback: (persist: boolean) => void = jest.fn().mockImplementation(() => { throw new Error('expected callback to be replaced!'); diff --git a/src/plugins/telemetry/common/telemetry_config/get_telemetry_opt_in.ts b/src/plugins/telemetry/common/telemetry_config/get_telemetry_opt_in.ts index 7beb5415ad7b1..14b28a1a5013e 100644 --- a/src/plugins/telemetry/common/telemetry_config/get_telemetry_opt_in.ts +++ b/src/plugins/telemetry/common/telemetry_config/get_telemetry_opt_in.ts @@ -17,7 +17,8 @@ * under the License. */ -import semver from 'semver'; +import SemVer from 'semver/classes/semver'; +import semverParse from 'semver/functions/parse'; import { TelemetrySavedObject } from './types'; interface GetTelemetryOptInConfig { @@ -80,10 +81,10 @@ export const getTelemetryOptIn: GetTelemetryOptIn = ({ return savedOptIn; }; -function parseSemver(version: string): semver.SemVer | null { +function parseSemver(version: string): SemVer | null { // semver functions both return nulls AND throw exceptions: "it depends!" try { - return semver.parse(version); + return semverParse(version); } catch (err) { return null; } diff --git a/src/plugins/telemetry/public/components/opt_in_banner.test.tsx b/src/plugins/telemetry/public/components/opt_in_banner.test.tsx index 097c17862c668..f180927618aab 100644 --- a/src/plugins/telemetry/public/components/opt_in_banner.test.tsx +++ b/src/plugins/telemetry/public/components/opt_in_banner.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; import { EuiButton } from '@elastic/eui'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { OptInBanner } from './opt_in_banner'; describe('OptInDetailsComponent', () => { diff --git a/src/plugins/telemetry/public/components/opt_in_message.test.tsx b/src/plugins/telemetry/public/components/opt_in_message.test.tsx index dbe0941345a02..19dd805129b23 100644 --- a/src/plugins/telemetry/public/components/opt_in_message.test.tsx +++ b/src/plugins/telemetry/public/components/opt_in_message.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { OptInMessage } from './opt_in_message'; describe('OptInMessage', () => { diff --git a/src/plugins/telemetry/public/components/opted_in_notice_banner.test.tsx b/src/plugins/telemetry/public/components/opted_in_notice_banner.test.tsx index f4e0287cab93f..6c5fb2473023e 100644 --- a/src/plugins/telemetry/public/components/opted_in_notice_banner.test.tsx +++ b/src/plugins/telemetry/public/components/opted_in_notice_banner.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; import { EuiButton } from '@elastic/eui'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { OptedInNoticeBanner } from './opted_in_notice_banner'; describe('OptInDetailsComponent', () => { diff --git a/src/plugins/telemetry_management_section/public/components/example_security_payload.test.tsx b/src/plugins/telemetry_management_section/public/components/example_security_payload.test.tsx index e27342a0621be..2baa590c3aadc 100644 --- a/src/plugins/telemetry_management_section/public/components/example_security_payload.test.tsx +++ b/src/plugins/telemetry_management_section/public/components/example_security_payload.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import ExampleSecurityPayload from './example_security_payload'; describe('example security payload', () => { diff --git a/src/plugins/telemetry_management_section/public/components/opt_in_example_flyout.test.tsx b/src/plugins/telemetry_management_section/public/components/opt_in_example_flyout.test.tsx index fe5e73a244893..f91c534ad5ff7 100644 --- a/src/plugins/telemetry_management_section/public/components/opt_in_example_flyout.test.tsx +++ b/src/plugins/telemetry_management_section/public/components/opt_in_example_flyout.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { OptInExampleFlyout } from './opt_in_example_flyout'; describe('OptInDetailsComponent', () => { diff --git a/src/plugins/telemetry_management_section/public/components/opt_in_security_example_flyout.test.tsx b/src/plugins/telemetry_management_section/public/components/opt_in_security_example_flyout.test.tsx index c80d0daf5a695..09858a6a8474f 100644 --- a/src/plugins/telemetry_management_section/public/components/opt_in_security_example_flyout.test.tsx +++ b/src/plugins/telemetry_management_section/public/components/opt_in_security_example_flyout.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { OptInSecurityExampleFlyout } from './opt_in_security_example_flyout'; describe('security flyout renders as expected', () => { diff --git a/src/plugins/telemetry_management_section/public/components/telemetry_management_section.test.tsx b/src/plugins/telemetry_management_section/public/components/telemetry_management_section.test.tsx index cb21c66c1cbc1..e7693d1e918bb 100644 --- a/src/plugins/telemetry_management_section/public/components/telemetry_management_section.test.tsx +++ b/src/plugins/telemetry_management_section/public/components/telemetry_management_section.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; import TelemetryManagementSection from './telemetry_management_section'; import { TelemetryService } from '../../../telemetry/public/services'; import { coreMock } from '../../../../core/public/mocks'; diff --git a/src/plugins/vis_default_editor/public/components/controls/components/number_list/number_list.test.tsx b/src/plugins/vis_default_editor/public/components/controls/components/number_list/number_list.test.tsx index 7964da23d8f50..25c0387bee9fb 100644 --- a/src/plugins/vis_default_editor/public/components/controls/components/number_list/number_list.test.tsx +++ b/src/plugins/vis_default_editor/public/components/controls/components/number_list/number_list.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { shallow } from 'enzyme'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { NumberList, NumberListProps } from './number_list'; import { NumberRow } from './number_row'; diff --git a/src/plugins/vis_default_editor/public/components/controls/date_ranges.test.tsx b/src/plugins/vis_default_editor/public/components/controls/date_ranges.test.tsx index 5c95d72bcd282..5e4260059cea9 100644 --- a/src/plugins/vis_default_editor/public/components/controls/date_ranges.test.tsx +++ b/src/plugins/vis_default_editor/public/components/controls/date_ranges.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { DateRangesParamEditor } from './date_ranges'; import { KibanaContextProvider } from '../../../../kibana_react/public'; import { docLinksServiceMock } from '../../../../../core/public/mocks'; diff --git a/src/plugins/vis_default_editor/public/components/controls/size.test.tsx b/src/plugins/vis_default_editor/public/components/controls/size.test.tsx index caab47892de93..f4eb5e30408b2 100644 --- a/src/plugins/vis_default_editor/public/components/controls/size.test.tsx +++ b/src/plugins/vis_default_editor/public/components/controls/size.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { EuiIconTip } from '@elastic/eui'; import { SizeParamEditor, SizeParamEditorProps } from './size'; import { aggParamCommonPropsMock } from './test_utils'; diff --git a/src/plugins/vis_default_editor/public/components/controls/top_aggregate.test.tsx b/src/plugins/vis_default_editor/public/components/controls/top_aggregate.test.tsx index 74dab1a3b551a..3948c8bcb0b0b 100644 --- a/src/plugins/vis_default_editor/public/components/controls/top_aggregate.test.tsx +++ b/src/plugins/vis_default_editor/public/components/controls/top_aggregate.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { AggregateValueProp, TopAggregateParamEditor, diff --git a/src/plugins/vis_type_tagcloud/public/components/tag_cloud.test.js b/src/plugins/vis_type_tagcloud/public/components/tag_cloud.test.js index 89a6a67bcb2fb..11e3b71345a5d 100644 --- a/src/plugins/vis_type_tagcloud/public/components/tag_cloud.test.js +++ b/src/plugins/vis_type_tagcloud/public/components/tag_cloud.test.js @@ -23,7 +23,7 @@ import 'jest-canvas-mock'; import { fromNode, delay } from 'bluebird'; import { TagCloud } from './tag_cloud'; -import { setHTMLElementOffset, setSVGElementGetBBox } from '../../../../test_utils/public'; +import { setHTMLElementOffset, setSVGElementGetBBox } from '@kbn/test/jest'; describe('tag cloud tests', () => { let SVGElementGetBBoxSpyInstance; diff --git a/src/plugins/vis_type_tagcloud/public/components/tag_cloud_visualization.test.js b/src/plugins/vis_type_tagcloud/public/components/tag_cloud_visualization.test.js index 7da77ce4785cb..597aafea0d162 100644 --- a/src/plugins/vis_type_tagcloud/public/components/tag_cloud_visualization.test.js +++ b/src/plugins/vis_type_tagcloud/public/components/tag_cloud_visualization.test.js @@ -22,7 +22,7 @@ import 'jest-canvas-mock'; import { TagCloudVisualization } from './tag_cloud_visualization'; import { setFormatService } from '../services'; import { dataPluginMock } from '../../../data/public/mocks'; -import { setHTMLElementOffset, setSVGElementGetBBox } from '../../../../test_utils/public'; +import { setHTMLElementOffset, setSVGElementGetBBox } from '@kbn/test/jest'; const seedColors = ['#00a69b', '#57c17b', '#6f87d8', '#663db8', '#bc52bc', '#9e3533', '#daa05d']; diff --git a/src/plugins/vis_type_timeseries/common/constants.ts b/src/plugins/vis_type_timeseries/common/constants.ts index fc402d6ab7db5..92dfc6d522957 100644 --- a/src/plugins/vis_type_timeseries/common/constants.ts +++ b/src/plugins/vis_type_timeseries/common/constants.ts @@ -18,3 +18,4 @@ */ export const MAX_BUCKETS_SETTING = 'metrics:max_buckets'; +export const INDEXES_SEPARATOR = ','; diff --git a/src/plugins/vis_type_timeseries/public/application/components/add_delete_buttons.test.tsx b/src/plugins/vis_type_timeseries/public/application/components/add_delete_buttons.test.tsx index 0fb3e80344e2b..3c6c649f2948b 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/add_delete_buttons.test.tsx +++ b/src/plugins/vis_type_timeseries/public/application/components/add_delete_buttons.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { AddDeleteButtons } from './add_delete_buttons'; describe('AddDeleteButtons', () => { diff --git a/src/plugins/vis_type_timeseries/public/application/components/aggs/agg_select.test.tsx b/src/plugins/vis_type_timeseries/public/application/components/aggs/agg_select.test.tsx index 6c75e081429de..00e62a9bfad44 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/aggs/agg_select.test.tsx +++ b/src/plugins/vis_type_timeseries/public/application/components/aggs/agg_select.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { AggSelect } from './agg_select'; import { METRIC, SERIES } from '../../../test_utils'; import { EuiComboBox } from '@elastic/eui'; diff --git a/src/plugins/vis_type_timeseries/public/application/components/aggs/filter_ratio.test.js b/src/plugins/vis_type_timeseries/public/application/components/aggs/filter_ratio.test.js index f25cd310f6353..5c337a05c091a 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/aggs/filter_ratio.test.js +++ b/src/plugins/vis_type_timeseries/public/application/components/aggs/filter_ratio.test.js @@ -18,7 +18,7 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { FilterRatioAgg } from './filter_ratio'; import { FIELDS, METRIC, SERIES, PANEL } from '../../../test_utils'; import { EuiComboBox } from '@elastic/eui'; diff --git a/src/plugins/vis_type_timeseries/public/application/components/aggs/histogram_support.test.js b/src/plugins/vis_type_timeseries/public/application/components/aggs/histogram_support.test.js index aa4afda028a29..8f7267f20729b 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/aggs/histogram_support.test.js +++ b/src/plugins/vis_type_timeseries/public/application/components/aggs/histogram_support.test.js @@ -18,7 +18,7 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { Agg } from './agg'; import { FieldSelect } from './field_select'; import { FIELDS, METRIC, SERIES, PANEL } from '../../../test_utils'; diff --git a/src/plugins/vis_type_timeseries/public/application/components/color_rules.test.js b/src/plugins/vis_type_timeseries/public/application/components/color_rules.test.js index db6024d48be12..fb84ae9dd17b4 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/color_rules.test.js +++ b/src/plugins/vis_type_timeseries/public/application/components/color_rules.test.js @@ -22,7 +22,7 @@ import { collectionActions } from './lib/collection_actions'; import { ColorRules } from './color_rules'; import { keys } from '@elastic/eui'; import { findTestSubject } from '@elastic/eui/lib/test'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; describe('src/legacy/core_plugins/metrics/public/components/color_rules.test.js', () => { let defaultProps; diff --git a/src/plugins/vis_type_timeseries/public/application/components/panel_config/gauge.test.js b/src/plugins/vis_type_timeseries/public/application/components/panel_config/gauge.test.js index 936cc000db8d9..81ccf69fc974a 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/panel_config/gauge.test.js +++ b/src/plugins/vis_type_timeseries/public/application/components/panel_config/gauge.test.js @@ -18,7 +18,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; jest.mock('../lib/get_default_query_language', () => ({ getDefaultQueryLanguage: () => 'kuery', diff --git a/src/plugins/vis_type_timeseries/public/application/components/vis_types/gauge/series.test.js b/src/plugins/vis_type_timeseries/public/application/components/vis_types/gauge/series.test.js index 39a2228984854..727c2ebd763c6 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/vis_types/gauge/series.test.js +++ b/src/plugins/vis_type_timeseries/public/application/components/vis_types/gauge/series.test.js @@ -18,7 +18,7 @@ */ import React from 'react'; import { GaugeSeries } from './series'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; const defaultProps = { disableAdd: true, diff --git a/src/plugins/vis_type_timeseries/public/application/components/vis_types/metric/series.test.js b/src/plugins/vis_type_timeseries/public/application/components/vis_types/metric/series.test.js index cd4bca453d4d8..e8057a8ffb081 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/vis_types/metric/series.test.js +++ b/src/plugins/vis_type_timeseries/public/application/components/vis_types/metric/series.test.js @@ -19,7 +19,7 @@ import React from 'react'; import { MetricSeries } from './series'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; const defaultProps = { disableAdd: false, diff --git a/src/plugins/vis_type_timeseries/public/application/components/yes_no.test.js b/src/plugins/vis_type_timeseries/public/application/components/yes_no.test.js index 39ae94b7489a2..112cfeaa29d5a 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/yes_no.test.js +++ b/src/plugins/vis_type_timeseries/public/application/components/yes_no.test.js @@ -19,7 +19,7 @@ import React from 'react'; import { expect } from 'chai'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import sinon from 'sinon'; import { YesNo } from './yes_no'; diff --git a/src/plugins/vis_type_timeseries/public/metrics_type.ts b/src/plugins/vis_type_timeseries/public/metrics_type.ts index 682517ab1a996..01b6ea0768338 100644 --- a/src/plugins/vis_type_timeseries/public/metrics_type.ts +++ b/src/plugins/vis_type_timeseries/public/metrics_type.ts @@ -25,7 +25,9 @@ import { EditorController } from './application'; // @ts-ignore import { PANEL_TYPES } from '../common/panel_types'; import { VisEditor } from './application/components/vis_editor_lazy'; -import { VIS_EVENT_TO_TRIGGER, VisGroups } from '../../visualizations/public'; +import { VIS_EVENT_TO_TRIGGER, VisGroups, VisParams } from '../../visualizations/public'; +import { getDataStart } from './services'; +import { INDEXES_SEPARATOR } from '../common/constants'; export const metricsVisDefinition = { name: 'metrics', @@ -84,5 +86,21 @@ export const metricsVisDefinition = { return [VIS_EVENT_TO_TRIGGER.applyFilter]; }, inspectorAdapters: {}, + getUsedIndexPattern: async (params: VisParams) => { + const { indexPatterns } = getDataStart(); + const indexes: string = params.index_pattern; + + if (indexes) { + const cachedIndexes = await indexPatterns.getIdsWithTitle(); + const ids = indexes + .split(INDEXES_SEPARATOR) + .map((title) => cachedIndexes.find((i) => i.title === title)?.id) + .filter((id) => id); + + return Promise.all(ids.map((id) => indexPatterns.get(id!))); + } + + return []; + }, responseHandler: 'none', }; diff --git a/src/plugins/vis_type_vega/public/vega_visualization.test.js b/src/plugins/vis_type_vega/public/vega_visualization.test.js index 837fdf2a9aea3..a2214e139a296 100644 --- a/src/plugins/vis_type_vega/public/vega_visualization.test.js +++ b/src/plugins/vis_type_vega/public/vega_visualization.test.js @@ -100,7 +100,8 @@ describe('VegaVisualizations', () => { mockHeight.mockRestore(); }); - test('should show vegalite graph and update on resize (may fail in dev env)', async () => { + // SKIP: https://github.com/elastic/kibana/issues/83385 + test.skip('should show vegalite graph and update on resize (may fail in dev env)', async () => { let vegaVis; try { vegaVis = new VegaVisualization(domNode, jest.fn()); @@ -131,7 +132,8 @@ describe('VegaVisualizations', () => { } }); - test('should show vega graph (may fail in dev env)', async () => { + // SKIP: https://github.com/elastic/kibana/issues/83385 + test.skip('should show vega graph (may fail in dev env)', async () => { let vegaVis; try { vegaVis = new VegaVisualization(domNode, jest.fn()); diff --git a/src/plugins/vis_type_vislib/public/components/options/metrics_axes/value_axes_panel.test.tsx b/src/plugins/vis_type_vislib/public/components/options/metrics_axes/value_axes_panel.test.tsx index c5dfebdf720d8..070433ca03f6d 100644 --- a/src/plugins/vis_type_vislib/public/components/options/metrics_axes/value_axes_panel.test.tsx +++ b/src/plugins/vis_type_vislib/public/components/options/metrics_axes/value_axes_panel.test.tsx @@ -22,7 +22,7 @@ import { shallow } from 'enzyme'; import { ValueAxesPanel, ValueAxesPanelProps } from './value_axes_panel'; import { ValueAxis, SeriesParam } from '../../../types'; import { Positions } from '../../../utils/collections'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { valueAxis, seriesParam, vis } from './mocks'; describe('ValueAxesPanel component', () => { diff --git a/src/plugins/vis_type_vislib/public/vislib/lib/chart_title.test.js b/src/plugins/vis_type_vislib/public/vislib/lib/chart_title.test.js index d8d5087f8c380..57e378846e92c 100644 --- a/src/plugins/vis_type_vislib/public/vislib/lib/chart_title.test.js +++ b/src/plugins/vis_type_vislib/public/vislib/lib/chart_title.test.js @@ -23,7 +23,7 @@ import { setHTMLElementClientSizes, setSVGElementGetBBox, setSVGElementGetComputedTextLength, -} from '../../../../../test_utils/public'; +} from '@kbn/test/jest'; import { ChartTitle } from './chart_title'; import { VisConfig } from './vis_config'; diff --git a/src/plugins/vis_type_vislib/public/vislib/lib/dispatch.test.js b/src/plugins/vis_type_vislib/public/vislib/lib/dispatch.test.js index 9c714af4d8434..f383c87b87a21 100644 --- a/src/plugins/vis_type_vislib/public/vislib/lib/dispatch.test.js +++ b/src/plugins/vis_type_vislib/public/vislib/lib/dispatch.test.js @@ -23,7 +23,7 @@ import { setHTMLElementClientSizes, setSVGElementGetBBox, setSVGElementGetComputedTextLength, -} from '../../../../../test_utils/public'; +} from '@kbn/test/jest'; // Data import data from '../../fixtures/mock_data/date_histogram/_series'; diff --git a/src/plugins/vis_type_vislib/public/vislib/lib/handler.test.js b/src/plugins/vis_type_vislib/public/vislib/lib/handler.test.js index 119a24d2f25d1..a4814a6b81454 100644 --- a/src/plugins/vis_type_vislib/public/vislib/lib/handler.test.js +++ b/src/plugins/vis_type_vislib/public/vislib/lib/handler.test.js @@ -22,7 +22,7 @@ import { setHTMLElementClientSizes, setSVGElementGetBBox, setSVGElementGetComputedTextLength, -} from '../../../../../test_utils/public'; +} from '@kbn/test/jest'; // Data import series from '../../fixtures/mock_data/date_histogram/_series'; diff --git a/src/plugins/vis_type_vislib/public/vislib/lib/layout/layout.test.js b/src/plugins/vis_type_vislib/public/vislib/lib/layout/layout.test.js index 824d7073d6db5..e30df49c3e776 100644 --- a/src/plugins/vis_type_vislib/public/vislib/lib/layout/layout.test.js +++ b/src/plugins/vis_type_vislib/public/vislib/lib/layout/layout.test.js @@ -23,7 +23,7 @@ import { setHTMLElementClientSizes, setSVGElementGetBBox, setSVGElementGetComputedTextLength, -} from '../../../../../../test_utils/public'; +} from '@kbn/test/jest'; // Data import series from '../../../fixtures/mock_data/date_histogram/_series'; diff --git a/src/plugins/vis_type_vislib/public/vislib/vis.test.js b/src/plugins/vis_type_vislib/public/vislib/vis.test.js index 0c4fac97ccb9c..933eea12481b6 100644 --- a/src/plugins/vis_type_vislib/public/vislib/vis.test.js +++ b/src/plugins/vis_type_vislib/public/vislib/vis.test.js @@ -23,7 +23,7 @@ import { setHTMLElementClientSizes, setSVGElementGetBBox, setSVGElementGetComputedTextLength, -} from '../../../../test_utils/public'; +} from '@kbn/test/jest'; import series from '../fixtures/mock_data/date_histogram/_series'; import columns from '../fixtures/mock_data/date_histogram/_columns'; import rows from '../fixtures/mock_data/date_histogram/_rows'; diff --git a/src/plugins/vis_type_vislib/public/vislib/visualizations/chart.test.js b/src/plugins/vis_type_vislib/public/vislib/visualizations/chart.test.js index 94c9693819b69..3aedb61f5b3a7 100644 --- a/src/plugins/vis_type_vislib/public/vislib/visualizations/chart.test.js +++ b/src/plugins/vis_type_vislib/public/vislib/visualizations/chart.test.js @@ -18,7 +18,7 @@ */ import d3 from 'd3'; -import { setHTMLElementClientSizes, setSVGElementGetBBox } from '../../../../../test_utils/public'; +import { setHTMLElementClientSizes, setSVGElementGetBBox } from '@kbn/test/jest'; import { Chart } from './_chart'; import { getMockUiState } from '../../fixtures/mocks'; import { getVis } from './_vis_fixture'; diff --git a/src/plugins/vis_type_vislib/public/vislib/visualizations/gauge_chart.test.js b/src/plugins/vis_type_vislib/public/vislib/visualizations/gauge_chart.test.js index 913b237a10e58..95b9a3c1b033a 100644 --- a/src/plugins/vis_type_vislib/public/vislib/visualizations/gauge_chart.test.js +++ b/src/plugins/vis_type_vislib/public/vislib/visualizations/gauge_chart.test.js @@ -19,7 +19,7 @@ import $ from 'jquery'; import _ from 'lodash'; -import { setHTMLElementClientSizes, setSVGElementGetBBox } from '../../../../../test_utils/public'; +import { setHTMLElementClientSizes, setSVGElementGetBBox } from '@kbn/test/jest'; import data from '../../fixtures/mock_data/terms/_series_multiple'; import { getMockUiState } from '../../fixtures/mocks'; diff --git a/src/plugins/vis_type_vislib/public/vislib/visualizations/pie_chart.test.js b/src/plugins/vis_type_vislib/public/vislib/visualizations/pie_chart.test.js index 1207db2e54bb8..2538f7c1c5c64 100644 --- a/src/plugins/vis_type_vislib/public/vislib/visualizations/pie_chart.test.js +++ b/src/plugins/vis_type_vislib/public/vislib/visualizations/pie_chart.test.js @@ -24,7 +24,7 @@ import { setHTMLElementClientSizes, setSVGElementGetBBox, setSVGElementGetComputedTextLength, -} from '../../../../../test_utils/public'; +} from '@kbn/test/jest'; import { getMockUiState } from '../../fixtures/mocks'; import { getVis } from './_vis_fixture'; import { pieChartMockData } from './pie_chart_mock_data'; diff --git a/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/area_chart.test.js b/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/area_chart.test.js index ae15d95d560ca..b65381ec294ee 100644 --- a/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/area_chart.test.js +++ b/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/area_chart.test.js @@ -24,7 +24,7 @@ import { setHTMLElementClientSizes, setSVGElementGetBBox, setSVGElementGetComputedTextLength, -} from '../../../../../../test_utils/public'; +} from '@kbn/test/jest'; import { getMockUiState } from '../../../fixtures/mocks'; import { getVis } from '../_vis_fixture'; diff --git a/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/column_chart.test.js b/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/column_chart.test.js index d7fc177a30009..e693c44f741f8 100644 --- a/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/column_chart.test.js +++ b/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/column_chart.test.js @@ -24,7 +24,7 @@ import { setHTMLElementClientSizes, setSVGElementGetBBox, setSVGElementGetComputedTextLength, -} from '../../../../../../test_utils/public'; +} from '@kbn/test/jest'; // Data import series from '../../../fixtures/mock_data/date_histogram/_series'; diff --git a/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/heatmap_chart.test.js b/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/heatmap_chart.test.js index a7534add76e36..875ddd6c33ca7 100644 --- a/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/heatmap_chart.test.js +++ b/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/heatmap_chart.test.js @@ -24,7 +24,7 @@ import { setHTMLElementClientSizes, setSVGElementGetBBox, setSVGElementGetComputedTextLength, -} from '../../../../../../test_utils/public'; +} from '@kbn/test/jest'; // Data import series from '../../../fixtures/mock_data/date_histogram/_series'; diff --git a/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/line_chart.test.js b/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/line_chart.test.js index 8d86df7c27da4..bed33fd801002 100644 --- a/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/line_chart.test.js +++ b/src/plugins/vis_type_vislib/public/vislib/visualizations/point_series/line_chart.test.js @@ -24,7 +24,7 @@ import { setHTMLElementClientSizes, setSVGElementGetBBox, setSVGElementGetComputedTextLength, -} from '../../../../../../test_utils/public'; +} from '@kbn/test/jest'; // Data import seriesPos from '../../../fixtures/mock_data/date_histogram/_series'; diff --git a/src/plugins/visualizations/public/embeddable/create_vis_embeddable_from_object.ts b/src/plugins/visualizations/public/embeddable/create_vis_embeddable_from_object.ts index 36f3f7d6ed22e..c064298658fff 100644 --- a/src/plugins/visualizations/public/embeddable/create_vis_embeddable_from_object.ts +++ b/src/plugins/visualizations/public/embeddable/create_vis_embeddable_from_object.ts @@ -41,6 +41,7 @@ import { import { VisualizeEmbeddableFactoryDeps } from './visualize_embeddable_factory'; import { VISUALIZE_ENABLE_LABS_SETTING } from '../../common/constants'; import { SavedVisualizationsLoader } from '../saved_visualizations'; +import { IndexPattern } from '../../../data/public'; export const createVisEmbeddableFromObject = (deps: VisualizeEmbeddableFactoryDeps) => async ( vis: Vis, @@ -69,8 +70,14 @@ export const createVisEmbeddableFromObject = (deps: VisualizeEmbeddableFactoryDe return new DisabledLabEmbeddable(vis.title, input); } - const indexPattern = vis.data.indexPattern; - const indexPatterns = indexPattern ? [indexPattern] : []; + let indexPatterns: IndexPattern[] = []; + + if (vis.type.getUsedIndexPattern) { + indexPatterns = await vis.type.getUsedIndexPattern(vis.params); + } else if (vis.data.indexPattern) { + indexPatterns = [vis.data.indexPattern]; + } + const editable = getCapabilities().visualize.save as boolean; return new VisualizeEmbeddable( diff --git a/src/plugins/visualizations/public/vis.ts b/src/plugins/visualizations/public/vis.ts index 5c3233a8de896..cae9058071b6c 100644 --- a/src/plugins/visualizations/public/vis.ts +++ b/src/plugins/visualizations/public/vis.ts @@ -137,7 +137,6 @@ export class Vis { if (state.params || typeChanged) { this.params = this.getParams(state.params); } - if (state.data && state.data.searchSource) { this.data.searchSource = await getSearch().searchSource.create(state.data.searchSource!); this.data.indexPattern = this.data.searchSource.getField('index'); diff --git a/src/plugins/visualizations/public/vis_types/base_vis_type.ts b/src/plugins/visualizations/public/vis_types/base_vis_type.ts index 807582723172d..e52cd4d2b2d56 100644 --- a/src/plugins/visualizations/public/vis_types/base_vis_type.ts +++ b/src/plugins/visualizations/public/vis_types/base_vis_type.ts @@ -44,6 +44,7 @@ interface CommonBaseVisTypeOptions | 'editorConfig' | 'hidden' | 'stage' + | 'getUsedIndexPattern' | 'useCustomNoDataScreen' | 'visConfig' | 'group' @@ -96,6 +97,7 @@ export class BaseVisType implements VisType public readonly responseHandler; public readonly hierarchicalData; public readonly setup; + public readonly getUsedIndexPattern; public readonly useCustomNoDataScreen; public readonly inspectorAdapters; public readonly toExpressionAst; @@ -126,6 +128,7 @@ export class BaseVisType implements VisType this.responseHandler = opts.responseHandler ?? 'none'; this.setup = opts.setup; this.hierarchicalData = opts.hierarchicalData ?? false; + this.getUsedIndexPattern = opts.getUsedIndexPattern; this.useCustomNoDataScreen = opts.useCustomNoDataScreen ?? false; this.inspectorAdapters = opts.inspectorAdapters; this.toExpressionAst = opts.toExpressionAst; diff --git a/src/plugins/visualizations/public/vis_types/types.ts b/src/plugins/visualizations/public/vis_types/types.ts index ee804e5677243..6ea44dc360559 100644 --- a/src/plugins/visualizations/public/vis_types/types.ts +++ b/src/plugins/visualizations/public/vis_types/types.ts @@ -20,10 +20,11 @@ import { IconType } from '@elastic/eui'; import React from 'react'; import { Adapters } from 'src/plugins/inspector'; +import { IndexPattern } from 'src/plugins/data/public'; import { VisEditorConstructor } from 'src/plugins/visualize/public'; import { ISchemas } from 'src/plugins/vis_default_editor/public'; import { TriggerContextMapping } from '../../../ui_actions/public'; -import { Vis, VisToExpressionAst, VisualizationControllerConstructor } from '../types'; +import { Vis, VisParams, VisToExpressionAst, VisualizationControllerConstructor } from '../types'; export interface VisTypeOptions { showTimePicker: boolean; @@ -64,6 +65,13 @@ export interface VisType { * If given, it will return the supported triggers for this vis. */ readonly getSupportedTriggers?: () => Array; + + /** + * Some visualizations are created without SearchSource and may change the used indexes during the visualization configuration. + * Using this method we can rewrite the standard mechanism for getting used indexes + */ + readonly getUsedIndexPattern?: (visParams: VisParams) => IndexPattern[] | Promise; + readonly isAccessible?: boolean; readonly requestHandler?: string | unknown; readonly responseHandler?: string | unknown; diff --git a/src/plugins/visualizations/public/wizard/agg_based_selection/agg_based_selection.test.tsx b/src/plugins/visualizations/public/wizard/agg_based_selection/agg_based_selection.test.tsx index 3cbe6a0b604c6..20cc1c0630ff9 100644 --- a/src/plugins/visualizations/public/wizard/agg_based_selection/agg_based_selection.test.tsx +++ b/src/plugins/visualizations/public/wizard/agg_based_selection/agg_based_selection.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { TypesStart, VisType, VisGroups } from '../../vis_types'; import { AggBasedSelection } from './agg_based_selection'; diff --git a/src/plugins/visualizations/public/wizard/group_selection/group_selection.test.tsx b/src/plugins/visualizations/public/wizard/group_selection/group_selection.test.tsx index b357f42bbae8b..797f0cf9d7ad0 100644 --- a/src/plugins/visualizations/public/wizard/group_selection/group_selection.test.tsx +++ b/src/plugins/visualizations/public/wizard/group_selection/group_selection.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { TypesStart, VisType, VisGroups } from '../../vis_types'; import { GroupSelection } from './group_selection'; import { DocLinksStart } from '../../../../../core/public'; diff --git a/src/plugins/visualizations/public/wizard/new_vis_modal.test.tsx b/src/plugins/visualizations/public/wizard/new_vis_modal.test.tsx index eea364b754e31..c41ccd23a8497 100644 --- a/src/plugins/visualizations/public/wizard/new_vis_modal.test.tsx +++ b/src/plugins/visualizations/public/wizard/new_vis_modal.test.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { TypesStart, VisType, VisGroups } from '../vis_types'; import NewVisModal from './new_vis_modal'; import { ApplicationStart, SavedObjectsStart, DocLinksStart } from '../../../../core/public'; diff --git a/src/test_utils/public/enzyme_helpers.tsx b/src/test_utils/public/enzyme_helpers.tsx deleted file mode 100644 index ce4e7c7298734..0000000000000 --- a/src/test_utils/public/enzyme_helpers.tsx +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * Components using the @kbn/i18n module require access to the intl context. - * This is not available when mounting single components in Enzyme. - * These helper functions aim to address that and wrap a valid, - * intl context around them. - */ - -import { I18nProvider, InjectedIntl, intlShape, __IntlProvider } from '@kbn/i18n/react'; -import { mount, ReactWrapper, render, shallow } from 'enzyme'; -import React, { ReactElement, ValidationMap } from 'react'; - -// Use fake component to extract `intl` property to use in tests. -const { intl } = (mount( - -
-
-).find('IntlProvider') as ReactWrapper<{}, {}, __IntlProvider>) - .instance() - .getChildContext(); - -function getOptions(context = {}, childContextTypes: ValidationMap = {}, props = {}) { - return { - context: { - ...context, - intl, - }, - childContextTypes: { - ...childContextTypes, - intl: intlShape, - }, - ...props, - }; -} - -/** - * When using @kbn/i18n `injectI18n` on components, props.intl is required. - */ -function nodeWithIntlProp(node: ReactElement): ReactElement { - return React.cloneElement(node, { intl }); -} - -/** - * Creates the wrapper instance using shallow with provided intl object into context - * - * @param node The React element or cheerio wrapper - * @param options properties to pass into shallow wrapper - * @return The wrapper instance around the rendered output with intl object in context - */ -export function shallowWithIntl( - node: ReactElement, - { - context, - childContextTypes, - ...props - }: { - context?: any; - childContextTypes?: ValidationMap; - } = {} -) { - const options = getOptions(context, childContextTypes, props); - - return shallow(nodeWithIntlProp(node), options); -} - -/** - * Creates the wrapper instance using mount with provided intl object into context - * - * @param node The React element or cheerio wrapper - * @param options properties to pass into mount wrapper - * @return The wrapper instance around the rendered output with intl object in context - */ -export function mountWithIntl( - node: ReactElement, - { - context, - childContextTypes, - ...props - }: { - context?: any; - childContextTypes?: ValidationMap; - } = {} -) { - const options = getOptions(context, childContextTypes, props); - - return mount(nodeWithIntlProp(node), options); -} - -/** - * Creates the wrapper instance using render with provided intl object into context - * - * @param node The React element or cheerio wrapper - * @param options properties to pass into render wrapper - * @return The wrapper instance around the rendered output with intl object in context - */ -export function renderWithIntl( - node: ReactElement, - { - context, - childContextTypes, - ...props - }: { - context?: any; - childContextTypes?: ValidationMap; - } = {} -) { - const options = getOptions(context, childContextTypes, props); - - return render(nodeWithIntlProp(node), options); -} - -export const nextTick = () => new Promise((res) => process.nextTick(res)); - -export function shallowWithI18nProvider(child: ReactElement) { - const wrapped = shallow({child}); - const name = typeof child.type === 'string' ? child.type : child.type.name; - return wrapped.find(name).dive(); -} - -export function mountWithI18nProvider(child: ReactElement) { - const wrapped = mount({child}); - const name = typeof child.type === 'string' ? child.type : child.type.name; - return wrapped.find(name); -} diff --git a/src/test_utils/public/testbed/testbed.ts b/src/test_utils/public/testbed/testbed.ts deleted file mode 100644 index 1044189009c64..0000000000000 --- a/src/test_utils/public/testbed/testbed.ts +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { ComponentType, ReactWrapper } from 'enzyme'; - -import { findTestSubject, reactRouterMock } from '../helpers'; -import { - mountComponentSync, - mountComponentAsync, - getJSXComponentWithProps, -} from './mount_component'; -import { TestBedConfig, TestBed, SetupFunc } from './types'; - -const defaultConfig: TestBedConfig = { - defaultProps: {}, - memoryRouter: { - wrapComponent: true, - }, - store: null, -}; - -/** - * Register a new Testbed to test a React Component. - * - * @param Component The component under test - * @param config An optional configuration object for the Testbed - * - * @example - ```typescript - import { registerTestBed } from '../../../../test_utils'; - import { RemoteClusterList } from '../../app/sections/remote_cluster_list'; - import { remoteClustersStore } from '../../app/store'; - - const setup = registerTestBed(RemoteClusterList, { store: remoteClustersStore }); - - describe(', () > { - test('it should have a table', () => { - const { exists } = setup(); - expect(exists('remoteClustersTable')).toBe(true); - }); - }); - ``` - */ -export const registerTestBed = ( - Component: ComponentType, - config?: TestBedConfig -): SetupFunc => { - const { - defaultProps = defaultConfig.defaultProps, - memoryRouter = defaultConfig.memoryRouter!, - store = defaultConfig.store, - doMountAsync = false, - } = config || {}; - - // Keep a reference to the React Router - let router: any; - - const onRouter = (_router: any) => { - router = _router; - - if (memoryRouter.onRouter) { - memoryRouter.onRouter(_router); - } - }; - - /** - * In some cases, component have some logic that interacts with the react router - * _before_ the component is mounted.(Class constructor() I'm looking at you :) - * - * By adding the following lines, we make sure there is always a router available - * when instantiating the Component. - */ - onRouter(reactRouterMock); - - const setup: SetupFunc = (props) => { - // If a function is provided we execute it - const storeToMount = typeof store === 'function' ? store() : store!; - const mountConfig = { - Component, - memoryRouter, - store: storeToMount, - props: { - ...defaultProps, - ...props, - }, - onRouter, - }; - - if (doMountAsync) { - return mountComponentAsync(mountConfig).then(onComponentMounted); - } - - return onComponentMounted(mountComponentSync(mountConfig)); - - // --------------------- - - function onComponentMounted(component: ReactWrapper) { - /** - * ---------------------------------------------------------------- - * Utils - * ---------------------------------------------------------------- - */ - - const find: TestBed['find'] = (testSubject: T, sourceReactWrapper = component) => { - const testSubjectToArray = testSubject.split('.'); - - return testSubjectToArray.reduce((reactWrapper, subject, i) => { - const target = findTestSubject(reactWrapper, subject); - if (!target.length && i < testSubjectToArray.length - 1) { - throw new Error( - `Can't access nested test subject "${ - testSubjectToArray[i + 1] - }" of unknown node "${subject}"` - ); - } - return target; - }, sourceReactWrapper); - }; - - const exists: TestBed['exists'] = (testSubject, count = 1) => - find(testSubject).length === count; - - const setProps: TestBed['setProps'] = (updatedProps) => { - if (memoryRouter.wrapComponent !== false) { - throw new Error( - 'setProps() can only be called on a component **not** wrapped by a router route.' - ); - } - if (store === null) { - return component.setProps({ ...defaultProps, ...updatedProps }); - } - // Update the props on the Redux Provider children - return component.setProps({ - children: getJSXComponentWithProps(Component, { ...defaultProps, ...updatedProps }), - }); - }; - - const waitFor: TestBed['waitFor'] = async (testSubject: T, count = 1) => { - const triggeredAt = Date.now(); - - /** - * The way jest run tests in parallel + the not deterministic DOM update from React "hooks" - * add flakiness to the tests. This is especially true for component integration tests that - * make many update to the DOM. - * - * For this reason, when we _know_ that an element should be there after we updated some state, - * we will give it 30 seconds to appear in the DOM, checking every 100 ms for its presence. - */ - const MAX_WAIT_TIME = 30000; - const WAIT_INTERVAL = 100; - - const process = async (): Promise => { - const elemFound = exists(testSubject, count); - - if (elemFound) { - // Great! nothing else to do here. - return; - } - - const timeElapsed = Date.now() - triggeredAt; - if (timeElapsed > MAX_WAIT_TIME) { - throw new Error( - `I waited patiently for the "${testSubject}" test subject to appear with no luck. It is nowhere to be found!` - ); - } - - return new Promise((resolve) => setTimeout(resolve, WAIT_INTERVAL)).then(() => { - component.update(); - return process(); - }); - }; - - return process(); - }; - - /** - * ---------------------------------------------------------------- - * Forms - * ---------------------------------------------------------------- - */ - - const setInputValue: TestBed['form']['setInputValue'] = ( - input, - value, - isAsync = false - ) => { - const formInput = typeof input === 'string' ? find(input) : (input as ReactWrapper); - - if (!formInput.length) { - throw new Error(`Input "${input}" was not found.`); - } - formInput.simulate('change', { target: { value } }); - component.update(); - - if (!isAsync) { - return; - } - return new Promise((resolve) => setTimeout(resolve)); - }; - - const setSelectValue: TestBed['form']['setSelectValue'] = ( - select, - value, - doUpdateComponent = true - ) => { - const formSelect = typeof select === 'string' ? find(select) : (select as ReactWrapper); - - if (!formSelect.length) { - throw new Error(`Select "${select}" was not found.`); - } - - formSelect.simulate('change', { target: { value } }); - - if (doUpdateComponent) { - component.update(); - } - }; - - const selectCheckBox: TestBed['form']['selectCheckBox'] = ( - testSubject, - isChecked = true - ) => { - const checkBox = find(testSubject); - if (!checkBox.length) { - throw new Error(`"${testSubject}" was not found.`); - } - checkBox.simulate('change', { target: { checked: isChecked } }); - }; - - const toggleEuiSwitch: TestBed['form']['toggleEuiSwitch'] = (testSubject) => { - const checkBox = find(testSubject); - if (!checkBox.length) { - throw new Error(`"${testSubject}" was not found.`); - } - checkBox.simulate('click'); - }; - - const setComboBoxValue: TestBed['form']['setComboBoxValue'] = ( - comboBoxTestSubject, - value - ) => { - const comboBox = find(comboBoxTestSubject); - const formInput = findTestSubject(comboBox, 'comboBoxSearchInput'); - setInputValue(formInput, value); - - // keyCode 13 === ENTER - comboBox.simulate('keydown', { keyCode: 13 }); - component.update(); - }; - - const getErrorsMessages: TestBed['form']['getErrorsMessages'] = () => { - const errorMessagesWrappers = component.find('.euiFormErrorText'); - return errorMessagesWrappers.map((err) => err.text()); - }; - - /** - * ---------------------------------------------------------------- - * Tables - * ---------------------------------------------------------------- - */ - - /** - * Parse an EUI table and return meta data information about its rows and colum content. - * - * @param tableTestSubject The data test subject of the EUI table - */ - const getMetaData: TestBed['table']['getMetaData'] = (tableTestSubject) => { - const table = find(tableTestSubject); - - if (!table.length) { - throw new Error(`Eui Table "${tableTestSubject}" not found.`); - } - - const rows = table - .find('tr') - .slice(1) // we remove the first row as it is the table header - .map((row) => ({ - reactWrapper: row, - columns: row.find('td').map((col) => ({ - reactWrapper: col, - // We can't access the td value with col.text() because - // eui adds an extra div in td on mobile => (.euiTableRowCell__mobileHeader) - value: col.find('.euiTableCellContent').text(), - })), - })); - - // Also output the raw cell values, in the following format: [[td0, td1, td2], [td0, td1, td2]] - const tableCellsValues = rows.map(({ columns }) => columns.map((col) => col.value)); - return { rows, tableCellsValues }; - }; - - /** - * ---------------------------------------------------------------- - * Router - * ---------------------------------------------------------------- - */ - const navigateTo = (_url: string) => { - const url = - _url[0] === '#' - ? _url.replace('#', '') // remove the beginning hash as the memory router does not understand them - : _url; - router.history.push(url); - }; - - return { - component, - exists, - find, - setProps, - waitFor, - table: { - getMetaData, - }, - form: { - setInputValue, - setSelectValue, - selectCheckBox, - toggleEuiSwitch, - setComboBoxValue, - getErrorsMessages, - }, - router: { - navigateTo, - }, - }; - } - }; - - return setup; -}; diff --git a/x-pack/dev-tools/jest/create_jest_config.js b/x-pack/dev-tools/jest/create_jest_config.js index 1495d52fceae8..2ddc58500d15e 100644 --- a/x-pack/dev-tools/jest/create_jest_config.js +++ b/x-pack/dev-tools/jest/create_jest_config.js @@ -4,71 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -export function createJestConfig({ kibanaDirectory, rootDir, xPackKibanaDirectory }) { - const fileMockPath = `${kibanaDirectory}/src/dev/jest/mocks/file_mock.js`; +export function createJestConfig({ kibanaDirectory, rootDir }) { return { - rootDir, - roots: ['/plugins'], - moduleFileExtensions: ['js', 'mjs', 'json', 'ts', 'tsx', 'node'], - moduleNameMapper: { - '@elastic/eui$': `${kibanaDirectory}/node_modules/@elastic/eui/test-env`, - '@elastic/eui/lib/(.*)?': `${kibanaDirectory}/node_modules/@elastic/eui/test-env/$1`, - '^fixtures/(.*)': `${kibanaDirectory}/src/fixtures/$1`, - '^src/core/(.*)': `${kibanaDirectory}/src/core/$1`, - '^src/legacy/(.*)': `${kibanaDirectory}/src/legacy/$1`, - '^src/plugins/(.*)': `${kibanaDirectory}/src/plugins/$1`, - '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': fileMockPath, - '\\.module.(css|scss)$': `${kibanaDirectory}/src/dev/jest/mocks/css_module_mock.js`, - '\\.(css|less|scss)$': `${kibanaDirectory}/src/dev/jest/mocks/style_mock.js`, - '\\.ace\\.worker.js$': `${kibanaDirectory}/src/dev/jest/mocks/worker_module_mock.js`, - '\\.editor\\.worker.js$': `${kibanaDirectory}/src/dev/jest/mocks/worker_module_mock.js`, - '^test_utils/enzyme_helpers': `${xPackKibanaDirectory}/test_utils/enzyme_helpers.tsx`, - '^test_utils/find_test_subject': `${xPackKibanaDirectory}/test_utils/find_test_subject.ts`, - '^test_utils/stub_web_worker': `${xPackKibanaDirectory}/test_utils/stub_web_worker.ts`, - '^(!!)?file-loader!': fileMockPath, - }, - collectCoverageFrom: [ - 'plugins/**/*.{js,mjs,jsx,ts,tsx}', - '!**/{__test__,__snapshots__,__examples__,integration_tests,tests}/**', - '!**/*.test.{js,mjs,ts,tsx}', - '!**/flot-charts/**', - '!**/test/**', - '!**/build/**', - '!**/scripts/**', - '!**/mocks/**', - '!**/plugins/apm/e2e/**', - '!**/plugins/siem/cypress/**', - '!**/plugins/**/test_helpers/**', - ], - coveragePathIgnorePatterns: ['.*\\.d\\.ts'], - coverageDirectory: `${kibanaDirectory}/target/kibana-coverage/jest`, - coverageReporters: !!process.env.CODE_COVERAGE ? ['json'] : ['html'], - setupFiles: [ - `${kibanaDirectory}/src/dev/jest/setup/babel_polyfill.js`, - `${xPackKibanaDirectory}/dev-tools/jest/setup/polyfills.js`, - `${xPackKibanaDirectory}/dev-tools/jest/setup/enzyme.js`, - ], - setupFilesAfterEnv: [ - `${xPackKibanaDirectory}/dev-tools/jest/setup/setup_test.js`, - `${kibanaDirectory}/src/dev/jest/setup/mocks.js`, - `${kibanaDirectory}/src/dev/jest/setup/react_testing_library.js`, - ], - testEnvironment: 'jest-environment-jsdom-thirteen', - testMatch: ['**/*.test.{js,mjs,ts,tsx}'], - testRunner: 'jest-circus/runner', - transform: { - '^.+\\.(js|tsx?)$': `${kibanaDirectory}/src/dev/jest/babel_transform.js`, - '^.+\\.html?$': 'jest-raw-loader', - }, - transformIgnorePatterns: [ - // ignore all node_modules except monaco-editor which requires babel transforms to handle dynamic import() - // since ESM modules are not natively supported in Jest yet (https://github.com/facebook/jest/issues/4842) - '[/\\\\]node_modules(?![\\/\\\\]monaco-editor)[/\\\\].+\\.js$', - ], - snapshotSerializers: [ - `${kibanaDirectory}/node_modules/enzyme-to-json/serializer`, - `${kibanaDirectory}/src/plugins/kibana_react/public/util/test_helpers/react_mount_serializer.ts`, - ], + preset: '@kbn/test', + rootDir: kibanaDirectory, + roots: [`${rootDir}/plugins`], reporters: [ 'default', [ diff --git a/x-pack/dev-tools/jest/setup/enzyme.js b/x-pack/dev-tools/jest/setup/enzyme.js deleted file mode 100644 index 290e3d220aa4b..0000000000000 --- a/x-pack/dev-tools/jest/setup/enzyme.js +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { configure } from 'enzyme'; -import Adapter from 'enzyme-adapter-react-16'; - -configure({ adapter: new Adapter() }); diff --git a/x-pack/dev-tools/jest/setup/polyfills.js b/x-pack/dev-tools/jest/setup/polyfills.js deleted file mode 100644 index a841a3bf9cad0..0000000000000 --- a/x-pack/dev-tools/jest/setup/polyfills.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -// bluebird < v3.3.5 does not work with MutationObserver polyfill -// when MutationObserver exists, bluebird avoids using node's builtin async schedulers -// x-pack has a different version of bluebird so it needs its own polyfills.js to ensure -// the scheduler is set on the right bluebird instance -const bluebird = require('bluebird'); -bluebird.Promise.setScheduler(function (fn) { - global.setImmediate.call(global, fn); -}); - -const MutationObserver = require('mutation-observer'); -Object.defineProperty(window, 'MutationObserver', { value: MutationObserver }); - -require('whatwg-fetch'); - -if (!global.URL.hasOwnProperty('createObjectURL')) { - Object.defineProperty(global.URL, 'createObjectURL', { value: () => '' }); -} - -// Will be replaced with a better solution in EUI -// https://github.com/elastic/eui/issues/3713 -global._isJest = true; diff --git a/x-pack/dev-tools/jest/setup/setup_test.js b/x-pack/dev-tools/jest/setup/setup_test.js deleted file mode 100644 index 0f044717ac789..0000000000000 --- a/x-pack/dev-tools/jest/setup/setup_test.js +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -/* - Global import, so we don't need to remember to import the lib in each file - https://www.npmjs.com/package/jest-styled-components#global-installation -*/ - -import 'jest-styled-components'; -import '@testing-library/jest-dom'; diff --git a/x-pack/plugins/alerts/common/builtin_action_groups.ts b/x-pack/plugins/alerts/common/builtin_action_groups.ts new file mode 100644 index 0000000000000..d31f75357d370 --- /dev/null +++ b/x-pack/plugins/alerts/common/builtin_action_groups.ts @@ -0,0 +1,18 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { i18n } from '@kbn/i18n'; +import { ActionGroup } from './alert_type'; + +export const ResolvedActionGroup: ActionGroup = { + id: 'resolved', + name: i18n.translate('xpack.alerts.builtinActionGroups.resolved', { + defaultMessage: 'Resolved', + }), +}; + +export function getBuiltinActionGroups(): ActionGroup[] { + return [ResolvedActionGroup]; +} diff --git a/x-pack/plugins/alerts/common/index.ts b/x-pack/plugins/alerts/common/index.ts index 65aeec840da7e..4d0e7bf7eb0bc 100644 --- a/x-pack/plugins/alerts/common/index.ts +++ b/x-pack/plugins/alerts/common/index.ts @@ -12,11 +12,7 @@ export * from './alert_instance'; export * from './alert_task_instance'; export * from './alert_navigation'; export * from './alert_instance_summary'; - -export interface ActionGroup { - id: string; - name: string; -} +export * from './builtin_action_groups'; export interface AlertingFrameworkHealth { isSufficientlySecure: boolean; diff --git a/x-pack/plugins/alerts/server/alert_type_registry.test.ts b/x-pack/plugins/alerts/server/alert_type_registry.test.ts index 9e1545bae5384..8dc387f96addb 100644 --- a/x-pack/plugins/alerts/server/alert_type_registry.test.ts +++ b/x-pack/plugins/alerts/server/alert_type_registry.test.ts @@ -95,6 +95,33 @@ describe('register()', () => { ); }); + test('throws if AlertType action groups contains reserved group id', () => { + const alertType = { + id: 'test', + name: 'Test', + actionGroups: [ + { + id: 'default', + name: 'Default', + }, + { + id: 'resolved', + name: 'Resolved', + }, + ], + defaultActionGroupId: 'default', + executor: jest.fn(), + producer: 'alerts', + }; + const registry = new AlertTypeRegistry(alertTypeRegistryParams); + + expect(() => registry.register(alertType)).toThrowError( + new Error( + `Alert type [id="${alertType.id}"] cannot be registered. Action groups [resolved] are reserved by the framework.` + ) + ); + }); + test('registers the executor with the task manager', () => { const alertType = { id: 'test', @@ -201,6 +228,10 @@ describe('get()', () => { "id": "default", "name": "Default", }, + Object { + "id": "resolved", + "name": "Resolved", + }, ], "actionVariables": Object { "context": Array [], @@ -255,6 +286,10 @@ describe('list()', () => { "id": "testActionGroup", "name": "Test Action Group", }, + Object { + "id": "resolved", + "name": "Resolved", + }, ], "actionVariables": Object { "context": Array [], diff --git a/x-pack/plugins/alerts/server/alert_type_registry.ts b/x-pack/plugins/alerts/server/alert_type_registry.ts index 1d2d9981faeaa..8fe2ab06acd9a 100644 --- a/x-pack/plugins/alerts/server/alert_type_registry.ts +++ b/x-pack/plugins/alerts/server/alert_type_registry.ts @@ -8,6 +8,8 @@ import Boom from '@hapi/boom'; import { i18n } from '@kbn/i18n'; import { schema } from '@kbn/config-schema'; import typeDetect from 'type-detect'; +import { intersection } from 'lodash'; +import _ from 'lodash'; import { RunContext, TaskManagerSetupContract } from '../../task_manager/server'; import { TaskRunnerFactory } from './task_runner'; import { @@ -16,7 +18,9 @@ import { AlertTypeState, AlertInstanceState, AlertInstanceContext, + ActionGroup, } from './types'; +import { getBuiltinActionGroups } from '../common'; interface ConstructorOptions { taskManager: TaskManagerSetupContract; @@ -82,6 +86,8 @@ export class AlertTypeRegistry { ); } alertType.actionVariables = normalizedActionVariables(alertType.actionVariables); + validateActionGroups(alertType.id, alertType.actionGroups); + alertType.actionGroups = [...alertType.actionGroups, ..._.cloneDeep(getBuiltinActionGroups())]; this.alertTypes.set(alertIdSchema.validate(alertType.id), { ...alertType } as AlertType); this.taskManager.registerTaskDefinitions({ [`alerting:${alertType.id}`]: { @@ -137,3 +143,22 @@ function normalizedActionVariables(actionVariables: AlertType['actionVariables'] params: actionVariables?.params ?? [], }; } + +function validateActionGroups(alertTypeId: string, actionGroups: ActionGroup[]) { + const reservedActionGroups = intersection( + actionGroups.map((item) => item.id), + getBuiltinActionGroups().map((item) => item.id) + ); + if (reservedActionGroups.length > 0) { + throw new Error( + i18n.translate('xpack.alerts.alertTypeRegistry.register.reservedActionGroupUsageError', { + defaultMessage: + 'Alert type [id="{alertTypeId}"] cannot be registered. Action groups [{actionGroups}] are reserved by the framework.', + values: { + actionGroups: reservedActionGroups.join(', '), + alertTypeId, + }, + }) + ); + } +} diff --git a/x-pack/plugins/alerts/server/task_runner/task_runner.test.ts b/x-pack/plugins/alerts/server/task_runner/task_runner.test.ts index 859b6ec4362ce..bd583159af5d5 100644 --- a/x-pack/plugins/alerts/server/task_runner/task_runner.test.ts +++ b/x-pack/plugins/alerts/server/task_runner/task_runner.test.ts @@ -25,12 +25,12 @@ import { alertsMock, alertsClientMock } from '../mocks'; import { eventLoggerMock } from '../../../event_log/server/event_logger.mock'; import { IEventLogger } from '../../../event_log/server'; import { SavedObjectsErrorHelpers } from '../../../../../src/core/server'; -import { Alert } from '../../common'; +import { Alert, ResolvedActionGroup } from '../../common'; import { omit } from 'lodash'; const alertType = { id: 'test', name: 'My test alert', - actionGroups: [{ id: 'default', name: 'Default' }], + actionGroups: [{ id: 'default', name: 'Default' }, ResolvedActionGroup], defaultActionGroupId: 'default', executor: jest.fn(), producer: 'alerts', @@ -91,7 +91,7 @@ describe('Task Runner', () => { throttle: null, muteAll: false, enabled: true, - alertTypeId: '123', + alertTypeId: alertType.id, apiKey: '', apiKeyOwner: 'elastic', schedule: { interval: '10s' }, @@ -112,6 +112,14 @@ describe('Task Runner', () => { foo: true, }, }, + { + group: ResolvedActionGroup.id, + id: '2', + actionTypeId: 'action', + params: { + isResolved: true, + }, + }, ], executionStatus: { status: 'unknown', @@ -507,6 +515,79 @@ describe('Task Runner', () => { `); }); + test('fire resolved actions for execution for the alertInstances which is in the resolved state', async () => { + taskRunnerFactoryInitializerParams.actionsPlugin.isActionTypeEnabled.mockReturnValue(true); + taskRunnerFactoryInitializerParams.actionsPlugin.isActionExecutable.mockReturnValue(true); + + alertType.executor.mockImplementation( + ({ services: executorServices }: AlertExecutorOptions) => { + executorServices.alertInstanceFactory('1').scheduleActions('default'); + } + ); + const taskRunner = new TaskRunner( + alertType, + { + ...mockedTaskInstance, + state: { + ...mockedTaskInstance.state, + alertInstances: { + '1': { meta: {}, state: { bar: false } }, + '2': { meta: {}, state: { bar: false } }, + }, + }, + }, + taskRunnerFactoryInitializerParams + ); + alertsClient.get.mockResolvedValue(mockedAlertTypeSavedObject); + encryptedSavedObjectsClient.getDecryptedAsInternalUser.mockResolvedValue({ + id: '1', + type: 'alert', + attributes: { + apiKey: Buffer.from('123:abc').toString('base64'), + }, + references: [], + }); + const runnerResult = await taskRunner.run(); + expect(runnerResult.state.alertInstances).toMatchInlineSnapshot(` + Object { + "1": Object { + "meta": Object { + "lastScheduledActions": Object { + "date": 1970-01-01T00:00:00.000Z, + "group": "default", + }, + }, + "state": Object { + "bar": false, + }, + }, + } + `); + + const eventLogger = taskRunnerFactoryInitializerParams.eventLogger; + expect(eventLogger.logEvent).toHaveBeenCalledTimes(5); + expect(actionsClient.enqueueExecution).toHaveBeenCalledTimes(2); + expect(actionsClient.enqueueExecution.mock.calls[0]).toMatchInlineSnapshot(` + Array [ + Object { + "apiKey": "MTIzOmFiYw==", + "id": "2", + "params": Object { + "isResolved": true, + }, + "source": Object { + "source": Object { + "id": "1", + "type": "alert", + }, + "type": "SAVED_OBJECT", + }, + "spaceId": undefined, + }, + ] + `); + }); + test('persists alertInstances passed in from state, only if they are scheduled for execution', async () => { alertType.executor.mockImplementation( ({ services: executorServices }: AlertExecutorOptions) => { diff --git a/x-pack/plugins/alerts/server/task_runner/task_runner.ts b/x-pack/plugins/alerts/server/task_runner/task_runner.ts index 5bccf5c497a60..0dad952a86590 100644 --- a/x-pack/plugins/alerts/server/task_runner/task_runner.ts +++ b/x-pack/plugins/alerts/server/task_runner/task_runner.ts @@ -37,6 +37,7 @@ import { IEvent, IEventLogger, SAVED_OBJECT_REL_PRIMARY } from '../../../event_l import { isAlertSavedObjectNotFoundError } from '../lib/is_alert_not_found_error'; import { AlertsClient } from '../alerts_client'; import { partiallyUpdateAlert } from '../saved_objects'; +import { ResolvedActionGroup } from '../../common'; const FALLBACK_RETRY_INTERVAL = '5m'; @@ -210,6 +211,7 @@ export class TaskRunner { const instancesWithScheduledActions = pickBy(alertInstances, (alertInstance: AlertInstance) => alertInstance.hasScheduledActions() ); + generateNewAndResolvedInstanceEvents({ eventLogger, originalAlertInstances, @@ -220,6 +222,14 @@ export class TaskRunner { }); if (!muteAll) { + scheduleActionsForResolvedInstances( + alertInstances, + executionHandler, + originalAlertInstances, + instancesWithScheduledActions, + alert.mutedInstanceIds + ); + const mutedInstanceIdsSet = new Set(mutedInstanceIds); await Promise.all( @@ -479,6 +489,34 @@ function generateNewAndResolvedInstanceEvents(params: GenerateNewAndResolvedInst } } +function scheduleActionsForResolvedInstances( + alertInstancesMap: Record, + executionHandler: ReturnType, + originalAlertInstances: Record, + currentAlertInstances: Dictionary, + mutedInstanceIds: string[] +) { + const currentAlertInstanceIds = Object.keys(currentAlertInstances); + const originalAlertInstanceIds = Object.keys(originalAlertInstances); + const resolvedIds = without( + originalAlertInstanceIds, + ...currentAlertInstanceIds, + ...mutedInstanceIds + ); + for (const id of resolvedIds) { + const instance = alertInstancesMap[id]; + instance.updateLastScheduledActions(ResolvedActionGroup.id); + instance.unscheduleActions(); + executionHandler({ + actionGroup: ResolvedActionGroup.id, + context: {}, + state: {}, + alertInstanceId: id, + }); + instance.scheduleActions(ResolvedActionGroup.id); + } +} + /** * If an error is thrown, wrap it in an AlertTaskRunResult * so that we can treat each field independantly diff --git a/x-pack/plugins/apm/public/application/index.tsx b/x-pack/plugins/apm/public/application/index.tsx index 2e1f259bd8c42..79c29867cb8e3 100644 --- a/x-pack/plugins/apm/public/application/index.tsx +++ b/x-pack/plugins/apm/public/application/index.tsx @@ -33,11 +33,9 @@ import { ApmPluginSetupDeps } from '../plugin'; import { createCallApmApi } from '../services/rest/createCallApmApi'; import { createStaticIndexPattern } from '../services/rest/index_pattern'; import { setHelpExtension } from '../setHelpExtension'; -import { px, units } from '../style/variables'; import { setReadonlyBadge } from '../updateBadge'; const MainContainer = styled.div` - padding: ${px(units.plus)}; height: 100%; `; diff --git a/x-pack/plugins/apm/public/components/app/Correlations/index.tsx b/x-pack/plugins/apm/public/components/app/Correlations/index.tsx index afee2b9f5e881..e3dea70a232eb 100644 --- a/x-pack/plugins/apm/public/components/app/Correlations/index.tsx +++ b/x-pack/plugins/apm/public/components/app/Correlations/index.tsx @@ -75,7 +75,7 @@ export function Correlations() { return ( <> - +

Correlations

diff --git a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx index e95d35142684d..f47674ba5891f 100644 --- a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx +++ b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx @@ -8,6 +8,8 @@ import { EuiBadge, EuiFlexGroup, EuiFlexItem, + EuiPage, + EuiPageBody, EuiPanel, EuiSpacer, EuiText, @@ -24,6 +26,7 @@ import { useUrlParams } from '../../../hooks/useUrlParams'; import { callApmApi } from '../../../services/rest/createCallApmApi'; import { fontFamilyCode, fontSizes, px, units } from '../../../style/variables'; import { ApmHeader } from '../../shared/ApmHeader'; +import { SearchBar } from '../../shared/search_bar'; import { DetailView } from './DetailView'; import { ErrorDistribution } from './Distribution'; @@ -120,7 +123,7 @@ export function ErrorGroupDetails({ location, match }: ErrorGroupDetailsProps) { errorGroupData.error?.error.exception?.[0].handled === false; return ( -
+ <> @@ -146,62 +149,67 @@ export function ErrorGroupDetails({ location, match }: ErrorGroupDetailsProps) { )} - - - - - {showDetails && ( - - - {logMessage && ( - + + + + + {showDetails && ( + + + {logMessage && ( + + + {logMessage} + + )} - {logMessage} - + {excMessage || NOT_AVAILABLE_LABEL} + + {culprit || NOT_AVAILABLE_LABEL} + + + )} + - {i18n.translate( - 'xpack.apm.errorGroupDetails.exceptionMessageLabel', - { - defaultMessage: 'Exception message', - } - )} - - {excMessage || NOT_AVAILABLE_LABEL} - - {culprit || NOT_AVAILABLE_LABEL} - - - )} - + + + {showDetails && ( + )} - /> - - - {showDetails && ( - - )} -
+ + + ); } diff --git a/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/index.tsx b/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/index.tsx index 42b0016ca8cfe..52fb4b33cbc55 100644 --- a/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/index.tsx +++ b/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/index.tsx @@ -7,6 +7,7 @@ import { EuiFlexGroup, EuiFlexItem, + EuiPage, EuiPanel, EuiSpacer, EuiTitle, @@ -19,6 +20,7 @@ import { useFetcher } from '../../../hooks/useFetcher'; import { useUrlParams } from '../../../hooks/useUrlParams'; import { callApmApi } from '../../../services/rest/createCallApmApi'; import { LocalUIFilters } from '../../shared/LocalUIFilters'; +import { SearchBar } from '../../shared/search_bar'; import { ErrorDistribution } from '../ErrorGroupDetails/Distribution'; import { ErrorGroupList } from './List'; @@ -95,39 +97,41 @@ function ErrorGroupOverview({ serviceName }: ErrorGroupOverviewProps) { return ( <> - - - - - - - - - - - - - - -

Errors

-
+ + + + + + + + + + + - -
-
-
+ + +

Errors

+
+ + + +
+ + + ); } diff --git a/x-pack/plugins/apm/public/components/app/Home/index.tsx b/x-pack/plugins/apm/public/components/app/Home/index.tsx index 717ce9b8ebd52..5b1ddaf1e49ef 100644 --- a/x-pack/plugins/apm/public/components/app/Home/index.tsx +++ b/x-pack/plugins/apm/public/components/app/Home/index.tsx @@ -4,79 +4,76 @@ * you may not use this file except in compliance with the Elastic License. */ -import { EuiTabs, EuiTitle } from '@elastic/eui'; +import { EuiTab, EuiTitle } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import React from 'react'; +import React, { ComponentType } from 'react'; import { $ElementType } from 'utility-types'; import { ApmHeader } from '../../shared/ApmHeader'; -import { EuiTabLink } from '../../shared/EuiTabLink'; -import { ServiceMapLink } from '../../shared/Links/apm/ServiceMapLink'; -import { ServiceInventoryLink } from '../../shared/Links/apm/service_inventory_link'; -import { TraceOverviewLink } from '../../shared/Links/apm/TraceOverviewLink'; +import { useServiceMapHref } from '../../shared/Links/apm/ServiceMapLink'; +import { useServiceInventoryHref } from '../../shared/Links/apm/service_inventory_link'; +import { useTraceOverviewHref } from '../../shared/Links/apm/TraceOverviewLink'; +import { MainTabs } from '../../shared/main_tabs'; import { ServiceMap } from '../ServiceMap'; import { ServiceInventory } from '../service_inventory'; import { TraceOverview } from '../TraceOverview'; -const homeTabs = [ - { - link: ( - - {i18n.translate('xpack.apm.home.servicesTabLabel', { - defaultMessage: 'Services', - })} - - ), - render: () => , - name: 'services', - }, - { - link: ( - - {i18n.translate('xpack.apm.home.tracesTabLabel', { - defaultMessage: 'Traces', - })} - - ), - render: () => , - name: 'traces', - }, - { - link: ( - - {i18n.translate('xpack.apm.home.serviceMapTabLabel', { - defaultMessage: 'Service Map', - })} - - ), - render: () => , - name: 'service-map', - }, -]; +interface Tab { + key: string; + href: string; + text: string; + Component: ComponentType; +} interface Props { tab: 'traces' | 'services' | 'service-map'; } export function Home({ tab }: Props) { + const homeTabs: Tab[] = [ + { + key: 'services', + href: useServiceInventoryHref(), + text: i18n.translate('xpack.apm.home.servicesTabLabel', { + defaultMessage: 'Services', + }), + Component: ServiceInventory, + }, + { + key: 'traces', + href: useTraceOverviewHref(), + text: i18n.translate('xpack.apm.home.tracesTabLabel', { + defaultMessage: 'Traces', + }), + Component: TraceOverview, + }, + { + key: 'service-map', + href: useServiceMapHref(), + text: i18n.translate('xpack.apm.home.serviceMapTabLabel', { + defaultMessage: 'Service Map', + }), + Component: ServiceMap, + }, + ]; const selectedTab = homeTabs.find( - (homeTab) => homeTab.name === tab + (homeTab) => homeTab.key === tab ) as $ElementType; return ( -
+ <> - +

APM

- - {homeTabs.map((homeTab) => ( - - {homeTab.link} - + + {homeTabs.map(({ href, key, text }) => ( + + {text} + ))} - - {selectedTab.render()} -
+ + + ); } diff --git a/x-pack/plugins/apm/public/components/app/RumDashboard/RumHome.tsx b/x-pack/plugins/apm/public/components/app/RumDashboard/RumHome.tsx index f25761bd8abad..da83d3425a99c 100644 --- a/x-pack/plugins/apm/public/components/app/RumDashboard/RumHome.tsx +++ b/x-pack/plugins/apm/public/components/app/RumDashboard/RumHome.tsx @@ -21,7 +21,7 @@ export function RumHome() { - +

{UX_LABEL}

diff --git a/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceDetailTabs.tsx b/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceDetailTabs.tsx index 625a8e73debc9..f42b94b8afe33 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceDetailTabs.tsx +++ b/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceDetailTabs.tsx @@ -4,20 +4,20 @@ * you may not use this file except in compliance with the Elastic License. */ -import { EuiTabs } from '@elastic/eui'; +import { EuiTab } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import React from 'react'; +import React, { ReactNode } from 'react'; import { isJavaAgentName, isRumAgentName } from '../../../../common/agent_name'; import { enableServiceOverview } from '../../../../common/ui_settings_keys'; import { useAgentName } from '../../../hooks/useAgentName'; import { useApmPluginContext } from '../../../hooks/useApmPluginContext'; -import { EuiTabLink } from '../../shared/EuiTabLink'; -import { ErrorOverviewLink } from '../../shared/Links/apm/ErrorOverviewLink'; -import { MetricOverviewLink } from '../../shared/Links/apm/MetricOverviewLink'; -import { ServiceMapLink } from '../../shared/Links/apm/ServiceMapLink'; -import { ServiceNodeOverviewLink } from '../../shared/Links/apm/ServiceNodeOverviewLink'; -import { ServiceOverviewLink } from '../../shared/Links/apm/service_overview_link'; -import { TransactionOverviewLink } from '../../shared/Links/apm/TransactionOverviewLink'; +import { useErrorOverviewHref } from '../../shared/Links/apm/ErrorOverviewLink'; +import { useMetricOverviewHref } from '../../shared/Links/apm/MetricOverviewLink'; +import { useServiceMapHref } from '../../shared/Links/apm/ServiceMapLink'; +import { useServiceNodeOverviewHref } from '../../shared/Links/apm/ServiceNodeOverviewLink'; +import { useServiceOverviewHref } from '../../shared/Links/apm/service_overview_link'; +import { useTransactionOverviewHref } from '../../shared/Links/apm/TransactionOverviewLink'; +import { MainTabs } from '../../shared/main_tabs'; import { ErrorGroupOverview } from '../ErrorGroupOverview'; import { ServiceMap } from '../ServiceMap'; import { ServiceMetrics } from '../ServiceMetrics'; @@ -25,6 +25,13 @@ import { ServiceNodeOverview } from '../ServiceNodeOverview'; import { ServiceOverview } from '../service_overview'; import { TransactionOverview } from '../TransactionOverview'; +interface Tab { + key: string; + href: string; + text: string; + render: () => ReactNode; +} + interface Props { serviceName: string; tab: @@ -41,107 +48,91 @@ export function ServiceDetailTabs({ serviceName, tab }: Props) { const { uiSettings } = useApmPluginContext().core; const overviewTab = { - link: ( - - {i18n.translate('xpack.apm.serviceDetails.overviewTabLabel', { - defaultMessage: 'Overview', - })} - - ), + key: 'overview', + href: useServiceOverviewHref(serviceName), + text: i18n.translate('xpack.apm.serviceDetails.overviewTabLabel', { + defaultMessage: 'Overview', + }), render: () => ( ), - name: 'overview', }; const transactionsTab = { - link: ( - - {i18n.translate('xpack.apm.serviceDetails.transactionsTabLabel', { - defaultMessage: 'Transactions', - })} - - ), + key: 'transactions', + href: useTransactionOverviewHref(serviceName), + text: i18n.translate('xpack.apm.serviceDetails.transactionsTabLabel', { + defaultMessage: 'Transactions', + }), render: () => , - name: 'transactions', }; const errorsTab = { - link: ( - - {i18n.translate('xpack.apm.serviceDetails.errorsTabLabel', { - defaultMessage: 'Errors', - })} - - ), + key: 'errors', + href: useErrorOverviewHref(serviceName), + text: i18n.translate('xpack.apm.serviceDetails.errorsTabLabel', { + defaultMessage: 'Errors', + }), render: () => { return ; }, - name: 'errors', }; const serviceMapTab = { - link: ( - - {i18n.translate('xpack.apm.home.serviceMapTabLabel', { - defaultMessage: 'Service Map', - })} - - ), + key: 'service-map', + href: useServiceMapHref(serviceName), + text: i18n.translate('xpack.apm.home.serviceMapTabLabel', { + defaultMessage: 'Service Map', + }), render: () => , - name: 'service-map', }; - const tabs = [transactionsTab, errorsTab, serviceMapTab]; + const nodesListTab = { + key: 'nodes', + href: useServiceNodeOverviewHref(serviceName), + text: i18n.translate('xpack.apm.serviceDetails.nodesTabLabel', { + defaultMessage: 'JVMs', + }), + render: () => , + }; + + const metricsTab = { + key: 'metrics', + href: useMetricOverviewHref(serviceName), + text: i18n.translate('xpack.apm.serviceDetails.metricsTabLabel', { + defaultMessage: 'Metrics', + }), + render: () => + agentName ? ( + + ) : null, + }; + + const tabs: Tab[] = [transactionsTab, errorsTab]; if (uiSettings.get(enableServiceOverview)) { tabs.unshift(overviewTab); } if (isJavaAgentName(agentName)) { - const nodesListTab = { - link: ( - - {i18n.translate('xpack.apm.serviceDetails.nodesTabLabel', { - defaultMessage: 'JVMs', - })} - - ), - render: () => , - name: 'nodes', - }; tabs.push(nodesListTab); } else if (agentName && !isRumAgentName(agentName)) { - const metricsTab = { - link: ( - - {i18n.translate('xpack.apm.serviceDetails.metricsTabLabel', { - defaultMessage: 'Metrics', - })} - - ), - render: () => ( - - ), - name: 'metrics', - }; tabs.push(metricsTab); } - const selectedTab = tabs.find((serviceTab) => serviceTab.name === tab); + tabs.push(serviceMapTab); + + const selectedTab = tabs.find((serviceTab) => serviceTab.key === tab); return ( <> - - {tabs.map((serviceTab) => ( - - {serviceTab.link} - + + {tabs.map(({ href, key, text }) => ( + + {text} + ))} - + {selectedTab ? selectedTab.render() : null} ); diff --git a/x-pack/plugins/apm/public/components/app/ServiceDetails/index.tsx b/x-pack/plugins/apm/public/components/app/ServiceDetails/index.tsx index aa5dcd5a5ea18..8df2b0fda7a7e 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceDetails/index.tsx +++ b/x-pack/plugins/apm/public/components/app/ServiceDetails/index.tsx @@ -20,7 +20,7 @@ export function ServiceDetails({ match, tab }: Props) { return (
- +

{serviceName}

diff --git a/x-pack/plugins/apm/public/components/app/ServiceMap/cytoscape_options.ts b/x-pack/plugins/apm/public/components/app/ServiceMap/cytoscape_options.ts index e51f53567b5ff..d8a8a3c8e9ab4 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceMap/cytoscape_options.ts +++ b/x-pack/plugins/apm/public/components/app/ServiceMap/cytoscape_options.ts @@ -252,7 +252,6 @@ center, ${theme.eui.euiColorLightShade}`, backgroundSize: `${theme.eui.euiSizeL} ${theme.eui.euiSizeL}`, cursor: `${status === FETCH_STATUS.LOADING ? 'wait' : 'grab'}`, - margin: `-${theme.eui.gutterTypes.gutterLarge}`, marginTop: 0, }); diff --git a/x-pack/plugins/apm/public/components/app/ServiceMap/index.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/index.tsx index 752f9b7fda243..15adf8a70d357 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceMap/index.tsx +++ b/x-pack/plugins/apm/public/components/app/ServiceMap/index.tsx @@ -5,7 +5,8 @@ */ import { EuiFlexGroup, EuiFlexItem, EuiLoadingSpinner } from '@elastic/eui'; -import React, { ReactNode } from 'react'; +import React, { PropsWithChildren, ReactNode } from 'react'; +import styled from 'styled-components'; import { useTrackPageview } from '../../../../../observability/public'; import { invalidLicenseMessage, @@ -17,20 +18,27 @@ import { useLicense } from '../../../hooks/useLicense'; import { useTheme } from '../../../hooks/useTheme'; import { useUrlParams } from '../../../hooks/useUrlParams'; import { callApmApi } from '../../../services/rest/createCallApmApi'; +import { DatePicker } from '../../shared/DatePicker'; import { LicensePrompt } from '../../shared/LicensePrompt'; import { Controls } from './Controls'; import { Cytoscape } from './Cytoscape'; import { getCytoscapeDivStyle } from './cytoscape_options'; import { EmptyBanner } from './EmptyBanner'; import { EmptyPrompt } from './empty_prompt'; -import { TimeoutPrompt } from './timeout_prompt'; import { Popover } from './Popover'; +import { TimeoutPrompt } from './timeout_prompt'; import { useRefDimensions } from './useRefDimensions'; interface ServiceMapProps { serviceName?: string; } +const ServiceMapDatePickerFlexGroup = styled(EuiFlexGroup)` + padding: ${({ theme }) => theme.eui.euiSizeM}; + border-bottom: ${({ theme }) => theme.eui.euiBorderThin}; + margin: 0; +`; + function PromptContainer({ children }: { children: ReactNode }) { return ( ) { const theme = useTheme(); const license = useLicense(); const { urlParams } = useUrlParams(); @@ -126,24 +136,25 @@ export function ServiceMap({ serviceName }: ServiceMapProps) { } return ( -
- - - {serviceName && } - {status === FETCH_STATUS.LOADING && } - - -
+ <> + + + + + +
+ + + {serviceName && } + {status === FETCH_STATUS.LOADING && } + + +
+ ); } diff --git a/x-pack/plugins/apm/public/components/app/ServiceMetrics/index.tsx b/x-pack/plugins/apm/public/components/app/ServiceMetrics/index.tsx index 042752ef62f53..5808c54d578c6 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceMetrics/index.tsx +++ b/x-pack/plugins/apm/public/components/app/ServiceMetrics/index.tsx @@ -7,6 +7,7 @@ import { EuiFlexGrid, EuiFlexItem, + EuiPage, EuiPanel, EuiSpacer, EuiFlexGroup, @@ -18,6 +19,7 @@ import { useUrlParams } from '../../../hooks/useUrlParams'; import { LegacyChartsSyncContextProvider as ChartsSyncContextProvider } from '../../../context/charts_sync_context'; import { Projection } from '../../../../common/projections'; import { LocalUIFilters } from '../../shared/LocalUIFilters'; +import { SearchBar } from '../../shared/search_bar'; interface ServiceMetricsProps { agentName: string; @@ -46,26 +48,28 @@ export function ServiceMetrics({ return ( <> - - - - - - - - - {data.charts.map((chart) => ( - - - - - - ))} - - - - - + + + + + + + + + + {data.charts.map((chart) => ( + + + + + + ))} + + + + + + ); } diff --git a/x-pack/plugins/apm/public/components/app/ServiceNodeMetrics/index.tsx b/x-pack/plugins/apm/public/components/app/ServiceNodeMetrics/index.tsx index 566585c67e212..7c6b63f75382c 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceNodeMetrics/index.tsx +++ b/x-pack/plugins/apm/public/components/app/ServiceNodeMetrics/index.tsx @@ -83,7 +83,7 @@ export function ServiceNodeMetrics({ match }: ServiceNodeMetricsProps) { - +

{serviceName}

diff --git a/x-pack/plugins/apm/public/components/app/ServiceNodeOverview/index.tsx b/x-pack/plugins/apm/public/components/app/ServiceNodeOverview/index.tsx index 02dc3934dd01e..b05785db14625 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceNodeOverview/index.tsx +++ b/x-pack/plugins/apm/public/components/app/ServiceNodeOverview/index.tsx @@ -3,30 +3,31 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import React, { useMemo } from 'react'; import { EuiFlexGroup, EuiFlexItem, + EuiPage, EuiPanel, EuiToolTip, - EuiSpacer, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; +import React, { useMemo } from 'react'; import styled from 'styled-components'; +import { UNIDENTIFIED_SERVICE_NODES_LABEL } from '../../../../common/i18n'; +import { Projection } from '../../../../common/projections'; +import { SERVICE_NODE_NAME_MISSING } from '../../../../common/service_nodes'; import { asDynamicBytes, asInteger, asPercent, } from '../../../../common/utils/formatters'; -import { UNIDENTIFIED_SERVICE_NODES_LABEL } from '../../../../common/i18n'; -import { SERVICE_NODE_NAME_MISSING } from '../../../../common/service_nodes'; -import { Projection } from '../../../../common/projections'; -import { LocalUIFilters } from '../../shared/LocalUIFilters'; -import { useUrlParams } from '../../../hooks/useUrlParams'; -import { ManagedTable, ITableColumn } from '../../shared/ManagedTable'; import { useFetcher } from '../../../hooks/useFetcher'; +import { useUrlParams } from '../../../hooks/useUrlParams'; +import { px, truncate, unit } from '../../../style/variables'; import { ServiceNodeMetricOverviewLink } from '../../shared/Links/apm/ServiceNodeMetricOverviewLink'; -import { truncate, px, unit } from '../../../style/variables'; +import { LocalUIFilters } from '../../shared/LocalUIFilters'; +import { ITableColumn, ManagedTable } from '../../shared/ManagedTable'; +import { SearchBar } from '../../shared/search_bar'; const INITIAL_PAGE_SIZE = 25; const INITIAL_SORT_FIELD = 'cpu'; @@ -157,29 +158,31 @@ function ServiceNodeOverview({ serviceName }: ServiceNodeOverviewProps) { return ( <> - - - - - - - - - - - + + + + + + + + + + + + + ); } diff --git a/x-pack/plugins/apm/public/components/app/TraceOverview/index.tsx b/x-pack/plugins/apm/public/components/app/TraceOverview/index.tsx index 06b4459fb56eb..a87bbdb926a21 100644 --- a/x-pack/plugins/apm/public/components/app/TraceOverview/index.tsx +++ b/x-pack/plugins/apm/public/components/app/TraceOverview/index.tsx @@ -4,15 +4,16 @@ * you may not use this file except in compliance with the Elastic License. */ -import { EuiPanel, EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; +import { EuiFlexGroup, EuiFlexItem, EuiPage, EuiPanel } from '@elastic/eui'; import React, { useMemo } from 'react'; -import { FETCH_STATUS, useFetcher } from '../../../hooks/useFetcher'; -import { TraceList } from './TraceList'; -import { useUrlParams } from '../../../hooks/useUrlParams'; import { useTrackPageview } from '../../../../../observability/public'; -import { LocalUIFilters } from '../../shared/LocalUIFilters'; import { Projection } from '../../../../common/projections'; +import { FETCH_STATUS, useFetcher } from '../../../hooks/useFetcher'; +import { useUrlParams } from '../../../hooks/useUrlParams'; import { APIReturnType } from '../../../services/rest/createCallApmApi'; +import { LocalUIFilters } from '../../shared/LocalUIFilters'; +import { SearchBar } from '../../shared/search_bar'; +import { TraceList } from './TraceList'; type TracesAPIResponse = APIReturnType<'/api/apm/traces'>; const DEFAULT_RESPONSE: TracesAPIResponse = { @@ -56,20 +57,22 @@ export function TraceOverview() { return ( <> - - - - - - - - - - - + + + + + + + + + + + + + ); } diff --git a/x-pack/plugins/apm/public/components/app/TransactionDetails/index.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/index.tsx index e4c36b028e55c..9d9261fec6c1e 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionDetails/index.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/index.tsx @@ -8,6 +8,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule, + EuiPage, EuiPanel, EuiSpacer, EuiTitle, @@ -32,6 +33,7 @@ import { useUrlParams } from '../../../hooks/useUrlParams'; import { LocalUIFilters } from '../../shared/LocalUIFilters'; import { HeightRetainer } from '../../shared/HeightRetainer'; import { Correlations } from '../Correlations'; +import { SearchBar } from '../../shared/search_bar'; interface Sample { traceId: string; @@ -109,58 +111,59 @@ export function TransactionDetails({ }; return ( -
+ <> - +

{transactionName}

- - - - - - - - - - - - - - - - { - if (!isEmpty(bucket.samples)) { - selectSampleFromBucketClick(bucket.samples[0]); - } - }} - /> - - - - - - - - - -
+ + + + + + + + + + + + + + + + { + if (!isEmpty(bucket.samples)) { + selectSampleFromBucketClick(bucket.samples[0]); + } + }} + /> + + + + + + + + + + + ); } diff --git a/x-pack/plugins/apm/public/components/app/TransactionOverview/TransactionOverview.test.tsx b/x-pack/plugins/apm/public/components/app/TransactionOverview/TransactionOverview.test.tsx index c530a7e1489ad..2d7992feb3760 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionOverview/TransactionOverview.test.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionOverview/TransactionOverview.test.tsx @@ -119,14 +119,18 @@ describe('TransactionOverview', () => { }, }); - expect(history.location.search).toEqual('?transactionType=secondType'); + expect(history.location.search).toEqual( + '?transactionType=secondType&rangeFrom=now-15m&rangeTo=now' + ); expect(getByText(container, 'firstType')).toBeInTheDocument(); expect(getByText(container, 'secondType')).toBeInTheDocument(); fireEvent.click(getByText(container, 'firstType')); expect(history.push).toHaveBeenCalled(); - expect(history.location.search).toEqual('?transactionType=firstType'); + expect(history.location.search).toEqual( + '?transactionType=firstType&rangeFrom=now-15m&rangeTo=now' + ); }); }); diff --git a/x-pack/plugins/apm/public/components/app/TransactionOverview/index.tsx b/x-pack/plugins/apm/public/components/app/TransactionOverview/index.tsx index df9e673ed4847..a4f8d37867dd5 100644 --- a/x-pack/plugins/apm/public/components/app/TransactionOverview/index.tsx +++ b/x-pack/plugins/apm/public/components/app/TransactionOverview/index.tsx @@ -10,6 +10,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule, + EuiPage, EuiPanel, EuiSpacer, EuiTitle, @@ -33,6 +34,7 @@ import { ElasticDocsLink } from '../../shared/Links/ElasticDocsLink'; import { fromQuery, toQuery } from '../../shared/Links/url_helpers'; import { LocalUIFilters } from '../../shared/LocalUIFilters'; import { TransactionTypeFilter } from '../../shared/LocalUIFilters/TransactionTypeFilter'; +import { SearchBar } from '../../shared/search_bar'; import { Correlations } from '../Correlations'; import { TransactionList } from './TransactionList'; import { useRedirect } from './useRedirect'; @@ -120,82 +122,84 @@ export function TransactionOverview({ serviceName }: TransactionOverviewProps) { return ( <> + - - - - - - - - - - - {transactionType === TRANSACTION_PAGE_LOAD && ( - <> - - - - )} - - - - - - -

Transactions

-
- - {!transactionListData.isAggregationAccurate && ( - -

- - xpack.apm.ui.transactionGroupBucketSize - - ), - }} - /> - - - {i18n.translate( - 'xpack.apm.transactionCardinalityWarning.docsLink', - { defaultMessage: 'Learn more in the docs' } - )} - -

-
+ + + + + + + + + + + {transactionType === TRANSACTION_PAGE_LOAD && ( + <> + + + )} - - -
-
-
+ + + +

Transactions

+
+ + {!transactionListData.isAggregationAccurate && ( + +

+ + xpack.apm.ui.transactionGroupBucketSize + + ), + }} + /> + + + {i18n.translate( + 'xpack.apm.transactionCardinalityWarning.docsLink', + { defaultMessage: 'Learn more in the docs' } + )} + +

+
+ )} + + +
+ +
+ ); } diff --git a/x-pack/plugins/apm/public/components/app/service_inventory/index.tsx b/x-pack/plugins/apm/public/components/app/service_inventory/index.tsx index 43af1a3e04dcd..7a5893314ddf0 100644 --- a/x-pack/plugins/apm/public/components/app/service_inventory/index.tsx +++ b/x-pack/plugins/apm/public/components/app/service_inventory/index.tsx @@ -4,24 +4,30 @@ * you may not use this file except in compliance with the Elastic License. */ -import { EuiPanel, EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; -import { EuiLink } from '@elastic/eui'; +import { + EuiFlexGroup, + EuiFlexItem, + EuiLink, + EuiPage, + EuiPanel, +} from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React, { useEffect, useMemo } from 'react'; import url from 'url'; import { toMountPoint } from '../../../../../../../src/plugins/kibana_react/public'; -import { useFetcher, FETCH_STATUS } from '../../../hooks/useFetcher'; -import { NoServicesMessage } from './no_services_message'; -import { ServiceList } from './ServiceList'; -import { useUrlParams } from '../../../hooks/useUrlParams'; import { useTrackPageview } from '../../../../../observability/public'; import { Projection } from '../../../../common/projections'; -import { LocalUIFilters } from '../../shared/LocalUIFilters'; +import { useAnomalyDetectionJobs } from '../../../hooks/useAnomalyDetectionJobs'; import { useApmPluginContext } from '../../../hooks/useApmPluginContext'; -import { MLCallout } from './ServiceList/MLCallout'; +import { FETCH_STATUS, useFetcher } from '../../../hooks/useFetcher'; import { useLocalStorage } from '../../../hooks/useLocalStorage'; -import { useAnomalyDetectionJobs } from '../../../hooks/useAnomalyDetectionJobs'; +import { useUrlParams } from '../../../hooks/useUrlParams'; +import { LocalUIFilters } from '../../shared/LocalUIFilters'; +import { SearchBar } from '../../shared/search_bar'; import { Correlations } from '../Correlations'; +import { NoServicesMessage } from './no_services_message'; +import { ServiceList } from './ServiceList'; +import { MLCallout } from './ServiceList/MLCallout'; const initialData = { items: [], @@ -121,37 +127,39 @@ export function ServiceInventory() { return ( <> - - - - - - - - - - - {displayMlCallout ? ( + + + + + + + + + + {displayMlCallout ? ( + + setUserHasDismissedCallout(true)} + /> + + ) : null} - setUserHasDismissedCallout(true)} /> + + + } + /> + - ) : null} - - - - } - /> - - - - - + + + + ); } diff --git a/x-pack/plugins/apm/public/components/app/service_inventory/service_inventory.test.tsx b/x-pack/plugins/apm/public/components/app/service_inventory/service_inventory.test.tsx index 247e91fb438ef..de5e92664a769 100644 --- a/x-pack/plugins/apm/public/components/app/service_inventory/service_inventory.test.tsx +++ b/x-pack/plugins/apm/public/components/app/service_inventory/service_inventory.test.tsx @@ -21,8 +21,9 @@ import { import * as useAnomalyDetectionJobs from '../../../hooks/useAnomalyDetectionJobs'; import { FETCH_STATUS } from '../../../hooks/useFetcher'; import * as useLocalUIFilters from '../../../hooks/useLocalUIFilters'; -import * as urlParamsHooks from '../../../hooks/useUrlParams'; +import * as useDynamicIndexPatternHooks from '../../../hooks/useDynamicIndexPattern'; import { SessionStorageMock } from '../../../services/__test__/SessionStorageMock'; +import { MockUrlParamsContextProvider } from '../../../context/UrlParamsContext/MockUrlParamsContextProvider'; const KibanaReactContext = createKibanaReactContext({ usageCollection: { reportUiStats: () => {} }, @@ -50,7 +51,16 @@ function wrapper({ children }: { children?: ReactNode }) { - {children} + + {children} + @@ -63,16 +73,6 @@ describe('ServiceInventory', () => { // @ts-expect-error global.sessionStorage = new SessionStorageMock(); - // mock urlParams - jest.spyOn(urlParamsHooks, 'useUrlParams').mockReturnValue({ - urlParams: { - start: 'myStart', - end: 'myEnd', - }, - refreshTimeRange: jest.fn(), - uiFilters: {}, - }); - jest.spyOn(useLocalUIFilters, 'useLocalUIFilters').mockReturnValue({ filters: [], setFilterValue: () => null, @@ -90,6 +90,13 @@ describe('ServiceInventory', () => { }, refetch: () => undefined, }); + + jest + .spyOn(useDynamicIndexPatternHooks, 'useDynamicIndexPattern') + .mockReturnValue({ + indexPattern: undefined, + status: FETCH_STATUS.SUCCESS, + }); }); afterEach(() => { diff --git a/x-pack/plugins/apm/public/components/app/service_overview/index.tsx b/x-pack/plugins/apm/public/components/app/service_overview/index.tsx index ee77157fe4eb3..44bd7d6c73d8e 100644 --- a/x-pack/plugins/apm/public/components/app/service_overview/index.tsx +++ b/x-pack/plugins/apm/public/components/app/service_overview/index.tsx @@ -4,7 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ -import { EuiFlexGroup, EuiFlexItem, EuiPanel, EuiTitle } from '@elastic/eui'; +import { + EuiFlexGroup, + EuiFlexItem, + EuiPage, + EuiPanel, + EuiTitle, +} from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React from 'react'; import styled from 'styled-components'; @@ -14,6 +20,7 @@ import { ChartsSyncContextProvider } from '../../../context/charts_sync_context' import { TransactionErrorRateChart } from '../../shared/charts/transaction_error_rate_chart'; import { ServiceMapLink } from '../../shared/Links/apm/ServiceMapLink'; import { TransactionOverviewLink } from '../../shared/Links/apm/TransactionOverviewLink'; +import { SearchBar } from '../../shared/search_bar'; import { ServiceOverviewErrorsTable } from './service_overview_errors_table'; import { TableLinkFlexItem } from './table_link_flex_item'; @@ -42,177 +49,167 @@ export function ServiceOverview({ return ( - - - - - Search bar - - - Comparison picker - - - Date picker - - - - - - -

- {i18n.translate('xpack.apm.serviceOverview.latencyChartTitle', { - defaultMessage: 'Latency', - })} -

-
-
-
- - - - - -

- {i18n.translate( - 'xpack.apm.serviceOverview.trafficChartTitle', - { - defaultMessage: 'Traffic', - } - )} -

-
-
-
- - - - - -

- {i18n.translate( - 'xpack.apm.serviceOverview.transactionsTableTitle', - { - defaultMessage: 'Transactions', - } - )} -

-
-
- - + + + + + + +

+ {i18n.translate( + 'xpack.apm.serviceOverview.latencyChartTitle', + { + defaultMessage: 'Latency', + } + )} +

+
+
+
+ + + + + +

{i18n.translate( - 'xpack.apm.serviceOverview.transactionsTableLinkText', + 'xpack.apm.serviceOverview.trafficChartTitle', { - defaultMessage: 'View transactions', + defaultMessage: 'Traffic', } )} - - - - - - - - - - {!isRumAgentName(agentName) && ( - - +

+
+
- )} - - - - - -
-
- - - - - - - -

+ + + + + +

+ {i18n.translate( + 'xpack.apm.serviceOverview.transactionsTableTitle', + { + defaultMessage: 'Transactions', + } + )} +

+
+
+ + {i18n.translate( - 'xpack.apm.serviceOverview.averageDurationBySpanTypeChartTitle', + 'xpack.apm.serviceOverview.transactionsTableLinkText', { - defaultMessage: 'Average duration by span type', + defaultMessage: 'View transactions', } )} -

-
-
-
-
-
- - - - - -

+ + + + + + + + + + {!isRumAgentName(agentName) && ( + + + + )} + + + + + + + + + + + + + + +

+ {i18n.translate( + 'xpack.apm.serviceOverview.averageDurationBySpanTypeChartTitle', + { + defaultMessage: 'Average duration by span type', + } + )} +

+
+
+
+
+
+ + + + + +

+ {i18n.translate( + 'xpack.apm.serviceOverview.dependenciesTableTitle', + { + defaultMessage: 'Dependencies', + } + )} +

+
+
+ + {i18n.translate( - 'xpack.apm.serviceOverview.dependenciesTableTitle', + 'xpack.apm.serviceOverview.dependenciesTableLinkText', { - defaultMessage: 'Dependencies', + defaultMessage: 'View service map', } )} -

-
-
- - + + +
+
+
+
+
+ + + + + +

{i18n.translate( - 'xpack.apm.serviceOverview.dependenciesTableLinkText', + 'xpack.apm.serviceOverview.instancesLatencyDistributionChartTitle', { - defaultMessage: 'View service map', + defaultMessage: 'Instances latency distribution', } )} - - - - - - - - - - - - -

- {i18n.translate( - 'xpack.apm.serviceOverview.instancesLatencyDistributionChartTitle', - { - defaultMessage: 'Instances latency distribution', - } - )} -

-
-
-
- - - -

- {i18n.translate( - 'xpack.apm.serviceOverview.instancesTableTitle', - { - defaultMessage: 'Instances', - } - )} -

-
-
-
-
-
- +

+
+
+
+ + + +

+ {i18n.translate( + 'xpack.apm.serviceOverview.instancesTableTitle', + { + defaultMessage: 'Instances', + } + )} +

+
+
+
+
+
+
+
); } diff --git a/x-pack/plugins/apm/public/components/app/service_overview/service_overview.test.tsx b/x-pack/plugins/apm/public/components/app/service_overview/service_overview.test.tsx index 210d353303854..8f9e76a5a79a6 100644 --- a/x-pack/plugins/apm/public/components/app/service_overview/service_overview.test.tsx +++ b/x-pack/plugins/apm/public/components/app/service_overview/service_overview.test.tsx @@ -8,7 +8,15 @@ import React, { ReactNode } from 'react'; import { MemoryRouter } from 'react-router-dom'; import { CoreStart } from 'src/core/public'; import { createKibanaReactContext } from '../../../../../../../src/plugins/kibana_react/public'; -import { MockApmPluginContextWrapper } from '../../../context/ApmPluginContext/MockApmPluginContext'; +import { ApmPluginContextValue } from '../../../context/ApmPluginContext'; +import { + mockApmPluginContextValue, + MockApmPluginContextWrapper, +} from '../../../context/ApmPluginContext/MockApmPluginContext'; +import { MockUrlParamsContextProvider } from '../../../context/UrlParamsContext/MockUrlParamsContextProvider'; +import * as useDynamicIndexPatternHooks from '../../../hooks/useDynamicIndexPattern'; +import * as useFetcherHooks from '../../../hooks/useFetcher'; +import { FETCH_STATUS } from '../../../hooks/useFetcher'; import { renderWithTheme } from '../../../utils/testHelpers'; import { ServiceOverview } from './'; @@ -17,10 +25,27 @@ const KibanaReactContext = createKibanaReactContext({ } as Partial); function Wrapper({ children }: { children?: ReactNode }) { + const value = ({ + ...mockApmPluginContextValue, + core: { + ...mockApmPluginContextValue.core, + http: { + basePath: { prepend: () => {} }, + get: () => {}, + }, + }, + } as unknown) as ApmPluginContextValue; + return ( - + - {children} + + + {children} + + ); @@ -28,6 +53,25 @@ function Wrapper({ children }: { children?: ReactNode }) { describe('ServiceOverview', () => { it('renders', () => { + jest + .spyOn(useDynamicIndexPatternHooks, 'useDynamicIndexPattern') + .mockReturnValue({ + indexPattern: undefined, + status: FETCH_STATUS.SUCCESS, + }); + jest.spyOn(useFetcherHooks, 'useFetcher').mockReturnValue({ + data: { + items: [], + tableOptions: { + pageIndex: 0, + sort: { direction: 'desc', field: 'test field' }, + }, + totalItemCount: 0, + }, + refetch: () => {}, + status: FETCH_STATUS.SUCCESS, + }); + expect(() => renderWithTheme(, { wrapper: Wrapper, diff --git a/x-pack/plugins/apm/public/components/shared/ApmHeader/apm_header.stories.tsx b/x-pack/plugins/apm/public/components/shared/ApmHeader/apm_header.stories.tsx index 4078998bc7e3e..56501d8c916f4 100644 --- a/x-pack/plugins/apm/public/components/shared/ApmHeader/apm_header.stories.tsx +++ b/x-pack/plugins/apm/public/components/shared/ApmHeader/apm_header.stories.tsx @@ -38,7 +38,7 @@ export default { export function Example() { return ( - +

GET /api/v1/regions/azure-eastus2/clusters/elasticsearch/xc18de071deb4262be54baebf5f6a1ce/proxy/_snapshot/found-snapshots/_all diff --git a/x-pack/plugins/apm/public/components/shared/ApmHeader/index.tsx b/x-pack/plugins/apm/public/components/shared/ApmHeader/index.tsx index 96f170fa6a093..a806a3ea60154 100644 --- a/x-pack/plugins/apm/public/components/shared/ApmHeader/index.tsx +++ b/x-pack/plugins/apm/public/components/shared/ApmHeader/index.tsx @@ -4,40 +4,31 @@ * you may not use this file except in compliance with the Elastic License. */ -import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; +import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import React, { ReactNode } from 'react'; +import styled from 'styled-components'; import { HeaderMenuPortal } from '../../../../../observability/public'; import { ActionMenu } from '../../../application/action_menu'; import { useApmPluginContext } from '../../../hooks/useApmPluginContext'; -import { DatePicker } from '../DatePicker'; import { EnvironmentFilter } from '../EnvironmentFilter'; -import { KueryBar } from '../KueryBar'; + +const HeaderFlexGroup = styled(EuiFlexGroup)` + padding: ${({ theme }) => theme.eui.gutterTypes.gutterMedium}; + border-bottom: ${({ theme }) => theme.eui.euiBorderThin}; +`; export function ApmHeader({ children }: { children: ReactNode }) { const { setHeaderActionMenu } = useApmPluginContext().appMountParameters; return ( - <> + - - {children} - - - - - - - - - - - - - - - - + {children} + + + + ); } diff --git a/x-pack/plugins/apm/public/components/shared/EnvironmentFilter/index.tsx b/x-pack/plugins/apm/public/components/shared/EnvironmentFilter/index.tsx index e6e40e44bad38..cace4c2770f37 100644 --- a/x-pack/plugins/apm/public/components/shared/EnvironmentFilter/index.tsx +++ b/x-pack/plugins/apm/public/components/shared/EnvironmentFilter/index.tsx @@ -73,6 +73,11 @@ export function EnvironmentFilter() { end, }); + // Set the min-width so we don't see as much collapsing of the select during + // the loading state. 200px is what is looks like if "production" is + // the contents. + const minWidth = 200; + return ( ); } diff --git a/x-pack/plugins/apm/public/components/shared/EuiTabLink.tsx b/x-pack/plugins/apm/public/components/shared/EuiTabLink.tsx deleted file mode 100644 index d29ccd8abcd42..0000000000000 --- a/x-pack/plugins/apm/public/components/shared/EuiTabLink.tsx +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -import React from 'react'; -import cls from 'classnames'; -import styled from 'styled-components'; -import { px, unit } from '../../style/variables'; - -// TODO: replace this component with EUITab w/ a href prop -// as soon as EUI is upgraded to 13.8.1 -// see https://github.com/elastic/eui/pull/2275 - -interface Props { - isSelected: boolean; - children: React.ReactNode; -} - -// We need to remove padding and add it to the link, -// to prevent the user from clicking in the tab, but outside of the link -// We also need to override the color here to subdue the color of the link -// when not selected - -const Wrapper = styled.div<{ isSelected: boolean }>` - padding: 0; - a { - display: inline-block; - padding: ${px(unit * 0.75)} ${px(unit)}; - ${({ isSelected, theme }) => - !isSelected ? `color: ${theme.eui.euiTextColor} !important;` : ''} - } -`; - -function EuiTabLink(props: Props) { - const { isSelected, children } = props; - - const className = cls('euiTab', { - 'euiTab-isSelected': isSelected, - }); - - return ( - - {children} - - ); -} - -export { EuiTabLink }; diff --git a/x-pack/plugins/apm/public/components/shared/KueryBar/index.tsx b/x-pack/plugins/apm/public/components/shared/KueryBar/index.tsx index dce8e49deec41..2ef93fc32200e 100644 --- a/x-pack/plugins/apm/public/components/shared/KueryBar/index.tsx +++ b/x-pack/plugins/apm/public/components/shared/KueryBar/index.tsx @@ -80,13 +80,6 @@ export function KueryBar() { }, }); - // The bar should be disabled when viewing the service map - const disabled = /\/(service-map)$/.test(location.pathname); - const disabledPlaceholder = i18n.translate( - 'xpack.apm.kueryBar.disabledPlaceholder', - { defaultMessage: 'Search is not available here' } - ); - async function onChange(inputValue: string, selectionStart: number) { if (indexPattern == null) { return; @@ -153,13 +146,12 @@ export function KueryBar() { return ( ); diff --git a/x-pack/plugins/apm/public/components/shared/Links/apm/APMLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/APMLink.tsx index bd43f2455c545..41c932bf9c9f5 100644 --- a/x-pack/plugins/apm/public/components/shared/Links/apm/APMLink.tsx +++ b/x-pack/plugins/apm/public/components/shared/Links/apm/APMLink.tsx @@ -10,7 +10,9 @@ import { pick } from 'lodash'; import React from 'react'; import { useLocation } from 'react-router-dom'; import url from 'url'; +import { pickKeys } from '../../../../../common/utils/pick_keys'; import { useApmPluginContext } from '../../../../hooks/useApmPluginContext'; +import { useUrlParams } from '../../../../hooks/useUrlParams'; import { APMQueryParams, fromQuery, toQuery } from '../url_helpers'; interface Props extends EuiLinkAnchorProps { @@ -21,7 +23,7 @@ interface Props extends EuiLinkAnchorProps { export type APMLinkExtendProps = Omit; -export const PERSISTENT_APM_PARAMS = [ +export const PERSISTENT_APM_PARAMS: Array = [ 'kuery', 'rangeFrom', 'rangeTo', @@ -30,6 +32,21 @@ export const PERSISTENT_APM_PARAMS = [ 'environment', ]; +/** + * Hook to get a link for a path with persisted filters + */ +export function useAPMHref( + path: string, + persistentFilters: Array = PERSISTENT_APM_PARAMS +) { + const { urlParams } = useUrlParams(); + const { basePath } = useApmPluginContext().core.http; + const { search } = useLocation(); + const query = pickKeys(urlParams as APMQueryParams, ...persistentFilters); + + return getAPMHref({ basePath, path, query, search }); +} + /** * Get an APM link for a path. */ diff --git a/x-pack/plugins/apm/public/components/shared/Links/apm/ErrorOverviewLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/ErrorOverviewLink.tsx index 862b1ac649648..30b91fe2564f1 100644 --- a/x-pack/plugins/apm/public/components/shared/Links/apm/ErrorOverviewLink.tsx +++ b/x-pack/plugins/apm/public/components/shared/Links/apm/ErrorOverviewLink.tsx @@ -4,37 +4,38 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { APMLink, APMLinkExtendProps } from './APMLink'; -import { useUrlParams } from '../../../../hooks/useUrlParams'; import { pickKeys } from '../../../../../common/utils/pick_keys'; +import { useUrlParams } from '../../../../hooks/useUrlParams'; import { APMQueryParams } from '../url_helpers'; +import { APMLink, APMLinkExtendProps, useAPMHref } from './APMLink'; + +const persistedFilters: Array = [ + 'host', + 'containerId', + 'podName', + 'serviceVersion', +]; + +export function useErrorOverviewHref(serviceName: string) { + return useAPMHref(`/services/${serviceName}/errors`, persistedFilters); +} interface Props extends APMLinkExtendProps { serviceName: string; query?: APMQueryParams; } -function ErrorOverviewLink({ serviceName, query, ...rest }: Props) { +export function ErrorOverviewLink({ serviceName, query, ...rest }: Props) { const { urlParams } = useUrlParams(); - const persistedFilters = pickKeys( - urlParams, - 'host', - 'containerId', - 'podName', - 'serviceVersion' - ); - return ( ); } - -export { ErrorOverviewLink }; diff --git a/x-pack/plugins/apm/public/components/shared/Links/apm/MetricOverviewLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/MetricOverviewLink.tsx index 35ba5db68d507..fbae80203f03b 100644 --- a/x-pack/plugins/apm/public/components/shared/Links/apm/MetricOverviewLink.tsx +++ b/x-pack/plugins/apm/public/components/shared/Links/apm/MetricOverviewLink.tsx @@ -4,32 +4,34 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { APMLink, APMLinkExtendProps } from './APMLink'; -import { useUrlParams } from '../../../../hooks/useUrlParams'; import { pickKeys } from '../../../../../common/utils/pick_keys'; +import { useUrlParams } from '../../../../hooks/useUrlParams'; +import { APMQueryParams } from '../url_helpers'; +import { APMLink, APMLinkExtendProps, useAPMHref } from './APMLink'; + +const persistedFilters: Array = [ + 'host', + 'containerId', + 'podName', + 'serviceVersion', +]; + +export function useMetricOverviewHref(serviceName: string) { + return useAPMHref(`/services/${serviceName}/metrics`, persistedFilters); +} interface Props extends APMLinkExtendProps { serviceName: string; } -function MetricOverviewLink({ serviceName, ...rest }: Props) { +export function MetricOverviewLink({ serviceName, ...rest }: Props) { const { urlParams } = useUrlParams(); - const persistedFilters = pickKeys( - urlParams, - 'host', - 'containerId', - 'podName', - 'serviceVersion' - ); - return ( ); } - -export { MetricOverviewLink }; diff --git a/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceMapLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceMapLink.tsx index ff8b1354daeb5..ae5dc86608a90 100644 --- a/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceMapLink.tsx +++ b/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceMapLink.tsx @@ -1,26 +1,24 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { APMLink, APMLinkExtendProps } from './APMLink'; +import { APMLink, APMLinkExtendProps, useAPMHref } from './APMLink'; + +function pathFor(serviceName?: string) { + return serviceName ? `/services/${serviceName}/service-map` : '/service-map'; +} + +export function useServiceMapHref(serviceName?: string) { + return useAPMHref(pathFor(serviceName)); +} interface ServiceMapLinkProps extends APMLinkExtendProps { serviceName?: string; } -function ServiceMapLink({ serviceName, ...rest }: ServiceMapLinkProps) { - const path = serviceName - ? `/services/${serviceName}/service-map` - : '/service-map'; +export function ServiceMapLink({ serviceName, ...rest }: ServiceMapLinkProps) { + const path = pathFor(serviceName); return ; } - -export { ServiceMapLink }; diff --git a/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceNodeOverviewLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceNodeOverviewLink.tsx index 111c2391cd54f..0a9553bcbfe6c 100644 --- a/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceNodeOverviewLink.tsx +++ b/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceNodeOverviewLink.tsx @@ -4,32 +4,34 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { APMLink, APMLinkExtendProps } from './APMLink'; +import { APMLink, APMLinkExtendProps, useAPMHref } from './APMLink'; import { useUrlParams } from '../../../../hooks/useUrlParams'; import { pickKeys } from '../../../../../common/utils/pick_keys'; +import { APMQueryParams } from '../url_helpers'; + +const persistedFilters: Array = [ + 'host', + 'containerId', + 'podName', + 'serviceVersion', +]; + +export function useServiceNodeOverviewHref(serviceName: string) { + return useAPMHref(`/services/${serviceName}/nodes`, persistedFilters); +} interface Props extends APMLinkExtendProps { serviceName: string; } -function ServiceNodeOverviewLink({ serviceName, ...rest }: Props) { +export function ServiceNodeOverviewLink({ serviceName, ...rest }: Props) { const { urlParams } = useUrlParams(); - const persistedFilters = pickKeys( - urlParams, - 'host', - 'containerId', - 'podName', - 'serviceVersion' - ); - return ( ); } - -export { ServiceNodeOverviewLink }; diff --git a/x-pack/plugins/apm/public/components/shared/Links/apm/TraceOverviewLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/TraceOverviewLink.tsx index 8f3ea191fab1a..6aa362707800f 100644 --- a/x-pack/plugins/apm/public/components/shared/Links/apm/TraceOverviewLink.tsx +++ b/x-pack/plugins/apm/public/components/shared/Links/apm/TraceOverviewLink.tsx @@ -10,22 +10,30 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { APMLink, APMLinkExtendProps } from './APMLink'; -import { useUrlParams } from '../../../../hooks/useUrlParams'; import { pickKeys } from '../../../../../common/utils/pick_keys'; +import { useUrlParams } from '../../../../hooks/useUrlParams'; +import { APMQueryParams } from '../url_helpers'; +import { APMLink, APMLinkExtendProps, useAPMHref } from './APMLink'; -function TraceOverviewLink(props: APMLinkExtendProps) { +const persistedFilters: Array = [ + 'transactionResult', + 'host', + 'containerId', + 'podName', +]; + +export function useTraceOverviewHref() { + return useAPMHref('/traces', persistedFilters); +} + +export function TraceOverviewLink(props: APMLinkExtendProps) { const { urlParams } = useUrlParams(); - const persistedFilters = pickKeys( - urlParams, - 'transactionResult', - 'host', - 'containerId', - 'podName' + return ( + ); - - return ; } - -export { TraceOverviewLink }; diff --git a/x-pack/plugins/apm/public/components/shared/Links/apm/TransactionOverviewLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/TransactionOverviewLink.tsx index adc64f5a2d3dc..23e795b026d0c 100644 --- a/x-pack/plugins/apm/public/components/shared/Links/apm/TransactionOverviewLink.tsx +++ b/x-pack/plugins/apm/public/components/shared/Links/apm/TransactionOverviewLink.tsx @@ -4,33 +4,35 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { APMLink, APMLinkExtendProps } from './APMLink'; +import { APMLink, APMLinkExtendProps, useAPMHref } from './APMLink'; import { useUrlParams } from '../../../../hooks/useUrlParams'; import { pickKeys } from '../../../../../common/utils/pick_keys'; +import { APMQueryParams } from '../url_helpers'; + +const persistedFilters: Array = [ + 'transactionResult', + 'host', + 'containerId', + 'podName', + 'serviceVersion', +]; + +export function useTransactionOverviewHref(serviceName: string) { + return useAPMHref(`/services/${serviceName}/transactions`, persistedFilters); +} interface Props extends APMLinkExtendProps { serviceName: string; } -function TransactionOverviewLink({ serviceName, ...rest }: Props) { +export function TransactionOverviewLink({ serviceName, ...rest }: Props) { const { urlParams } = useUrlParams(); - const persistedFilters = pickKeys( - urlParams, - 'transactionResult', - 'host', - 'containerId', - 'podName', - 'serviceVersion' - ); - return ( ); } - -export { TransactionOverviewLink }; diff --git a/x-pack/plugins/apm/public/components/shared/Links/apm/service_inventory_link.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/service_inventory_link.tsx index e3fa03a4d4f86..039d9dcb1c0ed 100644 --- a/x-pack/plugins/apm/public/components/shared/Links/apm/service_inventory_link.tsx +++ b/x-pack/plugins/apm/public/components/shared/Links/apm/service_inventory_link.tsx @@ -10,16 +10,21 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { APMLink, APMLinkExtendProps } from './APMLink'; -import { useUrlParams } from '../../../../hooks/useUrlParams'; import { pickKeys } from '../../../../../common/utils/pick_keys'; +import { useUrlParams } from '../../../../hooks/useUrlParams'; +import { APMQueryParams } from '../url_helpers'; +import { APMLink, APMLinkExtendProps, useAPMHref } from './APMLink'; + +const persistedFilters: Array = ['host', 'agentName']; -function ServiceInventoryLink(props: APMLinkExtendProps) { +export function useServiceInventoryHref() { + return useAPMHref('/services', persistedFilters); +} + +export function ServiceInventoryLink(props: APMLinkExtendProps) { const { urlParams } = useUrlParams(); - const persistedFilters = pickKeys(urlParams, 'host', 'agentName'); + const query = pickKeys(urlParams as APMQueryParams, ...persistedFilters); - return ; + return ; } - -export { ServiceInventoryLink }; diff --git a/x-pack/plugins/apm/public/components/shared/Links/apm/service_overview_link.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/service_overview_link.tsx index 5d7859e7362c7..78e409bb4558c 100644 --- a/x-pack/plugins/apm/public/components/shared/Links/apm/service_overview_link.tsx +++ b/x-pack/plugins/apm/public/components/shared/Links/apm/service_overview_link.tsx @@ -9,12 +9,16 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { APMLink, APMLinkExtendProps } from './APMLink'; +import { APMLink, APMLinkExtendProps, useAPMHref } from './APMLink'; interface ServiceOverviewLinkProps extends APMLinkExtendProps { serviceName: string; } +export function useServiceOverviewHref(serviceName: string) { + return useAPMHref(`/services/${serviceName}/overview`); +} + export function ServiceOverviewLink({ serviceName, ...rest diff --git a/x-pack/plugins/apm/public/components/shared/main_tabs.tsx b/x-pack/plugins/apm/public/components/shared/main_tabs.tsx new file mode 100644 index 0000000000000..a165cabec857c --- /dev/null +++ b/x-pack/plugins/apm/public/components/shared/main_tabs.tsx @@ -0,0 +1,21 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { EuiTabs } from '@elastic/eui'; +import React, { ReactNode } from 'react'; +import styled from 'styled-components'; + +// Since our `EuiTab` components have `APMLink`s inside of them and not just +// `href`s, we need to override the color of the links inside or they will all +// be the primary color. +const StyledTabs = styled(EuiTabs)` + padding: ${({ theme }) => `${theme.eui.gutterTypes.gutterMedium}`}; + border-bottom: ${({ theme }) => theme.eui.euiBorderThin}; +`; + +export function MainTabs({ children }: { children: ReactNode }) { + return {children}; +} diff --git a/x-pack/plugins/apm/public/components/shared/search_bar.tsx b/x-pack/plugins/apm/public/components/shared/search_bar.tsx new file mode 100644 index 0000000000000..686df42cf3b8a --- /dev/null +++ b/x-pack/plugins/apm/public/components/shared/search_bar.tsx @@ -0,0 +1,29 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; +import React from 'react'; +import styled from 'styled-components'; +import { DatePicker } from './DatePicker'; +import { KueryBar } from './KueryBar'; + +const SearchBarFlexGroup = styled(EuiFlexGroup)` + margin: ${({ theme }) => + `${theme.eui.euiSizeM} ${theme.eui.euiSizeM} -${theme.eui.gutterTypes.gutterMedium} ${theme.eui.euiSizeM}`}; +`; + +export function SearchBar() { + return ( + + + + + + + + + ); +} diff --git a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/auto_follow_pattern_list.test.js b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/auto_follow_pattern_list.test.js index 60b5b393c5b07..808417c5fa38c 100644 --- a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/auto_follow_pattern_list.test.js +++ b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/auto_follow_pattern_list.test.js @@ -6,7 +6,7 @@ import { getAutoFollowPatternMock } from './fixtures/auto_follow_pattern'; import './mocks'; -import { setupEnvironment, pageHelpers, nextTick, getRandomString } from './helpers'; +import { setupEnvironment, pageHelpers, nextTick, delay, getRandomString } from './helpers'; const { setup } = pageHelpers.autoFollowPatternList; @@ -146,7 +146,7 @@ describe('', () => { afterEach(async () => { // The updates are not all synchronouse // We need to wait for all the updates to ran before unmounting our component - await nextTick(100); + await delay(100); }); test('should not display the empty prompt', () => { diff --git a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/fixtures/auto_follow_pattern.ts b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/fixtures/auto_follow_pattern.ts index e6444c37e8590..a1d99c9d81fe7 100644 --- a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/fixtures/auto_follow_pattern.ts +++ b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/fixtures/auto_follow_pattern.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getRandomString } from '../../../../../../test_utils'; +import { getRandomString } from '@kbn/test/jest'; import { AutoFollowPattern } from '../../../../common/types'; export const getAutoFollowPatternMock = ({ diff --git a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/fixtures/follower_index.ts b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/fixtures/follower_index.ts index ce40a0e46b0a0..244b460a364bc 100644 --- a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/fixtures/follower_index.ts +++ b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/fixtures/follower_index.ts @@ -5,7 +5,7 @@ */ import Chance from 'chance'; -import { getRandomString } from '../../../../../../test_utils'; +import { getRandomString } from '@kbn/test/jest'; import { FollowerIndex } from '../../../../common/types'; const chance = new Chance(); diff --git a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/follower_index_add.test.js b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/follower_index_add.test.js index f5305f43e7f8c..36927ef2d16be 100644 --- a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/follower_index_add.test.js +++ b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/follower_index_add.test.js @@ -6,7 +6,7 @@ import { indexPatterns } from '../../../../../../src/plugins/data/public'; import './mocks'; -import { setupEnvironment, pageHelpers, nextTick } from './helpers'; +import { setupEnvironment, pageHelpers, nextTick, delay } from './helpers'; import { RemoteClustersFormField } from '../../app/components'; const { setup } = pageHelpers.followerIndexAdd; @@ -169,7 +169,7 @@ describe('Create Follower index', () => { const totalRequests = server.requests.length; form.setInputValue('followerIndexInput', 'index-name'); - await nextTick(550); // we need to wait as there is a debounce of 500ms on the http validation + await delay(550); // we need to wait as there is a debounce of 500ms on the http validation expect(server.requests.length).toBe(totalRequests + 1); expect(server.requests[server.requests.length - 1].url).toBe( @@ -182,7 +182,7 @@ describe('Create Follower index', () => { httpRequestsMockHelpers.setGetClusterIndicesResponse([{ name: indexName }]); form.setInputValue('followerIndexInput', indexName); - await nextTick(550); + await delay(550); component.update(); expect(form.getErrorsMessages()).toContain('An index with the same name already exists.'); diff --git a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/follower_indices_list.test.js b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/follower_indices_list.test.js index 91227299e92f9..3219cabe335e0 100644 --- a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/follower_indices_list.test.js +++ b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/follower_indices_list.test.js @@ -10,11 +10,11 @@ Could not load worker ReferenceError: Worker is not defined at createWorker (//node_modules/brace/index.js:17992:5) */ -import * as stubWebWorker from '../../../../../test_utils/stub_web_worker'; // eslint-disable-line no-unused-vars +import { stubWebWorker } from '@kbn/test/jest'; // eslint-disable-line no-unused-vars import { getFollowerIndexMock } from './fixtures/follower_index'; import './mocks'; -import { setupEnvironment, pageHelpers, nextTick, getRandomString } from './helpers'; +import { setupEnvironment, pageHelpers, nextTick, delay, getRandomString } from './helpers'; const { setup } = pageHelpers.followerIndexList; @@ -147,7 +147,7 @@ describe('', () => { afterEach(async () => { // The updates are not all synchronouse // We need to wait for all the updates to ran before unmounting our component - await nextTick(100); + await delay(100); }); test('should not display the empty prompt', () => { diff --git a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/auto_follow_pattern_add.helpers.js b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/auto_follow_pattern_add.helpers.js index a4edee7268a23..8bbc6dac022cb 100644 --- a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/auto_follow_pattern_add.helpers.js +++ b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/auto_follow_pattern_add.helpers.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../test_utils'; +import { registerTestBed } from '@kbn/test/jest'; import { AutoFollowPatternAdd } from '../../../app/sections/auto_follow_pattern_add'; import { ccrStore } from '../../../app/store'; import { routing } from '../../../app/services/routing'; diff --git a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/auto_follow_pattern_edit.helpers.js b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/auto_follow_pattern_edit.helpers.js index ea372d534d817..e316c9ab404df 100644 --- a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/auto_follow_pattern_edit.helpers.js +++ b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/auto_follow_pattern_edit.helpers.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../test_utils'; +import { registerTestBed } from '@kbn/test/jest'; import { AutoFollowPatternEdit } from '../../../app/sections/auto_follow_pattern_edit'; import { ccrStore } from '../../../app/store'; import { routing } from '../../../app/services/routing'; diff --git a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/auto_follow_pattern_list.helpers.js b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/auto_follow_pattern_list.helpers.js index 550e178a1c733..9a64ea708a8b6 100644 --- a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/auto_follow_pattern_list.helpers.js +++ b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/auto_follow_pattern_list.helpers.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, findTestSubject } from '../../../../../../test_utils'; +import { registerTestBed, findTestSubject } from '@kbn/test/jest'; import { AutoFollowPatternList } from '../../../app/sections/home/auto_follow_pattern_list'; import { ccrStore } from '../../../app/store'; import { routing } from '../../../app/services/routing'; diff --git a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/follower_index_add.helpers.js b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/follower_index_add.helpers.js index 31f3844f57fb5..c2b61436ca31d 100644 --- a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/follower_index_add.helpers.js +++ b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/follower_index_add.helpers.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../test_utils'; +import { registerTestBed } from '@kbn/test/jest'; import { FollowerIndexAdd } from '../../../app/sections/follower_index_add'; import { ccrStore } from '../../../app/store'; import { routing } from '../../../app/services/routing'; diff --git a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/follower_index_edit.helpers.js b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/follower_index_edit.helpers.js index 8fc2811e58cdb..f269c453165e4 100644 --- a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/follower_index_edit.helpers.js +++ b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/follower_index_edit.helpers.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../test_utils'; +import { registerTestBed } from '@kbn/test/jest'; import { FollowerIndexEdit } from '../../../app/sections/follower_index_edit'; import { ccrStore } from '../../../app/store'; import { routing } from '../../../app/services/routing'; diff --git a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/follower_index_list.helpers.js b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/follower_index_list.helpers.js index 65be10b9d272e..31afebcc59055 100644 --- a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/follower_index_list.helpers.js +++ b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/follower_index_list.helpers.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, findTestSubject } from '../../../../../../test_utils'; +import { registerTestBed, findTestSubject } from '@kbn/test/jest'; import { FollowerIndicesList } from '../../../app/sections/home/follower_indices_list'; import { ccrStore } from '../../../app/store'; import { routing } from '../../../app/services/routing'; diff --git a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/home.helpers.js b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/home.helpers.js index e51c444a6b370..2a1628f1418b8 100644 --- a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/home.helpers.js +++ b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/home.helpers.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../test_utils'; +import { registerTestBed } from '@kbn/test/jest'; import { CrossClusterReplicationHome } from '../../../app/sections/home/home'; import { ccrStore } from '../../../app/store'; import { routing } from '../../../app/services/routing'; diff --git a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/index.js b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/index.js index fdcc3ccb08876..05c38956fff56 100644 --- a/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/index.js +++ b/x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/helpers/index.js @@ -12,7 +12,7 @@ import { setup as followerIndexAddSetup } from './follower_index_add.helpers'; import { setup as followerIndexEditSetup } from './follower_index_edit.helpers'; import { setup as homeSetup } from './home.helpers'; -export { nextTick, getRandomString, findTestSubject } from '../../../../../../test_utils'; +export { nextTick, getRandomString, findTestSubject, delay } from '@kbn/test/jest'; export { setupEnvironment } from './setup_environment'; diff --git a/x-pack/plugins/enterprise_search/common/version.ts b/x-pack/plugins/enterprise_search/common/version.ts index c23b05f7cdb3d..e1a990e5c4710 100644 --- a/x-pack/plugins/enterprise_search/common/version.ts +++ b/x-pack/plugins/enterprise_search/common/version.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SemVer } from 'semver'; +import SemVer from 'semver/classes/semver'; import pkg from '../../../../package.json'; export const CURRENT_VERSION = new SemVer(pkg.version as string); diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.test.tsx index e38381cad32ba..8f067754c48a0 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.test.tsx @@ -17,6 +17,8 @@ jest.mock('../../../shared/flash_messages', () => ({ })); import { setQueuedErrorMessage } from '../../../shared/flash_messages'; +import { Loading } from '../../../shared/loading'; + import { EngineRouter } from './'; describe('EngineRouter', () => { @@ -59,10 +61,10 @@ describe('EngineRouter', () => { ); }); - it('does not render if async data is still loading', () => { + it('renders a loading component if async data is still loading', () => { setMockValues({ ...values, dataLoading: true }); const wrapper = shallow(); - expect(wrapper.isEmptyRender()).toBe(true); + expect(wrapper.find(Loading)).toHaveLength(1); }); it('renders a default engine overview', () => { diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.tsx index 3e6856771f7d9..9833305c438c1 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.tsx @@ -45,6 +45,8 @@ import { // API_LOGS_TITLE, } from './constants'; +import { Loading } from '../../../shared/loading'; + import { EngineLogic } from './'; export const EngineRouter: React.FC = () => { @@ -86,7 +88,7 @@ export const EngineRouter: React.FC = () => { return ; } - if (dataLoading) return null; + if (dataLoading) return ; return ( diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/shared/loading/index.ts b/x-pack/plugins/enterprise_search/public/applications/shared/loading/index.ts similarity index 100% rename from x-pack/plugins/enterprise_search/public/applications/workplace_search/components/shared/loading/index.ts rename to x-pack/plugins/enterprise_search/public/applications/shared/loading/index.ts diff --git a/x-pack/test_utils/lib/index.ts b/x-pack/plugins/enterprise_search/public/applications/shared/loading/loading.scss similarity index 69% rename from x-pack/test_utils/lib/index.ts rename to x-pack/plugins/enterprise_search/public/applications/shared/loading/loading.scss index 07120636f09cf..84591962d4789 100644 --- a/x-pack/test_utils/lib/index.ts +++ b/x-pack/plugins/enterprise_search/public/applications/shared/loading/loading.scss @@ -4,4 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -export { nextTick, getRandomString, getRandomNumber } from './utils'; +.enterpriseSearchLoading { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%); +} diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/shared/loading/loading.test.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/loading/loading.test.tsx similarity index 100% rename from x-pack/plugins/enterprise_search/public/applications/workplace_search/components/shared/loading/loading.test.tsx rename to x-pack/plugins/enterprise_search/public/applications/shared/loading/loading.test.tsx index 8b4a999824e35..bfd30238c4357 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/shared/loading/loading.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/loading/loading.test.tsx @@ -6,6 +6,7 @@ import React from 'react'; import { shallow } from 'enzyme'; + import { EuiLoadingSpinner } from '@elastic/eui'; import { Loading } from './'; @@ -13,7 +14,6 @@ import { Loading } from './'; describe('Loading', () => { it('renders', () => { const wrapper = shallow(); - expect(wrapper.find(EuiLoadingSpinner)).toHaveLength(1); }); }); diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/shared/loading/loading.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/loading/loading.tsx similarity index 79% rename from x-pack/plugins/enterprise_search/public/applications/workplace_search/components/shared/loading/loading.tsx rename to x-pack/plugins/enterprise_search/public/applications/shared/loading/loading.tsx index 399abedf55e87..fc67e3ceb028a 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/shared/loading/loading.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/loading/loading.tsx @@ -5,13 +5,12 @@ */ import React from 'react'; - import { EuiLoadingSpinner } from '@elastic/eui'; import './loading.scss'; export const Loading: React.FC = () => ( -
- +
+
); diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/shared/loading/loading.scss b/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/shared/loading/loading.scss deleted file mode 100644 index 008a8066f807b..0000000000000 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/components/shared/loading/loading.scss +++ /dev/null @@ -1,14 +0,0 @@ -.loadingSpinnerWrapper { - width: 100%; - height: 90vh; - margin: auto; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; -} - -.loadingSpinner { - width: $euiSizeXXL * 1.25; - height: $euiSizeXXL * 1.25; -} diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_overview.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_overview.test.tsx index acb2fcfbaaa32..74dee238ee826 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_overview.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_overview.test.tsx @@ -21,7 +21,7 @@ import { import { ContentSection } from '../../../components/shared/content_section'; import { ViewContentHeader } from '../../../components/shared/view_content_header'; import { SourcesTable } from '../../../components/shared/sources_table'; -import { Loading } from '../../../components/shared/loading'; +import { Loading } from '../../../../shared/loading'; import { EuiFieldText } from '@elastic/eui'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_overview.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_overview.tsx index fd97f1c0a03ca..6f55c03746aa8 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_overview.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_overview.tsx @@ -26,7 +26,7 @@ import { AppLogic } from '../../../app_logic'; import { TruncatedContent } from '../../../../shared/truncate'; import { ContentSection } from '../../../components/shared/content_section'; import { ViewContentHeader } from '../../../components/shared/view_content_header'; -import { Loading } from '../../../components/shared/loading'; +import { Loading } from '../../../../shared/loading'; import { SourcesTable } from '../../../components/shared/sources_table'; import { GroupUsersTable } from './group_users_table'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_source_prioritization.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_source_prioritization.test.tsx index 81639327f4ba0..367f1862b2bb9 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_source_prioritization.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_source_prioritization.test.tsx @@ -12,7 +12,7 @@ import { groups } from '../../../__mocks__/groups.mock'; import React from 'react'; import { shallow } from 'enzyme'; -import { Loading } from '../../../components/shared/loading'; +import { Loading } from '../../../../shared/loading'; import { GroupSourcePrioritization } from './group_source_prioritization'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_source_prioritization.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_source_prioritization.tsx index 8c054ed9abc87..662c0dbc3bb1a 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_source_prioritization.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/components/group_source_prioritization.tsx @@ -26,7 +26,7 @@ import { EuiTableRowCell, } from '@elastic/eui'; -import { Loading } from '../../../components/shared/loading'; +import { Loading } from '../../../../shared/loading'; import { ViewContentHeader } from '../../../components/shared/view_content_header'; import { SourceIcon } from '../../../components/shared/source_icon'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups.test.tsx index 98f40acb96469..cc50c4d0af5c4 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups.test.tsx @@ -16,7 +16,7 @@ import { shallow } from 'enzyme'; import { Groups } from './groups'; import { ViewContentHeader } from '../../components/shared/view_content_header'; -import { Loading } from '../../components/shared/loading'; +import { Loading } from '../../../shared/loading'; import { FlashMessages } from '../../../shared/flash_messages'; import { AddGroupModal } from './components/add_group_modal'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups.tsx index ae87ef735bb9f..4064391c09893 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups.tsx @@ -14,7 +14,7 @@ import { EuiButton as EuiLinkButton } from '../../../shared/react_router_helpers import { AppLogic } from '../../app_logic'; -import { Loading } from '../../components/shared/loading'; +import { Loading } from '../../../shared/loading'; import { ViewContentHeader } from '../../components/shared/view_content_header'; import { getGroupPath, USERS_PATH } from '../../routes'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/overview.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/overview.test.tsx index c7bab66490f44..256f350d57233 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/overview.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/overview.test.tsx @@ -11,7 +11,7 @@ import { mockActions, setMockValues } from './__mocks__'; import React from 'react'; import { shallow, mount } from 'enzyme'; -import { Loading } from '../../components/shared/loading'; +import { Loading } from '../../../shared/loading'; import { ViewContentHeader } from '../../components/shared/view_content_header'; import { OnboardingSteps } from './onboarding_steps'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/overview.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/overview.tsx index a712fbdd0dea6..aafff53a7ddbc 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/overview.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/overview.tsx @@ -17,7 +17,7 @@ import { SendWorkplaceSearchTelemetry as SendTelemetry } from '../../../shared/t import { AppLogic } from '../../app_logic'; import { OverviewLogic } from './overview_logic'; -import { Loading } from '../../components/shared/loading'; +import { Loading } from '../../../shared/loading'; import { ProductButton } from '../../components/shared/product_button'; import { ViewContentHeader } from '../../components/shared/view_content_header'; @@ -56,7 +56,14 @@ export const Overview: React.FC = () => { initializeOverview(); }, [initializeOverview]); - if (dataLoading) return ; + // TODO: Remove div wrapper once the Overview page is using the full Layout + if (dataLoading) { + return ( +
+ +
+ ); + } const hideOnboarding = hasUsers && hasOrgSources && isOldAccount && orgName !== defaultOrgName; diff --git a/x-pack/plugins/fleet/common/services/is_agent_upgradeable.ts b/x-pack/plugins/fleet/common/services/is_agent_upgradeable.ts index b93e5d99543f6..e48d0cb61c22d 100644 --- a/x-pack/plugins/fleet/common/services/is_agent_upgradeable.ts +++ b/x-pack/plugins/fleet/common/services/is_agent_upgradeable.ts @@ -3,7 +3,8 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import semver from 'semver'; +import semverCoerce from 'semver/functions/coerce'; +import semverLt from 'semver/functions/lt'; import { Agent } from '../types'; export function isAgentUpgradeable(agent: Agent, kibanaVersion: string) { @@ -17,9 +18,9 @@ export function isAgentUpgradeable(agent: Agent, kibanaVersion: string) { if (!agent.local_metadata.elastic.agent.upgradeable) return false; // make sure versions are only the number before comparison - const agentVersionNumber = semver.coerce(agentVersion); + const agentVersionNumber = semverCoerce(agentVersion); if (!agentVersionNumber) throw new Error('agent version is invalid'); - const kibanaVersionNumber = semver.coerce(kibanaVersion); + const kibanaVersionNumber = semverCoerce(kibanaVersion); if (!kibanaVersionNumber) throw new Error('kibana version is invalid'); - return semver.lt(agentVersionNumber, kibanaVersionNumber); + return semverLt(agentVersionNumber, kibanaVersionNumber); } diff --git a/x-pack/plugins/fleet/server/routes/agent/upgrade_handler.ts b/x-pack/plugins/fleet/server/routes/agent/upgrade_handler.ts index 6224c44a329c6..93e6609167a2e 100644 --- a/x-pack/plugins/fleet/server/routes/agent/upgrade_handler.ts +++ b/x-pack/plugins/fleet/server/routes/agent/upgrade_handler.ts @@ -6,7 +6,7 @@ import { RequestHandler } from 'src/core/server'; import { TypeOf } from '@kbn/config-schema'; -import semver from 'semver'; +import semverCoerce from 'semver/functions/coerce'; import { AgentSOAttributes, PostAgentUpgradeResponse, @@ -122,9 +122,9 @@ export const postBulkAgentsUpgradeHandler: RequestHandler< export const checkVersionIsSame = (version: string, kibanaVersion: string) => { // get version number only in case "-SNAPSHOT" is in it - const kibanaVersionNumber = semver.coerce(kibanaVersion)?.version; + const kibanaVersionNumber = semverCoerce(kibanaVersion)?.version; if (!kibanaVersionNumber) throw new Error(`kibanaVersion ${kibanaVersionNumber} is not valid`); - const versionToUpgradeNumber = semver.coerce(version)?.version; + const versionToUpgradeNumber = semverCoerce(version)?.version; if (!versionToUpgradeNumber) throw new Error(`version to upgrade ${versionToUpgradeNumber} is not valid`); // temporarily only allow upgrading to the same version as the installed kibana version diff --git a/x-pack/plugins/fleet/server/services/agents/checkin/state_new_actions.ts b/x-pack/plugins/fleet/server/services/agents/checkin/state_new_actions.ts index aa48d8fe18e9f..59887d223371f 100644 --- a/x-pack/plugins/fleet/server/services/agents/checkin/state_new_actions.ts +++ b/x-pack/plugins/fleet/server/services/agents/checkin/state_new_actions.ts @@ -4,7 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import semver from 'semver'; +import semverParse from 'semver/functions/parse'; +import semverLt from 'semver/functions/lt'; + import { timer, from, Observable, TimeoutError, of, EMPTY } from 'rxjs'; import { omit } from 'lodash'; import { @@ -132,18 +134,14 @@ export async function createAgentActionFromPolicyAction( policyAction: AgentPolicyAction ) { // Transform the policy action for agent version <= 7.9.x for BWC - const agentVersion = semver.parse((agent.local_metadata?.elastic as any)?.agent?.version); + const agentVersion = semverParse((agent.local_metadata?.elastic as any)?.agent?.version); const agentPolicyAction: AgentPolicyAction | AgentPolicyActionV7_9 = agentVersion && - semver.lt( + semverLt( agentVersion, // A prerelease tag is added here so that agent versions with prerelease tags can be compared // correctly using `semvar` '7.10.0-SNAPSHOT', - // `@types/semvar` is out of date with the version of `semvar` we use and doesn't have a - // corresponding release version we can update the typing to :( so, the typing error is - // suppressed here even though it is supported by `semvar` - // @ts-expect-error { includePrerelease: true } ) ? { diff --git a/x-pack/plugins/fleet/server/services/agents/enroll.ts b/x-pack/plugins/fleet/server/services/agents/enroll.ts index 89ee0c70ba87c..39b757b9776ed 100644 --- a/x-pack/plugins/fleet/server/services/agents/enroll.ts +++ b/x-pack/plugins/fleet/server/services/agents/enroll.ts @@ -5,7 +5,10 @@ */ import Boom from '@hapi/boom'; -import semver from 'semver'; +import semverParse from 'semver/functions/parse'; +import semverDiff from 'semver/functions/diff'; +import semverLte from 'semver/functions/lte'; + import { SavedObjectsClientContract } from 'src/core/server'; import { AgentType, Agent, AgentSOAttributes } from '../../types'; import { savedObjectToAgent } from './saved_objects'; @@ -94,17 +97,17 @@ export function validateAgentVersion( agentVersion: string, kibanaVersion = appContextService.getKibanaVersion() ) { - const agentVersionParsed = semver.parse(agentVersion); + const agentVersionParsed = semverParse(agentVersion); if (!agentVersionParsed) { throw Boom.badRequest('Agent version not provided'); } - const kibanaVersionParsed = semver.parse(kibanaVersion); + const kibanaVersionParsed = semverParse(kibanaVersion); if (!kibanaVersionParsed) { throw Boom.badRequest('Kibana version is not set or provided'); } - const diff = semver.diff(agentVersion, kibanaVersion); + const diff = semverDiff(agentVersion, kibanaVersion); switch (diff) { // section 1) very close versions, only patch release differences - all combos should work // Agent a.b.1 < Kibana a.b.2 @@ -130,7 +133,7 @@ export function validateAgentVersion( // Agent 7.10.x > Kibana 7.9.x // Agent 8.0.x > Kibana 7.9.x default: - if (semver.lte(agentVersionParsed, kibanaVersionParsed)) return; + if (semverLte(agentVersionParsed, kibanaVersionParsed)) return; else throw Boom.badRequest( `Agent version ${agentVersion} is not compatible with Kibana version ${kibanaVersion}` diff --git a/x-pack/plugins/fleet/server/services/epm/packages/install.ts b/x-pack/plugins/fleet/server/services/epm/packages/install.ts index 023691cad1913..c471ea732b9dc 100644 --- a/x-pack/plugins/fleet/server/services/epm/packages/install.ts +++ b/x-pack/plugins/fleet/server/services/epm/packages/install.ts @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import semver from 'semver'; +import semverGt from 'semver/functions/gt'; +import semverLt from 'semver/functions/lt'; import Boom from '@hapi/boom'; import { UnwrapPromise } from '@kbn/utility-types'; import { SavedObject, SavedObjectsClientContract } from 'src/core/server'; @@ -185,7 +186,7 @@ export async function upgradePackage({ latestPkg, pkgToUpgrade, }: UpgradePackageParams): Promise { - if (!installedPkg || semver.gt(latestPkg.version, installedPkg.attributes.version)) { + if (!installedPkg || semverGt(latestPkg.version, installedPkg.attributes.version)) { const pkgkey = Registry.pkgToPkgKey({ name: latestPkg.name, version: latestPkg.version, @@ -255,7 +256,7 @@ async function installPackageFromRegistry({ // let the user install if using the force flag or needing to reinstall or install a previous version due to failed update const installOutOfDateVersionOk = installType === 'reinstall' || installType === 'reupdate' || installType === 'rollback'; - if (semver.lt(pkgVersion, latestPackage.version) && !force && !installOutOfDateVersionOk) { + if (semverLt(pkgVersion, latestPackage.version) && !force && !installOutOfDateVersionOk) { throw new PackageOutdatedError(`${pkgkey} is out-of-date and cannot be installed or updated`); } diff --git a/x-pack/plugins/fleet/server/services/epm/registry/index.ts b/x-pack/plugins/fleet/server/services/epm/registry/index.ts index aef1bb75619cd..a6f42ebb96752 100644 --- a/x-pack/plugins/fleet/server/services/epm/registry/index.ts +++ b/x-pack/plugins/fleet/server/services/epm/registry/index.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import mime from 'mime-types'; -import semver from 'semver'; +import semverValid from 'semver/functions/valid'; import { Response } from 'node-fetch'; import { URL } from 'url'; import { @@ -52,7 +52,7 @@ export function splitPkgKey(pkgkey: string): { pkgName: string; pkgVersion: stri // this will return the entire string if `indexOf` return -1 const pkgVersion = pkgkey.substr(pkgkey.indexOf('-') + 1); - if (!semver.valid(pkgVersion)) { + if (!semverValid(pkgVersion)) { throw new Error('Package key parsing failed: package version was not a valid semver'); } return { pkgName, pkgVersion }; diff --git a/x-pack/plugins/global_search/public/services/utils.test.ts b/x-pack/plugins/global_search/public/services/utils.test.ts index f69fb1d2fd825..d3cff49db1ec0 100644 --- a/x-pack/plugins/global_search/public/services/utils.test.ts +++ b/x-pack/plugins/global_search/public/services/utils.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { StubBrowserStorage } from '../../../../../src/test_utils/public/stub_browser_storage'; +import { StubBrowserStorage } from '@kbn/test/jest'; import { getDefaultPreference } from './utils'; describe('getDefaultPreference', () => { diff --git a/x-pack/plugins/global_search_bar/public/components/search_bar.test.tsx b/x-pack/plugins/global_search_bar/public/components/search_bar.test.tsx index b669499c63f05..a3e2d66eabe5b 100644 --- a/x-pack/plugins/global_search_bar/public/components/search_bar.test.tsx +++ b/x-pack/plugins/global_search_bar/public/components/search_bar.test.tsx @@ -9,7 +9,7 @@ import { waitFor, act } from '@testing-library/react'; import { ReactWrapper } from 'enzyme'; import { of, BehaviorSubject } from 'rxjs'; import { filter, map } from 'rxjs/operators'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { applicationServiceMock } from '../../../../../src/core/public/mocks'; import { GlobalSearchBatchedResults, GlobalSearchResult } from '../../../global_search/public'; import { globalSearchPluginMock } from '../../../global_search/public/mocks'; diff --git a/x-pack/plugins/graph/public/components/search_bar.test.tsx b/x-pack/plugins/graph/public/components/search_bar.test.tsx index 1b783df1b7d02..f26666025d35d 100644 --- a/x-pack/plugins/graph/public/components/search_bar.test.tsx +++ b/x-pack/plugins/graph/public/components/search_bar.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { SearchBar, OuterSearchBarProps } from './search_bar'; import React, { ReactElement } from 'react'; import { CoreStart } from 'src/core/public'; diff --git a/x-pack/plugins/graph/public/components/settings/settings.test.tsx b/x-pack/plugins/graph/public/components/settings/settings.test.tsx index 7d13249288d53..135b9744765c6 100644 --- a/x-pack/plugins/graph/public/components/settings/settings.test.tsx +++ b/x-pack/plugins/graph/public/components/settings/settings.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { EuiTab, EuiListGroupItem, EuiButton, EuiAccordion, EuiFieldText } from '@elastic/eui'; import * as Rx from 'rxjs'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { Settings, AngularProps } from './settings'; import { act } from '@testing-library/react'; import { ReactWrapper } from 'enzyme'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.helpers.tsx b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.helpers.tsx index de7242a6c5ddf..1530d5c2cc4c8 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.helpers.tsx +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.helpers.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; -import { registerTestBed, TestBed, TestBedConfig } from '../../../../../test_utils'; +import { registerTestBed, TestBed, TestBedConfig } from '@kbn/test/jest'; import { App } from '../../../public/application/app'; import { TestSubjects } from '../helpers'; import { createBreadcrumbsMock } from '../../../public/application/services/breadcrumbs.mock'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.helpers.tsx b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.helpers.tsx index 646978dd68153..f9f2233ff02ee 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.helpers.tsx +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.helpers.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; -import { registerTestBed, TestBedConfig } from '../../../../../test_utils'; +import { registerTestBed, TestBedConfig } from '@kbn/test/jest'; import { EditPolicy } from '../../../public/application/sections/edit_policy'; import { DataTierAllocationType } from '../../../public/application/sections/edit_policy/types'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/components/edit_policy.test.tsx b/x-pack/plugins/index_lifecycle_management/__jest__/components/edit_policy.test.tsx index 43910583ceec9..3e1577d8033ba 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/components/edit_policy.test.tsx +++ b/x-pack/plugins/index_lifecycle_management/__jest__/components/edit_policy.test.tsx @@ -9,7 +9,7 @@ import { act } from 'react-dom/test-utils'; import moment from 'moment-timezone'; import { findTestSubject } from '@elastic/eui/lib/test'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { SinonFakeServer } from 'sinon'; import { ReactWrapper } from 'enzyme'; import axios from 'axios'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/components/policy_table.test.tsx b/x-pack/plugins/index_lifecycle_management/__jest__/components/policy_table.test.tsx index 0d66d9a8cdf9f..4b4096e8716b8 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/components/policy_table.test.tsx +++ b/x-pack/plugins/index_lifecycle_management/__jest__/components/policy_table.test.tsx @@ -6,7 +6,7 @@ import moment from 'moment-timezone'; import React, { ReactElement } from 'react'; import { ReactWrapper } from 'enzyme'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { findTestSubject, takeMountedSnapshot } from '@elastic/eui/lib/test'; import { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/extend_index_management.test.tsx b/x-pack/plugins/index_lifecycle_management/__jest__/extend_index_management.test.tsx index ca3121bf6b7a6..27900add85e0b 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/extend_index_management.test.tsx +++ b/x-pack/plugins/index_lifecycle_management/__jest__/extend_index_management.test.tsx @@ -8,7 +8,7 @@ import moment from 'moment-timezone'; import axios from 'axios'; import axiosXhrAdapter from 'axios/lib/adapters/xhr'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { usageCollectionPluginMock } from '../../../../src/plugins/usage_collection/public/mocks'; import { Index } from '../common/types'; import { diff --git a/x-pack/plugins/index_management/__jest__/client_integration/helpers/index.ts b/x-pack/plugins/index_management/__jest__/client_integration/helpers/index.ts index f581083e28cc6..d2d7eb0165d30 100644 --- a/x-pack/plugins/index_management/__jest__/client_integration/helpers/index.ts +++ b/x-pack/plugins/index_management/__jest__/client_integration/helpers/index.ts @@ -6,7 +6,7 @@ import './mocks'; -export { nextTick, getRandomString, findTestSubject, TestBed } from '../../../../../test_utils'; +export { nextTick, getRandomString, findTestSubject, TestBed } from '@kbn/test/jest'; export { setupEnvironment, WithAppDependencies, services } from './setup_environment'; diff --git a/x-pack/plugins/index_management/__jest__/client_integration/home/data_streams_tab.helpers.ts b/x-pack/plugins/index_management/__jest__/client_integration/home/data_streams_tab.helpers.ts index ab796767487b5..148b20e5de533 100644 --- a/x-pack/plugins/index_management/__jest__/client_integration/home/data_streams_tab.helpers.ts +++ b/x-pack/plugins/index_management/__jest__/client_integration/home/data_streams_tab.helpers.ts @@ -8,12 +8,7 @@ import { act } from 'react-dom/test-utils'; import { ReactWrapper } from 'enzyme'; import { EuiDescriptionListDescription } from '@elastic/eui'; -import { - registerTestBed, - TestBed, - TestBedConfig, - findTestSubject, -} from '../../../../../test_utils'; +import { registerTestBed, TestBed, TestBedConfig, findTestSubject } from '@kbn/test/jest'; import { DataStream } from '../../../common'; import { IndexManagementHome } from '../../../public/application/sections/home'; import { indexManagementStore } from '../../../public/application/store'; diff --git a/x-pack/plugins/index_management/__jest__/client_integration/home/home.helpers.ts b/x-pack/plugins/index_management/__jest__/client_integration/home/home.helpers.ts index 27920ad8cdbdb..21c29baefce7c 100644 --- a/x-pack/plugins/index_management/__jest__/client_integration/home/home.helpers.ts +++ b/x-pack/plugins/index_management/__jest__/client_integration/home/home.helpers.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, TestBed, TestBedConfig } from '../../../../../test_utils'; +import { registerTestBed, TestBed, TestBedConfig } from '@kbn/test/jest'; import { IndexManagementHome } from '../../../public/application/sections/home'; import { indexManagementStore } from '../../../public/application/store'; import { WithAppDependencies, services, TestSubjects } from '../helpers'; diff --git a/x-pack/plugins/index_management/__jest__/client_integration/home/home.test.ts b/x-pack/plugins/index_management/__jest__/client_integration/home/home.test.ts index a7ac2ebf9bb02..48551321fde8a 100644 --- a/x-pack/plugins/index_management/__jest__/client_integration/home/home.test.ts +++ b/x-pack/plugins/index_management/__jest__/client_integration/home/home.test.ts @@ -15,7 +15,7 @@ import { HomeTestBed, setup } from './home.helpers'; Could not load worker ReferenceError: Worker is not defined at createWorker (//node_modules/brace/index.js:17992:5) */ -import { stubWebWorker } from '../../../../../test_utils/stub_web_worker'; +import { stubWebWorker } from '@kbn/test/jest'; stubWebWorker(); describe('', () => { diff --git a/x-pack/plugins/index_management/__jest__/client_integration/home/index_templates_tab.helpers.ts b/x-pack/plugins/index_management/__jest__/client_integration/home/index_templates_tab.helpers.ts index fe938bb087d2e..583f8f723f0a7 100644 --- a/x-pack/plugins/index_management/__jest__/client_integration/home/index_templates_tab.helpers.ts +++ b/x-pack/plugins/index_management/__jest__/client_integration/home/index_templates_tab.helpers.ts @@ -6,12 +6,7 @@ import { act } from 'react-dom/test-utils'; -import { - registerTestBed, - TestBed, - TestBedConfig, - findTestSubject, -} from '../../../../../test_utils'; +import { registerTestBed, TestBed, TestBedConfig, findTestSubject } from '@kbn/test/jest'; import { TemplateList } from '../../../public/application/sections/home/template_list'; import { TemplateDeserialized } from '../../../common'; import { WithAppDependencies, TestSubjects } from '../helpers'; diff --git a/x-pack/plugins/index_management/__jest__/client_integration/home/indices_tab.helpers.ts b/x-pack/plugins/index_management/__jest__/client_integration/home/indices_tab.helpers.ts index c7af3a8f45105..f20d0487e1378 100644 --- a/x-pack/plugins/index_management/__jest__/client_integration/home/indices_tab.helpers.ts +++ b/x-pack/plugins/index_management/__jest__/client_integration/home/indices_tab.helpers.ts @@ -7,12 +7,7 @@ import { act } from 'react-dom/test-utils'; import { ReactWrapper } from 'enzyme'; -import { - registerTestBed, - TestBed, - TestBedConfig, - findTestSubject, -} from '../../../../../test_utils'; +import { registerTestBed, TestBed, TestBedConfig, findTestSubject } from '@kbn/test/jest'; import { IndexManagementHome } from '../../../public/application/sections/home'; import { indexManagementStore } from '../../../public/application/store'; import { WithAppDependencies, services, TestSubjects } from '../helpers'; diff --git a/x-pack/plugins/index_management/__jest__/client_integration/home/indices_tab.test.ts b/x-pack/plugins/index_management/__jest__/client_integration/home/indices_tab.test.ts index adc47515acaee..db4624d4389ff 100644 --- a/x-pack/plugins/index_management/__jest__/client_integration/home/indices_tab.test.ts +++ b/x-pack/plugins/index_management/__jest__/client_integration/home/indices_tab.test.ts @@ -17,7 +17,7 @@ import { createDataStreamPayload } from './data_streams_tab.helpers'; Could not load worker ReferenceError: Worker is not defined at createWorker (//node_modules/brace/index.js:17992:5) */ -import { stubWebWorker } from '../../../../../test_utils/stub_web_worker'; +import { stubWebWorker } from '@kbn/test/jest'; import { createMemoryHistory } from 'history'; stubWebWorker(); diff --git a/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_clone.helpers.ts b/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_clone.helpers.ts index 62adb8c433366..4cc40c71e4efd 100644 --- a/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_clone.helpers.ts +++ b/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_clone.helpers.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, TestBedConfig } from '../../../../../test_utils'; +import { registerTestBed, TestBedConfig } from '@kbn/test/jest'; import { TemplateClone } from '../../../public/application/sections/template_clone'; import { WithAppDependencies } from '../helpers'; diff --git a/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_create.helpers.ts b/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_create.helpers.ts index 9ad8d61e637e5..330723d87a3de 100644 --- a/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_create.helpers.ts +++ b/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_create.helpers.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, TestBedConfig } from '../../../../../test_utils'; +import { registerTestBed, TestBedConfig } from '@kbn/test/jest'; import { TemplateCreate } from '../../../public/application/sections/template_create'; import { WithAppDependencies } from '../helpers'; diff --git a/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_edit.helpers.ts b/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_edit.helpers.ts index c3a139f89cb5f..21ecf18aa0d38 100644 --- a/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_edit.helpers.ts +++ b/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_edit.helpers.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, TestBedConfig } from '../../../../../test_utils'; +import { registerTestBed, TestBedConfig } from '@kbn/test/jest'; import { TemplateEdit } from '../../../public/application/sections/template_edit'; import { WithAppDependencies } from '../helpers'; diff --git a/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_form.helpers.ts b/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_form.helpers.ts index 2ce5aa2fccfc4..1be020c37ea37 100644 --- a/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_form.helpers.ts +++ b/x-pack/plugins/index_management/__jest__/client_integration/index_template_wizard/template_form.helpers.ts @@ -5,7 +5,7 @@ */ import { act } from 'react-dom/test-utils'; -import { TestBed, SetupFunc, UnwrapPromise } from '../../../../../test_utils'; +import { TestBed, SetupFunc, UnwrapPromise } from '@kbn/test/jest'; import { TemplateDeserialized } from '../../../common'; interface MappingField { diff --git a/x-pack/plugins/index_management/__jest__/components/index_table.test.js b/x-pack/plugins/index_management/__jest__/components/index_table.test.js index 49902d8b09675..67623b18930c8 100644 --- a/x-pack/plugins/index_management/__jest__/components/index_table.test.js +++ b/x-pack/plugins/index_management/__jest__/components/index_table.test.js @@ -15,7 +15,7 @@ import { MemoryRouter } from 'react-router-dom'; Could not load worker ReferenceError: Worker is not defined at createWorker (//node_modules/brace/index.js:17992:5) */ -import * as stubWebWorker from '../../../../test_utils/stub_web_worker'; // eslint-disable-line no-unused-vars +import { mountWithIntl, stubWebWorker } from '@kbn/test/jest'; // eslint-disable-line no-unused-vars import { AppWithoutRouter } from '../../public/application/app'; import { AppContextProvider } from '../../public/application/app_context'; @@ -29,7 +29,6 @@ import { setUiMetricService } from '../../public/application/services/api'; import { indexManagementStore } from '../../public/application/store'; import { setExtensionsService } from '../../public/application/store/selectors'; import { BASE_PATH, API_BASE_PATH } from '../../common/constants'; -import { mountWithIntl } from '../../../../test_utils/enzyme_helpers'; import { ExtensionsService } from '../../public/services'; import sinon from 'sinon'; import { findTestSubject } from '@elastic/eui/lib/test'; diff --git a/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/component_template_create.helpers.ts b/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/component_template_create.helpers.ts index e6ced2fcc309a..fcfb97d72e383 100644 --- a/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/component_template_create.helpers.ts +++ b/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/component_template_create.helpers.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, TestBed, TestBedConfig } from '../../../../../../../../../test_utils'; +import { registerTestBed, TestBed, TestBedConfig } from '@kbn/test/jest'; import { BASE_PATH } from '../../../../../../../common'; import { ComponentTemplateCreate } from '../../../component_template_wizard'; diff --git a/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/component_template_details.helpers.ts b/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/component_template_details.helpers.ts index fe81e8dcfe123..b8ce9dfa2d04a 100644 --- a/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/component_template_details.helpers.ts +++ b/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/component_template_details.helpers.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, TestBed } from '../../../../../../../../../test_utils'; +import { registerTestBed, TestBed } from '@kbn/test/jest'; import { WithAppDependencies } from './setup_environment'; import { ComponentTemplateDetailsFlyoutContent } from '../../../component_template_details'; diff --git a/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/component_template_edit.helpers.ts b/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/component_template_edit.helpers.ts index 3c0cbb19577a9..f7575c6fc987f 100644 --- a/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/component_template_edit.helpers.ts +++ b/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/component_template_edit.helpers.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, TestBed, TestBedConfig } from '../../../../../../../../../test_utils'; +import { registerTestBed, TestBed, TestBedConfig } from '@kbn/test/jest'; import { BASE_PATH } from '../../../../../../../common'; import { ComponentTemplateEdit } from '../../../component_template_wizard'; diff --git a/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/component_template_form.helpers.ts b/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/component_template_form.helpers.ts index 870b8b7ec5509..d8b3413eebf7e 100644 --- a/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/component_template_form.helpers.ts +++ b/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/component_template_form.helpers.ts @@ -5,7 +5,7 @@ */ import { act } from 'react-dom/test-utils'; -import { TestBed } from '../../../../../../../../../test_utils'; +import { TestBed } from '@kbn/test/jest'; interface MappingField { name: string; diff --git a/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/component_template_list.helpers.ts b/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/component_template_list.helpers.ts index cdcb1abf8ed5d..bd760fb79e696 100644 --- a/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/component_template_list.helpers.ts +++ b/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/component_template_list.helpers.ts @@ -6,14 +6,8 @@ import { act } from 'react-dom/test-utils'; +import { registerTestBed, TestBed, TestBedConfig, findTestSubject, nextTick } from '@kbn/test/jest'; import { BASE_PATH } from '../../../../../../../common'; -import { - registerTestBed, - TestBed, - TestBedConfig, - findTestSubject, - nextTick, -} from '../../../../../../../../../test_utils'; import { WithAppDependencies } from './setup_environment'; import { ComponentTemplateList } from '../../../component_template_list/component_template_list'; diff --git a/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/index.ts b/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/index.ts index 4b92235993e26..4e03adcbcbb44 100644 --- a/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/index.ts +++ b/x-pack/plugins/index_management/public/application/components/component_templates/__jest__/client_integration/helpers/index.ts @@ -7,7 +7,7 @@ import { setup as componentTemplatesListSetup } from './component_template_list.helpers'; import { setup as componentTemplateDetailsSetup } from './component_template_details.helpers'; -export { nextTick, getRandomString, findTestSubject } from '../../../../../../../../../test_utils'; +export { nextTick, getRandomString, findTestSubject } from '@kbn/test/jest'; export { setupEnvironment, appDependencies } from './setup_environment'; diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/__jest__/client_integration/helpers/index.ts b/x-pack/plugins/index_management/public/application/components/mappings_editor/__jest__/client_integration/helpers/index.ts index afdc039ae77d2..f47ab3884d083 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/__jest__/client_integration/helpers/index.ts +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/__jest__/client_integration/helpers/index.ts @@ -10,12 +10,7 @@ import { getMappingsEditorDataFactory, } from './mappings_editor.helpers'; -export { - nextTick, - getRandomString, - findTestSubject, - TestBed, -} from '../../../../../../../../../test_utils'; +export { nextTick, getRandomString, findTestSubject, TestBed } from '@kbn/test/jest'; export const componentHelpers = { mappingsEditor: { setup: mappingsEditorSetup, getMappingsEditorDataFactory }, diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/__jest__/client_integration/helpers/mappings_editor.helpers.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/__jest__/client_integration/helpers/mappings_editor.helpers.tsx index a625cc8c0ab4b..9302e080028cc 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/__jest__/client_integration/helpers/mappings_editor.helpers.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/__jest__/client_integration/helpers/mappings_editor.helpers.tsx @@ -7,8 +7,8 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; import { ReactWrapper } from 'enzyme'; +import { registerTestBed, TestBed } from '@kbn/test/jest'; import { GlobalFlyout } from '../../../../../../../../../../src/plugins/es_ui_shared/public'; -import { registerTestBed, TestBed } from '../../../../../../../../../test_utils'; import { getChildFieldsName } from '../../../lib'; import { MappingsEditor } from '../../../mappings_editor'; import { MappingsEditorProvider } from '../../../mappings_editor_context'; diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/load_mappings/load_mappings_provider.test.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/load_mappings/load_mappings_provider.test.tsx index 88a7e9252d6dd..2918bac9aa683 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/load_mappings/load_mappings_provider.test.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/load_mappings/load_mappings_provider.test.tsx @@ -32,7 +32,7 @@ jest.mock('lodash', () => { }; }); -import { registerTestBed, TestBed } from '../../../../../../../../test_utils'; +import { registerTestBed, TestBed } from '@kbn/test/jest'; import { LoadMappingsProvider } from './load_mappings_provider'; const ComponentToTest = ({ onJson }: { onJson: () => void }) => ( diff --git a/x-pack/plugins/index_management/test/fixtures/template.ts b/x-pack/plugins/index_management/test/fixtures/template.ts index ac6e8b7879a26..016100faea601 100644 --- a/x-pack/plugins/index_management/test/fixtures/template.ts +++ b/x-pack/plugins/index_management/test/fixtures/template.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getRandomString, getRandomNumber } from '../../../../test_utils'; +import { getRandomString, getRandomNumber } from '@kbn/test/jest'; import { TemplateDeserialized, TemplateType, TemplateListItem } from '../../common'; const objHasProperties = (obj?: Record): boolean => { diff --git a/x-pack/plugins/infra/public/alerting/inventory/components/expression.test.tsx b/x-pack/plugins/infra/public/alerting/inventory/components/expression.test.tsx index 54d3b783d22f6..6f830598ac46d 100644 --- a/x-pack/plugins/infra/public/alerting/inventory/components/expression.test.tsx +++ b/x-pack/plugins/infra/public/alerting/inventory/components/expression.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { actionTypeRegistryMock } from '../../../../../triggers_actions_ui/public/application/action_type_registry.mock'; import { alertTypeRegistryMock } from '../../../../../triggers_actions_ui/public/application/alert_type_registry.mock'; import { coreMock } from '../../../../../../../src/core/public/mocks'; diff --git a/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression.test.tsx b/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression.test.tsx index b14c7877787ab..c83f9ff33bac5 100644 --- a/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression.test.tsx +++ b/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { actionTypeRegistryMock } from '../../../../../triggers_actions_ui/public/application/action_type_registry.mock'; import { alertTypeRegistryMock } from '../../../../../triggers_actions_ui/public/application/alert_type_registry.mock'; import { coreMock } from '../../../../../../../src/core/public/mocks'; diff --git a/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx b/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx index 39a5a7feb2774..5f3f0ea7f3490 100644 --- a/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx +++ b/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { actionTypeRegistryMock } from '../../../../../triggers_actions_ui/public/application/action_type_registry.mock'; import { alertTypeRegistryMock } from '../../../../../triggers_actions_ui/public/application/alert_type_registry.mock'; import { coreMock } from '../../../../../../../src/core/public/mocks'; diff --git a/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_row.test.tsx b/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_row.test.tsx index d5be8a2ec2675..8fae6c6a51343 100644 --- a/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_row.test.tsx +++ b/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_row.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { MetricExpression } from '../types'; import React from 'react'; import { ExpressionRow } from './expression_row'; diff --git a/x-pack/plugins/infra/public/containers/logs/log_view_configuration.test.tsx b/x-pack/plugins/infra/public/containers/logs/log_view_configuration.test.tsx index 5954cb834a11d..d3f46bed07cc0 100644 --- a/x-pack/plugins/infra/public/containers/logs/log_view_configuration.test.tsx +++ b/x-pack/plugins/infra/public/containers/logs/log_view_configuration.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { mountHook } from 'test_utils/enzyme_helpers'; +import { mountHook } from '@kbn/test/jest'; import { useLogViewConfiguration } from './log_view_configuration'; diff --git a/x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/metrics_time.test.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/metrics_time.test.tsx index d2076ad6df502..62688a19ad835 100644 --- a/x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/metrics_time.test.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/metrics_time.test.tsx @@ -7,7 +7,7 @@ import { createMemoryHistory } from 'history'; import React from 'react'; import { Router } from 'react-router-dom'; -import { mountHook } from 'test_utils/enzyme_helpers'; +import { mountHook } from '@kbn/test/jest'; import { ScopedHistory } from '../../../../../../../../src/core/public'; import { useMetricsTime } from './use_metrics_time'; diff --git a/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/index.ts b/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/index.ts index 6216119c5d1d1..a86a18cca0717 100644 --- a/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/index.ts +++ b/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/index.ts @@ -9,7 +9,7 @@ import { setup as pipelinesCreateSetup } from './pipelines_create.helpers'; import { setup as pipelinesCloneSetup } from './pipelines_clone.helpers'; import { setup as pipelinesEditSetup } from './pipelines_edit.helpers'; -export { nextTick, getRandomString, findTestSubject } from '../../../../../test_utils'; +export { nextTick, getRandomString, findTestSubject } from '@kbn/test/jest'; export { setupEnvironment } from './setup_environment'; diff --git a/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipeline_form.helpers.ts b/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipeline_form.helpers.ts index dd354b4927836..fd92c25d250cf 100644 --- a/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipeline_form.helpers.ts +++ b/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipeline_form.helpers.ts @@ -5,7 +5,7 @@ */ import { act } from 'react-dom/test-utils'; -import { TestBed } from '../../../../../test_utils'; +import { TestBed } from '@kbn/test/jest'; export const getFormActions = (testBed: TestBed) => { const { find, form, component } = testBed; diff --git a/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipelines_clone.helpers.ts b/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipelines_clone.helpers.ts index 2559b93bd606d..a200509f98e04 100644 --- a/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipelines_clone.helpers.ts +++ b/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipelines_clone.helpers.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, TestBedConfig, TestBed } from '../../../../../test_utils'; +import { registerTestBed, TestBedConfig, TestBed } from '@kbn/test/jest'; import { PipelinesClone } from '../../../public/application/sections/pipelines_clone'; import { getFormActions, PipelineFormTestSubjects } from './pipeline_form.helpers'; import { WithAppDependencies } from './setup_environment'; diff --git a/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipelines_create.helpers.ts b/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipelines_create.helpers.ts index 22f68f12804d6..0cbcca8b49dc8 100644 --- a/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipelines_create.helpers.ts +++ b/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipelines_create.helpers.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, TestBedConfig, TestBed } from '../../../../../test_utils'; +import { registerTestBed, TestBedConfig, TestBed } from '@kbn/test/jest'; import { PipelinesCreate } from '../../../public/application/sections/pipelines_create'; import { getFormActions, PipelineFormTestSubjects } from './pipeline_form.helpers'; import { WithAppDependencies } from './setup_environment'; diff --git a/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipelines_edit.helpers.ts b/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipelines_edit.helpers.ts index 5e0739f78eecd..498a1b3ad3688 100644 --- a/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipelines_edit.helpers.ts +++ b/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipelines_edit.helpers.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, TestBedConfig, TestBed } from '../../../../../test_utils'; +import { registerTestBed, TestBedConfig, TestBed } from '@kbn/test/jest'; import { PipelinesEdit } from '../../../public/application/sections/pipelines_edit'; import { getFormActions, PipelineFormTestSubjects } from './pipeline_form.helpers'; import { WithAppDependencies } from './setup_environment'; diff --git a/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipelines_list.helpers.ts b/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipelines_list.helpers.ts index 6c446e8254f6b..76cd525bc9c45 100644 --- a/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipelines_list.helpers.ts +++ b/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipelines_list.helpers.ts @@ -6,12 +6,7 @@ import { act } from 'react-dom/test-utils'; -import { - registerTestBed, - TestBed, - TestBedConfig, - findTestSubject, -} from '../../../../../test_utils'; +import { registerTestBed, TestBed, TestBedConfig, findTestSubject } from '@kbn/test/jest'; import { PipelinesList } from '../../../public/application/sections/pipelines_list'; import { WithAppDependencies } from './setup_environment'; import { getListPath, ROUTES } from '../../../public/application/services/navigation'; diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/__jest__/pipeline_processors_editor.helpers.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/__jest__/pipeline_processors_editor.helpers.tsx index 135a5854f36cd..36c7e9b752e08 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/__jest__/pipeline_processors_editor.helpers.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/__jest__/pipeline_processors_editor.helpers.tsx @@ -6,7 +6,7 @@ import { act } from 'react-dom/test-utils'; import React from 'react'; -import { registerTestBed, TestBed } from '../../../../../../../test_utils'; +import { registerTestBed, TestBed } from '@kbn/test/jest'; import { Props } from '../'; import { ProcessorsEditorWithDeps } from './processors_editor'; diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/__jest__/test_pipeline.helpers.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/__jest__/test_pipeline.helpers.tsx index 570d9878f7634..7294446d82b41 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/__jest__/test_pipeline.helpers.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/__jest__/test_pipeline.helpers.tsx @@ -11,8 +11,8 @@ import axiosXhrAdapter from 'axios/lib/adapters/xhr'; /* eslint-disable @kbn/eslint/no-restricted-paths */ import { usageCollectionPluginMock } from 'src/plugins/usage_collection/public/mocks'; -import { registerTestBed, TestBed } from '../../../../../../../test_utils'; -import { stubWebWorker } from '../../../../../../../test_utils/stub_web_worker'; +import { registerTestBed, TestBed } from '@kbn/test/jest'; +import { stubWebWorker } from '@kbn/test/jest'; import { uiMetricService, apiService } from '../../../services'; import { Props } from '../'; import { initHttpRequests } from './http_requests.helpers'; diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/load_from_json/modal_provider.test.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/load_from_json/modal_provider.test.tsx index 2f4cdce1edd0b..67350314e260a 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/load_from_json/modal_provider.test.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/load_from_json/modal_provider.test.tsx @@ -32,7 +32,7 @@ jest.mock('lodash', () => { }; }); -import { registerTestBed, TestBed } from '../../../../../../../../test_utils/testbed'; +import { registerTestBed, TestBed } from '@kbn/test/jest'; const setup = ({ onDone }: { onDone: OnDoneLoadJsonHandler }) => { return registerTestBed( diff --git a/x-pack/plugins/lens/public/datatable_visualization/expression.test.tsx b/x-pack/plugins/lens/public/datatable_visualization/expression.test.tsx index c95f6085b4791..ea6b99a3fc767 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/expression.test.tsx +++ b/x-pack/plugins/lens/public/datatable_visualization/expression.test.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { shallow } from 'enzyme'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { datatable, DatatableComponent } from './expression'; import { LensMultiTable } from '../types'; import { DatatableProps } from './expression'; diff --git a/x-pack/plugins/lens/public/debounced_component/debounced_component.test.tsx b/x-pack/plugins/lens/public/debounced_component/debounced_component.test.tsx index 929dd8e434afe..fab2483de4fd6 100644 --- a/x-pack/plugins/lens/public/debounced_component/debounced_component.test.tsx +++ b/x-pack/plugins/lens/public/debounced_component/debounced_component.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { mountWithIntl as mount } from 'test_utils/enzyme_helpers'; +import { mountWithIntl as mount } from '@kbn/test/jest'; import { debouncedComponent } from './debounced_component'; import { act } from 'react-dom/test-utils'; diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.test.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.test.tsx index c0cd211a49dd9..f440042801ca6 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.test.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.test.tsx @@ -14,7 +14,7 @@ import { } from '../../mocks'; import { ChildDragDropProvider, DroppableEvent } from '../../../drag_drop'; import { EuiFormRow } from '@elastic/eui'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { Visualization } from '../../../types'; import { LayerPanel } from './layer_panel'; import { coreMock } from 'src/core/public/mocks'; diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/editor_frame.test.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/editor_frame.test.tsx index b3ea14efbae80..53d94f24d616c 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/editor_frame.test.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/editor_frame.test.tsx @@ -7,7 +7,7 @@ import React, { ReactElement } from 'react'; import { ReactWrapper } from 'enzyme'; import { EuiPanel, EuiToolTip } from '@elastic/eui'; -import { mountWithIntl as mount } from 'test_utils/enzyme_helpers'; +import { mountWithIntl as mount } from '@kbn/test/jest'; import { EditorFrame } from './editor_frame'; import { DatasourcePublicAPI, DatasourceSuggestion, Visualization } from '../../types'; import { act } from 'react-dom/test-utils'; diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx index 8694cebc70391..382178a14793b 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { mountWithIntl as mount } from 'test_utils/enzyme_helpers'; +import { mountWithIntl as mount } from '@kbn/test/jest'; import { Visualization } from '../../types'; import { createMockVisualization, diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/chart_switch.test.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/chart_switch.test.tsx index 5109d8808a233..0bbb42012b68b 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/chart_switch.test.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/chart_switch.test.tsx @@ -12,7 +12,7 @@ import { createMockDatasource, } from '../../mocks'; import { EuiKeyPadMenuItem } from '@elastic/eui'; -import { mountWithIntl as mount } from 'test_utils/enzyme_helpers'; +import { mountWithIntl as mount } from '@kbn/test/jest'; import { Visualization, FramePublicAPI, DatasourcePublicAPI } from '../../../types'; import { Action } from '../state_management'; import { ChartSwitch } from './chart_switch'; diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx index 231c38ea54048..33deb0356660c 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx @@ -23,7 +23,7 @@ jest.mock('../../../debounced_component', () => { }); import { WorkspacePanel, WorkspacePanelProps } from './workspace_panel'; -import { mountWithIntl as mount } from 'test_utils/enzyme_helpers'; +import { mountWithIntl as mount } from '@kbn/test/jest'; import { ReactWrapper } from 'enzyme'; import { DragDrop, ChildDragDropProvider } from '../../../drag_drop'; import { Ast } from '@kbn/interpreter/common'; diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.test.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.test.tsx index 6cca42dc1cb93..db0be190c45c8 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.test.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { Visualization } from '../../../types'; import { createMockVisualization, createMockFramePublicAPI, FrameMock } from '../../mocks'; -import { mountWithIntl as mount } from 'test_utils/enzyme_helpers'; +import { mountWithIntl as mount } from '@kbn/test/jest'; import { ReactWrapper } from 'enzyme'; import { WorkspacePanelWrapper, WorkspacePanelWrapperProps } from './workspace_panel_wrapper'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/datapanel.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/datapanel.test.tsx index d2ec1c81bbeec..ac82caf9d5227 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/datapanel.test.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/datapanel.test.tsx @@ -13,7 +13,7 @@ import { NoFieldsCallout } from './no_fields_callout'; import { act } from 'react-dom/test-utils'; import { coreMock } from 'src/core/public/mocks'; import { IndexPatternPrivateState } from './types'; -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { ChangeIndexPattern } from './change_indexpattern'; import { EuiProgress, EuiLoadingSpinner } from '@elastic/eui'; import { documentField } from './document_field'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_panel.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_panel.test.tsx index e9eb3fa4542fe..b2edc61a56736 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_panel.test.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_panel.test.tsx @@ -13,7 +13,7 @@ import { IndexPatternDimensionEditorComponent, IndexPatternDimensionEditorProps, } from './dimension_panel'; -import { mountWithIntl as mount, shallowWithIntl as shallow } from 'test_utils/enzyme_helpers'; +import { mountWithIntl as mount, shallowWithIntl as shallow } from '@kbn/test/jest'; import { IUiSettingsClient, SavedObjectsClientContract, HttpSetup, CoreSetup } from 'kibana/public'; import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { IndexPatternPrivateState } from '../types'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/field_item.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/field_item.test.tsx index 781222888b6dc..2f3549911dfe7 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/field_item.test.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/field_item.test.tsx @@ -10,7 +10,7 @@ import { act } from 'react-dom/test-utils'; import { EuiLoadingSpinner, EuiPopover } from '@elastic/eui'; import { InnerFieldItem, FieldItemProps } from './field_item'; import { coreMock } from 'src/core/public/mocks'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { DataPublicPluginStart } from '../../../../../src/plugins/data/public'; import { dataPluginMock } from '../../../../../src/plugins/data/public/mocks'; import { IndexPattern } from './types'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/fields_accordion.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/fields_accordion.test.tsx index 7d1c80e5a7f6a..d85d08e4ae000 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/fields_accordion.test.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/fields_accordion.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { EuiLoadingSpinner, EuiNotificationBadge } from '@elastic/eui'; import { coreMock } from 'src/core/public/mocks'; -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { DataPublicPluginStart } from '../../../../../src/plugins/data/public'; import { dataPluginMock } from '../../../../../src/plugins/data/public/mocks'; import { IndexPattern } from './types'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/layerpanel.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/layerpanel.test.tsx index b7df3cc5c3687..2c6a1c67d2948 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/layerpanel.test.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/layerpanel.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { IndexPatternPrivateState } from './types'; import { IndexPatternLayerPanelProps, LayerPanel } from './layerpanel'; -import { shallowWithIntl as shallow } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl as shallow } from '@kbn/test/jest'; import { ShallowWrapper } from 'enzyme'; import { EuiSelectable } from '@elastic/eui'; import { ChangeIndexPattern } from './change_indexpattern'; diff --git a/x-pack/plugins/lens/public/shared_components/legend_settings_popover.test.tsx b/x-pack/plugins/lens/public/shared_components/legend_settings_popover.test.tsx index 1e0e6b33b6cd4..f5ae125945c45 100644 --- a/x-pack/plugins/lens/public/shared_components/legend_settings_popover.test.tsx +++ b/x-pack/plugins/lens/public/shared_components/legend_settings_popover.test.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { Position } from '@elastic/charts'; -import { shallowWithIntl as shallow } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl as shallow } from '@kbn/test/jest'; import { LegendSettingsPopover, LegendSettingsPopoverProps } from './legend_settings_popover'; describe('Legend Settings', () => { diff --git a/x-pack/plugins/lens/public/xy_visualization/axis_settings_popover.test.tsx b/x-pack/plugins/lens/public/xy_visualization/axis_settings_popover.test.tsx index 9e71323377c1a..0ba7a56f50695 100644 --- a/x-pack/plugins/lens/public/xy_visualization/axis_settings_popover.test.tsx +++ b/x-pack/plugins/lens/public/xy_visualization/axis_settings_popover.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl as shallow } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl as shallow } from '@kbn/test/jest'; import { AxisSettingsPopover, AxisSettingsPopoverProps } from './axis_settings_popover'; import { ToolbarPopover } from '../shared_components'; diff --git a/x-pack/plugins/lens/public/xy_visualization/expression.test.tsx b/x-pack/plugins/lens/public/xy_visualization/expression.test.tsx index a5d292fdf265a..1bcae4d09e7e7 100644 --- a/x-pack/plugins/lens/public/xy_visualization/expression.test.tsx +++ b/x-pack/plugins/lens/public/xy_visualization/expression.test.tsx @@ -34,7 +34,7 @@ import { gridlinesConfig, } from './types'; import { createMockExecutionContext } from '../../../../../src/plugins/expressions/common/mocks'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { chartPluginMock } from '../../../../../src/plugins/charts/public/mocks'; import { EmptyPlaceholder } from '../shared_components/empty_placeholder'; diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel.test.tsx b/x-pack/plugins/lens/public/xy_visualization/xy_config_panel.test.tsx index 721bff8684a19..99fbfa058a2de 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel.test.tsx +++ b/x-pack/plugins/lens/public/xy_visualization/xy_config_panel.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { mountWithIntl as mount, shallowWithIntl as shallow } from 'test_utils/enzyme_helpers'; +import { mountWithIntl as mount, shallowWithIntl as shallow } from '@kbn/test/jest'; import { EuiButtonGroupProps, EuiSuperSelect, EuiButtonGroup } from '@elastic/eui'; import { LayerContextMenu, XyToolbar, DimensionEditor } from './xy_config_panel'; import { ToolbarPopover } from '../shared_components'; diff --git a/x-pack/plugins/license_management/__jest__/upload_license.test.tsx b/x-pack/plugins/license_management/__jest__/upload_license.test.tsx index 947907c7dcc9c..4dd32c1a6025c 100644 --- a/x-pack/plugins/license_management/__jest__/upload_license.test.tsx +++ b/x-pack/plugins/license_management/__jest__/upload_license.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { Provider } from 'react-redux'; import { LocationDescriptorObject } from 'history'; import { httpServiceMock, scopedHistoryMock } from '../../../../src/core/public/mocks'; -import { mountWithIntl } from '../../../test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; // @ts-ignore import { uploadLicense } from '../public/application/store/actions/upload_license'; diff --git a/x-pack/plugins/license_management/__jest__/util/util.js b/x-pack/plugins/license_management/__jest__/util/util.js index c13dcdb7fdbfa..38ef3ed01c012 100644 --- a/x-pack/plugins/license_management/__jest__/util/util.js +++ b/x-pack/plugins/license_management/__jest__/util/util.js @@ -8,7 +8,7 @@ import React from 'react'; import { Provider } from 'react-redux'; -import { mountWithIntl } from '../../../../test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { httpServiceMock, scopedHistoryMock } from '../../../../../src/core/public/mocks'; import { licenseManagementStore } from '../../public/application/store/store'; import { AppContextProvider } from '../../public/application/app_context'; diff --git a/x-pack/plugins/logstash/public/application/components/pipeline_editor/pipeline_editor.test.js b/x-pack/plugins/logstash/public/application/components/pipeline_editor/pipeline_editor.test.js index bb5961ce36120..be5f6b984fea5 100644 --- a/x-pack/plugins/logstash/public/application/components/pipeline_editor/pipeline_editor.test.js +++ b/x-pack/plugins/logstash/public/application/components/pipeline_editor/pipeline_editor.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import 'brace'; import { PipelineEditor } from './pipeline_editor'; diff --git a/x-pack/plugins/logstash/public/application/components/pipeline_list/add_role_alert.test.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/add_role_alert.test.js index 6da29411a025d..d611fd4836024 100644 --- a/x-pack/plugins/logstash/public/application/components/pipeline_list/add_role_alert.test.js +++ b/x-pack/plugins/logstash/public/application/components/pipeline_list/add_role_alert.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { AddRoleAlert } from './add_role_alert'; describe('AddRoleAlert component', () => { diff --git a/x-pack/plugins/logstash/public/application/components/pipeline_list/alert_call_out.test.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/alert_call_out.test.js index b717cf5340942..c43a0839f4c11 100644 --- a/x-pack/plugins/logstash/public/application/components/pipeline_list/alert_call_out.test.js +++ b/x-pack/plugins/logstash/public/application/components/pipeline_list/alert_call_out.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { AlertCallOut } from './alert_call_out'; describe('AlertCallOut component', () => { diff --git a/x-pack/plugins/logstash/public/application/components/pipeline_list/confirm_delete_modal.test.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/confirm_delete_modal.test.js index bbf91f2c0b957..60d05e2359836 100644 --- a/x-pack/plugins/logstash/public/application/components/pipeline_list/confirm_delete_modal.test.js +++ b/x-pack/plugins/logstash/public/application/components/pipeline_list/confirm_delete_modal.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; import { ConfirmDeleteModal } from './confirm_delete_modal'; describe('ConfirmDeleteModal component', () => { diff --git a/x-pack/plugins/logstash/public/application/components/pipeline_list/enable_monitoring_alert.test.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/enable_monitoring_alert.test.js index da70815bc1313..e27864ad5ffc0 100644 --- a/x-pack/plugins/logstash/public/application/components/pipeline_list/enable_monitoring_alert.test.js +++ b/x-pack/plugins/logstash/public/application/components/pipeline_list/enable_monitoring_alert.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { EnableMonitoringAlert } from './enable_monitoring_alert'; describe('EnableMonitoringAlert component', () => { diff --git a/x-pack/plugins/logstash/public/application/components/pipeline_list/pipeline_list.test.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/pipeline_list.test.js index 019cd29f7a017..cd7a218f54385 100644 --- a/x-pack/plugins/logstash/public/application/components/pipeline_list/pipeline_list.test.js +++ b/x-pack/plugins/logstash/public/application/components/pipeline_list/pipeline_list.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { PipelineList } from './pipeline_list'; describe('PipelineList component', () => { diff --git a/x-pack/plugins/logstash/public/application/components/pipeline_list/pipelines_table.test.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/pipelines_table.test.js index 6c2f0d02801c4..2a187d95ec9a7 100644 --- a/x-pack/plugins/logstash/public/application/components/pipeline_list/pipelines_table.test.js +++ b/x-pack/plugins/logstash/public/application/components/pipeline_list/pipelines_table.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; import { PipelinesTable } from './pipelines_table'; describe('PipelinesTable component', () => { diff --git a/x-pack/plugins/logstash/public/application/components/upgrade_failure/upgrade_failure.test.js b/x-pack/plugins/logstash/public/application/components/upgrade_failure/upgrade_failure.test.js index d9d6c544141d3..fe93ddb22077c 100644 --- a/x-pack/plugins/logstash/public/application/components/upgrade_failure/upgrade_failure.test.js +++ b/x-pack/plugins/logstash/public/application/components/upgrade_failure/upgrade_failure.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; import { UpgradeFailure } from './upgrade_failure'; describe('UpgradeFailure component', () => { diff --git a/x-pack/plugins/logstash/public/application/components/upgrade_failure/upgrade_failure_actions.test.js b/x-pack/plugins/logstash/public/application/components/upgrade_failure/upgrade_failure_actions.test.js index 6ff28a1d36a6e..603ab0ff543b8 100644 --- a/x-pack/plugins/logstash/public/application/components/upgrade_failure/upgrade_failure_actions.test.js +++ b/x-pack/plugins/logstash/public/application/components/upgrade_failure/upgrade_failure_actions.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; import { UpgradeFailureActions } from './upgrade_failure_actions'; describe('UpgradeFailureActions component', () => { diff --git a/x-pack/plugins/maps/public/connected_components/layer_panel/view.test.js b/x-pack/plugins/maps/public/connected_components/layer_panel/view.test.js index 1a0eda102986f..cdc24ed728abb 100644 --- a/x-pack/plugins/maps/public/connected_components/layer_panel/view.test.js +++ b/x-pack/plugins/maps/public/connected_components/layer_panel/view.test.js @@ -52,7 +52,7 @@ jest.mock('../../kibana_services', () => { }); import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { LayerPanel } from './view'; diff --git a/x-pack/plugins/maps/public/connected_components/widget_overlay/attribution_control/view.test.js b/x-pack/plugins/maps/public/connected_components/widget_overlay/attribution_control/view.test.js index 2e85e8ab792d3..96cc6cf812020 100644 --- a/x-pack/plugins/maps/public/connected_components/widget_overlay/attribution_control/view.test.js +++ b/x-pack/plugins/maps/public/connected_components/widget_overlay/attribution_control/view.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { AttributionControl } from './view'; diff --git a/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/view.test.js b/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/view.test.js index 877e8658ab03e..e25e5bb36be1a 100644 --- a/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/view.test.js +++ b/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/view.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; jest.mock('../../../../../kibana_services', () => { return { diff --git a/x-pack/plugins/ml/common/util/job_utils.ts b/x-pack/plugins/ml/common/util/job_utils.ts index 878f5a2c71cb9..a5b854a8d59a7 100644 --- a/x-pack/plugins/ml/common/util/job_utils.ts +++ b/x-pack/plugins/ml/common/util/job_utils.ts @@ -5,8 +5,7 @@ */ import { isEmpty, isEqual, each, pick } from 'lodash'; - -import semver from 'semver'; +import semverGte from 'semver/functions/gte'; import moment, { Duration } from 'moment'; // @ts-ignore import numeral from '@elastic/numeral'; @@ -205,7 +204,7 @@ export function isModelPlotEnabled( // created with) is greater than or equal to the supplied version (e.g. '6.1.0'). export function isJobVersionGte(job: CombinedJob, version: string): boolean { const jobVersion = job.job_version ?? '0.0.0'; - return semver.gte(jobVersion, version); + return semverGte(jobVersion, version); } // Takes an ML detector 'function' and returns the corresponding ES aggregation name diff --git a/x-pack/plugins/ml/public/application/components/annotations/annotation_description_list/index.test.tsx b/x-pack/plugins/ml/public/application/components/annotations/annotation_description_list/index.test.tsx index e7330ca1dbe5d..9d885742f2008 100644 --- a/x-pack/plugins/ml/public/application/components/annotations/annotation_description_list/index.test.tsx +++ b/x-pack/plugins/ml/public/application/components/annotations/annotation_description_list/index.test.tsx @@ -8,7 +8,7 @@ import mockAnnotations from '../annotations_table/__mocks__/mock_annotations.jso import moment from 'moment-timezone'; import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { AnnotationDescriptionList } from './index'; diff --git a/x-pack/plugins/ml/public/application/components/annotations/annotation_flyout/index.test.tsx b/x-pack/plugins/ml/public/application/components/annotations/annotation_flyout/index.test.tsx index d71a23f478282..a4d2cd6b091a8 100644 --- a/x-pack/plugins/ml/public/application/components/annotations/annotation_flyout/index.test.tsx +++ b/x-pack/plugins/ml/public/application/components/annotations/annotation_flyout/index.test.tsx @@ -9,7 +9,7 @@ import useObservable from 'react-use/lib/useObservable'; import mockAnnotations from '../annotations_table/__mocks__/mock_annotations.json'; import React from 'react'; -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { Annotation } from '../../../../../common/types/annotations'; import { annotation$ } from '../../../services/annotations_service'; diff --git a/x-pack/plugins/ml/public/application/components/annotations/annotations_table/annotations_table.test.js b/x-pack/plugins/ml/public/application/components/annotations/annotations_table/annotations_table.test.js index b19328f89fbe4..339695eff8ad0 100644 --- a/x-pack/plugins/ml/public/application/components/annotations/annotations_table/annotations_table.test.js +++ b/x-pack/plugins/ml/public/application/components/annotations/annotations_table/annotations_table.test.js @@ -7,7 +7,7 @@ import jobConfig from '../../../../../common/types/__mocks__/job_config_farequote'; import mockAnnotations from './__mocks__/mock_annotations.json'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { AnnotationsTable } from './annotations_table'; diff --git a/x-pack/plugins/ml/public/application/components/anomalies_table/anomaly_details.test.js b/x-pack/plugins/ml/public/application/components/anomalies_table/anomaly_details.test.js index 78c036eac1903..219ca77804113 100644 --- a/x-pack/plugins/ml/public/application/components/anomalies_table/anomaly_details.test.js +++ b/x-pack/plugins/ml/public/application/components/anomalies_table/anomaly_details.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; import { AnomalyDetails } from './anomaly_details'; const props = { diff --git a/x-pack/plugins/ml/public/application/components/entity_cell/entity_cell.test.js b/x-pack/plugins/ml/public/application/components/entity_cell/entity_cell.test.js index 674cdb8b869b0..59f1e1acf9326 100644 --- a/x-pack/plugins/ml/public/application/components/entity_cell/entity_cell.test.js +++ b/x-pack/plugins/ml/public/application/components/entity_cell/entity_cell.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { EntityCell } from './entity_cell'; const defaultProps = { diff --git a/x-pack/plugins/ml/public/application/components/field_title_bar/field_title_bar.test.js b/x-pack/plugins/ml/public/application/components/field_title_bar/field_title_bar.test.js index 329863fdc9986..b467b6bfa3654 100644 --- a/x-pack/plugins/ml/public/application/components/field_title_bar/field_title_bar.test.js +++ b/x-pack/plugins/ml/public/application/components/field_title_bar/field_title_bar.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { FieldTitleBar } from './field_title_bar'; diff --git a/x-pack/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector.test.tsx b/x-pack/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector.test.tsx index bed8deff1ff83..c3a936027d9cc 100644 --- a/x-pack/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector.test.tsx +++ b/x-pack/plugins/ml/public/application/components/full_time_range_selector/full_time_range_selector.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { FullTimeRangeSelector } from './index'; import { Query } from 'src/plugins/data/public'; import { IndexPattern } from '../../../../../../../src/plugins/data/public'; diff --git a/x-pack/plugins/ml/public/application/components/rule_editor/actions_section.test.js b/x-pack/plugins/ml/public/application/components/rule_editor/actions_section.test.js index 692817be1fa89..c02a212d64034 100644 --- a/x-pack/plugins/ml/public/application/components/rule_editor/actions_section.test.js +++ b/x-pack/plugins/ml/public/application/components/rule_editor/actions_section.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ActionsSection } from './actions_section'; diff --git a/x-pack/plugins/ml/public/application/components/rule_editor/components/detector_description_list/detector_description_list.test.js b/x-pack/plugins/ml/public/application/components/rule_editor/components/detector_description_list/detector_description_list.test.js index d873734adce7d..3f2994f690e79 100644 --- a/x-pack/plugins/ml/public/application/components/rule_editor/components/detector_description_list/detector_description_list.test.js +++ b/x-pack/plugins/ml/public/application/components/rule_editor/components/detector_description_list/detector_description_list.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { DetectorDescriptionList } from './detector_description_list'; diff --git a/x-pack/plugins/ml/public/application/components/rule_editor/condition_expression.test.js b/x-pack/plugins/ml/public/application/components/rule_editor/condition_expression.test.js index 79ed620d151f2..3417bd263b4d9 100644 --- a/x-pack/plugins/ml/public/application/components/rule_editor/condition_expression.test.js +++ b/x-pack/plugins/ml/public/application/components/rule_editor/condition_expression.test.js @@ -7,7 +7,7 @@ // Mock the mlJobService that is imported for saving rules. jest.mock('../../services/job_service.js', () => 'mlJobService'); -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ConditionExpression } from './condition_expression'; diff --git a/x-pack/plugins/ml/public/application/components/rule_editor/conditions_section.test.js b/x-pack/plugins/ml/public/application/components/rule_editor/conditions_section.test.js index 5fdfff79e694f..c330e3827465d 100644 --- a/x-pack/plugins/ml/public/application/components/rule_editor/conditions_section.test.js +++ b/x-pack/plugins/ml/public/application/components/rule_editor/conditions_section.test.js @@ -7,7 +7,7 @@ // Mock the mlJobService that is imported for saving rules. jest.mock('../../services/job_service.js', () => 'mlJobService'); -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ConditionsSection } from './conditions_section'; diff --git a/x-pack/plugins/ml/public/application/components/rule_editor/rule_editor_flyout.test.js b/x-pack/plugins/ml/public/application/components/rule_editor/rule_editor_flyout.test.js index 79080ef0f9bb6..b5c4abc5efd7c 100644 --- a/x-pack/plugins/ml/public/application/components/rule_editor/rule_editor_flyout.test.js +++ b/x-pack/plugins/ml/public/application/components/rule_editor/rule_editor_flyout.test.js @@ -55,7 +55,7 @@ jest.mock('../../../../../../../src/plugins/kibana_react/public', () => ({ }, })); -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { RuleEditorFlyout } from './rule_editor_flyout'; diff --git a/x-pack/plugins/ml/public/application/components/rule_editor/scope_expression.test.js b/x-pack/plugins/ml/public/application/components/rule_editor/scope_expression.test.js index d671492d566ad..db59020630043 100644 --- a/x-pack/plugins/ml/public/application/components/rule_editor/scope_expression.test.js +++ b/x-pack/plugins/ml/public/application/components/rule_editor/scope_expression.test.js @@ -7,7 +7,7 @@ // Mock the mlJobService that is imported for saving rules. jest.mock('../../services/job_service.js', () => 'mlJobService'); -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ScopeExpression } from './scope_expression'; diff --git a/x-pack/plugins/ml/public/application/components/rule_editor/scope_section.test.js b/x-pack/plugins/ml/public/application/components/rule_editor/scope_section.test.js index 839dcee870983..7aeb9366eacf6 100644 --- a/x-pack/plugins/ml/public/application/components/rule_editor/scope_section.test.js +++ b/x-pack/plugins/ml/public/application/components/rule_editor/scope_section.test.js @@ -15,7 +15,7 @@ jest.mock('../../capabilities/check_capabilities', () => ({ checkPermission: (privilege) => mockCheckPermission(privilege), })); -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ScopeSection } from './scope_section'; diff --git a/x-pack/plugins/ml/public/application/components/rule_editor/select_rule_action/add_to_filter_list_link.test.js b/x-pack/plugins/ml/public/application/components/rule_editor/select_rule_action/add_to_filter_list_link.test.js index 717ebd71d9c62..63e38f947742a 100644 --- a/x-pack/plugins/ml/public/application/components/rule_editor/select_rule_action/add_to_filter_list_link.test.js +++ b/x-pack/plugins/ml/public/application/components/rule_editor/select_rule_action/add_to_filter_list_link.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { AddToFilterListLink } from './add_to_filter_list_link'; diff --git a/x-pack/plugins/ml/public/application/components/rule_editor/select_rule_action/delete_rule_modal.test.js b/x-pack/plugins/ml/public/application/components/rule_editor/select_rule_action/delete_rule_modal.test.js index 4774539a1881c..91aaee09bc7ae 100644 --- a/x-pack/plugins/ml/public/application/components/rule_editor/select_rule_action/delete_rule_modal.test.js +++ b/x-pack/plugins/ml/public/application/components/rule_editor/select_rule_action/delete_rule_modal.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { DeleteRuleModal } from './delete_rule_modal'; diff --git a/x-pack/plugins/ml/public/application/components/rule_editor/select_rule_action/edit_condition_link.test.js b/x-pack/plugins/ml/public/application/components/rule_editor/select_rule_action/edit_condition_link.test.js index 5d8916cf22a12..3a2e75d13a5db 100644 --- a/x-pack/plugins/ml/public/application/components/rule_editor/select_rule_action/edit_condition_link.test.js +++ b/x-pack/plugins/ml/public/application/components/rule_editor/select_rule_action/edit_condition_link.test.js @@ -6,7 +6,7 @@ jest.mock('../../../services/job_service.js', () => 'mlJobService'); -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { EditConditionLink } from './edit_condition_link'; diff --git a/x-pack/plugins/ml/public/application/components/rule_editor/select_rule_action/rule_action_panel.test.js b/x-pack/plugins/ml/public/application/components/rule_editor/select_rule_action/rule_action_panel.test.js index 1fbf44d55c025..aaa74454085d2 100644 --- a/x-pack/plugins/ml/public/application/components/rule_editor/select_rule_action/rule_action_panel.test.js +++ b/x-pack/plugins/ml/public/application/components/rule_editor/select_rule_action/rule_action_panel.test.js @@ -28,7 +28,7 @@ jest.mock('../../../services/ml_api_service', () => ({ }, })); -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { RuleActionPanel } from './rule_action_panel'; diff --git a/x-pack/plugins/ml/public/application/components/validate_job/validate_job_view.test.js b/x-pack/plugins/ml/public/application/components/validate_job/validate_job_view.test.js index 280dbd76d5487..f2f785d91dcac 100644 --- a/x-pack/plugins/ml/public/application/components/validate_job/validate_job_view.test.js +++ b/x-pack/plugins/ml/public/application/components/validate_job/validate_job_view.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ValidateJob } from './validate_job_view'; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/use_create_analytics_form.test.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/use_create_analytics_form.test.tsx index f833cf4708cec..96d6c5ff4837d 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/use_create_analytics_form.test.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/use_create_analytics_form.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { mountHook } from 'test_utils/enzyme_helpers'; +import { mountHook } from '@kbn/test/jest'; import { MlContext } from '../../../../../contexts/ml'; import { kibanaContextValueMock } from '../../../../../contexts/ml/__mocks__/kibana_context_value'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/overrides.test.js b/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/overrides.test.js index 1a2bc20a5192a..05ebf601b5979 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/overrides.test.js +++ b/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/edit_flyout/overrides.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { Overrides } from './overrides'; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_card/content_types/date_content.tsx b/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_card/content_types/date_content.tsx index 76d05539c0c82..61addb4689f4e 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_card/content_types/date_content.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_card/content_types/date_content.tsx @@ -25,7 +25,7 @@ export const DateContent: FC = ({ config }) => { return (
- +   = ({ config }) => { -
+
= ({ config }) => { -
+
= ({ config }) => { return (
- +   = ({ config }) => {
- +   = ({ config }) => { return (
- +   = ({ config }) => {
- +   = ({ config }) => { - + - + - + @@ -145,14 +147,14 @@ export const NumberContent: FC = ({ config }) => { setDetailsMode(optionId as DETAILS_MODE)} + onChange={(optionId) => setDetailsMode(optionId as DetailsModeType)} legend={i18n.translate( 'xpack.ml.fieldDataCard.cardNumber.selectMetricDetailsDisplayAriaLabel', { defaultMessage: 'Select display option for metric details', } )} - data-test-subj="mlFieldDataCardNumberDetailsSelect" + data-test-subj="mlFieldDataCardDetailsSelect" isFullWidth={true} buttonSize="compressed" /> diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_card/document_count_chart/document_count_chart.tsx b/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_card/document_count_chart/document_count_chart.tsx index a2cc59bb38939..7e2671884b101 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_card/document_count_chart/document_count_chart.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_card/document_count_chart/document_count_chart.tsx @@ -61,7 +61,7 @@ export const DocumentCountChart: FC = ({ const EVENT_RATE_COLOR = themeName.euiColorVis2; return ( -
+
= ({ examples }) => { }); return ( -
+
= ({ config }) => { hasShadow={false} > -
+
{loading === true ? : getCardContent()}
diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_card/metric_distribution_chart/metric_distribution_chart.tsx b/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_card/metric_distribution_chart/metric_distribution_chart.tsx index 4189308a3bc99..9ff6e99dbc5c2 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_card/metric_distribution_chart/metric_distribution_chart.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/field_data_card/metric_distribution_chart/metric_distribution_chart.tsx @@ -72,7 +72,7 @@ export const MetricDistributionChart: FC = ({ width, height, chartData, f }; return ( -
+
= ({ stats, fieldFormat, barColor }) => { const progressBarMax = isTopValuesSampled === true ? topValuesSampleSize : count; return ( - +
{topValues.map((value: any) => ( @@ -55,7 +55,7 @@ export const TopValues: FC = ({ stats, fieldFormat, barColor }) => { - + @@ -79,6 +79,6 @@ export const TopValues: FC = ({ stats, fieldFormat, barColor }) => { )} - +
); }; diff --git a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/search_panel.tsx b/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/search_panel.tsx index b93ae9e67ef72..9e14e4044a297 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/search_panel.tsx +++ b/x-pack/plugins/ml/public/application/datavisualizer/index_based/components/search_panel/search_panel.tsx @@ -48,16 +48,20 @@ const searchSizeOptions = [1000, 5000, 10000, 100000, -1].map((v) => { value: String(v), inputDisplay: v > 0 ? ( - {v} }} - /> + + {v} }} + /> + ) : ( - + + + ), }; }); @@ -174,10 +178,18 @@ export const SearchPanel: FC = ({ {totalCount}, + strongTotalCount: ( + + + + ), }} /> diff --git a/x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_chart_distribution.test.js b/x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_chart_distribution.test.js index 53aca826f2dda..1b1098576fb21 100644 --- a/x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_chart_distribution.test.js +++ b/x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_chart_distribution.test.js @@ -24,7 +24,7 @@ jest.mock('../../services/field_format_service', () => ({ }, })); -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ExplorerChartDistribution } from './explorer_chart_distribution'; diff --git a/x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_chart_info_tooltip.test.js b/x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_chart_info_tooltip.test.js index 632c5a1006df5..afc4162cdc0a6 100644 --- a/x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_chart_info_tooltip.test.js +++ b/x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_chart_info_tooltip.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ExplorerChartInfoTooltip } from './explorer_chart_info_tooltip'; diff --git a/x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_chart_single_metric.test.js b/x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_chart_single_metric.test.js index a1e9a9b4760dd..f9060a5f8a14e 100644 --- a/x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_chart_single_metric.test.js +++ b/x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_chart_single_metric.test.js @@ -24,7 +24,7 @@ jest.mock('../../services/field_format_service', () => ({ }, })); -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ExplorerChartSingleMetric } from './explorer_chart_single_metric'; diff --git a/x-pack/plugins/ml/public/application/settings/calendars/edit/calendar_form/calendar_form.test.js b/x-pack/plugins/ml/public/application/settings/calendars/edit/calendar_form/calendar_form.test.js index 54a6cdfea7b4f..b72cfc5995ca5 100644 --- a/x-pack/plugins/ml/public/application/settings/calendars/edit/calendar_form/calendar_form.test.js +++ b/x-pack/plugins/ml/public/application/settings/calendars/edit/calendar_form/calendar_form.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { CalendarForm } from './calendar_form'; diff --git a/x-pack/plugins/ml/public/application/settings/calendars/edit/events_table/events_table.test.js b/x-pack/plugins/ml/public/application/settings/calendars/edit/events_table/events_table.test.js index 8336a2d286639..d0564fc5a5b2a 100644 --- a/x-pack/plugins/ml/public/application/settings/calendars/edit/events_table/events_table.test.js +++ b/x-pack/plugins/ml/public/application/settings/calendars/edit/events_table/events_table.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { EventsTable } from './events_table'; diff --git a/x-pack/plugins/ml/public/application/settings/calendars/edit/import_modal/import_modal.test.js b/x-pack/plugins/ml/public/application/settings/calendars/edit/import_modal/import_modal.test.js index 2faac7d850fa9..725486888f84b 100644 --- a/x-pack/plugins/ml/public/application/settings/calendars/edit/import_modal/import_modal.test.js +++ b/x-pack/plugins/ml/public/application/settings/calendars/edit/import_modal/import_modal.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ImportModal } from './import_modal'; diff --git a/x-pack/plugins/ml/public/application/settings/calendars/edit/imported_events/imported_events.test.js b/x-pack/plugins/ml/public/application/settings/calendars/edit/imported_events/imported_events.test.js index c41ed3d17a56a..b10b9b84f39cd 100644 --- a/x-pack/plugins/ml/public/application/settings/calendars/edit/imported_events/imported_events.test.js +++ b/x-pack/plugins/ml/public/application/settings/calendars/edit/imported_events/imported_events.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ImportedEvents } from './imported_events'; diff --git a/x-pack/plugins/ml/public/application/settings/calendars/edit/new_calendar.test.js b/x-pack/plugins/ml/public/application/settings/calendars/edit/new_calendar.test.js index 068d443300088..c03a5d73125d3 100644 --- a/x-pack/plugins/ml/public/application/settings/calendars/edit/new_calendar.test.js +++ b/x-pack/plugins/ml/public/application/settings/calendars/edit/new_calendar.test.js @@ -57,7 +57,7 @@ jest.mock('../../../../../../../../src/plugins/kibana_react/public', () => ({ }, })); -import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { NewCalendar } from './new_calendar'; diff --git a/x-pack/plugins/ml/public/application/settings/calendars/edit/new_event_modal/new_event_modal.test.js b/x-pack/plugins/ml/public/application/settings/calendars/edit/new_event_modal/new_event_modal.test.js index f8b9c97db09e3..80d392f027813 100644 --- a/x-pack/plugins/ml/public/application/settings/calendars/edit/new_event_modal/new_event_modal.test.js +++ b/x-pack/plugins/ml/public/application/settings/calendars/edit/new_event_modal/new_event_modal.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { NewEventModal } from './new_event_modal'; import moment from 'moment'; diff --git a/x-pack/plugins/ml/public/application/settings/calendars/list/calendars_list.test.js b/x-pack/plugins/ml/public/application/settings/calendars/list/calendars_list.test.js index 619478db54441..ff294645deeb6 100644 --- a/x-pack/plugins/ml/public/application/settings/calendars/list/calendars_list.test.js +++ b/x-pack/plugins/ml/public/application/settings/calendars/list/calendars_list.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { ml } from '../../../services/ml_api_service'; import { CalendarsList } from './calendars_list'; diff --git a/x-pack/plugins/ml/public/application/settings/calendars/list/header.test.js b/x-pack/plugins/ml/public/application/settings/calendars/list/header.test.js index 857d2e7e6659b..3b674f3a71959 100644 --- a/x-pack/plugins/ml/public/application/settings/calendars/list/header.test.js +++ b/x-pack/plugins/ml/public/application/settings/calendars/list/header.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { CalendarsListHeader } from './header'; diff --git a/x-pack/plugins/ml/public/application/settings/calendars/list/table/table.test.js b/x-pack/plugins/ml/public/application/settings/calendars/list/table/table.test.js index f2c6a619adde5..6fcb25f28bed8 100644 --- a/x-pack/plugins/ml/public/application/settings/calendars/list/table/table.test.js +++ b/x-pack/plugins/ml/public/application/settings/calendars/list/table/table.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { CalendarsListTable } from './table'; diff --git a/x-pack/plugins/ml/public/application/settings/filter_lists/components/add_item_popover/add_item_popover.test.js b/x-pack/plugins/ml/public/application/settings/filter_lists/components/add_item_popover/add_item_popover.test.js index 1641a1d4ba7bb..97ab683e29708 100644 --- a/x-pack/plugins/ml/public/application/settings/filter_lists/components/add_item_popover/add_item_popover.test.js +++ b/x-pack/plugins/ml/public/application/settings/filter_lists/components/add_item_popover/add_item_popover.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { AddItemPopover } from './add_item_popover'; diff --git a/x-pack/plugins/ml/public/application/settings/filter_lists/components/delete_filter_list_modal/delete_filter_list_modal.test.js b/x-pack/plugins/ml/public/application/settings/filter_lists/components/delete_filter_list_modal/delete_filter_list_modal.test.js index bb909ddc3aa78..4cc38c530ae39 100644 --- a/x-pack/plugins/ml/public/application/settings/filter_lists/components/delete_filter_list_modal/delete_filter_list_modal.test.js +++ b/x-pack/plugins/ml/public/application/settings/filter_lists/components/delete_filter_list_modal/delete_filter_list_modal.test.js @@ -13,7 +13,7 @@ jest.mock('../../../../capabilities/check_capabilities', () => ({ })); jest.mock('../../../../services/ml_api_service', () => 'ml'); -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { DeleteFilterListModal } from './delete_filter_list_modal'; diff --git a/x-pack/plugins/ml/public/application/settings/filter_lists/components/edit_description_popover/edit_description_popover.test.js b/x-pack/plugins/ml/public/application/settings/filter_lists/components/edit_description_popover/edit_description_popover.test.js index f97bfe6682f5e..a137b2367cda7 100644 --- a/x-pack/plugins/ml/public/application/settings/filter_lists/components/edit_description_popover/edit_description_popover.test.js +++ b/x-pack/plugins/ml/public/application/settings/filter_lists/components/edit_description_popover/edit_description_popover.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { EditDescriptionPopover } from './edit_description_popover'; diff --git a/x-pack/plugins/ml/public/application/settings/filter_lists/edit/edit_filter_list.test.js b/x-pack/plugins/ml/public/application/settings/filter_lists/edit/edit_filter_list.test.js index 1223194030e64..148f435a9104f 100644 --- a/x-pack/plugins/ml/public/application/settings/filter_lists/edit/edit_filter_list.test.js +++ b/x-pack/plugins/ml/public/application/settings/filter_lists/edit/edit_filter_list.test.js @@ -42,7 +42,7 @@ jest.mock('../../../../../../../../src/plugins/kibana_react/public', () => ({ }, })); -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { EditFilterList } from './edit_filter_list'; diff --git a/x-pack/plugins/ml/public/application/settings/filter_lists/edit/header.test.js b/x-pack/plugins/ml/public/application/settings/filter_lists/edit/header.test.js index b23b1eedf172a..ba10deedd02ac 100644 --- a/x-pack/plugins/ml/public/application/settings/filter_lists/edit/header.test.js +++ b/x-pack/plugins/ml/public/application/settings/filter_lists/edit/header.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { EditFilterListHeader } from './header'; diff --git a/x-pack/plugins/ml/public/application/settings/filter_lists/edit/toolbar.test.js b/x-pack/plugins/ml/public/application/settings/filter_lists/edit/toolbar.test.js index 143cfbf100421..d7c13392b32c9 100644 --- a/x-pack/plugins/ml/public/application/settings/filter_lists/edit/toolbar.test.js +++ b/x-pack/plugins/ml/public/application/settings/filter_lists/edit/toolbar.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { EditFilterListToolbar } from './toolbar'; diff --git a/x-pack/plugins/ml/public/application/settings/filter_lists/list/filter_lists.test.js b/x-pack/plugins/ml/public/application/settings/filter_lists/list/filter_lists.test.js index 6ddea7a3281d3..1f290f807ab45 100644 --- a/x-pack/plugins/ml/public/application/settings/filter_lists/list/filter_lists.test.js +++ b/x-pack/plugins/ml/public/application/settings/filter_lists/list/filter_lists.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { FilterLists } from './filter_lists'; diff --git a/x-pack/plugins/ml/public/application/settings/filter_lists/list/header.test.js b/x-pack/plugins/ml/public/application/settings/filter_lists/list/header.test.js index a21b70f563680..908991606df4e 100644 --- a/x-pack/plugins/ml/public/application/settings/filter_lists/list/header.test.js +++ b/x-pack/plugins/ml/public/application/settings/filter_lists/list/header.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { FilterListsHeader } from './header'; diff --git a/x-pack/plugins/ml/public/application/settings/filter_lists/list/table.test.js b/x-pack/plugins/ml/public/application/settings/filter_lists/list/table.test.js index 29b1185ddd4ab..e54dd3e88f19c 100644 --- a/x-pack/plugins/ml/public/application/settings/filter_lists/list/table.test.js +++ b/x-pack/plugins/ml/public/application/settings/filter_lists/list/table.test.js @@ -11,7 +11,7 @@ jest.mock('../../../capabilities/check_capabilities', () => ({ })); jest.mock('../../../services/ml_api_service', () => 'ml'); -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { FilterListsTable } from './table'; diff --git a/x-pack/plugins/ml/public/application/settings/settings.test.tsx b/x-pack/plugins/ml/public/application/settings/settings.test.tsx index a5e69f233e2df..1ef216560604b 100644 --- a/x-pack/plugins/ml/public/application/settings/settings.test.tsx +++ b/x-pack/plugins/ml/public/application/settings/settings.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { AnomalyDetectionSettingsContext } from './anomaly_detection_settings_context'; diff --git a/x-pack/plugins/ml/public/application/timeseriesexplorer/components/timeseries_chart/timeseries_chart.test.js b/x-pack/plugins/ml/public/application/timeseriesexplorer/components/timeseries_chart/timeseries_chart.test.js index 2a0fcd57467bd..2140eea27d265 100644 --- a/x-pack/plugins/ml/public/application/timeseriesexplorer/components/timeseries_chart/timeseries_chart.test.js +++ b/x-pack/plugins/ml/public/application/timeseriesexplorer/components/timeseries_chart/timeseries_chart.test.js @@ -7,7 +7,7 @@ //import mockOverallSwimlaneData from './__mocks__/mock_overall_swimlane.json'; import moment from 'moment-timezone'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { TimeseriesChart } from './timeseries_chart'; diff --git a/x-pack/plugins/monitoring/public/components/cluster/overview/__tests__/helpers.test.js b/x-pack/plugins/monitoring/public/components/cluster/overview/__tests__/helpers.test.js index e09c42bc59429..a4d7e7527024d 100644 --- a/x-pack/plugins/monitoring/public/components/cluster/overview/__tests__/helpers.test.js +++ b/x-pack/plugins/monitoring/public/components/cluster/overview/__tests__/helpers.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { renderWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl } from '@kbn/test/jest'; import { BytesUsage, BytesPercentageUsage } from '../helpers'; describe('Bytes Usage', () => { diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/__tests__/cells.test.js b/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/__tests__/cells.test.js index f0b131b65433c..67773a6745f96 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/__tests__/cells.test.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/__tests__/cells.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { renderWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl } from '@kbn/test/jest'; import { MetricCell } from '../cells'; describe('Node Listing Metric Cell', () => { diff --git a/x-pack/plugins/monitoring/public/components/no_data/__tests__/checker_errors.test.js b/x-pack/plugins/monitoring/public/components/no_data/__tests__/checker_errors.test.js index 22700bf3fb5a8..b3dd093022a2b 100644 --- a/x-pack/plugins/monitoring/public/components/no_data/__tests__/checker_errors.test.js +++ b/x-pack/plugins/monitoring/public/components/no_data/__tests__/checker_errors.test.js @@ -6,7 +6,7 @@ import React from 'react'; import { boomify, forbidden } from '@hapi/boom'; -import { renderWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl } from '@kbn/test/jest'; import { CheckerErrors } from '../checker_errors'; describe('CheckerErrors', () => { diff --git a/x-pack/plugins/monitoring/public/components/no_data/__tests__/no_data.test.js b/x-pack/plugins/monitoring/public/components/no_data/__tests__/no_data.test.js index 5b54df3a82812..f692c7ee919dc 100644 --- a/x-pack/plugins/monitoring/public/components/no_data/__tests__/no_data.test.js +++ b/x-pack/plugins/monitoring/public/components/no_data/__tests__/no_data.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { renderWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl } from '@kbn/test/jest'; import { NoData } from '../'; const enabler = {}; diff --git a/x-pack/plugins/monitoring/public/components/no_data/explanations/collection_enabled/__tests__/collection_enabled.test.js b/x-pack/plugins/monitoring/public/components/no_data/explanations/collection_enabled/__tests__/collection_enabled.test.js index 13a49b1c7b200..6dd1ac185f901 100644 --- a/x-pack/plugins/monitoring/public/components/no_data/explanations/collection_enabled/__tests__/collection_enabled.test.js +++ b/x-pack/plugins/monitoring/public/components/no_data/explanations/collection_enabled/__tests__/collection_enabled.test.js @@ -6,7 +6,7 @@ import React from 'react'; import sinon from 'sinon'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { ExplainCollectionEnabled } from '../collection_enabled'; import { findTestSubject } from '@elastic/eui/lib/test'; diff --git a/x-pack/plugins/monitoring/public/components/no_data/explanations/collection_interval/__tests__/collection_interval.test.js b/x-pack/plugins/monitoring/public/components/no_data/explanations/collection_interval/__tests__/collection_interval.test.js index 88185283b6faa..6e8dde4056e8d 100644 --- a/x-pack/plugins/monitoring/public/components/no_data/explanations/collection_interval/__tests__/collection_interval.test.js +++ b/x-pack/plugins/monitoring/public/components/no_data/explanations/collection_interval/__tests__/collection_interval.test.js @@ -6,7 +6,7 @@ import React from 'react'; import sinon from 'sinon'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { ExplainCollectionInterval } from '../collection_interval'; import { findTestSubject } from '@elastic/eui/lib/test'; diff --git a/x-pack/plugins/monitoring/public/components/no_data/explanations/exporters/__tests__/exporters.test.js b/x-pack/plugins/monitoring/public/components/no_data/explanations/exporters/__tests__/exporters.test.js index 44b97bc807ce9..ea41cf1b81cd5 100644 --- a/x-pack/plugins/monitoring/public/components/no_data/explanations/exporters/__tests__/exporters.test.js +++ b/x-pack/plugins/monitoring/public/components/no_data/explanations/exporters/__tests__/exporters.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { renderWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl } from '@kbn/test/jest'; import { ExplainExporters, ExplainExportersCloud } from '../exporters'; describe('ExplainExporters', () => { diff --git a/x-pack/plugins/monitoring/public/components/no_data/explanations/plugin_enabled/__tests__/plugin_enabled.test.js b/x-pack/plugins/monitoring/public/components/no_data/explanations/plugin_enabled/__tests__/plugin_enabled.test.js index 031c4baa0a424..2f101f44f014a 100644 --- a/x-pack/plugins/monitoring/public/components/no_data/explanations/plugin_enabled/__tests__/plugin_enabled.test.js +++ b/x-pack/plugins/monitoring/public/components/no_data/explanations/plugin_enabled/__tests__/plugin_enabled.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { renderWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl } from '@kbn/test/jest'; import { ExplainPluginEnabled } from '../plugin_enabled'; describe('ExplainPluginEnabled', () => { diff --git a/x-pack/plugins/monitoring/public/components/no_data/reasons/__tests__/reason_found.test.js b/x-pack/plugins/monitoring/public/components/no_data/reasons/__tests__/reason_found.test.js index a5f9691880b2c..f30799ebd4f73 100644 --- a/x-pack/plugins/monitoring/public/components/no_data/reasons/__tests__/reason_found.test.js +++ b/x-pack/plugins/monitoring/public/components/no_data/reasons/__tests__/reason_found.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { renderWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl } from '@kbn/test/jest'; import { ReasonFound } from '../'; const enabler = {}; diff --git a/x-pack/plugins/monitoring/public/components/no_data/reasons/__tests__/we_tried.test.js b/x-pack/plugins/monitoring/public/components/no_data/reasons/__tests__/we_tried.test.js index 95970453d4b7c..57cee4baeb8bf 100644 --- a/x-pack/plugins/monitoring/public/components/no_data/reasons/__tests__/we_tried.test.js +++ b/x-pack/plugins/monitoring/public/components/no_data/reasons/__tests__/we_tried.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { renderWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl } from '@kbn/test/jest'; import { WeTried } from '../'; describe('WeTried', () => { diff --git a/x-pack/plugins/monitoring/public/components/page_loading/__tests__/page_loading.test.js b/x-pack/plugins/monitoring/public/components/page_loading/__tests__/page_loading.test.js index 41f3ef4be969e..bbe6afce193d5 100644 --- a/x-pack/plugins/monitoring/public/components/page_loading/__tests__/page_loading.test.js +++ b/x-pack/plugins/monitoring/public/components/page_loading/__tests__/page_loading.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { renderWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl } from '@kbn/test/jest'; import { PageLoading } from '../'; describe('PageLoading', () => { diff --git a/x-pack/plugins/monitoring/public/components/summary_status/summary_status.test.js b/x-pack/plugins/monitoring/public/components/summary_status/summary_status.test.js index 5f4dced47ee6f..b3930e6e3e47b 100644 --- a/x-pack/plugins/monitoring/public/components/summary_status/summary_status.test.js +++ b/x-pack/plugins/monitoring/public/components/summary_status/summary_status.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { renderWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl } from '@kbn/test/jest'; import { SummaryStatus } from './summary_status'; jest.mock(`@elastic/eui/lib/components/form/form_row/make_id`, () => () => `generated-id`); diff --git a/x-pack/plugins/monitoring/public/lib/logstash/pipelines.js b/x-pack/plugins/monitoring/public/lib/logstash/pipelines.js index a93cb28e07745..8f0175386526a 100644 --- a/x-pack/plugins/monitoring/public/lib/logstash/pipelines.js +++ b/x-pack/plugins/monitoring/public/lib/logstash/pipelines.js @@ -4,10 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ -import semver from 'semver'; +import semverMajor from 'semver/functions/major'; import { LOGSTASH } from '../../../common/constants'; export function isPipelineMonitoringSupportedInVersion(logstashVersion) { - const major = semver.major(logstashVersion); + const major = semverMajor(logstashVersion); return major >= LOGSTASH.MAJOR_VER_REQD_FOR_PIPELINES; } diff --git a/x-pack/plugins/observability/public/components/app/header/index.tsx b/x-pack/plugins/observability/public/components/app/header/index.tsx index 5884fef36b46d..b195bb52e7ed2 100644 --- a/x-pack/plugins/observability/public/components/app/header/index.tsx +++ b/x-pack/plugins/observability/public/components/app/header/index.tsx @@ -65,7 +65,7 @@ export function Header({ color, datePicker = null, restrictWidth }: Props) { - +

{i18n.translate('xpack.observability.home.title', { defaultMessage: 'Observability', diff --git a/x-pack/plugins/remote_clusters/__jest__/client_integration/add/remote_clusters_add.helpers.js b/x-pack/plugins/remote_clusters/__jest__/client_integration/add/remote_clusters_add.helpers.js index f420e83adc031..f01e01224f1f1 100644 --- a/x-pack/plugins/remote_clusters/__jest__/client_integration/add/remote_clusters_add.helpers.js +++ b/x-pack/plugins/remote_clusters/__jest__/client_integration/add/remote_clusters_add.helpers.js @@ -5,7 +5,7 @@ */ import { act } from 'react-dom/test-utils'; -import { registerTestBed } from '../../../../../test_utils'; +import { registerTestBed } from '@kbn/test/jest'; import { RemoteClusterAdd } from '../../../public/application/sections/remote_cluster_add'; import { createRemoteClustersStore } from '../../../public/application/store'; diff --git a/x-pack/plugins/remote_clusters/__jest__/client_integration/edit/remote_clusters_edit.helpers.js b/x-pack/plugins/remote_clusters/__jest__/client_integration/edit/remote_clusters_edit.helpers.js index 331ef24d1d8a1..fc6fa7edda927 100644 --- a/x-pack/plugins/remote_clusters/__jest__/client_integration/edit/remote_clusters_edit.helpers.js +++ b/x-pack/plugins/remote_clusters/__jest__/client_integration/edit/remote_clusters_edit.helpers.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../test_utils'; +import { registerTestBed } from '@kbn/test/jest'; import { RemoteClusterEdit } from '../../../public/application/sections/remote_cluster_edit'; import { createRemoteClustersStore } from '../../../public/application/store'; diff --git a/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/index.js b/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/index.js index 6ef0e10b6ae15..ddf7c1a61299f 100644 --- a/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/index.js +++ b/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/index.js @@ -4,5 +4,5 @@ * you may not use this file except in compliance with the Elastic License. */ -export { nextTick, getRandomString, findTestSubject } from '../../../../../test_utils'; +export { nextTick, getRandomString, findTestSubject } from '@kbn/test/jest'; export { setupEnvironment } from './setup_environment'; diff --git a/x-pack/plugins/remote_clusters/__jest__/client_integration/list/remote_clusters_list.helpers.js b/x-pack/plugins/remote_clusters/__jest__/client_integration/list/remote_clusters_list.helpers.js index 5f34728def3d3..83a0f634ab55a 100644 --- a/x-pack/plugins/remote_clusters/__jest__/client_integration/list/remote_clusters_list.helpers.js +++ b/x-pack/plugins/remote_clusters/__jest__/client_integration/list/remote_clusters_list.helpers.js @@ -5,7 +5,7 @@ */ import { act } from 'react-dom/test-utils'; -import { registerTestBed, findTestSubject } from '../../../../../test_utils'; +import { registerTestBed, findTestSubject } from '@kbn/test/jest'; import { RemoteClusterList } from '../../../public/application/sections/remote_cluster_list'; import { createRemoteClustersStore } from '../../../public/application/store'; diff --git a/x-pack/plugins/remote_clusters/fixtures/remote_cluster.js b/x-pack/plugins/remote_clusters/fixtures/remote_cluster.js index 6a3bcba21d772..d063a53c3c374 100644 --- a/x-pack/plugins/remote_clusters/fixtures/remote_cluster.js +++ b/x-pack/plugins/remote_clusters/fixtures/remote_cluster.js @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { getRandomString } from '../../../test_utils'; +import { getRandomString } from '@kbn/test/jest'; import { SNIFF_MODE } from '../common/constants'; diff --git a/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/remote_cluster_form.test.js b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/remote_cluster_form.test.js index a5c2b355863af..e02ee1f7e012b 100644 --- a/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/remote_cluster_form.test.js +++ b/x-pack/plugins/remote_clusters/public/application/sections/components/remote_cluster_form/remote_cluster_form.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { mountWithIntl, renderWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, renderWithIntl } from '@kbn/test/jest'; import { findTestSubject, takeMountedSnapshot } from '@elastic/eui/lib/test'; import { RemoteClusterForm } from './remote_cluster_form'; diff --git a/x-pack/plugins/reporting/public/components/buttons/report_info_button.test.tsx b/x-pack/plugins/reporting/public/components/buttons/report_info_button.test.tsx index 028a8e960040a..5de520d2a6386 100644 --- a/x-pack/plugins/reporting/public/components/buttons/report_info_button.test.tsx +++ b/x-pack/plugins/reporting/public/components/buttons/report_info_button.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { ReportInfoButton } from './report_info_button'; jest.mock('../../lib/reporting_api_client'); diff --git a/x-pack/plugins/reporting/public/components/report_listing.test.tsx b/x-pack/plugins/reporting/public/components/report_listing.test.tsx index cacae943687e1..c8e192814f806 100644 --- a/x-pack/plugins/reporting/public/components/report_listing.test.tsx +++ b/x-pack/plugins/reporting/public/components/report_listing.test.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { Observable } from 'rxjs'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { ILicense } from '../../../licensing/public'; import { ReportingAPIClient } from '../lib/reporting_api_client'; diff --git a/x-pack/plugins/rollup/fixtures/job.js b/x-pack/plugins/rollup/fixtures/job.js index edcc99f7cae1b..e9fdae66c003f 100644 --- a/x-pack/plugins/rollup/fixtures/job.js +++ b/x-pack/plugins/rollup/fixtures/job.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getRandomString } from '../../../test_utils'; +import { getRandomString } from '@kbn/test/jest'; const initialValues = { dateHistogramField: 'timestamp', diff --git a/x-pack/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.test.js b/x-pack/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.test.js index 3ac2ee5f5aadb..12c00c0ad6b44 100644 --- a/x-pack/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.test.js +++ b/x-pack/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../../test_utils'; +import { registerTestBed } from '@kbn/test/jest'; import { getJob } from '../../../../../fixtures'; import { rollupJobsStore } from '../../../store'; import { DetailPanel } from './detail_panel'; diff --git a/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_list.test.js b/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_list.test.js index ea70bdb3fbc41..91cd9e573e744 100644 --- a/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_list.test.js +++ b/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_list.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { registerTestBed } from '../../../../../../test_utils'; +import { registerTestBed } from '@kbn/test/jest'; import { rollupJobsStore } from '../../store'; import { JobList } from './job_list'; diff --git a/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.test.js b/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.test.js index 462742bee978f..a7171a8b1960c 100644 --- a/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.test.js +++ b/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.test.js @@ -6,7 +6,7 @@ import { Pager } from '@elastic/eui'; -import { registerTestBed } from '../../../../../../../test_utils'; +import { registerTestBed } from '@kbn/test/jest'; import { getJobs, jobCount } from '../../../../../fixtures'; import { rollupJobsStore } from '../../../store'; import { JobTable } from './job_table'; diff --git a/x-pack/plugins/rollup/public/test/client_integration/helpers/index.js b/x-pack/plugins/rollup/public/test/client_integration/helpers/index.js index 4a5b67e687d85..238e11b65b574 100644 --- a/x-pack/plugins/rollup/public/test/client_integration/helpers/index.js +++ b/x-pack/plugins/rollup/public/test/client_integration/helpers/index.js @@ -8,7 +8,7 @@ import { setup as jobCreateSetup } from './job_create.helpers'; import { setup as jobListSetup } from './job_list.helpers'; import { setup as jobCloneSetup } from './job_clone.helpers'; -export { nextTick, getRandomString, findTestSubject } from '../../../../../../test_utils'; +export { nextTick, getRandomString, findTestSubject } from '@kbn/test/jest'; export { mockHttpRequest } from './setup_environment'; diff --git a/x-pack/plugins/rollup/public/test/client_integration/helpers/job_clone.helpers.js b/x-pack/plugins/rollup/public/test/client_integration/helpers/job_clone.helpers.js index d0abb223a3cfc..5d850cb88bf51 100644 --- a/x-pack/plugins/rollup/public/test/client_integration/helpers/job_clone.helpers.js +++ b/x-pack/plugins/rollup/public/test/client_integration/helpers/job_clone.helpers.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../test_utils'; +import { registerTestBed } from '@kbn/test/jest'; import { createRollupJobsStore } from '../../../crud_app/store'; import { JobCreate } from '../../../crud_app/sections'; import { JOB_TO_CLONE } from './constants'; diff --git a/x-pack/plugins/rollup/public/test/client_integration/helpers/job_create.helpers.js b/x-pack/plugins/rollup/public/test/client_integration/helpers/job_create.helpers.js index b991fe4c45eae..3d26eea32012b 100644 --- a/x-pack/plugins/rollup/public/test/client_integration/helpers/job_create.helpers.js +++ b/x-pack/plugins/rollup/public/test/client_integration/helpers/job_create.helpers.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../test_utils'; +import { registerTestBed } from '@kbn/test/jest'; import { rollupJobsStore } from '../../../crud_app/store'; import { JobCreate } from '../../../crud_app/sections'; diff --git a/x-pack/plugins/rollup/public/test/client_integration/helpers/job_list.helpers.js b/x-pack/plugins/rollup/public/test/client_integration/helpers/job_list.helpers.js index f05b7046de344..3d924ca1838f1 100644 --- a/x-pack/plugins/rollup/public/test/client_integration/helpers/job_list.helpers.js +++ b/x-pack/plugins/rollup/public/test/client_integration/helpers/job_list.helpers.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../test_utils'; +import { registerTestBed } from '@kbn/test/jest'; import { registerRouter } from '../../../crud_app/services'; import { createRollupJobsStore } from '../../../crud_app/store'; import { JobList } from '../../../crud_app/sections/job_list'; diff --git a/x-pack/plugins/searchprofiler/public/application/components/empty_tree_placeholder/empty_tree_placeholder.test.tsx b/x-pack/plugins/searchprofiler/public/application/components/empty_tree_placeholder/empty_tree_placeholder.test.tsx index e945c6a28a46b..49bd4c746dd0f 100644 --- a/x-pack/plugins/searchprofiler/public/application/components/empty_tree_placeholder/empty_tree_placeholder.test.tsx +++ b/x-pack/plugins/searchprofiler/public/application/components/empty_tree_placeholder/empty_tree_placeholder.test.tsx @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../test_utils'; +import { registerTestBed } from '@kbn/test/jest'; import { EmptyTreePlaceHolder } from '.'; describe('EmptyTreePlaceholder', () => { diff --git a/x-pack/plugins/searchprofiler/public/application/components/highlight_details_flyout/highlight_details_flyout.test.tsx b/x-pack/plugins/searchprofiler/public/application/components/highlight_details_flyout/highlight_details_flyout.test.tsx index f539baadd5052..1d273b4dc4289 100644 --- a/x-pack/plugins/searchprofiler/public/application/components/highlight_details_flyout/highlight_details_flyout.test.tsx +++ b/x-pack/plugins/searchprofiler/public/application/components/highlight_details_flyout/highlight_details_flyout.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../test_utils'; +import { registerTestBed } from '@kbn/test/jest'; import { HighlightDetailsFlyout, Props } from '.'; describe('Highlight Details Flyout', () => { diff --git a/x-pack/plugins/searchprofiler/public/application/components/license_warning_notice/license_warning_notice.test.ts b/x-pack/plugins/searchprofiler/public/application/components/license_warning_notice/license_warning_notice.test.ts index 93465d112681f..26837631fbfa9 100644 --- a/x-pack/plugins/searchprofiler/public/application/components/license_warning_notice/license_warning_notice.test.ts +++ b/x-pack/plugins/searchprofiler/public/application/components/license_warning_notice/license_warning_notice.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../test_utils'; +import { registerTestBed } from '@kbn/test/jest'; import { LicenseWarningNotice } from './license_warning_notice'; diff --git a/x-pack/plugins/searchprofiler/public/application/components/profile_loading_placeholder/profile_loading_placeholder.test.tsx b/x-pack/plugins/searchprofiler/public/application/components/profile_loading_placeholder/profile_loading_placeholder.test.tsx index d540bfe0ed98b..1605f3c16e9b0 100644 --- a/x-pack/plugins/searchprofiler/public/application/components/profile_loading_placeholder/profile_loading_placeholder.test.tsx +++ b/x-pack/plugins/searchprofiler/public/application/components/profile_loading_placeholder/profile_loading_placeholder.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../test_utils'; +import { registerTestBed } from '@kbn/test/jest'; import { ProfileLoadingPlaceholder } from '.'; describe('Profile Loading Placeholder', () => { diff --git a/x-pack/plugins/searchprofiler/public/application/components/profile_query_editor/editor/editor.test.tsx b/x-pack/plugins/searchprofiler/public/application/components/profile_query_editor/editor/editor.test.tsx index e0d24c11ca5ed..89d0b885bb20f 100644 --- a/x-pack/plugins/searchprofiler/public/application/components/profile_query_editor/editor/editor.test.tsx +++ b/x-pack/plugins/searchprofiler/public/application/components/profile_query_editor/editor/editor.test.tsx @@ -6,7 +6,7 @@ import 'brace'; import 'brace/mode/json'; -import { registerTestBed } from '../../../../../../../test_utils'; +import { registerTestBed } from '@kbn/test/jest'; import { Editor, Props } from './editor'; describe('Editor Component', () => { diff --git a/x-pack/plugins/searchprofiler/public/application/components/profile_tree/__jest__/profile_tree.test.tsx b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/__jest__/profile_tree.test.tsx index 64f77e8b4e52c..a5787a6f3ba38 100644 --- a/x-pack/plugins/searchprofiler/public/application/components/profile_tree/__jest__/profile_tree.test.tsx +++ b/x-pack/plugins/searchprofiler/public/application/components/profile_tree/__jest__/profile_tree.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../../test_utils'; +import { registerTestBed } from '@kbn/test/jest'; import { searchResponse } from './fixtures/search_response'; import { ProfileTree, Props } from '../profile_tree'; diff --git a/x-pack/plugins/searchprofiler/public/application/components/searchprofiler_tabs/searchprofiler_tabs.test.ts b/x-pack/plugins/searchprofiler/public/application/components/searchprofiler_tabs/searchprofiler_tabs.test.ts index 575dbd68f0c97..aff12f7bd18d4 100644 --- a/x-pack/plugins/searchprofiler/public/application/components/searchprofiler_tabs/searchprofiler_tabs.test.ts +++ b/x-pack/plugins/searchprofiler/public/application/components/searchprofiler_tabs/searchprofiler_tabs.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../test_utils'; +import { registerTestBed } from '@kbn/test/jest'; import { SearchProfilerTabs, Props } from './searchprofiler_tabs'; diff --git a/x-pack/plugins/security/public/account_management/account_management_page.test.tsx b/x-pack/plugins/security/public/account_management/account_management_page.test.tsx index b677f6a1fe8bb..19517b0b6f8f8 100644 --- a/x-pack/plugins/security/public/account_management/account_management_page.test.tsx +++ b/x-pack/plugins/security/public/account_management/account_management_page.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; import { act } from '@testing-library/react'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { AuthenticatedUser } from '../../common/model'; import { AccountManagementPage } from './account_management_page'; import { coreMock } from 'src/core/public/mocks'; diff --git a/x-pack/plugins/security/public/authentication/access_agreement/access_agreement_page.test.tsx b/x-pack/plugins/security/public/authentication/access_agreement/access_agreement_page.test.tsx index 478b1513697a0..dcd53ffed2fe6 100644 --- a/x-pack/plugins/security/public/authentication/access_agreement/access_agreement_page.test.tsx +++ b/x-pack/plugins/security/public/authentication/access_agreement/access_agreement_page.test.tsx @@ -8,8 +8,8 @@ import React from 'react'; import ReactMarkdown from 'react-markdown'; import { EuiLoadingContent } from '@elastic/eui'; import { act } from '@testing-library/react'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { findTestSubject } from '@kbn/test/jest'; import { coreMock } from '../../../../../../src/core/public/mocks'; import { AccessAgreementPage } from './access_agreement_page'; diff --git a/x-pack/plugins/security/public/authentication/components/authentication_state_page/authentication_state_page.test.tsx b/x-pack/plugins/security/public/authentication/components/authentication_state_page/authentication_state_page.test.tsx index 946c58a1c8e99..642b1e67abe52 100644 --- a/x-pack/plugins/security/public/authentication/components/authentication_state_page/authentication_state_page.test.tsx +++ b/x-pack/plugins/security/public/authentication/components/authentication_state_page/authentication_state_page.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { AuthenticationStatePage } from './authentication_state_page'; import React from 'react'; diff --git a/x-pack/plugins/security/public/authentication/login/components/login_form/login_form.test.tsx b/x-pack/plugins/security/public/authentication/login/components/login_form/login_form.test.tsx index b6dd06595ae7f..e6d170122751e 100644 --- a/x-pack/plugins/security/public/authentication/login/components/login_form/login_form.test.tsx +++ b/x-pack/plugins/security/public/authentication/login/components/login_form/login_form.test.tsx @@ -8,8 +8,8 @@ import React from 'react'; import ReactMarkdown from 'react-markdown'; import { act } from '@testing-library/react'; import { EuiButton, EuiCallOut, EuiIcon } from '@elastic/eui'; -import { mountWithIntl, nextTick, shallowWithIntl } from 'test_utils/enzyme_helpers'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { mountWithIntl, nextTick, shallowWithIntl } from '@kbn/test/jest'; +import { findTestSubject } from '@kbn/test/jest'; import { LoginForm, PageMode } from './login_form'; import { coreMock } from '../../../../../../../../src/core/public/mocks'; diff --git a/x-pack/plugins/security/public/authentication/login/login_page.test.tsx b/x-pack/plugins/security/public/authentication/login/login_page.test.tsx index 5370c981f2b65..467b2a7ff9906 100644 --- a/x-pack/plugins/security/public/authentication/login/login_page.test.tsx +++ b/x-pack/plugins/security/public/authentication/login/login_page.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { shallow } from 'enzyme'; import { act } from '@testing-library/react'; -import { nextTick } from 'test_utils/enzyme_helpers'; +import { nextTick } from '@kbn/test/jest'; import { LoginState } from '../../../common/login_state'; import { LoginPage } from './login_page'; import { coreMock } from '../../../../../../src/core/public/mocks'; diff --git a/x-pack/plugins/security/public/authentication/overwritten_session/overwritten_session_page.test.tsx b/x-pack/plugins/security/public/authentication/overwritten_session/overwritten_session_page.test.tsx index 1fc8824eeff3a..4170ec1178c8d 100644 --- a/x-pack/plugins/security/public/authentication/overwritten_session/overwritten_session_page.test.tsx +++ b/x-pack/plugins/security/public/authentication/overwritten_session/overwritten_session_page.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { EuiButton } from '@elastic/eui'; import { act } from '@testing-library/react'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { OverwrittenSessionPage } from './overwritten_session_page'; import { coreMock } from '../../../../../../src/core/public/mocks'; diff --git a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx index 192d554bdc873..c58cb12f03a19 100644 --- a/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx +++ b/x-pack/plugins/security/public/management/api_keys/api_keys_grid/api_keys_grid_page.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ReactWrapper } from 'enzyme'; import { EuiCallOut } from '@elastic/eui'; diff --git a/x-pack/plugins/security/public/management/role_combo_box/role_combo_box.test.tsx b/x-pack/plugins/security/public/management/role_combo_box/role_combo_box.test.tsx index 72fc3a1213521..c5582d3526242 100644 --- a/x-pack/plugins/security/public/management/role_combo_box/role_combo_box.test.tsx +++ b/x-pack/plugins/security/public/management/role_combo_box/role_combo_box.test.tsx @@ -5,11 +5,11 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { RoleComboBox } from '.'; import { EuiComboBox } from '@elastic/eui'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { findTestSubject } from '@kbn/test/jest'; describe('RoleComboBox', () => { it('renders the provided list of roles via EuiComboBox options', () => { diff --git a/x-pack/plugins/security/public/management/role_combo_box/role_combo_box_option.test.tsx b/x-pack/plugins/security/public/management/role_combo_box/role_combo_box_option.test.tsx index c1ac381ba9994..b24a48145b461 100644 --- a/x-pack/plugins/security/public/management/role_combo_box/role_combo_box_option.test.tsx +++ b/x-pack/plugins/security/public/management/role_combo_box/role_combo_box_option.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { RoleComboBoxOption } from './role_combo_box_option'; describe('RoleComboBoxOption', () => { diff --git a/x-pack/plugins/security/public/management/role_mappings/components/delete_provider/delete_provider.test.tsx b/x-pack/plugins/security/public/management/role_mappings/components/delete_provider/delete_provider.test.tsx index 76c02158cc223..2d76b25a450a0 100644 --- a/x-pack/plugins/security/public/management/role_mappings/components/delete_provider/delete_provider.test.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/components/delete_provider/delete_provider.test.tsx @@ -7,8 +7,8 @@ import React from 'react'; import { EuiConfirmModal } from '@elastic/eui'; import { act } from '@testing-library/react'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { findTestSubject } from '@kbn/test/jest'; import { RoleMapping } from '../../../../../common/model'; import { DeleteProvider } from '.'; diff --git a/x-pack/plugins/security/public/management/role_mappings/components/section_loading/section_loading.test.tsx b/x-pack/plugins/security/public/management/role_mappings/components/section_loading/section_loading.test.tsx index 300f6ca0e1f72..89d2e838e8e39 100644 --- a/x-pack/plugins/security/public/management/role_mappings/components/section_loading/section_loading.test.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/components/section_loading/section_loading.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { SectionLoading } from '.'; describe('SectionLoading', () => { diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.test.tsx index aff8ed12bceb6..c7c40cea63e2e 100644 --- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.test.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/edit_role_mapping_page.test.tsx @@ -6,13 +6,13 @@ import React from 'react'; import type { PublicMethodsOf } from '@kbn/utility-types'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { findTestSubject } from '@kbn/test/jest'; // brace/ace uses the Worker class, which is not currently provided by JSDOM. // This is not required for the tests to pass, but it rather suppresses lengthy // warnings in the console which adds unnecessary noise to the test output. -import 'test_utils/stub_web_worker'; +import '@kbn/test/target/jest/utils/stub_web_worker'; import { EditRoleMappingPage } from '.'; import { NoCompatibleRealms, SectionLoading, PermissionDenied } from '../components'; diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/mapping_info_panel/mapping_info_panel.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/mapping_info_panel/mapping_info_panel.test.tsx index aaf223f5a8dcb..dbd034ff3f764 100644 --- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/mapping_info_panel/mapping_info_panel.test.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/mapping_info_panel/mapping_info_panel.test.tsx @@ -6,8 +6,8 @@ import React from 'react'; import type { PublicMethodsOf } from '@kbn/utility-types'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { mountWithIntl } from '@kbn/test/jest'; +import { findTestSubject } from '@kbn/test/jest'; import { Role, RoleMapping } from '../../../../../common/model'; import { RolesAPIClient } from '../../../roles'; import { DocumentationLinksService } from '../../documentation_links'; diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/role_selector/add_role_template_button.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/role_selector/add_role_template_button.test.tsx index 230664f6fc997..19697863451c1 100644 --- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/role_selector/add_role_template_button.test.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/role_selector/add_role_template_button.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; import { AddRoleTemplateButton } from './add_role_template_button'; describe('AddRoleTemplateButton', () => { diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/role_selector/role_selector.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/role_selector/role_selector.test.tsx index 29c5acdb1dda4..34590d2953c7c 100644 --- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/role_selector/role_selector.test.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/role_selector/role_selector.test.tsx @@ -5,8 +5,8 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { mountWithIntl } from '@kbn/test/jest'; +import { findTestSubject } from '@kbn/test/jest'; import { EuiComboBox } from '@elastic/eui'; import type { PublicMethodsOf } from '@kbn/utility-types'; import { RoleSelector } from './role_selector'; diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/role_selector/role_template_editor.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/role_selector/role_template_editor.test.tsx index 6d4af97e12def..3ba998f8ef4ab 100644 --- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/role_selector/role_template_editor.test.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/role_selector/role_template_editor.test.tsx @@ -5,9 +5,9 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { RoleTemplateEditor } from './role_template_editor'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { findTestSubject } from '@kbn/test/jest'; describe('RoleTemplateEditor', () => { it('allows inline templates to be edited', () => { diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/add_rule_button.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/add_rule_button.test.tsx index d1411bd9bf2b9..627abd6782084 100644 --- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/add_rule_button.test.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/add_rule_button.test.tsx @@ -6,8 +6,8 @@ import React from 'react'; import { AddRuleButton } from './add_rule_button'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { mountWithIntl } from '@kbn/test/jest'; +import { findTestSubject } from '@kbn/test/jest'; import { FieldRule, AllRule } from '../../model'; describe('AddRuleButton', () => { diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/field_rule_editor.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/field_rule_editor.test.tsx index 5374f4625336d..84c269decc57a 100644 --- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/field_rule_editor.test.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/field_rule_editor.test.tsx @@ -6,9 +6,9 @@ import React from 'react'; import { FieldRuleEditor } from './field_rule_editor'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { FieldRule } from '../../model'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { findTestSubject } from '@kbn/test/jest'; import { ReactWrapper } from 'enzyme'; function assertField(wrapper: ReactWrapper, index: number, field: string) { diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.test.tsx index c5b3ea433adaa..bae41b31cdcc1 100644 --- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.test.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/json_rule_editor.test.tsx @@ -10,11 +10,11 @@ import 'brace/mode/json'; // brace/ace uses the Worker class, which is not currently provided by JSDOM. // This is not required for the tests to pass, but it rather suppresses lengthy // warnings in the console which adds unnecessary noise to the test output. -import 'test_utils/stub_web_worker'; +import '@kbn/test/target/jest/utils/stub_web_worker'; import React from 'react'; import { act } from 'react-dom/test-utils'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { JSONRuleEditor } from './json_rule_editor'; import { EuiCodeEditor } from '@elastic/eui'; import { AllRule, AnyRule, FieldRule, ExceptAnyRule, ExceptAllRule } from '../../model'; diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.test.tsx index b9c650cc1f77a..ac31900b11a67 100644 --- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.test.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_editor_panel.test.tsx @@ -5,16 +5,16 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, findTestSubject } from '@kbn/test/jest'; import { RuleEditorPanel } from '.'; import { VisualRuleEditor } from './visual_rule_editor'; import { JSONRuleEditor } from './json_rule_editor'; -import { findTestSubject } from 'test_utils/find_test_subject'; // brace/ace uses the Worker class, which is not currently provided by JSDOM. // This is not required for the tests to pass, but it rather suppresses lengthy // warnings in the console which adds unnecessary noise to the test output. -import 'test_utils/stub_web_worker'; +import '@kbn/test/target/jest/utils/stub_web_worker'; + import { AllRule, FieldRule } from '../../model'; import { EuiErrorBoundary } from '@elastic/eui'; import { DocumentationLinksService } from '../../documentation_links'; diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_group_editor.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_group_editor.test.tsx index 48eb1380bd08f..3983702f66ac4 100644 --- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_group_editor.test.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/rule_group_editor.test.tsx @@ -6,12 +6,12 @@ import React from 'react'; import { RuleGroupEditor } from './rule_group_editor'; -import { shallowWithIntl, mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl, mountWithIntl, nextTick } from '@kbn/test/jest'; import { AllRule, FieldRule, AnyRule, ExceptAnyRule } from '../../model'; import { FieldRuleEditor } from './field_rule_editor'; import { AddRuleButton } from './add_rule_button'; import { EuiContextMenuItem } from '@elastic/eui'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { findTestSubject } from '@kbn/test/jest'; describe('RuleGroupEditor', () => { it('renders an empty group', () => { diff --git a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/visual_rule_editor.test.tsx b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/visual_rule_editor.test.tsx index 7ec723853863a..43df5a47045d6 100644 --- a/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/visual_rule_editor.test.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/edit_role_mapping/rule_editor_panel/visual_rule_editor.test.tsx @@ -5,9 +5,9 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { VisualRuleEditor } from './visual_rule_editor'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { findTestSubject } from '@kbn/test/jest'; import { AnyRule, AllRule, FieldRule, ExceptAnyRule, ExceptAllRule } from '../../model'; import { RuleGroupEditor } from './rule_group_editor'; import { FieldRuleEditor } from './field_rule_editor'; diff --git a/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx b/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx index 727d7bf56e9e2..a8001c1b775ea 100644 --- a/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx +++ b/x-pack/plugins/security/public/management/role_mappings/role_mappings_grid/role_mappings_grid_page.test.tsx @@ -6,11 +6,11 @@ import React from 'react'; import { CoreStart, ScopedHistory } from 'kibana/public'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { RoleMappingsGridPage } from '.'; import { SectionLoading, PermissionDenied, NoCompatibleRealms } from '../components'; import { EmptyPrompt } from './empty_prompt'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { findTestSubject } from '@kbn/test/jest'; import { EuiLink } from '@elastic/eui'; import { act } from '@testing-library/react'; import { DocumentationLinksService } from '../documentation_links'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/collapsible_panel/collapsible_panel.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/collapsible_panel/collapsible_panel.test.tsx index b1e23cb43983e..951cf3b022f83 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/collapsible_panel/collapsible_panel.test.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/collapsible_panel/collapsible_panel.test.tsx @@ -6,7 +6,7 @@ import { EuiLink } from '@elastic/eui'; import React from 'react'; -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { CollapsiblePanel } from './collapsible_panel'; test('it renders without blowing up', () => { diff --git a/x-pack/plugins/security/public/management/roles/edit_role/delete_role_button.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/delete_role_button.test.tsx index f4af935be6648..e7809835deac8 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/delete_role_button.test.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/delete_role_button.test.tsx @@ -6,7 +6,7 @@ import { EuiButtonEmpty, EuiConfirmModal } from '@elastic/eui'; import React from 'react'; -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { DeleteRoleButton } from './delete_role_button'; test('it renders without crashing', () => { diff --git a/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.test.tsx index e6daa15fe7e6e..b86fa1f175e96 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.test.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/edit_role_page.test.tsx @@ -7,7 +7,7 @@ import { ReactWrapper } from 'enzyme'; import React from 'react'; import { act } from '@testing-library/react'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { Capabilities } from 'src/core/public'; import { KibanaFeature } from '../../../../../features/public'; import { Role } from '../../../../common/model'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/cluster_privileges.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/cluster_privileges.test.tsx index 6912146b39e39..448fde808603b 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/cluster_privileges.test.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/cluster_privileges.test.tsx @@ -8,7 +8,7 @@ import { shallow } from 'enzyme'; import React from 'react'; import { Role } from '../../../../../../common/model'; import { ClusterPrivileges } from './cluster_privileges'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; test('it renders without crashing', () => { const role: Role = { diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/elasticsearch_privileges.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/elasticsearch_privileges.test.tsx index 7bca221682867..316822f7db024 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/elasticsearch_privileges.test.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/elasticsearch_privileges.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { DocumentationLinksService } from '../../../documentation_links'; import { RoleValidator } from '../../validate_role'; import { ClusterPrivileges } from './cluster_privileges'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/index_privilege_form.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/index_privilege_form.test.tsx index 879cd8e2759ab..889b72d0b65dd 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/index_privilege_form.test.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/index_privilege_form.test.tsx @@ -5,7 +5,7 @@ */ import { EuiButtonIcon, EuiTextArea } from '@elastic/eui'; import React from 'react'; -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { RoleValidator } from '../../validate_role'; import { IndexPrivilegeForm } from './index_privilege_form'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/index_privileges.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/index_privileges.test.tsx index 19f718beed4bf..dc54df84e9b71 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/index_privileges.test.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/index_privileges.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { RoleValidator } from '../../validate_role'; import { IndexPrivilegeForm } from './index_privilege_form'; import { IndexPrivileges } from './index_privileges'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/feature_table/__fixtures__/index.ts b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/feature_table/__fixtures__/index.ts index 7cfa50f6204fb..09e1c0403a403 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/feature_table/__fixtures__/index.ts +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/feature_table/__fixtures__/index.ts @@ -8,7 +8,7 @@ import { ReactWrapper } from 'enzyme'; import { EuiCheckbox, EuiCheckboxProps, EuiButtonGroup, EuiButtonGroupProps } from '@elastic/eui'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { findTestSubject } from '@kbn/test/jest'; import { EuiAccordion } from '@elastic/eui'; import { SubFeatureForm } from '../sub_feature_form'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/feature_table/feature_table.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/feature_table/feature_table.test.tsx index 002b13609005a..1735809152e99 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/feature_table/feature_table.test.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/feature_table/feature_table.test.tsx @@ -6,13 +6,13 @@ import React from 'react'; import { FeatureTable } from './feature_table'; import { Role } from '../../../../../../../common/model'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { KibanaFeature, SubFeatureConfig } from '../../../../../../../../features/public'; import { kibanaFeatures, createFeature } from '../../../../__fixtures__/kibana_features'; import { createKibanaPrivileges } from '../../../../__fixtures__/kibana_privileges'; import { PrivilegeFormCalculator } from '../privilege_form_calculator'; import { getDisplayedFeaturePrivileges } from './__fixtures__'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { findTestSubject } from '@kbn/test/jest'; import { EuiAccordion } from '@elastic/eui'; const createRole = (kibana: Role['kibana'] = []): Role => { diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/feature_table/feature_table_expanded_row.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/feature_table/feature_table_expanded_row.test.tsx index 8897d89a39926..f772e60df1986 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/feature_table/feature_table_expanded_row.test.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/feature_table/feature_table_expanded_row.test.tsx @@ -9,9 +9,9 @@ import { Role } from '../../../../../../../common/model'; import { createKibanaPrivileges } from '../../../../__fixtures__/kibana_privileges'; import { kibanaFeatures } from '../../../../__fixtures__/kibana_features'; import { PrivilegeFormCalculator } from '../privilege_form_calculator'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { FeatureTableExpandedRow } from './feature_table_expanded_row'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { findTestSubject } from '@kbn/test/jest'; import { act } from '@testing-library/react'; const createRole = (kibana: Role['kibana'] = []): Role => { diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/feature_table/sub_feature_form.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/feature_table/sub_feature_form.test.tsx index ced90e24b9c72..eba94338d52d3 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/feature_table/sub_feature_form.test.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/feature_table/sub_feature_form.test.tsx @@ -10,7 +10,7 @@ import { createKibanaPrivileges } from '../../../../__fixtures__/kibana_privileg import { SecuredSubFeature } from '../../../../model'; import { PrivilegeFormCalculator } from '../privilege_form_calculator'; import { Role } from '../../../../../../../common/model'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { SubFeatureForm } from './sub_feature_form'; import { EuiCheckbox, EuiButtonGroup } from '@elastic/eui'; import { act } from '@testing-library/react'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/feature_table_cell/feature_table_cell.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/feature_table_cell/feature_table_cell.test.tsx index 1514677c82457..fd4d8296455a0 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/feature_table_cell/feature_table_cell.test.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/feature_table_cell/feature_table_cell.test.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { createFeature } from '../../../../__fixtures__/kibana_features'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { FeatureTableCell } from '.'; import { SecuredFeature } from '../../../../model'; import { EuiIconTip } from '@elastic/eui'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/__fixtures__/index.ts b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/__fixtures__/index.ts index b920e7b696375..207a91cc3a610 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/__fixtures__/index.ts +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/__fixtures__/index.ts @@ -8,7 +8,7 @@ import { ReactWrapper } from 'enzyme'; import { EuiTableRow } from '@elastic/eui'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { findTestSubject } from '@kbn/test/jest'; import { Role, RoleKibanaPrivilege } from '../../../../../../../../common/model'; import { PrivilegeSummaryExpandedRow } from '../privilege_summary_expanded_row'; import { FeatureTableCell } from '../../feature_table_cell'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary.test.tsx index 85144d37ce754..6c9d9057d396a 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary.test.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary.test.tsx @@ -5,12 +5,12 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { createKibanaPrivileges } from '../../../../__fixtures__/kibana_privileges'; import { kibanaFeatures } from '../../../../__fixtures__/kibana_features'; import { RoleKibanaPrivilege } from '../../../../../../../common/model'; import { PrivilegeSummary } from '.'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { findTestSubject } from '@kbn/test/jest'; import { PrivilegeSummaryTable } from './privilege_summary_table'; const createRole = (roleKibanaPrivileges: RoleKibanaPrivilege[]) => ({ diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary_table.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary_table.test.tsx index 502868a509f91..0750335b0784c 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary_table.test.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/privilege_summary_table.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { createKibanaPrivileges } from '../../../../__fixtures__/kibana_privileges'; import { kibanaFeatures } from '../../../../__fixtures__/kibana_features'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { PrivilegeSummaryTable } from './privilege_summary_table'; import { RoleKibanaPrivilege } from '../../../../../../../common/model'; import { getDisplayedFeaturePrivileges } from './__fixtures__'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/space_column_header.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/space_column_header.test.tsx index 3c9d1789fa5ab..4752f7b3a5a17 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/space_column_header.test.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/privilege_summary/space_column_header.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { SpaceColumnHeader } from './space_column_header'; import { SpacesPopoverList } from '../../../spaces_popover_list'; import { SpaceAvatar } from '../../../../../../../../spaces/public'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/simple_privilege_section/simple_privilege_section.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/simple_privilege_section/simple_privilege_section.test.tsx index 8254e2632aa9d..7f22f1df694ad 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/simple_privilege_section/simple_privilege_section.test.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/simple_privilege_section/simple_privilege_section.test.tsx @@ -6,7 +6,7 @@ import { EuiButtonGroup, EuiButtonGroupProps, EuiComboBox, EuiSuperSelect } from '@elastic/eui'; import React from 'react'; -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { Role } from '../../../../../../../common/model'; import { SimplePrivilegeSection } from './simple_privilege_section'; import { UnsupportedSpacePrivilegesWarning } from './unsupported_space_privileges_warning'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_display.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_display.test.tsx index 155ccf98b9762..35ab151d02670 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_display.test.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_display.test.tsx @@ -6,7 +6,7 @@ import { EuiText } from '@elastic/eui'; import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { PrivilegeDisplay } from './privilege_display'; describe('PrivilegeDisplay', () => { diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_space_form.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_space_form.test.tsx index e4dc0606ebf67..3df4b7224f422 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_space_form.test.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_space_form.test.tsx @@ -7,13 +7,13 @@ import { Role } from '../../../../../../../common/model'; import { createKibanaPrivileges } from '../../../../__fixtures__/kibana_privileges'; import { kibanaFeatures } from '../../../../__fixtures__/kibana_features'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { PrivilegeSpaceForm } from './privilege_space_form'; import React from 'react'; import { Space } from '../../../../../../../../spaces/public'; import { FeatureTable } from '../feature_table'; import { getDisplayedFeaturePrivileges } from '../feature_table/__fixtures__'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { findTestSubject } from '@kbn/test/jest'; import { SpaceSelector } from './space_selector'; import { EuiButtonGroup } from '@elastic/eui'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_space_table.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_space_table.test.tsx index 0242fddc957c9..54caf66c73275 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_space_table.test.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/privilege_space_table.test.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { EuiBadge, EuiInMemoryTable } from '@elastic/eui'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { ReactWrapper } from 'enzyme'; import { PrivilegeSpaceTable } from './privilege_space_table'; import { PrivilegeDisplay } from './privilege_display'; @@ -14,7 +14,7 @@ import { Role, RoleKibanaPrivilege } from '../../../../../../../common/model'; import { createKibanaPrivileges } from '../../../../__fixtures__/kibana_privileges'; import { PrivilegeFormCalculator } from '../privilege_form_calculator'; import { KibanaFeature } from '../../../../../../../../features/public'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { findTestSubject } from '@kbn/test/jest'; interface TableRow { spaces: string[]; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/space_aware_privilege_section.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/space_aware_privilege_section.test.tsx index a9bcb5433fcc7..be5c73b0ba965 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/space_aware_privilege_section.test.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/kibana/space_aware_privilege_section/space_aware_privilege_section.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { RoleValidator } from '../../../validate_role'; import { PrivilegeSpaceForm } from './privilege_space_form'; import { PrivilegeSpaceTable } from './privilege_space_table'; diff --git a/x-pack/plugins/security/public/management/roles/edit_role/spaces_popover_list/spaces_popover_list.test.tsx b/x-pack/plugins/security/public/management/roles/edit_role/spaces_popover_list/spaces_popover_list.test.tsx index 9c68a097a890e..895402c2d9409 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/spaces_popover_list/spaces_popover_list.test.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/spaces_popover_list/spaces_popover_list.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { SpacesPopoverList } from '.'; import { EuiButtonEmpty, diff --git a/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.test.tsx b/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.test.tsx index 1ee621f9ba12d..cfb57f8a8a8d5 100644 --- a/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.test.tsx +++ b/x-pack/plugins/security/public/management/roles/roles_grid/roles_grid_page.test.tsx @@ -8,7 +8,7 @@ import { EuiIcon, EuiBasicTable } from '@elastic/eui'; import type { PublicMethodsOf } from '@kbn/utility-types'; import { ReactWrapper } from 'enzyme'; import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { RolesAPIClient } from '../roles_api_client'; import { PermissionDenied } from './permission_denied'; import { RolesGridPage } from './roles_grid_page'; @@ -16,7 +16,7 @@ import { RolesGridPage } from './roles_grid_page'; import { coreMock, scopedHistoryMock } from '../../../../../../../src/core/public/mocks'; import { rolesAPIClientMock } from '../index.mock'; import { ReservedBadge, DisabledBadge } from '../../badges'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { findTestSubject } from '@kbn/test/jest'; const mock403 = () => ({ body: { statusCode: 403 } }); diff --git a/x-pack/plugins/security/public/management/users/components/change_password_form/change_password_form.test.tsx b/x-pack/plugins/security/public/management/users/components/change_password_form/change_password_form.test.tsx index 43eb32853cf63..a462b185fb9fd 100644 --- a/x-pack/plugins/security/public/management/users/components/change_password_form/change_password_form.test.tsx +++ b/x-pack/plugins/security/public/management/users/components/change_password_form/change_password_form.test.tsx @@ -6,7 +6,7 @@ import { EuiFieldPassword } from '@elastic/eui'; import { ReactWrapper } from 'enzyme'; import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { User } from '../../../../../common/model'; import { ChangePasswordForm } from './change_password_form'; diff --git a/x-pack/plugins/security/public/management/users/components/confirm_delete_users/confirm_delete_users.test.tsx b/x-pack/plugins/security/public/management/users/components/confirm_delete_users/confirm_delete_users.test.tsx index e39a4acdaaff9..cfc9d6ba9b366 100644 --- a/x-pack/plugins/security/public/management/users/components/confirm_delete_users/confirm_delete_users.test.tsx +++ b/x-pack/plugins/security/public/management/users/components/confirm_delete_users/confirm_delete_users.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { ConfirmDeleteUsers } from './confirm_delete_users'; import React from 'react'; diff --git a/x-pack/plugins/security/public/management/users/edit_user/edit_user_page.test.tsx b/x-pack/plugins/security/public/management/users/edit_user/edit_user_page.test.tsx index 40ffc508f086b..5e8c9f2d14a4c 100644 --- a/x-pack/plugins/security/public/management/users/edit_user/edit_user_page.test.tsx +++ b/x-pack/plugins/security/public/management/users/edit_user/edit_user_page.test.tsx @@ -5,7 +5,7 @@ */ import { act } from '@testing-library/react'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { EditUserPage } from './edit_user_page'; import React from 'react'; import { User, Role } from '../../../../common/model'; @@ -15,7 +15,7 @@ import { mockAuthenticatedUser } from '../../../../common/model/authenticated_us import { securityMock } from '../../../mocks'; import { rolesAPIClientMock } from '../../roles/index.mock'; import { userAPIClientMock } from '../index.mock'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { findTestSubject } from '@kbn/test/jest'; const createUser = (username: string, roles = ['idk', 'something']) => { const user: User = { diff --git a/x-pack/plugins/security/public/management/users/users_grid/users_grid_page.test.tsx b/x-pack/plugins/security/public/management/users/users_grid/users_grid_page.test.tsx index 0cc3146172f70..efd6edbe7e697 100644 --- a/x-pack/plugins/security/public/management/users/users_grid/users_grid_page.test.tsx +++ b/x-pack/plugins/security/public/management/users/users_grid/users_grid_page.test.tsx @@ -7,14 +7,14 @@ import { LocationDescriptorObject } from 'history'; import { CoreStart, ScopedHistory } from 'kibana/public'; import { User } from '../../../../common/model'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { UsersGridPage } from './users_grid_page'; import React from 'react'; import { ReactWrapper } from 'enzyme'; import { userAPIClientMock } from '../index.mock'; import { coreMock, scopedHistoryMock } from '../../../../../../../src/core/public/mocks'; import { rolesAPIClientMock } from '../../roles/index.mock'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { findTestSubject } from '@kbn/test/jest'; import { EuiBasicTable } from '@elastic/eui'; describe('UsersGridPage', () => { diff --git a/x-pack/plugins/security/public/nav_control/nav_control_component.test.tsx b/x-pack/plugins/security/public/nav_control/nav_control_component.test.tsx index 1da91e80d062d..4a2b86447b7f7 100644 --- a/x-pack/plugins/security/public/nav_control/nav_control_component.test.tsx +++ b/x-pack/plugins/security/public/nav_control/nav_control_component.test.tsx @@ -6,11 +6,11 @@ import React from 'react'; import { BehaviorSubject } from 'rxjs'; -import { shallowWithIntl, nextTick, mountWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl, nextTick, mountWithIntl } from '@kbn/test/jest'; import { SecurityNavControl } from './nav_control_component'; import { AuthenticatedUser } from '../../common/model'; import { EuiPopover, EuiHeaderSectionItemButton } from '@elastic/eui'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { findTestSubject } from '@kbn/test/jest'; describe('SecurityNavControl', () => { it(`renders a loading spinner when the user promise hasn't resolved yet.`, async () => { diff --git a/x-pack/plugins/security/public/nav_control/nav_control_service.test.ts b/x-pack/plugins/security/public/nav_control/nav_control_service.test.ts index 5b9788d67500b..0e5c6e8bd6f2e 100644 --- a/x-pack/plugins/security/public/nav_control/nav_control_service.test.ts +++ b/x-pack/plugins/security/public/nav_control/nav_control_service.test.ts @@ -9,7 +9,7 @@ import { BehaviorSubject } from 'rxjs'; import { ILicense } from '../../../licensing/public'; import { SecurityNavControlService } from '.'; import { SecurityLicenseService } from '../../common/licensing'; -import { nextTick } from 'test_utils/enzyme_helpers'; +import { nextTick } from '@kbn/test/jest'; import { securityMock } from '../mocks'; import { mockAuthenticatedUser } from '../../common/model/authenticated_user.mock'; diff --git a/x-pack/plugins/security/public/session/session_idle_timeout_warning.test.tsx b/x-pack/plugins/security/public/session/session_idle_timeout_warning.test.tsx index bb4116420f15d..69eff1b6d31ee 100644 --- a/x-pack/plugins/security/public/session/session_idle_timeout_warning.test.tsx +++ b/x-pack/plugins/security/public/session/session_idle_timeout_warning.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { SessionIdleTimeoutWarning } from './session_idle_timeout_warning'; describe('SessionIdleTimeoutWarning', () => { diff --git a/x-pack/plugins/security/public/session/session_timeout.test.tsx b/x-pack/plugins/security/public/session/session_timeout.test.tsx index c49cd8cd4ed9c..1fad9a1c9f365 100644 --- a/x-pack/plugins/security/public/session/session_timeout.test.tsx +++ b/x-pack/plugins/security/public/session/session_timeout.test.tsx @@ -8,7 +8,7 @@ import { coreMock } from 'src/core/public/mocks'; import BroadcastChannel from 'broadcast-channel'; import { SessionTimeout } from './session_timeout'; import { createSessionExpiredMock } from './session_expired.mock'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; jest.useFakeTimers(); diff --git a/x-pack/plugins/security/server/authorization/authorization_service.test.ts b/x-pack/plugins/security/server/authorization/authorization_service.test.ts index 33abc22fdf096..01a3a60355019 100644 --- a/x-pack/plugins/security/server/authorization/authorization_service.test.ts +++ b/x-pack/plugins/security/server/authorization/authorization_service.test.ts @@ -22,7 +22,7 @@ import { authorizationModeFactory } from './mode'; import { privilegesFactory } from './privileges'; import { AuthorizationService } from '.'; -import { nextTick } from 'test_utils/enzyme_helpers'; +import { nextTick } from '@kbn/test/jest'; import { coreMock, elasticsearchServiceMock, diff --git a/x-pack/plugins/security/server/elasticsearch/elasticsearch_service.test.ts b/x-pack/plugins/security/server/elasticsearch/elasticsearch_service.test.ts index 073b0b6225478..812e3e3d17f99 100644 --- a/x-pack/plugins/security/server/elasticsearch/elasticsearch_service.test.ts +++ b/x-pack/plugins/security/server/elasticsearch/elasticsearch_service.test.ts @@ -20,7 +20,7 @@ import { loggingSystemMock, } from '../../../../../src/core/server/mocks'; import { licenseMock } from '../../common/licensing/index.mock'; -import { nextTick } from 'test_utils/enzyme_helpers'; +import { nextTick } from '@kbn/test/jest'; describe('ElasticsearchService', () => { let service: ElasticsearchService; diff --git a/x-pack/plugins/security/server/session_management/session_management_service.test.ts b/x-pack/plugins/security/server/session_management/session_management_service.test.ts index 155cc0bdd58ff..08d4c491d1556 100644 --- a/x-pack/plugins/security/server/session_management/session_management_service.test.ts +++ b/x-pack/plugins/security/server/session_management/session_management_service.test.ts @@ -14,7 +14,7 @@ import { import { Session } from './session'; import { SessionIndex } from './session_index'; -import { nextTick } from 'test_utils/enzyme_helpers'; +import { nextTick } from '@kbn/test/jest'; import { coreMock, elasticsearchServiceMock, diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/common/schemas.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/common/schemas.ts index 2180ebacc9db7..82b803c62a940 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/common/schemas.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/common/schemas.ts @@ -9,6 +9,11 @@ import * as t from 'io-ts'; import { Either } from 'fp-ts/lib/Either'; +import { + SavedObjectAttributes, + SavedObjectAttribute, + SavedObjectAttributeSingle, +} from 'src/core/types'; import { RiskScore } from '../types/risk_score'; import { UUID } from '../types/uuid'; import { IsoDateString } from '../types/iso_date_string'; @@ -66,6 +71,22 @@ export type ExcludeExportDetails = t.TypeOf; export const filters = t.array(t.unknown); // Filters are not easily type-able yet export type Filters = t.TypeOf; // Filters are not easily type-able yet +export const filtersOrUndefined = t.union([filters, t.undefined]); +export type FiltersOrUndefined = t.TypeOf; + +export const saved_object_attribute_single: t.Type = t.recursion( + 'saved_object_attribute_single', + () => t.union([t.string, t.number, t.boolean, t.null, t.undefined, saved_object_attributes]) +); +export const saved_object_attribute: t.Type = t.recursion( + 'saved_object_attribute', + () => t.union([saved_object_attribute_single, t.array(saved_object_attribute_single)]) +); +export const saved_object_attributes: t.Type = t.recursion( + 'saved_object_attributes', + () => t.record(t.string, saved_object_attribute) +); + /** * Params is an "object", since it is a type of AlertActionParams which is action templates. * @see x-pack/plugins/alerts/common/alert.ts @@ -73,7 +94,7 @@ export type Filters = t.TypeOf; // Filters are not easily type-a export const action_group = t.string; export const action_id = t.string; export const action_action_type_id = t.string; -export const action_params = t.object; +export const action_params = saved_object_attributes; export const action = t.exact( t.type({ group: action_group, @@ -86,6 +107,18 @@ export const action = t.exact( export const actions = t.array(action); export type Actions = t.TypeOf; +export const actionsCamel = t.array( + t.exact( + t.type({ + group: action_group, + id: action_id, + actionTypeId: action_action_type_id, + params: action_params, + }) + ) +); +export type ActionsCamel = t.TypeOf; + const stringValidator = (input: unknown): input is string => typeof input === 'string'; export const from = new t.Type( 'From', @@ -416,6 +449,10 @@ export const created_at = IsoDateString; export const updated_at = IsoDateString; export const updated_by = t.string; export const created_by = t.string; +export const updatedByOrNull = t.union([updated_by, t.null]); +export type UpdatedByOrNull = t.TypeOf; +export const createdByOrNull = t.union([created_by, t.null]); +export type CreatedByOrNull = t.TypeOf; export const version = PositiveIntegerGreaterThanZero; export type Version = t.TypeOf; diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_bulk_schema.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_bulk_schema.test.ts index 5c086511e6760..0d70b67f137e8 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_bulk_schema.test.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_bulk_schema.test.ts @@ -4,22 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ -import { - createRulesBulkSchema, - CreateRulesBulkSchema, - CreateRulesBulkSchemaDecoded, -} from './create_rules_bulk_schema'; +import { createRulesBulkSchema, CreateRulesBulkSchema } from './create_rules_bulk_schema'; import { exactCheck } from '../../../exact_check'; import { foldLeftRight } from '../../../test_utils'; -import { - getCreateRulesSchemaMock, - getCreateRulesSchemaDecodedMock, -} from './create_rules_schema.mock'; import { formatErrors } from '../../../format_errors'; -import { CreateRulesSchema } from './create_rules_schema'; +import { getCreateRulesSchemaMock } from './rule_schemas.mock'; // only the basics of testing are here. -// see: create_rules_schema.test.ts for the bulk of the validation tests +// see: rule_schemas.test.ts for the bulk of the validation tests // this just wraps createRulesSchema in an array describe('create_rules_bulk_schema', () => { test('can take an empty array and validate it', () => { @@ -38,13 +30,16 @@ describe('create_rules_bulk_schema', () => { const decoded = createRulesBulkSchema.decode(payload); const checked = exactCheck(payload, decoded); const output = foldLeftRight(checked); - expect(formatErrors(output.errors)).toEqual([ - 'Invalid value "undefined" supplied to "description"', - 'Invalid value "undefined" supplied to "risk_score"', - 'Invalid value "undefined" supplied to "name"', - 'Invalid value "undefined" supplied to "severity"', - 'Invalid value "undefined" supplied to "type"', - ]); + expect(formatErrors(output.errors)).toContain( + 'Invalid value "undefined" supplied to "description"' + ); + expect(formatErrors(output.errors)).toContain( + 'Invalid value "undefined" supplied to "risk_score"' + ); + expect(formatErrors(output.errors)).toContain('Invalid value "undefined" supplied to "name"'); + expect(formatErrors(output.errors)).toContain( + 'Invalid value "undefined" supplied to "severity"' + ); expect(output.schema).toEqual({}); }); @@ -55,7 +50,7 @@ describe('create_rules_bulk_schema', () => { const checked = exactCheck(payload, decoded); const output = foldLeftRight(checked); expect(formatErrors(output.errors)).toEqual([]); - expect(output.schema).toEqual([getCreateRulesSchemaDecodedMock()]); + expect(output.schema).toEqual(payload); }); test('two array elements do validate', () => { @@ -65,10 +60,7 @@ describe('create_rules_bulk_schema', () => { const checked = exactCheck(payload, decoded); const output = foldLeftRight(checked); expect(formatErrors(output.errors)).toEqual([]); - expect(output.schema).toEqual([ - getCreateRulesSchemaDecodedMock(), - getCreateRulesSchemaDecodedMock(), - ]); + expect(output.schema).toEqual(payload); }); test('single array element with a missing value (risk_score) will not validate', () => { @@ -137,7 +129,7 @@ describe('create_rules_bulk_schema', () => { }); test('two array elements where the first is invalid (extra key and value) but the second is valid will not validate', () => { - const singleItem: CreateRulesSchema & { madeUpValue: string } = { + const singleItem = { ...getCreateRulesSchemaMock(), madeUpValue: 'something', }; @@ -152,8 +144,8 @@ describe('create_rules_bulk_schema', () => { }); test('two array elements where the second is invalid (extra key and value) but the first is valid will not validate', () => { - const singleItem: CreateRulesSchema = getCreateRulesSchemaMock(); - const secondItem: CreateRulesSchema & { madeUpValue: string } = { + const singleItem = getCreateRulesSchemaMock(); + const secondItem = { ...getCreateRulesSchemaMock(), madeUpValue: 'something', }; @@ -167,11 +159,11 @@ describe('create_rules_bulk_schema', () => { }); test('two array elements where both are invalid (extra key and value) will not validate', () => { - const singleItem: CreateRulesSchema & { madeUpValue: string } = { + const singleItem = { ...getCreateRulesSchemaMock(), madeUpValue: 'something', }; - const secondItem: CreateRulesSchema & { madeUpValue: string } = { + const secondItem = { ...getCreateRulesSchemaMock(), madeUpValue: 'something', }; @@ -184,28 +176,6 @@ describe('create_rules_bulk_schema', () => { expect(output.schema).toEqual({}); }); - test('The default for "from" will be "now-6m"', () => { - const { from, ...withoutFrom } = getCreateRulesSchemaMock(); - const payload: CreateRulesBulkSchema = [withoutFrom]; - - const decoded = createRulesBulkSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const output = foldLeftRight(checked); - expect(formatErrors(output.errors)).toEqual([]); - expect((output.schema as CreateRulesBulkSchemaDecoded)[0].from).toEqual('now-6m'); - }); - - test('The default for "to" will be "now"', () => { - const { to, ...withoutTo } = getCreateRulesSchemaMock(); - const payload: CreateRulesBulkSchema = [withoutTo]; - - const decoded = createRulesBulkSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const output = foldLeftRight(checked); - expect(formatErrors(output.errors)).toEqual([]); - expect((output.schema as CreateRulesBulkSchemaDecoded)[0].to).toEqual('now'); - }); - test('You cannot set the severity to a value other than low, medium, high, or critical', () => { const badSeverity = { ...getCreateRulesSchemaMock(), severity: 'madeup' }; const payload = [badSeverity]; @@ -226,9 +196,7 @@ describe('create_rules_bulk_schema', () => { const checked = exactCheck(payload, decoded); const output = foldLeftRight(checked); expect(formatErrors(output.errors)).toEqual([]); - expect(output.schema).toEqual([ - { ...getCreateRulesSchemaDecodedMock(), note: '# test markdown' }, - ]); + expect(output.schema).toEqual(payload); }); test('You can set "note" to an empty string', () => { @@ -238,10 +206,10 @@ describe('create_rules_bulk_schema', () => { const checked = exactCheck(payload, decoded); const output = foldLeftRight(checked); expect(formatErrors(output.errors)).toEqual([]); - expect(output.schema).toEqual([{ ...getCreateRulesSchemaDecodedMock(), note: '' }]); + expect(output.schema).toEqual(payload); }); - test('You can set "note" to anything other than string', () => { + test('You cant set "note" to anything other than string', () => { const payload = [ { ...getCreateRulesSchemaMock(), @@ -259,26 +227,4 @@ describe('create_rules_bulk_schema', () => { ]); expect(output.schema).toEqual({}); }); - - test('The default for "actions" will be an empty array', () => { - const { actions, ...withoutActions } = getCreateRulesSchemaMock(); - const payload: CreateRulesBulkSchema = [withoutActions]; - - const decoded = createRulesBulkSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const output = foldLeftRight(checked); - expect(formatErrors(output.errors)).toEqual([]); - expect((output.schema as CreateRulesBulkSchemaDecoded)[0].actions).toEqual([]); - }); - - test('The default for "throttle" will be null', () => { - const { throttle, ...withoutThrottle } = getCreateRulesSchemaMock(); - const payload: CreateRulesBulkSchema = [withoutThrottle]; - - const decoded = createRulesBulkSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const output = foldLeftRight(checked); - expect(formatErrors(output.errors)).toEqual([]); - expect((output.schema as CreateRulesBulkSchemaDecoded)[0].throttle).toEqual(null); - }); }); diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_bulk_schema.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_bulk_schema.ts index c6233cc63fa9f..81b8bf7abbf78 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_bulk_schema.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_bulk_schema.ts @@ -6,9 +6,7 @@ import * as t from 'io-ts'; -import { createRulesSchema, CreateRulesSchemaDecoded } from './create_rules_schema'; +import { createRulesSchema } from './rule_schemas'; export const createRulesBulkSchema = t.array(createRulesSchema); export type CreateRulesBulkSchema = t.TypeOf; - -export type CreateRulesBulkSchemaDecoded = CreateRulesSchemaDecoded[]; diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_schema.mock.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_schema.mock.ts deleted file mode 100644 index 94dd1215d8026..0000000000000 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_schema.mock.ts +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { CreateRulesSchema, CreateRulesSchemaDecoded } from './create_rules_schema'; -import { DEFAULT_MAX_SIGNALS } from '../../../constants'; - -export const getCreateRulesSchemaMock = (ruleId = 'rule-1'): CreateRulesSchema => ({ - description: 'Detecting root and admin users', - name: 'Query with a rule id', - query: 'user.name: root or user.name: admin', - severity: 'high', - type: 'query', - risk_score: 55, - language: 'kuery', - rule_id: ruleId, -}); - -export const getCreateMlRulesSchemaMock = (ruleId = 'rule-1') => { - const { query, language, index, ...mlParams } = getCreateRulesSchemaMock(ruleId); - - return { - ...mlParams, - type: 'machine_learning', - anomaly_threshold: 58, - machine_learning_job_id: 'typical-ml-job-id', - }; -}; - -export const getCreateRulesSchemaDecodedMock = (): CreateRulesSchemaDecoded => ({ - author: [], - severity_mapping: [], - risk_score_mapping: [], - description: 'Detecting root and admin users', - name: 'Query with a rule id', - query: 'user.name: root or user.name: admin', - severity: 'high', - type: 'query', - risk_score: 55, - language: 'kuery', - references: [], - actions: [], - enabled: true, - false_positives: [], - from: 'now-6m', - interval: '5m', - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - to: 'now', - threat: [], - throttle: null, - version: 1, - exceptions_list: [], - rule_id: 'rule-1', -}); - -export const getCreateThreatMatchRulesSchemaMock = (ruleId = 'rule-1'): CreateRulesSchema => ({ - description: 'Detecting root and admin users', - name: 'Query with a rule id', - query: 'user.name: root or user.name: admin', - severity: 'high', - type: 'threat_match', - risk_score: 55, - language: 'kuery', - rule_id: ruleId, - threat_query: '*:*', - threat_index: ['list-index'], - threat_mapping: [ - { - entries: [ - { - field: 'host.name', - value: 'host.name', - type: 'mapping', - }, - ], - }, - ], - threat_filters: [ - { - bool: { - must: [ - { - query_string: { - query: 'host.name: linux', - analyze_wildcard: true, - time_zone: 'Zulu', - }, - }, - ], - filter: [], - should: [], - must_not: [], - }, - }, - ], -}); - -export const getCreateThreatMatchRulesSchemaDecodedMock = (): CreateRulesSchemaDecoded => ({ - author: [], - severity_mapping: [], - risk_score_mapping: [], - description: 'Detecting root and admin users', - name: 'Query with a rule id', - query: 'user.name: root or user.name: admin', - severity: 'high', - type: 'threat_match', - risk_score: 55, - language: 'kuery', - references: [], - actions: [], - enabled: true, - false_positives: [], - from: 'now-6m', - interval: '5m', - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - to: 'now', - threat: [], - throttle: null, - version: 1, - exceptions_list: [], - rule_id: 'rule-1', - threat_query: '*:*', - threat_index: ['list-index'], - threat_mapping: [ - { - entries: [ - { - field: 'host.name', - value: 'host.name', - type: 'mapping', - }, - ], - }, - ], - threat_filters: [ - { - bool: { - must: [ - { - query_string: { - query: 'host.name: linux', - analyze_wildcard: true, - time_zone: 'Zulu', - }, - }, - ], - filter: [], - should: [], - must_not: [], - }, - }, - ], -}); diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_schema.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_schema.ts deleted file mode 100644 index 2fe52bbe470a5..0000000000000 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_schema.ts +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import * as t from 'io-ts'; - -import { - description, - anomaly_threshold, - building_block_type, - filters, - RuleId, - index, - output_index, - saved_id, - timeline_id, - timeline_title, - meta, - machine_learning_job_id, - risk_score, - MaxSignals, - name, - severity, - Tags, - To, - type, - Threat, - threshold, - ThrottleOrNull, - note, - Version, - References, - Actions, - Enabled, - FalsePositives, - From, - Interval, - language, - query, - license, - rule_name_override, - timestamp_override, - Author, - RiskScoreMapping, - SeverityMapping, - event_category_override, -} from '../common/schemas'; -import { - threat_index, - concurrent_searches, - items_per_search, - threat_query, - threat_filters, - threat_mapping, - threat_language, -} from '../types/threat_mapping'; - -import { - DefaultStringArray, - DefaultActionsArray, - DefaultBooleanTrue, - DefaultFromString, - DefaultIntervalString, - DefaultMaxSignalsNumber, - DefaultToString, - DefaultThreatArray, - DefaultThrottleNull, - DefaultVersionNumber, - DefaultListArray, - ListArray, - DefaultUuid, - DefaultRiskScoreMappingArray, - DefaultSeverityMappingArray, -} from '../types'; - -export const createRulesSchema = t.intersection([ - t.exact( - t.type({ - description, - risk_score, - name, - severity, - type, - }) - ), - t.exact( - t.partial({ - actions: DefaultActionsArray, // defaults to empty actions array if not set during decode - anomaly_threshold, // defaults to undefined if not set during decode - author: DefaultStringArray, // defaults to empty array of strings if not set during decode - building_block_type, // defaults to undefined if not set during decode - enabled: DefaultBooleanTrue, // defaults to true if not set during decode - event_category_override, // defaults to "undefined" if not set during decode - false_positives: DefaultStringArray, // defaults to empty string array if not set during decode - filters, // defaults to undefined if not set during decode - from: DefaultFromString, // defaults to "now-6m" if not set during decode - rule_id: DefaultUuid, - index, // defaults to undefined if not set during decode - interval: DefaultIntervalString, // defaults to "5m" if not set during decode - query, // defaults to undefined if not set during decode - language, // defaults to undefined if not set during decode - license, // defaults to "undefined" if not set during decode - // TODO: output_index: This should be removed eventually - output_index, // defaults to "undefined" if not set during decode - saved_id, // defaults to "undefined" if not set during decode - timeline_id, // defaults to "undefined" if not set during decode - timeline_title, // defaults to "undefined" if not set during decode - meta, // defaults to "undefined" if not set during decode - machine_learning_job_id, // defaults to "undefined" if not set during decode - max_signals: DefaultMaxSignalsNumber, // defaults to DEFAULT_MAX_SIGNALS (100) if not set during decode - risk_score_mapping: DefaultRiskScoreMappingArray, // defaults to empty risk score mapping array if not set during decode - rule_name_override, // defaults to "undefined" if not set during decode - severity_mapping: DefaultSeverityMappingArray, // defaults to empty actions array if not set during decode - tags: DefaultStringArray, // defaults to empty string array if not set during decode - to: DefaultToString, // defaults to "now" if not set during decode - threat: DefaultThreatArray, // defaults to empty array if not set during decode - threshold, // defaults to "undefined" if not set during decode - throttle: DefaultThrottleNull, // defaults to "null" if not set during decode - timestamp_override, // defaults to "undefined" if not set during decode - references: DefaultStringArray, // defaults to empty array of strings if not set during decode - note, // defaults to "undefined" if not set during decode - version: DefaultVersionNumber, // defaults to 1 if not set during decode - exceptions_list: DefaultListArray, // defaults to empty array if not set during decode - threat_mapping, // defaults to "undefined" if not set during decode - threat_query, // defaults to "undefined" if not set during decode - threat_filters, // defaults to "undefined" if not set during decode - threat_index, // defaults to "undefined" if not set during decode - threat_language, // defaults "undefined" if not set during decode - concurrent_searches, // defaults "undefined" if not set during decode - items_per_search, // defaults "undefined" if not set during decode - }) - ), -]); - -export type CreateRulesSchema = t.TypeOf; - -// This type is used after a decode since some things are defaults after a decode. -export type CreateRulesSchemaDecoded = Omit< - CreateRulesSchema, - | 'author' - | 'references' - | 'actions' - | 'enabled' - | 'false_positives' - | 'from' - | 'interval' - | 'max_signals' - | 'risk_score_mapping' - | 'severity_mapping' - | 'tags' - | 'to' - | 'threat' - | 'throttle' - | 'version' - | 'exceptions_list' - | 'rule_id' -> & { - author: Author; - references: References; - actions: Actions; - enabled: Enabled; - false_positives: FalsePositives; - from: From; - interval: Interval; - max_signals: MaxSignals; - risk_score_mapping: RiskScoreMapping; - severity_mapping: SeverityMapping; - tags: Tags; - to: To; - threat: Threat; - throttle: ThrottleOrNull; - version: Version; - exceptions_list: ListArray; - rule_id: RuleId; -}; diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_type_dependents.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_type_dependents.test.ts index a78b41cd0da18..3c395df03e0f1 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_type_dependents.test.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_type_dependents.test.ts @@ -4,31 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import { - getCreateRulesSchemaMock, - getCreateThreatMatchRulesSchemaMock, -} from './create_rules_schema.mock'; -import { CreateRulesSchema } from './create_rules_schema'; +import { getCreateRulesSchemaMock, getCreateThreatMatchRulesSchemaMock } from './rule_schemas.mock'; +import { CreateRulesSchema } from './rule_schemas'; import { createRuleValidateTypeDependents } from './create_rules_type_dependents'; describe('create_rules_type_dependents', () => { - test('saved_id is required when type is saved_query and will not validate without out', () => { - const schema: CreateRulesSchema = { ...getCreateRulesSchemaMock(), type: 'saved_query' }; - delete schema.saved_id; - const errors = createRuleValidateTypeDependents(schema); - expect(errors).toEqual(['when "type" is "saved_query", "saved_id" is required']); - }); - - test('saved_id is required when type is saved_query and validates with it', () => { - const schema: CreateRulesSchema = { - ...getCreateRulesSchemaMock(), - type: 'saved_query', - saved_id: '123', - }; - const errors = createRuleValidateTypeDependents(schema); - expect(errors).toEqual([]); - }); - test('You cannot omit timeline_title when timeline_id is present', () => { const schema: CreateRulesSchema = { ...getCreateRulesSchemaMock(), @@ -69,63 +49,6 @@ describe('create_rules_type_dependents', () => { expect(errors).toEqual(['when "timeline_title" exists, "timeline_id" must also exist']); }); - test('threshold is required when type is threshold and validates with it', () => { - const schema: CreateRulesSchema = { - ...getCreateRulesSchemaMock(), - type: 'threshold', - }; - const errors = createRuleValidateTypeDependents(schema); - expect(errors).toEqual(['when "type" is "threshold", "threshold" is required']); - }); - - test('threshold.value is required and has to be bigger than 0 when type is threshold and validates with it', () => { - const schema: CreateRulesSchema = { - ...getCreateRulesSchemaMock(), - type: 'threshold', - threshold: { - field: '', - value: -1, - }, - }; - const errors = createRuleValidateTypeDependents(schema); - expect(errors).toEqual(['"threshold.value" has to be bigger than 0']); - }); - - test('threat_index, threat_query, and threat_mapping are required when type is "threat_match" and validates with it', () => { - const schema: CreateRulesSchema = { - ...getCreateRulesSchemaMock(), - type: 'threat_match', - }; - const errors = createRuleValidateTypeDependents(schema); - expect(errors).toEqual([ - 'when "type" is "threat_match", "threat_index" is required', - 'when "type" is "threat_match", "threat_query" is required', - 'when "type" is "threat_match", "threat_mapping" is required', - ]); - }); - - test('validates with threat_index, threat_query, and threat_mapping when type is "threat_match"', () => { - const schema = getCreateThreatMatchRulesSchemaMock(); - const { threat_filters: threatFilters, ...noThreatFilters } = schema; - const errors = createRuleValidateTypeDependents(noThreatFilters); - expect(errors).toEqual([]); - }); - - test('does NOT validate when threat_mapping is an empty array', () => { - const schema: CreateRulesSchema = { - ...getCreateThreatMatchRulesSchemaMock(), - threat_mapping: [], - }; - const errors = createRuleValidateTypeDependents(schema); - expect(errors).toEqual(['threat_mapping" must have at least one element']); - }); - - test('validates with threat_index, threat_query, threat_mapping, and an optional threat_filters, when type is "threat_match"', () => { - const schema = getCreateThreatMatchRulesSchemaMock(); - const errors = createRuleValidateTypeDependents(schema); - expect(errors).toEqual([]); - }); - test('validates that both "items_per_search" and "concurrent_searches" works when together', () => { const schema: CreateRulesSchema = { ...getCreateThreatMatchRulesSchemaMock(), diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_type_dependents.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_type_dependents.ts index c93b0f0b14f6a..771540189ad5f 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_type_dependents.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_type_dependents.ts @@ -4,69 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { isMlRule } from '../../../machine_learning/helpers'; -import { isThreatMatchRule, isThresholdRule } from '../../utils'; -import { CreateRulesSchema } from './create_rules_schema'; - -export const validateAnomalyThreshold = (rule: CreateRulesSchema): string[] => { - if (isMlRule(rule.type)) { - if (rule.anomaly_threshold == null) { - return ['when "type" is "machine_learning" anomaly_threshold is required']; - } else { - return []; - } - } else { - return []; - } -}; - -export const validateQuery = (rule: CreateRulesSchema): string[] => { - if (isMlRule(rule.type)) { - if (rule.query != null) { - return ['when "type" is "machine_learning", "query" cannot be set']; - } else { - return []; - } - } else { - return []; - } -}; - -export const validateLanguage = (rule: CreateRulesSchema): string[] => { - if (isMlRule(rule.type)) { - if (rule.language != null) { - return ['when "type" is "machine_learning", "language" cannot be set']; - } else { - return []; - } - } else { - return []; - } -}; - -export const validateSavedId = (rule: CreateRulesSchema): string[] => { - if (rule.type === 'saved_query') { - if (rule.saved_id == null) { - return ['when "type" is "saved_query", "saved_id" is required']; - } else { - return []; - } - } else { - return []; - } -}; - -export const validateMachineLearningJobId = (rule: CreateRulesSchema): string[] => { - if (isMlRule(rule.type)) { - if (rule.machine_learning_job_id == null) { - return ['when "type" is "machine_learning", "machine_learning_job_id" is required']; - } else { - return []; - } - } else { - return []; - } -}; +import { CreateRulesSchema } from './rule_schemas'; export const validateTimelineId = (rule: CreateRulesSchema): string[] => { if (rule.timeline_id != null) { @@ -94,33 +32,9 @@ export const validateTimelineTitle = (rule: CreateRulesSchema): string[] => { return []; }; -export const validateThreshold = (rule: CreateRulesSchema): string[] => { - if (isThresholdRule(rule.type)) { - if (!rule.threshold) { - return ['when "type" is "threshold", "threshold" is required']; - } else if (rule.threshold.value <= 0) { - return ['"threshold.value" has to be bigger than 0']; - } else { - return []; - } - } - return []; -}; - export const validateThreatMapping = (rule: CreateRulesSchema): string[] => { let errors: string[] = []; - if (isThreatMatchRule(rule.type)) { - if (rule.threat_mapping == null) { - errors = ['when "type" is "threat_match", "threat_mapping" is required', ...errors]; - } else if (rule.threat_mapping.length === 0) { - errors = ['threat_mapping" must have at least one element', ...errors]; - } - if (rule.threat_query == null) { - errors = ['when "type" is "threat_match", "threat_query" is required', ...errors]; - } - if (rule.threat_index == null) { - errors = ['when "type" is "threat_match", "threat_index" is required', ...errors]; - } + if (rule.type === 'threat_match') { if (rule.concurrent_searches == null && rule.items_per_search != null) { errors = ['when "items_per_search" exists, "concurrent_searches" must also exist', ...errors]; } @@ -133,14 +47,8 @@ export const validateThreatMapping = (rule: CreateRulesSchema): string[] => { export const createRuleValidateTypeDependents = (schema: CreateRulesSchema): string[] => { return [ - ...validateAnomalyThreshold(schema), - ...validateQuery(schema), - ...validateLanguage(schema), - ...validateSavedId(schema), - ...validateMachineLearningJobId(schema), ...validateTimelineId(schema), ...validateTimelineTitle(schema), - ...validateThreshold(schema), ...validateThreatMapping(schema), ]; }; diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/index.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/index.ts index abfbc39189643..a657191181c0f 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/index.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/index.ts @@ -5,7 +5,6 @@ */ export * from './add_prepackaged_rules_schema'; export * from './create_rules_bulk_schema'; -export * from './create_rules_schema'; export * from './export_rules_schema'; export * from './find_rules_schema'; export * from './import_rules_schema'; @@ -15,4 +14,4 @@ export * from './query_rules_schema'; export * from './query_signals_index_schema'; export * from './set_signal_status_schema'; export * from './update_rules_bulk_schema'; -export * from './update_rules_schema'; +export * from './rule_schemas'; diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/rule_schemas.mock.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/rule_schemas.mock.ts new file mode 100644 index 0000000000000..6be51d2a1adc2 --- /dev/null +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/rule_schemas.mock.ts @@ -0,0 +1,195 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { + MachineLearningCreateSchema, + MachineLearningUpdateSchema, + QueryCreateSchema, + QueryUpdateSchema, + SavedQueryCreateSchema, + SavedQueryUpdateSchema, + ThreatMatchCreateSchema, + ThreatMatchUpdateSchema, + ThresholdCreateSchema, +} from './rule_schemas'; + +export const getCreateRulesSchemaMock = (ruleId = 'rule-1'): QueryCreateSchema => ({ + description: 'Detecting root and admin users', + name: 'Query with a rule id', + query: 'user.name: root or user.name: admin', + severity: 'high', + type: 'query', + risk_score: 55, + language: 'kuery', + rule_id: ruleId, +}); + +export const getCreateSavedQueryRulesSchemaMock = (ruleId = 'rule-1'): SavedQueryCreateSchema => ({ + description: 'Detecting root and admin users', + name: 'Query with a rule id', + query: 'user.name: root or user.name: admin', + severity: 'high', + type: 'saved_query', + saved_id: 'some id', + risk_score: 55, + language: 'kuery', + rule_id: ruleId, +}); + +export const getCreateThreatMatchRulesSchemaMock = ( + ruleId = 'rule-1' +): ThreatMatchCreateSchema => ({ + description: 'Detecting root and admin users', + name: 'Query with a rule id', + query: 'user.name: root or user.name: admin', + severity: 'high', + type: 'threat_match', + risk_score: 55, + language: 'kuery', + rule_id: ruleId, + threat_query: '*:*', + threat_index: ['list-index'], + threat_mapping: [ + { + entries: [ + { + field: 'host.name', + value: 'host.name', + type: 'mapping', + }, + ], + }, + ], + threat_filters: [ + { + bool: { + must: [ + { + query_string: { + query: 'host.name: linux', + analyze_wildcard: true, + time_zone: 'Zulu', + }, + }, + ], + filter: [], + should: [], + must_not: [], + }, + }, + ], +}); + +export const getCreateMachineLearningRulesSchemaMock = ( + ruleId = 'rule-1' +): MachineLearningCreateSchema => ({ + description: 'Detecting root and admin users', + name: 'Query with a rule id', + severity: 'high', + risk_score: 55, + rule_id: ruleId, + type: 'machine_learning', + anomaly_threshold: 58, + machine_learning_job_id: 'typical-ml-job-id', +}); + +export const getCreateThresholdRulesSchemaMock = (ruleId = 'rule-1'): ThresholdCreateSchema => ({ + description: 'Detecting root and admin users', + name: 'Query with a rule id', + severity: 'high', + risk_score: 55, + rule_id: ruleId, + type: 'threshold', + query: 'user.name: root or user.name: admin', + threshold: { + field: 'some.field', + value: 4, + }, +}); + +export const getUpdateRulesSchemaMock = ( + id = '04128c15-0d1b-4716-a4c5-46997ac7f3bd' +): QueryUpdateSchema => ({ + description: 'Detecting root and admin users', + name: 'Query with a rule id', + query: 'user.name: root or user.name: admin', + severity: 'high', + type: 'query', + risk_score: 55, + language: 'kuery', + id, +}); + +export const getUpdateSavedQuerySchemaMock = ( + id = '04128c15-0d1b-4716-a4c5-46997ac7f3bd' +): SavedQueryUpdateSchema => ({ + description: 'Detecting root and admin users', + name: 'Query with a rule id', + query: 'user.name: root or user.name: admin', + severity: 'high', + type: 'saved_query', + saved_id: 'some id', + risk_score: 55, + language: 'kuery', + id, +}); + +export const getUpdateThreatMatchSchemaMock = ( + id = '04128c15-0d1b-4716-a4c5-46997ac7f3bd' +): ThreatMatchUpdateSchema => ({ + description: 'Detecting root and admin users', + name: 'Query with a rule id', + query: 'user.name: root or user.name: admin', + severity: 'high', + type: 'threat_match', + risk_score: 55, + language: 'kuery', + id, + threat_query: '*:*', + threat_index: ['list-index'], + threat_mapping: [ + { + entries: [ + { + field: 'host.name', + value: 'host.name', + type: 'mapping', + }, + ], + }, + ], + threat_filters: [ + { + bool: { + must: [ + { + query_string: { + query: 'host.name: linux', + analyze_wildcard: true, + time_zone: 'Zulu', + }, + }, + ], + filter: [], + should: [], + must_not: [], + }, + }, + ], +}); + +export const getUpdateMachineLearningSchemaMock = ( + id = '04128c15-0d1b-4716-a4c5-46997ac7f3bd' +): MachineLearningUpdateSchema => ({ + description: 'Detecting root and admin users', + name: 'Query with a rule id', + severity: 'high', + risk_score: 55, + id, + type: 'machine_learning', + anomaly_threshold: 58, + machine_learning_job_id: 'typical-ml-job-id', +}); diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_schema.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/rule_schemas.test.ts similarity index 63% rename from x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_schema.test.ts rename to x-pack/plugins/security_solution/common/detection_engine/schemas/request/rule_schemas.test.ts index 1b6a8d6f27762..c9330bbe73c89 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_schema.test.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/rule_schemas.test.ts @@ -4,38 +4,27 @@ * you may not use this file except in compliance with the Elastic License. */ -import { - createRulesSchema, - CreateRulesSchema, - CreateRulesSchemaDecoded, -} from './create_rules_schema'; +import { createRulesSchema, CreateRulesSchema, SavedQueryCreateSchema } from './rule_schemas'; import { exactCheck } from '../../../exact_check'; import { pipe } from 'fp-ts/lib/pipeable'; import { foldLeftRight, getPaths } from '../../../test_utils'; import { left } from 'fp-ts/lib/Either'; import { - getCreateRulesSchemaMock, - getCreateRulesSchemaDecodedMock, + getCreateSavedQueryRulesSchemaMock, getCreateThreatMatchRulesSchemaMock, - getCreateThreatMatchRulesSchemaDecodedMock, -} from './create_rules_schema.mock'; -import { DEFAULT_MAX_SIGNALS } from '../../../constants'; + getCreateRulesSchemaMock, + getCreateThresholdRulesSchemaMock, +} from './rule_schemas.mock'; import { getListArrayMock } from '../types/lists.mock'; describe('create rules schema', () => { test('empty objects do not validate', () => { - const payload: Partial = {}; + const payload = {}; const decoded = createRulesSchema.decode(payload); const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "description"', - 'Invalid value "undefined" supplied to "risk_score"', - 'Invalid value "undefined" supplied to "name"', - 'Invalid value "undefined" supplied to "severity"', - 'Invalid value "undefined" supplied to "type"', - ]); + expect(message.errors.length).toBeGreaterThan(0); expect(message.schema).toEqual({}); }); @@ -60,13 +49,7 @@ describe('create rules schema', () => { const decoded = createRulesSchema.decode(payload); const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "description"', - 'Invalid value "undefined" supplied to "risk_score"', - 'Invalid value "undefined" supplied to "name"', - 'Invalid value "undefined" supplied to "severity"', - 'Invalid value "undefined" supplied to "type"', - ]); + expect(message.errors.length).toBeGreaterThan(0); expect(message.schema).toEqual({}); }); @@ -79,12 +62,7 @@ describe('create rules schema', () => { const decoded = createRulesSchema.decode(payload); const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "risk_score"', - 'Invalid value "undefined" supplied to "name"', - 'Invalid value "undefined" supplied to "severity"', - 'Invalid value "undefined" supplied to "type"', - ]); + expect(message.errors.length).toBeGreaterThan(0); expect(message.schema).toEqual({}); }); @@ -98,12 +76,7 @@ describe('create rules schema', () => { const decoded = createRulesSchema.decode(payload); const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "risk_score"', - 'Invalid value "undefined" supplied to "name"', - 'Invalid value "undefined" supplied to "severity"', - 'Invalid value "undefined" supplied to "type"', - ]); + expect(message.errors.length).toBeGreaterThan(0); expect(message.schema).toEqual({}); }); @@ -118,12 +91,7 @@ describe('create rules schema', () => { const decoded = createRulesSchema.decode(payload); const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "risk_score"', - 'Invalid value "undefined" supplied to "name"', - 'Invalid value "undefined" supplied to "severity"', - 'Invalid value "undefined" supplied to "type"', - ]); + expect(message.errors.length).toBeGreaterThan(0); expect(message.schema).toEqual({}); }); @@ -139,11 +107,7 @@ describe('create rules schema', () => { const decoded = createRulesSchema.decode(payload); const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "risk_score"', - 'Invalid value "undefined" supplied to "severity"', - 'Invalid value "undefined" supplied to "type"', - ]); + expect(message.errors.length).toBeGreaterThan(0); expect(message.schema).toEqual({}); }); @@ -160,10 +124,7 @@ describe('create rules schema', () => { const decoded = createRulesSchema.decode(payload); const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "risk_score"', - 'Invalid value "undefined" supplied to "type"', - ]); + expect(message.errors.length).toBeGreaterThan(0); expect(message.schema).toEqual({}); }); @@ -249,33 +210,7 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - author: [], - severity_mapping: [], - risk_score_mapping: [], - rule_id: 'rule-1', - risk_score: 50, - description: 'some description', - from: 'now-5m', - to: 'now', - name: 'some-name', - severity: 'low', - type: 'query', - query: 'some query', - index: ['index-1'], - interval: '5m', - references: [], - actions: [], - enabled: true, - false_positives: [], - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - threat: [], - throttle: null, - version: 1, - exceptions_list: [], - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('[rule_id, description, from, to, index, name, severity, interval, type, query, language] does not validate', () => { @@ -322,34 +257,7 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - author: [], - severity_mapping: [], - risk_score_mapping: [], - rule_id: 'rule-1', - risk_score: 50, - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - query: 'some query', - language: 'kuery', - references: [], - actions: [], - enabled: true, - false_positives: [], - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - threat: [], - throttle: null, - version: 1, - exceptions_list: [], - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('[rule_id, description, from, to, index, name, severity, interval, type, query, language, risk_score, output_index] does validate', () => { @@ -373,35 +281,7 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - author: [], - severity_mapping: [], - risk_score_mapping: [], - rule_id: 'rule-1', - output_index: '.siem-signals', - risk_score: 50, - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - query: 'some query', - language: 'kuery', - references: [], - actions: [], - enabled: true, - false_positives: [], - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - threat: [], - throttle: null, - version: 1, - exceptions_list: [], - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score] does validate', () => { @@ -422,32 +302,7 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - author: [], - severity_mapping: [], - risk_score_mapping: [], - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - risk_score: 50, - references: [], - actions: [], - enabled: true, - false_positives: [], - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - threat: [], - throttle: null, - version: 1, - exceptions_list: [], - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, output_index] does validate', () => { @@ -472,33 +327,7 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - author: [], - severity_mapping: [], - risk_score_mapping: [], - rule_id: 'rule-1', - output_index: '.siem-signals', - risk_score: 50, - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - references: [], - actions: [], - enabled: true, - false_positives: [], - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - threat: [], - throttle: null, - version: 1, - exceptions_list: [], - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('You can send in an empty array to threat', () => { @@ -511,11 +340,7 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - ...getCreateRulesSchemaDecodedMock(), - threat: [], - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, output_index, threat] does validate', () => { @@ -554,49 +379,7 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - author: [], - severity_mapping: [], - risk_score_mapping: [], - rule_id: 'rule-1', - output_index: '.siem-signals', - risk_score: 50, - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - threat: [ - { - framework: 'someFramework', - tactic: { - id: 'fakeId', - name: 'fakeName', - reference: 'fakeRef', - }, - technique: [ - { - id: 'techniqueId', - name: 'techniqueName', - reference: 'techniqueRef', - }, - ], - }, - ], - references: [], - actions: [], - enabled: true, - false_positives: [], - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - throttle: null, - version: 1, - exceptions_list: [], - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('allows references to be sent as valid', () => { @@ -609,24 +392,7 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - ...getCreateRulesSchemaDecodedMock(), - references: ['index-1'], - }; - expect(message.schema).toEqual(expected); - }); - - test('defaults references to an array if it is not sent in', () => { - const { references, ...noReferences } = getCreateRulesSchemaMock(); - const decoded = createRulesSchema.decode(noReferences); - const checked = exactCheck(noReferences, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - ...getCreateRulesSchemaDecodedMock(), - references: [], - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('references cannot be numbers', () => { @@ -656,8 +422,8 @@ describe('create rules schema', () => { }); test('saved_query type can have filters with it', () => { - const payload: CreateRulesSchema = { - ...getCreateRulesSchemaMock(), + const payload: SavedQueryCreateSchema = { + ...getCreateSavedQueryRulesSchemaMock(), filters: [], }; @@ -665,15 +431,11 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - ...getCreateRulesSchemaDecodedMock(), - filters: [], - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('filters cannot be a string', () => { - const payload: Omit & { filters: string } = { + const payload = { ...getCreateRulesSchemaMock(), filters: 'some string', }; @@ -697,11 +459,7 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - ...getCreateRulesSchemaDecodedMock(), - language: 'kuery', - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('language validates with lucene', () => { @@ -714,15 +472,11 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - ...getCreateRulesSchemaDecodedMock(), - language: 'lucene', - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('language does not validate with something made up', () => { - const payload: Omit & { language: string } = { + const payload = { ...getCreateRulesSchemaMock(), language: 'something-made-up', }; @@ -774,11 +528,7 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - ...getCreateRulesSchemaDecodedMock(), - max_signals: 1, - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('You can optionally send in an array of tags', () => { @@ -791,15 +541,11 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - ...getCreateRulesSchemaDecodedMock(), - tags: ['tag_1', 'tag_2'], - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('You cannot send in an array of tags that are numbers', () => { - const payload: Omit & { tags: number[] } = { + const payload = { ...getCreateRulesSchemaMock(), tags: [0, 1, 2], }; @@ -816,9 +562,7 @@ describe('create rules schema', () => { }); test('You cannot send in an array of threat that are missing "framework"', () => { - const payload: Omit & { - threat: Array>>; - } = { + const payload = { ...getCreateRulesSchemaMock(), threat: [ { @@ -848,9 +592,7 @@ describe('create rules schema', () => { }); test('You cannot send in an array of threat that are missing "tactic"', () => { - const payload: Omit & { - threat: Array>>; - } = { + const payload = { ...getCreateRulesSchemaMock(), threat: [ { @@ -876,9 +618,7 @@ describe('create rules schema', () => { }); test('You cannot send in an array of threat that are missing "technique"', () => { - const payload: Omit & { - threat: Array>>; - } = { + const payload = { ...getCreateRulesSchemaMock(), threat: [ { @@ -911,15 +651,11 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - ...getCreateRulesSchemaDecodedMock(), - false_positives: ['false_1', 'false_2'], - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('You cannot send in an array of false positives that are numbers', () => { - const payload: Omit & { false_positives: number[] } = { + const payload = { ...getCreateRulesSchemaMock(), false_positives: [5, 4], }; @@ -935,7 +671,7 @@ describe('create rules schema', () => { }); test('You cannot set the immutable to a number when trying to create a rule', () => { - const payload: Omit & { immutable: number } = { + const payload = { ...getCreateRulesSchemaMock(), immutable: 5, }; @@ -985,11 +721,7 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - ...getCreateRulesSchemaDecodedMock(), - risk_score: 0, - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('You can set the risk_score to 100', () => { @@ -1002,11 +734,7 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - ...getCreateRulesSchemaDecodedMock(), - risk_score: 100, - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('You can set meta to any object you want', () => { @@ -1021,17 +749,11 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - ...getCreateRulesSchemaDecodedMock(), - meta: { - somethingMadeUp: { somethingElse: true }, - }, - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('You cannot create meta as a string', () => { - const payload: Omit & { meta: string } = { + const payload = { ...getCreateRulesSchemaMock(), meta: 'should not work', }; @@ -1056,13 +778,7 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - - const { query: expectedQuery, ...expectedNoQuery } = getCreateRulesSchemaDecodedMock(); - const expected: CreateRulesSchemaDecoded = { - ...expectedNoQuery, - filters: [], - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('validates with timeline_id and timeline_title', () => { @@ -1076,16 +792,11 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - ...getCreateRulesSchemaDecodedMock(), - timeline_id: 'timeline-id', - timeline_title: 'timeline-title', - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('You cannot set the severity to a value other than low, medium, high, or critical', () => { - const payload: Omit & { severity: string } = { + const payload = { ...getCreateRulesSchemaMock(), severity: 'junk', }; @@ -1098,7 +809,7 @@ describe('create rules schema', () => { }); test('You cannot send in an array of actions that are missing "group"', () => { - const payload: Omit = { + const payload = { ...getCreateRulesSchemaMock(), actions: [{ id: 'id', action_type_id: 'action_type_id', params: {} }], }; @@ -1113,7 +824,7 @@ describe('create rules schema', () => { }); test('You cannot send in an array of actions that are missing "id"', () => { - const payload: Omit = { + const payload = { ...getCreateRulesSchemaMock(), actions: [{ group: 'group', action_type_id: 'action_type_id', params: {} }], }; @@ -1128,7 +839,7 @@ describe('create rules schema', () => { }); test('You cannot send in an array of actions that are missing "action_type_id"', () => { - const payload: Omit = { + const payload = { ...getCreateRulesSchemaMock(), actions: [{ group: 'group', id: 'id', params: {} }], }; @@ -1143,7 +854,7 @@ describe('create rules schema', () => { }); test('You cannot send in an array of actions that are missing "params"', () => { - const payload: Omit = { + const payload = { ...getCreateRulesSchemaMock(), actions: [{ group: 'group', id: 'id', action_type_id: 'action_type_id' }], }; @@ -1158,7 +869,7 @@ describe('create rules schema', () => { }); test('You cannot send in an array of actions that are including "actionTypeId"', () => { - const payload: Omit = { + const payload = { ...getCreateRulesSchemaMock(), actions: [ { @@ -1190,11 +901,7 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - ...getCreateRulesSchemaDecodedMock(), - note: '# documentation markdown here', - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('You can set note to an empty string', () => { @@ -1207,15 +914,11 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - ...getCreateRulesSchemaDecodedMock(), - note: '', - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('You cannot create note as an object', () => { - const payload: Omit & { note: {} } = { + const payload = { ...getCreateRulesSchemaMock(), note: { somethingHere: 'something else', @@ -1278,154 +981,10 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - author: [], - severity_mapping: [], - risk_score_mapping: [], - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - risk_score: 50, - note: '# some markdown', - references: [], - actions: [], - enabled: true, - false_positives: [], - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - threat: [], - throttle: null, - version: 1, - exceptions_list: [], - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); }); - test('defaults interval to 5 min', () => { - const { interval, ...noInterval } = getCreateRulesSchemaMock(); - const payload: CreateRulesSchema = { - ...noInterval, - }; - - const decoded = createRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - - const { interval: expectedInterval, ...expectedNoInterval } = getCreateRulesSchemaDecodedMock(); - const expected: CreateRulesSchemaDecoded = { - ...expectedNoInterval, - interval: '5m', - }; - expect(message.schema).toEqual(expected); - }); - - test('defaults max signals to 100', () => { - // eslint-disable-next-line @typescript-eslint/naming-convention - const { max_signals, ...noMaxSignals } = getCreateRulesSchemaMock(); - const payload: CreateRulesSchema = { - ...noMaxSignals, - }; - - const decoded = createRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - - const { - max_signals: expectedMaxSignals, - ...expectedNoMaxSignals - } = getCreateRulesSchemaDecodedMock(); - const expected: CreateRulesSchemaDecoded = { - ...expectedNoMaxSignals, - max_signals: 100, - }; - expect(message.schema).toEqual(expected); - }); - - test('The default for "from" will be "now-6m"', () => { - const { from, ...noFrom } = getCreateRulesSchemaMock(); - const payload: CreateRulesSchema = { - ...noFrom, - }; - - const decoded = createRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - - const { from: expectedFrom, ...expectedNoFrom } = getCreateRulesSchemaDecodedMock(); - const expected: CreateRulesSchemaDecoded = { - ...expectedNoFrom, - from: 'now-6m', - }; - expect(message.schema).toEqual(expected); - }); - - test('The default for "to" will be "now"', () => { - const { to, ...noTo } = getCreateRulesSchemaMock(); - const payload: CreateRulesSchema = { - ...noTo, - }; - - const decoded = createRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - - const { to: expectedTo, ...expectedNoTo } = getCreateRulesSchemaDecodedMock(); - const expected: CreateRulesSchemaDecoded = { - ...expectedNoTo, - to: 'now', - }; - expect(message.schema).toEqual(expected); - }); - - test('The default for "actions" will be an empty array', () => { - const { actions, ...noActions } = getCreateRulesSchemaMock(); - const payload: CreateRulesSchema = { - ...noActions, - }; - - const decoded = createRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - - const { actions: expectedActions, ...expectedNoActions } = getCreateRulesSchemaDecodedMock(); - const expected: CreateRulesSchemaDecoded = { - ...expectedNoActions, - actions: [], - }; - expect(message.schema).toEqual(expected); - }); - - test('The default for "throttle" will be null', () => { - const { throttle, ...noThrottle } = getCreateRulesSchemaMock(); - const payload: CreateRulesSchema = { - ...noThrottle, - }; - - const decoded = createRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - - const { throttle: expectedThrottle, ...expectedNoThrottle } = getCreateRulesSchemaDecodedMock(); - const expected: CreateRulesSchemaDecoded = { - ...expectedNoThrottle, - throttle: null, - }; - expect(message.schema).toEqual(expected); - }); - test('machine_learning type does validate', () => { const payload: CreateRulesSchema = { type: 'machine_learning', @@ -1453,46 +1012,42 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - author: [], - severity_mapping: [], - risk_score_mapping: [], - type: 'machine_learning', - anomaly_threshold: 50, - machine_learning_job_id: 'linux_anomalous_network_activity_ecs', - false_positives: [], - references: [], - risk_score: 50, - threat: [], - name: 'ss', - description: 'ss', - severity: 'low', - tags: [], - interval: '5m', - from: 'now-360s', - to: 'now', - meta: { from: '1m' }, - actions: [], - enabled: true, - throttle: 'no_actions', - exceptions_list: [], - max_signals: DEFAULT_MAX_SIGNALS, - version: 1, - rule_id: 'rule-1', - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); - test('it generates a uuid v4 whenever you omit the rule_id', () => { - // eslint-disable-next-line @typescript-eslint/naming-convention - const { rule_id, ...noRuleId } = getCreateRulesSchemaMock(); - const decoded = createRulesSchema.decode(noRuleId); - const checked = exactCheck(noRuleId, decoded); + test('saved_id is required when type is saved_query and will not validate without it', () => { + /* eslint-disable @typescript-eslint/naming-convention */ + const { saved_id, ...payload } = getCreateSavedQueryRulesSchemaMock(); + const decoded = createRulesSchema.decode(payload); + const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - expect((message.schema as CreateRulesSchemaDecoded).rule_id).toMatch( - /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i - ); + expect(getPaths(left(message.errors))).toEqual([ + 'Invalid value "undefined" supplied to "saved_id"', + ]); + expect(message.schema).toEqual({}); + }); + + test('threshold is required when type is threshold and will not validate without it', () => { + const { threshold, ...payload } = getCreateThresholdRulesSchemaMock(); + const decoded = createRulesSchema.decode(payload); + const checked = exactCheck(payload, decoded); + const message = pipe(checked, foldLeftRight); + expect(getPaths(left(message.errors))).toEqual([ + 'Invalid value "undefined" supplied to "threshold"', + ]); + expect(message.schema).toEqual({}); + }); + + test('threshold rules fail validation if threshold is not greater than 0', () => { + const payload = getCreateThresholdRulesSchemaMock(); + payload.threshold.value = 0; + const decoded = createRulesSchema.decode(payload); + const checked = exactCheck(payload, decoded); + const message = pipe(checked, foldLeftRight); + expect(getPaths(left(message.errors))).toEqual([ + 'Invalid value "0" supplied to "threshold,value"', + ]); + expect(message.schema).toEqual({}); }); describe('exception_list', () => { @@ -1517,47 +1072,7 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - author: [], - severity_mapping: [], - risk_score_mapping: [], - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - risk_score: 50, - note: '# some markdown', - references: [], - actions: [], - enabled: true, - false_positives: [], - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - threat: [], - throttle: null, - version: 1, - filters: [], - exceptions_list: [ - { - id: 'some_uuid', - list_id: 'list_id_single', - namespace_type: 'single', - type: 'detection', - }, - { - id: 'endpoint_list', - list_id: 'endpoint_list', - namespace_type: 'agnostic', - type: 'endpoint', - }, - ], - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and empty exceptions_list] does validate', () => { @@ -1581,40 +1096,11 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - author: [], - severity_mapping: [], - risk_score_mapping: [], - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - risk_score: 50, - note: '# some markdown', - references: [], - actions: [], - enabled: true, - false_positives: [], - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - threat: [], - throttle: null, - version: 1, - filters: [], - exceptions_list: [], - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); test('rule_id, description, from, to, index, name, severity, interval, type, filters, risk_score, note, and invalid exceptions_list] does NOT validate', () => { - const payload: Omit & { - exceptions_list: Array<{ id: string; namespace_type: string }>; - } = { + const payload = { rule_id: 'rule-1', description: 'some description', from: 'now-5m', @@ -1661,34 +1147,7 @@ describe('create rules schema', () => { const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual([]); - const expected: CreateRulesSchemaDecoded = { - author: [], - severity_mapping: [], - risk_score_mapping: [], - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - risk_score: 50, - note: '# some markdown', - references: [], - actions: [], - enabled: true, - false_positives: [], - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - threat: [], - throttle: null, - version: 1, - exceptions_list: [], - filters: [], - }; - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); }); @@ -1698,27 +1157,39 @@ describe('create rules schema', () => { const decoded = createRulesSchema.decode(payload); const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); - const expected = getCreateThreatMatchRulesSchemaDecodedMock(); expect(getPaths(left(message.errors))).toEqual([]); - expect(message.schema).toEqual(expected); + expect(message.schema).toEqual(payload); }); - test('You can set a threat query, index, mapping, filters, concurrent_searches, items_per_search with a when creating a rule', () => { - const payload: CreateRulesSchema = { - ...getCreateThreatMatchRulesSchemaMock(), - concurrent_searches: 10, - items_per_search: 10, - }; + test('threat_index, threat_query, and threat_mapping are required when type is "threat_match" and validation fails without them', () => { + /* eslint-disable @typescript-eslint/naming-convention */ + const { + threat_index, + threat_query, + threat_mapping, + ...payload + } = getCreateThreatMatchRulesSchemaMock(); const decoded = createRulesSchema.decode(payload); const checked = exactCheck(payload, decoded); const message = pipe(checked, foldLeftRight); - const expected: CreateRulesSchemaDecoded = { - ...getCreateThreatMatchRulesSchemaDecodedMock(), - concurrent_searches: 10, - items_per_search: 10, - }; - expect(getPaths(left(message.errors))).toEqual([]); - expect(message.schema).toEqual(expected); + expect(getPaths(left(message.errors))).toEqual([ + 'Invalid value "undefined" supplied to "threat_query"', + 'Invalid value "undefined" supplied to "threat_mapping"', + 'Invalid value "undefined" supplied to "threat_index"', + ]); + expect(message.schema).toEqual({}); + }); + + test('fails validation when threat_mapping is an empty array', () => { + const payload = getCreateThreatMatchRulesSchemaMock(); + payload.threat_mapping = []; + const decoded = createRulesSchema.decode(payload); + const checked = exactCheck(payload, decoded); + const message = pipe(checked, foldLeftRight); + expect(getPaths(left(message.errors))).toEqual([ + 'Invalid value "[]" supplied to "threat_mapping"', + ]); + expect(message.schema).toEqual({}); }); }); }); diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/rule_schemas.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/rule_schemas.ts new file mode 100644 index 0000000000000..799b06f169df5 --- /dev/null +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/rule_schemas.ts @@ -0,0 +1,442 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import * as t from 'io-ts'; + +import { listArray } from '../types/lists'; +import { + threat_filters, + threat_query, + threat_mapping, + threat_index, + concurrent_searches, + items_per_search, +} from '../types/threat_mapping'; +import { + id, + index, + filters, + event_category_override, + risk_score_mapping, + severity_mapping, + building_block_type, + note, + license, + timeline_id, + timeline_title, + meta, + rule_name_override, + timestamp_override, + author, + description, + false_positives, + from, + rule_id, + immutable, + output_index, + query, + machine_learning_job_id, + max_signals, + risk_score, + severity, + threat, + to, + references, + version, + saved_id, + threshold, + anomaly_threshold, + name, + tags, + actions, + interval, + enabled, + updated_at, + created_at, + job_status, + status_date, + last_success_at, + last_success_message, + last_failure_at, + last_failure_message, + throttleOrNull, + createdByOrNull, + updatedByOrNull, +} from '../common/schemas'; + +const createSchema = < + Required extends t.Props, + Optional extends t.Props, + Defaultable extends t.Props +>( + requiredFields: Required, + optionalFields: Optional, + defaultableFields: Defaultable +) => { + return t.intersection([ + t.exact(t.type(requiredFields)), + t.exact(t.partial(optionalFields)), + t.exact(t.partial(defaultableFields)), + ]); +}; + +const patchSchema = < + Required extends t.Props, + Optional extends t.Props, + Defaultable extends t.Props +>( + requiredFields: Required, + optionalFields: Optional, + defaultableFields: Defaultable +) => { + return t.intersection([ + t.exact(t.partial(requiredFields)), + t.exact(t.partial(optionalFields)), + t.exact(t.partial(defaultableFields)), + ]); +}; + +const responseSchema = < + Required extends t.Props, + Optional extends t.Props, + Defaultable extends t.Props +>( + requiredFields: Required, + optionalFields: Optional, + defaultableFields: Defaultable +) => { + return t.intersection([ + t.exact(t.type(requiredFields)), + t.exact(t.partial(optionalFields)), + t.exact(t.type(defaultableFields)), + ]); +}; + +const buildAPISchemas = ( + params: APIParams +) => { + return { + create: createSchema(params.required, params.optional, params.defaultable), + patch: patchSchema(params.required, params.optional, params.defaultable), + response: responseSchema(params.required, params.optional, params.defaultable), + }; +}; + +interface APIParams< + Required extends t.Props, + Optional extends t.Props, + Defaultable extends t.Props +> { + required: Required; + optional: Optional; + defaultable: Defaultable; +} + +const commonParams = { + required: { + name, + description, + risk_score, + severity, + }, + optional: { + building_block_type, + note, + license, + output_index, + timeline_id, + timeline_title, + meta, + rule_name_override, + timestamp_override, + }, + defaultable: { + tags, + interval, + enabled, + throttle: throttleOrNull, + actions, + author, + false_positives, + from, + rule_id, + // maxSignals not used in ML rules but probably should be used + max_signals, + risk_score_mapping, + severity_mapping, + threat, + to, + references, + version, + exceptions_list: listArray, + }, +}; +const { + create: commonCreateParams, + patch: commonPatchParams, + response: commonResponseParams, +} = buildAPISchemas(commonParams); + +const eqlRuleParams = { + required: { + type: t.literal('eql'), + language: t.literal('eql'), + query, + }, + optional: { + index, + filters, + event_category_override, + }, + defaultable: {}, +}; +const { + create: eqlCreateParams, + patch: eqlPatchParams, + response: eqlResponseParams, +} = buildAPISchemas(eqlRuleParams); + +const threatMatchRuleParams = { + required: { + type: t.literal('threat_match'), + query, + threat_query, + threat_mapping, + threat_index, + }, + optional: { + index, + filters, + saved_id, + threat_filters, + threat_language: t.keyof({ kuery: null, lucene: null }), + concurrent_searches, + items_per_search, + }, + defaultable: { + language: t.keyof({ kuery: null, lucene: null }), + }, +}; +const { + create: threatMatchCreateParams, + patch: threatMatchPatchParams, + response: threatMatchResponseParams, +} = buildAPISchemas(threatMatchRuleParams); + +const queryRuleParams = { + required: { + type: t.literal('query'), + }, + optional: { + index, + filters, + saved_id, + }, + defaultable: { + query, + language: t.keyof({ kuery: null, lucene: null }), + }, +}; +const { + create: queryCreateParams, + patch: queryPatchParams, + response: queryResponseParams, +} = buildAPISchemas(queryRuleParams); + +const savedQueryRuleParams = { + required: { + type: t.literal('saved_query'), + saved_id, + }, + optional: { + // Having language, query, and filters possibly defined adds more code confusion and probably user confusion + // if the saved object gets deleted for some reason + index, + query, + filters, + }, + defaultable: { + language: t.keyof({ kuery: null, lucene: null }), + }, +}; +const { + create: savedQueryCreateParams, + patch: savedQueryPatchParams, + response: savedQueryResponseParams, +} = buildAPISchemas(savedQueryRuleParams); + +const thresholdRuleParams = { + required: { + type: t.literal('threshold'), + query, + threshold, + }, + optional: { + index, + filters, + saved_id, + }, + defaultable: { + language: t.keyof({ kuery: null, lucene: null }), + }, +}; +const { + create: thresholdCreateParams, + patch: thresholdPatchParams, + response: thresholdResponseParams, +} = buildAPISchemas(thresholdRuleParams); + +const machineLearningRuleParams = { + required: { + type: t.literal('machine_learning'), + anomaly_threshold, + machine_learning_job_id, + }, + optional: {}, + defaultable: {}, +}; +const { + create: machineLearningCreateParams, + patch: machineLearningPatchParams, + response: machineLearningResponseParams, +} = buildAPISchemas(machineLearningRuleParams); + +const createTypeSpecific = t.union([ + eqlCreateParams, + threatMatchCreateParams, + queryCreateParams, + savedQueryCreateParams, + thresholdCreateParams, + machineLearningCreateParams, +]); +export type CreateTypeSpecific = t.TypeOf; + +// Convenience types for building specific types of rules +export const eqlCreateSchema = t.intersection([eqlCreateParams, commonCreateParams]); +export type EqlCreateSchema = t.TypeOf; + +export const threatMatchCreateSchema = t.intersection([ + threatMatchCreateParams, + commonCreateParams, +]); +export type ThreatMatchCreateSchema = t.TypeOf; + +export const queryCreateSchema = t.intersection([queryCreateParams, commonCreateParams]); +export type QueryCreateSchema = t.TypeOf; + +export const savedQueryCreateSchema = t.intersection([savedQueryCreateParams, commonCreateParams]); +export type SavedQueryCreateSchema = t.TypeOf; + +export const thresholdCreateSchema = t.intersection([thresholdCreateParams, commonCreateParams]); +export type ThresholdCreateSchema = t.TypeOf; + +export const machineLearningCreateSchema = t.intersection([ + machineLearningCreateParams, + commonCreateParams, +]); +export type MachineLearningCreateSchema = t.TypeOf; + +export const createRulesSchema = t.intersection([commonCreateParams, createTypeSpecific]); +export type CreateRulesSchema = t.TypeOf; + +export const eqlUpdateSchema = t.intersection([ + eqlCreateParams, + commonCreateParams, + t.exact(t.partial({ id })), +]); +export type EqlUpdateSchema = t.TypeOf; + +export const threatMatchUpdateSchema = t.intersection([ + threatMatchCreateParams, + commonCreateParams, + t.exact(t.partial({ id })), +]); +export type ThreatMatchUpdateSchema = t.TypeOf; + +export const queryUpdateSchema = t.intersection([ + queryCreateParams, + commonCreateParams, + t.exact(t.partial({ id })), +]); +export type QueryUpdateSchema = t.TypeOf; + +export const savedQueryUpdateSchema = t.intersection([ + savedQueryCreateParams, + commonCreateParams, + t.exact(t.partial({ id })), +]); +export type SavedQueryUpdateSchema = t.TypeOf; + +export const thresholdUpdateSchema = t.intersection([ + thresholdCreateParams, + commonCreateParams, + t.exact(t.partial({ id })), +]); +export type ThresholdUpdateSchema = t.TypeOf; + +export const machineLearningUpdateSchema = t.intersection([ + machineLearningCreateParams, + commonCreateParams, + t.exact(t.partial({ id })), +]); +export type MachineLearningUpdateSchema = t.TypeOf; + +const patchTypeSpecific = t.union([ + eqlPatchParams, + threatMatchPatchParams, + queryPatchParams, + savedQueryPatchParams, + thresholdPatchParams, + machineLearningPatchParams, +]); + +const responseTypeSpecific = t.union([ + eqlResponseParams, + threatMatchResponseParams, + queryResponseParams, + savedQueryResponseParams, + thresholdResponseParams, + machineLearningResponseParams, +]); +export type ResponseTypeSpecific = t.TypeOf; + +export const updateRulesSchema = t.intersection([ + commonCreateParams, + createTypeSpecific, + t.exact(t.partial({ id })), +]); +export type UpdateRulesSchema = t.TypeOf; + +export const fullPatchSchema = t.intersection([ + commonPatchParams, + patchTypeSpecific, + t.exact(t.partial({ id })), +]); + +const responseRequiredFields = { + id, + immutable, + updated_at, + updated_by: updatedByOrNull, + created_at, + created_by: createdByOrNull, +}; +const responseOptionalFields = { + status: job_status, + status_date, + last_success_at, + last_success_message, + last_failure_at, + last_failure_message, +}; + +export const fullResponseSchema = t.intersection([ + commonResponseParams, + responseTypeSpecific, + t.exact(t.type(responseRequiredFields)), + t.exact(t.partial(responseOptionalFields)), +]); +export type FullResponseSchema = t.TypeOf; diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_bulk_schema.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_bulk_schema.test.ts index a82a3abc8c0ac..e3ad450eaa844 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_bulk_schema.test.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_bulk_schema.test.ts @@ -8,11 +8,8 @@ import { updateRulesBulkSchema, UpdateRulesBulkSchema } from './update_rules_bul import { exactCheck } from '../../../exact_check'; import { foldLeftRight } from '../../../test_utils'; import { formatErrors } from '../../../format_errors'; -import { - getUpdateRulesSchemaMock, - getUpdateRulesSchemaDecodedMock, -} from './update_rules_schema.mock'; -import { UpdateRulesSchema } from './update_rules_schema'; +import { getUpdateRulesSchemaMock } from './rule_schemas.mock'; +import { UpdateRulesSchema } from './rule_schemas'; // only the basics of testing are here. // see: update_rules_schema.test.ts for the bulk of the validation tests @@ -34,13 +31,16 @@ describe('update_rules_bulk_schema', () => { const decoded = updateRulesBulkSchema.decode(payload); const checked = exactCheck(payload, decoded); const output = foldLeftRight(checked); - expect(formatErrors(output.errors)).toEqual([ - 'Invalid value "undefined" supplied to "description"', - 'Invalid value "undefined" supplied to "risk_score"', - 'Invalid value "undefined" supplied to "name"', - 'Invalid value "undefined" supplied to "severity"', - 'Invalid value "undefined" supplied to "type"', - ]); + expect(formatErrors(output.errors)).toContain( + 'Invalid value "undefined" supplied to "description"' + ); + expect(formatErrors(output.errors)).toContain( + 'Invalid value "undefined" supplied to "risk_score"' + ); + expect(formatErrors(output.errors)).toContain('Invalid value "undefined" supplied to "name"'); + expect(formatErrors(output.errors)).toContain( + 'Invalid value "undefined" supplied to "severity"' + ); expect(output.schema).toEqual({}); }); @@ -51,7 +51,7 @@ describe('update_rules_bulk_schema', () => { const checked = exactCheck(payload, decoded); const output = foldLeftRight(checked); expect(formatErrors(output.errors)).toEqual([]); - expect(output.schema).toEqual([getUpdateRulesSchemaDecodedMock()]); + expect(output.schema).toEqual(payload); }); test('two array elements do validate', () => { @@ -61,10 +61,7 @@ describe('update_rules_bulk_schema', () => { const checked = exactCheck(payload, decoded); const output = foldLeftRight(checked); expect(formatErrors(output.errors)).toEqual([]); - expect(output.schema).toEqual([ - getUpdateRulesSchemaDecodedMock(), - getUpdateRulesSchemaDecodedMock(), - ]); + expect(output.schema).toEqual(payload); }); test('single array element with a missing value (risk_score) will not validate', () => { @@ -138,7 +135,7 @@ describe('update_rules_bulk_schema', () => { madeUpValue: 'something', }; const secondItem = getUpdateRulesSchemaMock(); - const payload: UpdateRulesBulkSchema = [singleItem, secondItem]; + const payload = [singleItem, secondItem]; const decoded = updateRulesBulkSchema.decode(payload); const checked = exactCheck(payload, decoded); @@ -180,28 +177,6 @@ describe('update_rules_bulk_schema', () => { expect(output.schema).toEqual({}); }); - test('The default for "from" will be "now-6m"', () => { - const { from, ...withoutFrom } = getUpdateRulesSchemaMock(); - const payload: UpdateRulesBulkSchema = [withoutFrom]; - - const decoded = updateRulesBulkSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const output = foldLeftRight(checked); - expect(formatErrors(output.errors)).toEqual([]); - expect((output.schema as UpdateRulesBulkSchema)[0].from).toEqual('now-6m'); - }); - - test('The default for "to" will be "now"', () => { - const { to, ...withoutTo } = getUpdateRulesSchemaMock(); - const payload: UpdateRulesBulkSchema = [withoutTo]; - - const decoded = updateRulesBulkSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const output = foldLeftRight(checked); - expect(formatErrors(output.errors)).toEqual([]); - expect((output.schema as UpdateRulesBulkSchema)[0].to).toEqual('now'); - }); - test('You cannot set the severity to a value other than low, medium, high, or critical', () => { const badSeverity = { ...getUpdateRulesSchemaMock(), severity: 'madeup' }; const payload = [badSeverity]; @@ -222,9 +197,7 @@ describe('update_rules_bulk_schema', () => { const checked = exactCheck(payload, decoded); const output = foldLeftRight(checked); expect(formatErrors(output.errors)).toEqual([]); - expect(output.schema).toEqual([ - { ...getUpdateRulesSchemaDecodedMock(), note: '# test markdown' }, - ]); + expect(output.schema).toEqual(payload); }); test('You can set "note" to an empty string', () => { @@ -234,10 +207,10 @@ describe('update_rules_bulk_schema', () => { const checked = exactCheck(payload, decoded); const output = foldLeftRight(checked); expect(formatErrors(output.errors)).toEqual([]); - expect(output.schema).toEqual([{ ...getUpdateRulesSchemaDecodedMock(), note: '' }]); + expect(output.schema).toEqual(payload); }); - test('You can set "note" to anything other than string', () => { + test('You cant set "note" to anything other than string', () => { const payload = [ { ...getUpdateRulesSchemaMock(), @@ -255,26 +228,4 @@ describe('update_rules_bulk_schema', () => { ]); expect(output.schema).toEqual({}); }); - - test('The default for "actions" will be an empty array', () => { - const { actions, ...withoutActions } = getUpdateRulesSchemaMock(); - const payload: UpdateRulesBulkSchema = [withoutActions]; - - const decoded = updateRulesBulkSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const output = foldLeftRight(checked); - expect(formatErrors(output.errors)).toEqual([]); - expect((output.schema as UpdateRulesBulkSchema)[0].actions).toEqual([]); - }); - - test('The default for "throttle" will be null', () => { - const { throttle, ...withoutThrottle } = getUpdateRulesSchemaMock(); - const payload: UpdateRulesBulkSchema = [withoutThrottle]; - - const decoded = updateRulesBulkSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const output = foldLeftRight(checked); - expect(formatErrors(output.errors)).toEqual([]); - expect((output.schema as UpdateRulesBulkSchema)[0].throttle).toEqual(null); - }); }); diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_bulk_schema.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_bulk_schema.ts index 429103c7df13e..f1d7c60991605 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_bulk_schema.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_bulk_schema.ts @@ -5,10 +5,7 @@ */ import * as t from 'io-ts'; - -import { updateRulesSchema, UpdateRulesSchemaDecoded } from './update_rules_schema'; +import { updateRulesSchema } from './rule_schemas'; export const updateRulesBulkSchema = t.array(updateRulesSchema); export type UpdateRulesBulkSchema = t.TypeOf; - -export type UpdateRulesBulkSchemaDecoded = UpdateRulesSchemaDecoded[]; diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_schema.mock.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_schema.mock.ts deleted file mode 100644 index b3fbf96188352..0000000000000 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_schema.mock.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { UpdateRulesSchema, UpdateRulesSchemaDecoded } from './update_rules_schema'; -import { DEFAULT_MAX_SIGNALS } from '../../../constants'; - -export const getUpdateRulesSchemaMock = (): UpdateRulesSchema => ({ - description: 'some description', - name: 'Query with a rule id', - query: 'user.name: root or user.name: admin', - severity: 'high', - type: 'query', - risk_score: 55, - language: 'kuery', - rule_id: 'rule-1', -}); - -export const getUpdateRulesSchemaDecodedMock = (): UpdateRulesSchemaDecoded => ({ - author: [], - description: 'some description', - name: 'Query with a rule id', - query: 'user.name: root or user.name: admin', - severity: 'high', - severity_mapping: [], - type: 'query', - risk_score: 55, - risk_score_mapping: [], - language: 'kuery', - references: [], - actions: [], - enabled: true, - false_positives: [], - from: 'now-6m', - interval: '5m', - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - to: 'now', - threat: [], - throttle: null, - exceptions_list: [], - rule_id: 'rule-1', -}); diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_schema.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_schema.test.ts deleted file mode 100644 index e3347b41ac0fa..0000000000000 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_schema.test.ts +++ /dev/null @@ -1,1628 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { - updateRulesSchema, - UpdateRulesSchema, - UpdateRulesSchemaDecoded, -} from './update_rules_schema'; -import { exactCheck } from '../../../exact_check'; -import { foldLeftRight, getPaths } from '../../../test_utils'; -import { pipe } from 'fp-ts/lib/pipeable'; -import { left } from 'fp-ts/lib/Either'; -import { - getUpdateRulesSchemaMock, - getUpdateRulesSchemaDecodedMock, -} from './update_rules_schema.mock'; -import { DEFAULT_MAX_SIGNALS } from '../../../constants'; -import { getListArrayMock } from '../types/lists.mock'; - -describe('update rules schema', () => { - test('empty objects do not validate', () => { - const payload: Partial = {}; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "description"', - 'Invalid value "undefined" supplied to "risk_score"', - 'Invalid value "undefined" supplied to "name"', - 'Invalid value "undefined" supplied to "severity"', - 'Invalid value "undefined" supplied to "type"', - ]); - expect(message.schema).toEqual({}); - }); - - test('made up values do not validate', () => { - const payload: UpdateRulesSchema & { madeUp: string } = { - ...getUpdateRulesSchemaMock(), - madeUp: 'hi', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual(['invalid keys "madeUp"']); - expect(message.schema).toEqual({}); - }); - - test('[rule_id] does not validate', () => { - const payload: Partial = { - rule_id: 'rule-1', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "description"', - 'Invalid value "undefined" supplied to "risk_score"', - 'Invalid value "undefined" supplied to "name"', - 'Invalid value "undefined" supplied to "severity"', - 'Invalid value "undefined" supplied to "type"', - ]); - expect(message.schema).toEqual({}); - }); - - test('[rule_id, description] does not validate', () => { - const payload: Partial = { - rule_id: 'rule-1', - description: 'some description', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "risk_score"', - 'Invalid value "undefined" supplied to "name"', - 'Invalid value "undefined" supplied to "severity"', - 'Invalid value "undefined" supplied to "type"', - ]); - expect(message.schema).toEqual({}); - }); - - test('[rule_id, description, from] does not validate', () => { - const payload: Partial = { - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "risk_score"', - 'Invalid value "undefined" supplied to "name"', - 'Invalid value "undefined" supplied to "severity"', - 'Invalid value "undefined" supplied to "type"', - ]); - expect(message.schema).toEqual({}); - }); - - test('[rule_id, description, from, to] does not validate', () => { - const payload: Partial = { - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "risk_score"', - 'Invalid value "undefined" supplied to "name"', - 'Invalid value "undefined" supplied to "severity"', - 'Invalid value "undefined" supplied to "type"', - ]); - expect(message.schema).toEqual({}); - }); - - test('name cannot be an empty string', () => { - const payload: UpdateRulesSchema = { - description: 'some description', - name: '', - risk_score: 50, - severity: 'low', - type: 'query', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual(['Invalid value "" supplied to "name"']); - expect(message.schema).toEqual({}); - }); - - test('description cannot be an empty string', () => { - const payload: UpdateRulesSchema = { - description: '', - name: 'rule name', - risk_score: 50, - severity: 'low', - type: 'query', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual(['Invalid value "" supplied to "description"']); - expect(message.schema).toEqual({}); - }); - - test('[rule_id, description, from, to, name] does not validate', () => { - const payload: Partial = { - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - name: 'some-name', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "risk_score"', - 'Invalid value "undefined" supplied to "severity"', - 'Invalid value "undefined" supplied to "type"', - ]); - expect(message.schema).toEqual({}); - }); - - test('[rule_id, description, from, to, name, severity] does not validate', () => { - const payload: Partial = { - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - name: 'some-name', - severity: 'low', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "risk_score"', - 'Invalid value "undefined" supplied to "type"', - ]); - expect(message.schema).toEqual({}); - }); - - test('[rule_id, description, from, to, name, severity, type] does not validate', () => { - const payload: Partial = { - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - name: 'some-name', - severity: 'low', - type: 'query', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "risk_score"', - ]); - expect(message.schema).toEqual({}); - }); - - test('[rule_id, description, from, to, name, severity, type, interval] does not validate', () => { - const payload: Partial = { - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "risk_score"', - ]); - expect(message.schema).toEqual({}); - }); - - test('[rule_id, description, from, to, name, severity, type, interval, index] does not validate', () => { - const payload: Partial = { - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - name: 'some-name', - severity: 'low', - type: 'query', - interval: '5m', - index: ['index-1'], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "risk_score"', - ]); - expect(message.schema).toEqual({}); - }); - - test('[rule_id, description, from, to, name, severity, type, query, index, interval] does validate', () => { - const payload: UpdateRulesSchema = { - rule_id: 'rule-1', - risk_score: 50, - description: 'some description', - from: 'now-5m', - to: 'now', - name: 'some-name', - severity: 'low', - type: 'query', - query: 'some query', - index: ['index-1'], - interval: '5m', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - author: [], - severity_mapping: [], - risk_score_mapping: [], - rule_id: 'rule-1', - risk_score: 50, - description: 'some description', - from: 'now-5m', - to: 'now', - name: 'some-name', - severity: 'low', - type: 'query', - query: 'some query', - index: ['index-1'], - interval: '5m', - references: [], - actions: [], - enabled: true, - false_positives: [], - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - threat: [], - throttle: null, - exceptions_list: [], - }; - expect(message.schema).toEqual(expected); - }); - - test('[rule_id, description, from, to, index, name, severity, interval, type, query, language] does not validate', () => { - const payload: Partial = { - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - query: 'some query', - language: 'kuery', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "risk_score"', - ]); - expect(message.schema).toEqual({}); - }); - - test('[rule_id, description, from, to, index, name, severity, interval, type, query, language, risk_score] does validate', () => { - const payload: UpdateRulesSchema = { - rule_id: 'rule-1', - risk_score: 50, - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - query: 'some query', - language: 'kuery', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - author: [], - severity_mapping: [], - risk_score_mapping: [], - rule_id: 'rule-1', - risk_score: 50, - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - query: 'some query', - language: 'kuery', - references: [], - actions: [], - enabled: true, - false_positives: [], - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - threat: [], - throttle: null, - exceptions_list: [], - }; - expect(message.schema).toEqual(expected); - }); - - test('[rule_id, description, from, to, index, name, severity, interval, type, query, language, risk_score, output_index] does validate', () => { - const payload: UpdateRulesSchema = { - rule_id: 'rule-1', - output_index: '.siem-signals', - risk_score: 50, - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - query: 'some query', - language: 'kuery', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - author: [], - severity_mapping: [], - risk_score_mapping: [], - rule_id: 'rule-1', - output_index: '.siem-signals', - risk_score: 50, - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - query: 'some query', - language: 'kuery', - references: [], - actions: [], - enabled: true, - false_positives: [], - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - threat: [], - throttle: null, - exceptions_list: [], - }; - expect(message.schema).toEqual(expected); - }); - - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score] does validate', () => { - const payload: UpdateRulesSchema = { - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - risk_score: 50, - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - author: [], - severity_mapping: [], - risk_score_mapping: [], - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - risk_score: 50, - references: [], - actions: [], - enabled: true, - false_positives: [], - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - threat: [], - throttle: null, - exceptions_list: [], - }; - expect(message.schema).toEqual(expected); - }); - - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, output_index] does validate', () => { - const payload: UpdateRulesSchema = { - rule_id: 'rule-1', - output_index: '.siem-signals', - risk_score: 50, - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - author: [], - severity_mapping: [], - risk_score_mapping: [], - rule_id: 'rule-1', - output_index: '.siem-signals', - risk_score: 50, - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - references: [], - actions: [], - enabled: true, - false_positives: [], - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - threat: [], - throttle: null, - exceptions_list: [], - }; - expect(message.schema).toEqual(expected); - }); - - test('You can send in an empty array to threat', () => { - const payload: UpdateRulesSchema = { - ...getUpdateRulesSchemaMock(), - threat: [], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - ...getUpdateRulesSchemaDecodedMock(), - threat: [], - }; - expect(message.schema).toEqual(expected); - }); - - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, output_index, threat] does validate', () => { - const payload: UpdateRulesSchema = { - rule_id: 'rule-1', - output_index: '.siem-signals', - risk_score: 50, - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - threat: [ - { - framework: 'someFramework', - tactic: { - id: 'fakeId', - name: 'fakeName', - reference: 'fakeRef', - }, - technique: [ - { - id: 'techniqueId', - name: 'techniqueName', - reference: 'techniqueRef', - }, - ], - }, - ], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - author: [], - severity_mapping: [], - risk_score_mapping: [], - rule_id: 'rule-1', - output_index: '.siem-signals', - risk_score: 50, - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - threat: [ - { - framework: 'someFramework', - tactic: { - id: 'fakeId', - name: 'fakeName', - reference: 'fakeRef', - }, - technique: [ - { - id: 'techniqueId', - name: 'techniqueName', - reference: 'techniqueRef', - }, - ], - }, - ], - references: [], - actions: [], - enabled: true, - false_positives: [], - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - throttle: null, - exceptions_list: [], - }; - expect(message.schema).toEqual(expected); - }); - - test('allows references to be sent as valid', () => { - const payload: UpdateRulesSchema = { - ...getUpdateRulesSchemaMock(), - references: ['index-1'], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - ...getUpdateRulesSchemaDecodedMock(), - references: ['index-1'], - }; - expect(message.schema).toEqual(expected); - }); - - test('defaults references to an array if it is not sent in', () => { - const { references, ...noReferences } = getUpdateRulesSchemaMock(); - const decoded = updateRulesSchema.decode(noReferences); - const checked = exactCheck(noReferences, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - ...getUpdateRulesSchemaDecodedMock(), - references: [], - }; - expect(message.schema).toEqual(expected); - }); - - test('references cannot be numbers', () => { - const payload: Omit & { references: number[] } = { - ...getUpdateRulesSchemaMock(), - references: [5], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to "references"']); - expect(message.schema).toEqual({}); - }); - - test('indexes cannot be numbers', () => { - const payload: Omit & { index: number[] } = { - ...getUpdateRulesSchemaMock(), - index: [5], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to "index"']); - expect(message.schema).toEqual({}); - }); - - test('defaults interval to 5 min', () => { - const { interval, ...noInterval } = getUpdateRulesSchemaMock(); - const payload: UpdateRulesSchema = { - ...noInterval, - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - - const { interval: expectedInterval, ...expectedNoInterval } = getUpdateRulesSchemaDecodedMock(); - const expected: UpdateRulesSchemaDecoded = { - ...expectedNoInterval, - interval: '5m', - }; - expect(message.schema).toEqual(expected); - }); - - test('defaults max signals to 100', () => { - // eslint-disable-next-line @typescript-eslint/naming-convention - const { max_signals, ...noMaxSignals } = getUpdateRulesSchemaMock(); - const payload: UpdateRulesSchema = { - ...noMaxSignals, - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - - const { - max_signals: expectedMaxSignals, - ...expectedNoMaxSignals - } = getUpdateRulesSchemaDecodedMock(); - const expected: UpdateRulesSchemaDecoded = { - ...expectedNoMaxSignals, - max_signals: 100, - }; - expect(message.schema).toEqual(expected); - }); - - test('saved_query type can have filters with it', () => { - const payload: UpdateRulesSchema = { - ...getUpdateRulesSchemaMock(), - filters: [], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - ...getUpdateRulesSchemaDecodedMock(), - filters: [], - }; - expect(message.schema).toEqual(expected); - }); - - test('filters cannot be a string', () => { - const payload: Omit & { filters: string } = { - ...getUpdateRulesSchemaMock(), - filters: 'some string', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "some string" supplied to "filters"', - ]); - expect(message.schema).toEqual({}); - }); - - test('language validates with kuery', () => { - const payload: UpdateRulesSchema = { - ...getUpdateRulesSchemaMock(), - language: 'kuery', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - ...getUpdateRulesSchemaDecodedMock(), - language: 'kuery', - }; - expect(message.schema).toEqual(expected); - }); - - test('language validates with lucene', () => { - const payload: UpdateRulesSchema = { - ...getUpdateRulesSchemaMock(), - language: 'lucene', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - ...getUpdateRulesSchemaDecodedMock(), - language: 'lucene', - }; - expect(message.schema).toEqual(expected); - }); - - test('language does not validate with something made up', () => { - const payload: Omit & { language: string } = { - ...getUpdateRulesSchemaMock(), - language: 'something-made-up', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "something-made-up" supplied to "language"', - ]); - expect(message.schema).toEqual({}); - }); - - test('max_signals cannot be negative', () => { - const payload: UpdateRulesSchema = { - ...getUpdateRulesSchemaMock(), - max_signals: -1, - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "-1" supplied to "max_signals"', - ]); - expect(message.schema).toEqual({}); - }); - - test('max_signals cannot be zero', () => { - const payload: UpdateRulesSchema = { - ...getUpdateRulesSchemaMock(), - max_signals: 0, - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual(['Invalid value "0" supplied to "max_signals"']); - expect(message.schema).toEqual({}); - }); - - test('max_signals can be 1', () => { - const payload: UpdateRulesSchema = { - ...getUpdateRulesSchemaMock(), - max_signals: 1, - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - ...getUpdateRulesSchemaDecodedMock(), - max_signals: 1, - }; - expect(message.schema).toEqual(expected); - }); - - test('You can optionally send in an array of tags', () => { - const payload: UpdateRulesSchema = { - ...getUpdateRulesSchemaMock(), - tags: ['tag_1', 'tag_2'], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - ...getUpdateRulesSchemaDecodedMock(), - tags: ['tag_1', 'tag_2'], - }; - expect(message.schema).toEqual(expected); - }); - - test('You cannot send in an array of tags that are numbers', () => { - const payload: Omit & { tags: number[] } = { - ...getUpdateRulesSchemaMock(), - tags: [0, 1, 2], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "0" supplied to "tags"', - 'Invalid value "1" supplied to "tags"', - 'Invalid value "2" supplied to "tags"', - ]); - expect(message.schema).toEqual({}); - }); - - test('You cannot send in an array of threat that are missing "framework"', () => { - const payload: Omit & { - threat: Array>>; - } = { - ...getUpdateRulesSchemaMock(), - threat: [ - { - tactic: { - id: 'fakeId', - name: 'fakeName', - reference: 'fakeRef', - }, - technique: [ - { - id: 'techniqueId', - name: 'techniqueName', - reference: 'techniqueRef', - }, - ], - }, - ], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "threat,framework"', - ]); - expect(message.schema).toEqual({}); - }); - - test('You cannot send in an array of threat that are missing "tactic"', () => { - const payload: Omit & { - threat: Array>>; - } = { - ...getUpdateRulesSchemaMock(), - threat: [ - { - framework: 'fake', - technique: [ - { - id: 'techniqueId', - name: 'techniqueName', - reference: 'techniqueRef', - }, - ], - }, - ], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "threat,tactic"', - ]); - expect(message.schema).toEqual({}); - }); - - test('You cannot send in an array of threat that are missing "technique"', () => { - const payload: Omit & { - threat: Array>>; - } = { - ...getUpdateRulesSchemaMock(), - threat: [ - { - framework: 'fake', - tactic: { - id: 'fakeId', - name: 'fakeName', - reference: 'fakeRef', - }, - }, - ], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "threat,technique"', - ]); - expect(message.schema).toEqual({}); - }); - - test('You can optionally send in an array of false positives', () => { - const payload: UpdateRulesSchema = { - ...getUpdateRulesSchemaMock(), - false_positives: ['false_1', 'false_2'], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - ...getUpdateRulesSchemaDecodedMock(), - false_positives: ['false_1', 'false_2'], - }; - expect(message.schema).toEqual(expected); - }); - - test('You cannot send in an array of false positives that are numbers', () => { - const payload: Omit & { false_positives: number[] } = { - ...getUpdateRulesSchemaMock(), - false_positives: [5, 4], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "5" supplied to "false_positives"', - 'Invalid value "4" supplied to "false_positives"', - ]); - expect(message.schema).toEqual({}); - }); - - test('You cannot set the immutable to a number when trying to update a rule', () => { - const payload: Omit & { immutable: number } = { - ...getUpdateRulesSchemaMock(), - immutable: 5, - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual(['invalid keys "immutable"']); - expect(message.schema).toEqual({}); - }); - - test('You cannot set the risk_score to 101', () => { - const payload: UpdateRulesSchema = { - ...getUpdateRulesSchemaMock(), - risk_score: 101, - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "101" supplied to "risk_score"', - ]); - expect(message.schema).toEqual({}); - }); - - test('You cannot set the risk_score to -1', () => { - const payload: UpdateRulesSchema = { - ...getUpdateRulesSchemaMock(), - risk_score: -1, - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual(['Invalid value "-1" supplied to "risk_score"']); - expect(message.schema).toEqual({}); - }); - - test('You can set the risk_score to 0', () => { - const payload: UpdateRulesSchema = { - ...getUpdateRulesSchemaMock(), - risk_score: 0, - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - ...getUpdateRulesSchemaDecodedMock(), - risk_score: 0, - }; - expect(message.schema).toEqual(expected); - }); - - test('You can set the risk_score to 100', () => { - const payload: UpdateRulesSchema = { - ...getUpdateRulesSchemaMock(), - risk_score: 100, - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - ...getUpdateRulesSchemaDecodedMock(), - risk_score: 100, - }; - expect(message.schema).toEqual(expected); - }); - - test('You can set meta to any object you want', () => { - const payload: UpdateRulesSchema = { - ...getUpdateRulesSchemaMock(), - meta: { - somethingMadeUp: { somethingElse: true }, - }, - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - ...getUpdateRulesSchemaDecodedMock(), - meta: { - somethingMadeUp: { somethingElse: true }, - }, - }; - expect(message.schema).toEqual(expected); - }); - - test('You cannot update meta as a string', () => { - const payload: Omit & { meta: string } = { - ...getUpdateRulesSchemaMock(), - meta: 'should not work', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "should not work" supplied to "meta"', - ]); - expect(message.schema).toEqual({}); - }); - - test('You can omit the query string when filters are present', () => { - const { query, ...noQuery } = getUpdateRulesSchemaMock(); - const payload: UpdateRulesSchema = { - ...noQuery, - filters: [], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - - const { query: expectedQuery, ...expectedNoQuery } = getUpdateRulesSchemaDecodedMock(); - const expected: UpdateRulesSchemaDecoded = { - ...expectedNoQuery, - filters: [], - }; - expect(message.schema).toEqual(expected); - }); - - test('validates with timeline_id and timeline_title', () => { - const payload: UpdateRulesSchema = { - ...getUpdateRulesSchemaMock(), - timeline_id: 'timeline-id', - timeline_title: 'timeline-title', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - ...getUpdateRulesSchemaDecodedMock(), - timeline_id: 'timeline-id', - timeline_title: 'timeline-title', - }; - expect(message.schema).toEqual(expected); - }); - - test('The default for "from" will be "now-6m"', () => { - const { from, ...noFrom } = getUpdateRulesSchemaMock(); - const payload: UpdateRulesSchema = { - ...noFrom, - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - - const { from: expectedFrom, ...expectedNoFrom } = getUpdateRulesSchemaDecodedMock(); - const expected: UpdateRulesSchemaDecoded = { - ...expectedNoFrom, - from: 'now-6m', - }; - expect(message.schema).toEqual(expected); - }); - - test('The default for "to" will be "now"', () => { - const { to, ...noTo } = getUpdateRulesSchemaMock(); - const payload: UpdateRulesSchema = { - ...noTo, - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - - const { to: expectedTo, ...expectedNoTo } = getUpdateRulesSchemaDecodedMock(); - const expected: UpdateRulesSchemaDecoded = { - ...expectedNoTo, - to: 'now', - }; - expect(message.schema).toEqual(expected); - }); - - test('You cannot set the severity to a value other than low, medium, high, or critical', () => { - const payload: Omit & { severity: string } = { - ...getUpdateRulesSchemaMock(), - severity: 'junk', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual(['Invalid value "junk" supplied to "severity"']); - expect(message.schema).toEqual({}); - }); - - test('The default for "actions" will be an empty array', () => { - const { actions, ...noActions } = getUpdateRulesSchemaMock(); - const payload: UpdateRulesSchema = { - ...noActions, - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - - const { actions: expectedActions, ...expectedNoActions } = getUpdateRulesSchemaDecodedMock(); - const expected: UpdateRulesSchemaDecoded = { - ...expectedNoActions, - actions: [], - }; - expect(message.schema).toEqual(expected); - }); - - test('You cannot send in an array of actions that are missing "group"', () => { - const payload: Omit = { - ...getUpdateRulesSchemaMock(), - actions: [{ id: 'id', action_type_id: 'action_type_id', params: {} }], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "actions,group"', - ]); - expect(message.schema).toEqual({}); - }); - - test('You cannot send in an array of actions that are missing "id"', () => { - const payload: Omit = { - ...getUpdateRulesSchemaMock(), - actions: [{ group: 'group', action_type_id: 'action_type_id', params: {} }], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "actions,id"', - ]); - expect(message.schema).toEqual({}); - }); - - test('You cannot send in an array of actions that are missing "action_type_id"', () => { - const payload: Omit = { - ...getUpdateRulesSchemaMock(), - actions: [{ group: 'group', id: 'id', params: {} }], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "actions,action_type_id"', - ]); - expect(message.schema).toEqual({}); - }); - - test('You cannot send in an array of actions that are missing "params"', () => { - const payload: Omit = { - ...getUpdateRulesSchemaMock(), - actions: [{ group: 'group', id: 'id', action_type_id: 'action_type_id' }], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "actions,params"', - ]); - expect(message.schema).toEqual({}); - }); - - test('You cannot send in an array of actions that are including "actionTypeId"', () => { - const payload: Omit = { - ...getUpdateRulesSchemaMock(), - actions: [ - { - group: 'group', - id: 'id', - actionTypeId: 'actionTypeId', - params: {}, - }, - ], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "actions,action_type_id"', - ]); - expect(message.schema).toEqual({}); - }); - - test('The default for "throttle" will be null', () => { - const { throttle, ...noThrottle } = getUpdateRulesSchemaMock(); - const payload: UpdateRulesSchema = { - ...noThrottle, - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - - const { throttle: expectedThrottle, ...expectedNoThrottle } = getUpdateRulesSchemaDecodedMock(); - const expected: UpdateRulesSchemaDecoded = { - ...expectedNoThrottle, - throttle: null, - }; - expect(message.schema).toEqual(expected); - }); - - describe('note', () => { - test('You can set note to a string', () => { - const payload: UpdateRulesSchema = { - ...getUpdateRulesSchemaMock(), - note: '# documentation markdown here', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - ...getUpdateRulesSchemaDecodedMock(), - note: '# documentation markdown here', - }; - expect(message.schema).toEqual(expected); - }); - - test('You can set note to an empty string', () => { - const payload: UpdateRulesSchema = { - ...getUpdateRulesSchemaMock(), - note: '', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - ...getUpdateRulesSchemaDecodedMock(), - note: '', - }; - expect(message.schema).toEqual(expected); - }); - - // Note: If you're looking to remove `note`, omit `note` entirely - test('You cannot set note to null', () => { - const payload: Omit & { note: null } = { - ...getUpdateRulesSchemaMock(), - note: null, - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual(['Invalid value "null" supplied to "note"']); - expect(message.schema).toEqual({}); - }); - - test('You cannot set note as an object', () => { - const payload: Omit & { note: {} } = { - ...getUpdateRulesSchemaMock(), - note: { - somethingHere: 'something else', - }, - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "{"somethingHere":"something else"}" supplied to "note"', - ]); - expect(message.schema).toEqual({}); - }); - - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note] does validate', () => { - const payload: UpdateRulesSchema = { - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - risk_score: 50, - note: '# some markdown', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - author: [], - severity_mapping: [], - risk_score_mapping: [], - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - risk_score: 50, - note: '# some markdown', - references: [], - actions: [], - enabled: true, - false_positives: [], - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - threat: [], - throttle: null, - exceptions_list: [], - }; - expect(message.schema).toEqual(expected); - }); - }); - - describe('exception_list', () => { - test('[rule_id, description, from, to, index, name, severity, interval, type, filters, risk_score, note, and exceptions_list] does validate', () => { - const payload: UpdateRulesSchema = { - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - risk_score: 50, - filters: [], - note: '# some markdown', - exceptions_list: getListArrayMock(), - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - author: [], - severity_mapping: [], - risk_score_mapping: [], - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - risk_score: 50, - note: '# some markdown', - references: [], - actions: [], - enabled: true, - false_positives: [], - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - threat: [], - throttle: null, - filters: [], - exceptions_list: [ - { - id: 'some_uuid', - list_id: 'list_id_single', - namespace_type: 'single', - type: 'detection', - }, - { - id: 'endpoint_list', - list_id: 'endpoint_list', - namespace_type: 'agnostic', - type: 'endpoint', - }, - ], - }; - expect(message.schema).toEqual(expected); - }); - - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and empty exceptions_list] does validate', () => { - const payload: UpdateRulesSchema = { - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - risk_score: 50, - filters: [], - note: '# some markdown', - exceptions_list: [], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - author: [], - severity_mapping: [], - risk_score_mapping: [], - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - risk_score: 50, - note: '# some markdown', - references: [], - actions: [], - enabled: true, - false_positives: [], - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - threat: [], - throttle: null, - filters: [], - exceptions_list: [], - }; - expect(message.schema).toEqual(expected); - }); - - test('rule_id, description, from, to, index, name, severity, interval, type, filters, risk_score, note, and invalid exceptions_list] does NOT validate', () => { - const payload: Omit & { - exceptions_list: Array<{ id: string; namespace_type: string }>; - } = { - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - risk_score: 50, - filters: [], - note: '# some markdown', - exceptions_list: [{ id: 'uuid_here', namespace_type: 'not a namespace type' }], - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "undefined" supplied to "exceptions_list,list_id"', - 'Invalid value "undefined" supplied to "exceptions_list,type"', - 'Invalid value "not a namespace type" supplied to "exceptions_list,namespace_type"', - ]); - expect(message.schema).toEqual({}); - }); - - test('[rule_id, description, from, to, index, name, severity, interval, type, filters, risk_score, note, and non-existent exceptions_list] does validate with empty exceptions_list', () => { - const payload: UpdateRulesSchema = { - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - risk_score: 50, - filters: [], - note: '# some markdown', - }; - - const decoded = updateRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - const expected: UpdateRulesSchemaDecoded = { - author: [], - severity_mapping: [], - risk_score_mapping: [], - rule_id: 'rule-1', - description: 'some description', - from: 'now-5m', - to: 'now', - index: ['index-1'], - name: 'some-name', - severity: 'low', - interval: '5m', - type: 'query', - risk_score: 50, - note: '# some markdown', - references: [], - actions: [], - enabled: true, - false_positives: [], - max_signals: DEFAULT_MAX_SIGNALS, - tags: [], - threat: [], - throttle: null, - exceptions_list: [], - filters: [], - }; - expect(message.schema).toEqual(expected); - }); - }); -}); diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_schema.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_schema.ts deleted file mode 100644 index 5d759fc12cd52..0000000000000 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_schema.ts +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import * as t from 'io-ts'; - -import { - description, - anomaly_threshold, - filters, - RuleId, - index, - output_index, - saved_id, - timeline_id, - timeline_title, - meta, - machine_learning_job_id, - risk_score, - rule_id, - MaxSignals, - name, - severity, - Tags, - To, - type, - Threat, - threshold, - ThrottleOrNull, - note, - version, - References, - Actions, - Enabled, - FalsePositives, - From, - Interval, - language, - query, - id, - building_block_type, - license, - rule_name_override, - timestamp_override, - Author, - RiskScoreMapping, - SeverityMapping, - event_category_override, -} from '../common/schemas'; -import { - threat_index, - concurrent_searches, - items_per_search, - threat_query, - threat_filters, - threat_mapping, - threat_language, -} from '../types/threat_mapping'; - -import { - DefaultStringArray, - DefaultActionsArray, - DefaultBooleanTrue, - DefaultFromString, - DefaultIntervalString, - DefaultMaxSignalsNumber, - DefaultToString, - DefaultThreatArray, - DefaultThrottleNull, - DefaultListArray, - ListArray, - DefaultRiskScoreMappingArray, - DefaultSeverityMappingArray, -} from '../types'; - -/** - * This almost identical to the create_rules_schema except for a few details. - * - The version will not be defaulted to a 1. If it is not given then its default will become the previous version auto-incremented - * This does break idempotency slightly as calls repeatedly without it will increment the number. If the version number is passed in - * this will update the rule's version number. - * - id is on here because you can pass in an id to update using it instead of rule_id. - */ -export const updateRulesSchema = t.intersection([ - t.exact( - t.type({ - description, - risk_score, - name, - severity, - type, - }) - ), - t.exact( - t.partial({ - id, // defaults to "undefined" if not set during decode - actions: DefaultActionsArray, // defaults to empty actions array if not set during decode - anomaly_threshold, // defaults to undefined if not set during decode - author: DefaultStringArray, // defaults to empty array of strings if not set during decode - building_block_type, // defaults to undefined if not set during decode - enabled: DefaultBooleanTrue, // defaults to true if not set during decode - event_category_override, - false_positives: DefaultStringArray, // defaults to empty string array if not set during decode - filters, // defaults to undefined if not set during decode - from: DefaultFromString, // defaults to "now-6m" if not set during decode - rule_id, // defaults to "undefined" if not set during decode - index, // defaults to undefined if not set during decode - interval: DefaultIntervalString, // defaults to "5m" if not set during decode - query, // defaults to undefined if not set during decode - language, // defaults to undefined if not set during decode - license, // defaults to "undefined" if not set during decode - // TODO: output_index: This should be removed eventually - output_index, // defaults to "undefined" if not set during decode - saved_id, // defaults to "undefined" if not set during decode - timeline_id, // defaults to "undefined" if not set during decode - timeline_title, // defaults to "undefined" if not set during decode - meta, // defaults to "undefined" if not set during decode - machine_learning_job_id, // defaults to "undefined" if not set during decode - max_signals: DefaultMaxSignalsNumber, // defaults to DEFAULT_MAX_SIGNALS (100) if not set during decode - risk_score_mapping: DefaultRiskScoreMappingArray, // defaults to empty risk score mapping array if not set during decode - rule_name_override, // defaults to "undefined" if not set during decode - severity_mapping: DefaultSeverityMappingArray, // defaults to empty actions array if not set during decode - tags: DefaultStringArray, // defaults to empty string array if not set during decode - to: DefaultToString, // defaults to "now" if not set during decode - threat: DefaultThreatArray, // defaults to empty array if not set during decode - threshold, // defaults to "undefined" if not set during decode - throttle: DefaultThrottleNull, // defaults to "null" if not set during decode - timestamp_override, // defaults to "undefined" if not set during decode - references: DefaultStringArray, // defaults to empty array of strings if not set during decode - note, // defaults to "undefined" if not set during decode - version, // defaults to "undefined" if not set during decode - exceptions_list: DefaultListArray, // defaults to empty array if not set during decode - threat_mapping, // defaults to "undefined" if not set during decode - threat_query, // defaults to "undefined" if not set during decode - threat_filters, // defaults to "undefined" if not set during decode - threat_index, // defaults to "undefined" if not set during decode - threat_language, // defaults "undefined" if not set during decode - concurrent_searches, // defaults to "undefined" if not set during decode - items_per_search, // defaults to "undefined" if not set during decode - }) - ), -]); - -export type UpdateRulesSchema = t.TypeOf; - -// This type is used after a decode since some things are defaults after a decode. -export type UpdateRulesSchemaDecoded = Omit< - UpdateRulesSchema, - | 'author' - | 'references' - | 'actions' - | 'enabled' - | 'false_positives' - | 'from' - | 'interval' - | 'max_signals' - | 'risk_score_mapping' - | 'severity_mapping' - | 'tags' - | 'to' - | 'threat' - | 'throttle' - | 'exceptions_list' - | 'rule_id' -> & { - author: Author; - references: References; - actions: Actions; - enabled: Enabled; - false_positives: FalsePositives; - from: From; - interval: Interval; - max_signals: MaxSignals; - risk_score_mapping: RiskScoreMapping; - severity_mapping: SeverityMapping; - tags: Tags; - to: To; - threat: Threat; - throttle: ThrottleOrNull; - exceptions_list: ListArray; - rule_id: RuleId; -}; diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_type_dependents.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_type_dependents.test.ts index 91b11ea758e93..c246a1bff9f64 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_type_dependents.test.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_type_dependents.test.ts @@ -4,28 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getUpdateRulesSchemaMock } from './update_rules_schema.mock'; -import { UpdateRulesSchema } from './update_rules_schema'; +import { getUpdateRulesSchemaMock } from './rule_schemas.mock'; +import { UpdateRulesSchema } from './rule_schemas'; import { updateRuleValidateTypeDependents } from './update_rules_type_dependents'; describe('update_rules_type_dependents', () => { - test('saved_id is required when type is saved_query and will not validate without out', () => { - const schema: UpdateRulesSchema = { ...getUpdateRulesSchemaMock(), type: 'saved_query' }; - delete schema.saved_id; - const errors = updateRuleValidateTypeDependents(schema); - expect(errors).toEqual(['when "type" is "saved_query", "saved_id" is required']); - }); - - test('saved_id is required when type is saved_query and validates with it', () => { - const schema: UpdateRulesSchema = { - ...getUpdateRulesSchemaMock(), - type: 'saved_query', - saved_id: '123', - }; - const errors = updateRuleValidateTypeDependents(schema); - expect(errors).toEqual([]); - }); - test('You cannot omit timeline_title when timeline_id is present', () => { const schema: UpdateRulesSchema = { ...getUpdateRulesSchemaMock(), @@ -85,26 +68,4 @@ describe('update_rules_type_dependents', () => { const errors = updateRuleValidateTypeDependents(schema); expect(errors).toEqual(['either "id" or "rule_id" must be set']); }); - - test('threshold is required when type is threshold and validates with it', () => { - const schema: UpdateRulesSchema = { - ...getUpdateRulesSchemaMock(), - type: 'threshold', - }; - const errors = updateRuleValidateTypeDependents(schema); - expect(errors).toEqual(['when "type" is "threshold", "threshold" is required']); - }); - - test('threshold.value is required and has to be bigger than 0 when type is threshold and validates with it', () => { - const schema: UpdateRulesSchema = { - ...getUpdateRulesSchemaMock(), - type: 'threshold', - threshold: { - field: '', - value: -1, - }, - }; - const errors = updateRuleValidateTypeDependents(schema); - expect(errors).toEqual(['"threshold.value" has to be bigger than 0']); - }); }); diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_type_dependents.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_type_dependents.ts index 5f297fb9688fc..e68ffd7925709 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_type_dependents.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_type_dependents.ts @@ -4,69 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { isMlRule } from '../../../machine_learning/helpers'; -import { isThresholdRule } from '../../utils'; -import { UpdateRulesSchema } from './update_rules_schema'; - -export const validateAnomalyThreshold = (rule: UpdateRulesSchema): string[] => { - if (isMlRule(rule.type)) { - if (rule.anomaly_threshold == null) { - return ['when "type" is "machine_learning" anomaly_threshold is required']; - } else { - return []; - } - } else { - return []; - } -}; - -export const validateQuery = (rule: UpdateRulesSchema): string[] => { - if (isMlRule(rule.type)) { - if (rule.query != null) { - return ['when "type" is "machine_learning", "query" cannot be set']; - } else { - return []; - } - } else { - return []; - } -}; - -export const validateLanguage = (rule: UpdateRulesSchema): string[] => { - if (isMlRule(rule.type)) { - if (rule.language != null) { - return ['when "type" is "machine_learning", "language" cannot be set']; - } else { - return []; - } - } else { - return []; - } -}; - -export const validateSavedId = (rule: UpdateRulesSchema): string[] => { - if (rule.type === 'saved_query') { - if (rule.saved_id == null) { - return ['when "type" is "saved_query", "saved_id" is required']; - } else { - return []; - } - } else { - return []; - } -}; - -export const validateMachineLearningJobId = (rule: UpdateRulesSchema): string[] => { - if (isMlRule(rule.type)) { - if (rule.machine_learning_job_id == null) { - return ['when "type" is "machine_learning", "machine_learning_job_id" is required']; - } else { - return []; - } - } else { - return []; - } -}; +import { UpdateRulesSchema } from './rule_schemas'; export const validateTimelineId = (rule: UpdateRulesSchema): string[] => { if (rule.timeline_id != null) { @@ -104,29 +42,6 @@ export const validateId = (rule: UpdateRulesSchema): string[] => { } }; -export const validateThreshold = (rule: UpdateRulesSchema): string[] => { - if (isThresholdRule(rule.type)) { - if (!rule.threshold) { - return ['when "type" is "threshold", "threshold" is required']; - } else if (rule.threshold.value <= 0) { - return ['"threshold.value" has to be bigger than 0']; - } else { - return []; - } - } - return []; -}; - export const updateRuleValidateTypeDependents = (schema: UpdateRulesSchema): string[] => { - return [ - ...validateId(schema), - ...validateAnomalyThreshold(schema), - ...validateQuery(schema), - ...validateLanguage(schema), - ...validateSavedId(schema), - ...validateMachineLearningJobId(schema), - ...validateTimelineId(schema), - ...validateTimelineTitle(schema), - ...validateThreshold(schema), - ]; + return [...validateId(schema), ...validateTimelineId(schema), ...validateTimelineTitle(schema)]; }; diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/index.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/index.ts index e76dd3fca3740..de0625e6b5817 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/index.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/index.ts @@ -28,6 +28,7 @@ export * from './default_version_number'; export * from './iso_date_string'; export * from './lists'; export * from './lists_default_array'; +export * from './non_empty_array'; export * from './non_empty_string'; export * from './only_false_allowed'; export * from './positive_integer'; diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/non_empty_array.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/non_empty_array.test.ts new file mode 100644 index 0000000000000..299cc92407983 --- /dev/null +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/non_empty_array.test.ts @@ -0,0 +1,94 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import * as t from 'io-ts'; + +import { NonEmptyArray } from './non_empty_array'; +import { pipe } from 'fp-ts/lib/pipeable'; +import { left } from 'fp-ts/lib/Either'; +import { foldLeftRight, getPaths } from '../../../test_utils'; + +const testSchema = t.keyof({ + valid: true, + also_valid: true, +}); +type TestSchema = t.TypeOf; + +const nonEmptyArraySchema = NonEmptyArray(testSchema, 'TestSchemaArray'); + +describe('non empty array', () => { + test('it should generate the correct name for non empty array', () => { + const newTestSchema = NonEmptyArray(testSchema); + expect(newTestSchema.name).toEqual('NonEmptyArray<"valid" | "also_valid">'); + }); + + test('it should use a supplied name override', () => { + const newTestSchema = NonEmptyArray(testSchema, 'someName'); + expect(newTestSchema.name).toEqual('someName'); + }); + + test('it should NOT validate an empty array', () => { + const payload: string[] = []; + const decoded = nonEmptyArraySchema.decode(payload); + const message = pipe(decoded, foldLeftRight); + + expect(getPaths(left(message.errors))).toEqual([ + 'Invalid value "[]" supplied to "TestSchemaArray"', + ]); + expect(message.schema).toEqual({}); + }); + + test('it should validate an array of testSchema', () => { + const payload: TestSchema[] = ['valid']; + const decoded = nonEmptyArraySchema.decode(payload); + const message = pipe(decoded, foldLeftRight); + + expect(getPaths(left(message.errors))).toEqual([]); + expect(message.schema).toEqual(payload); + }); + + test('it should validate an array of valid testSchema strings', () => { + const payload: TestSchema[] = ['valid', 'also_valid']; + const decoded = nonEmptyArraySchema.decode(payload); + const message = pipe(decoded, foldLeftRight); + + expect(getPaths(left(message.errors))).toEqual([]); + expect(message.schema).toEqual(payload); + }); + + test('it should not validate an array with a number', () => { + const payload = ['valid', 123]; + const decoded = nonEmptyArraySchema.decode(payload); + const message = pipe(decoded, foldLeftRight); + + expect(getPaths(left(message.errors))).toEqual([ + 'Invalid value "123" supplied to "TestSchemaArray"', + ]); + expect(message.schema).toEqual({}); + }); + + test('it should not validate an array with an invalid string', () => { + const payload = ['valid', 'invalid']; + const decoded = nonEmptyArraySchema.decode(payload); + const message = pipe(decoded, foldLeftRight); + + expect(getPaths(left(message.errors))).toEqual([ + 'Invalid value "invalid" supplied to "TestSchemaArray"', + ]); + expect(message.schema).toEqual({}); + }); + + test('it should not validate a null value', () => { + const payload = null; + const decoded = nonEmptyArraySchema.decode(payload); + const message = pipe(decoded, foldLeftRight); + + expect(getPaths(left(message.errors))).toEqual([ + 'Invalid value "null" supplied to "TestSchemaArray"', + ]); + expect(message.schema).toEqual({}); + }); +}); diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/non_empty_array.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/non_empty_array.ts new file mode 100644 index 0000000000000..433ee5a4bf080 --- /dev/null +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/non_empty_array.ts @@ -0,0 +1,28 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import * as t from 'io-ts'; +import { Either } from 'fp-ts/lib/Either'; + +export const NonEmptyArray = ( + codec: C, + name: string = `NonEmptyArray<${codec.name}>` +) => { + const arrType = t.array(codec); + type ArrType = t.TypeOf; + return new t.Type( + name, + arrType.is, + (input, context): Either => { + if (Array.isArray(input) && input.length === 0) { + return t.failure(input, context); + } else { + return arrType.validate(input, context); + } + }, + t.identity + ); +}; diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/threat_mapping.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/threat_mapping.test.ts index d8f61e4309b17..d3e8b95e69c3a 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/threat_mapping.test.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/threat_mapping.test.ts @@ -176,6 +176,19 @@ describe('threat_mapping', () => { expect(message.schema).toEqual({}); }); + test('it should fail validate with empty array', () => { + const payload: string[] = []; + + const decoded = threat_mapping.decode(payload); + const checked = exactCheck(payload, decoded); + const message = pipe(checked, foldLeftRight); + + expect(getPaths(left(message.errors))).toEqual([ + 'Invalid value "[]" supplied to "NonEmptyArray"', + ]); + expect(message.schema).toEqual({}); + }); + test('it should fail validation when concurrent_searches is < 0', () => { const payload = -1; const decoded = concurrent_searches.decode(payload); diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/threat_mapping.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/threat_mapping.ts index dec8ddd000132..ad54d05863ad3 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/threat_mapping.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/threat_mapping.ts @@ -8,6 +8,7 @@ import * as t from 'io-ts'; import { language } from '../common/schemas'; +import { NonEmptyArray } from './non_empty_array'; import { NonEmptyString } from './non_empty_string'; import { PositiveIntegerGreaterThanZero } from './positive_integer_greater_than_zero'; @@ -41,7 +42,7 @@ export const threatMap = t.exact( ); export type ThreatMap = t.TypeOf; -export const threat_mapping = t.array(threatMap); +export const threat_mapping = NonEmptyArray(threatMap, 'NonEmptyArray'); export type ThreatMapping = t.TypeOf; export const threatMappingOrUndefined = t.union([threat_mapping, t.undefined]); diff --git a/x-pack/plugins/security_solution/cypress/integration/timeline_template_creation.spec.ts b/x-pack/plugins/security_solution/cypress/integration/timeline_template_creation.spec.ts index 377b2100b36cd..74576f53242aa 100644 --- a/x-pack/plugins/security_solution/cypress/integration/timeline_template_creation.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/timeline_template_creation.spec.ts @@ -43,7 +43,8 @@ import { openTimeline } from '../tasks/timelines'; import { OVERVIEW_URL } from '../urls/navigation'; -describe('Timeline Templates', () => { +// FLAKY: https://github.com/elastic/kibana/issues/79967 +describe.skip('Timeline Templates', () => { before(() => { cy.server(); cy.route('PATCH', '**/api/timeline').as('timeline'); diff --git a/x-pack/plugins/security_solution/public/common/components/empty_value/empty_value.test.tsx b/x-pack/plugins/security_solution/public/common/components/empty_value/empty_value.test.tsx index fc1d30907ab09..3920c53e3dc22 100644 --- a/x-pack/plugins/security_solution/public/common/components/empty_value/empty_value.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/empty_value/empty_value.test.tsx @@ -8,7 +8,7 @@ import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; import { mount, shallow } from 'enzyme'; import React from 'react'; import { ThemeProvider } from 'styled-components'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { defaultToEmptyTag, diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/error_callout.test.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/error_callout.test.tsx index 9c86c502a7648..0659ce8eb227a 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/error_callout.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/error_callout.test.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { ThemeProvider } from 'styled-components'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import euiLightVars from '@elastic/eui/dist/eui_theme_light.json'; import { coreMock } from '../../../../../../../src/core/public/mocks'; diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/exceptions_utility.test.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/exceptions_utility.test.tsx index 6927ecec788fb..ff2181f21d362 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/exceptions_utility.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/exceptions_utility.test.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { ThemeProvider } from 'styled-components'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import euiLightVars from '@elastic/eui/dist/eui_theme_light.json'; import { ExceptionsViewerUtility } from './exceptions_utility'; diff --git a/x-pack/plugins/security_solution/public/common/components/links/index.test.tsx b/x-pack/plugins/security_solution/public/common/components/links/index.test.tsx index e6d34b5e432ac..2ae5b1d20c3c3 100644 --- a/x-pack/plugins/security_solution/public/common/components/links/index.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/links/index.test.tsx @@ -6,7 +6,7 @@ import { mount, shallow, ShallowWrapper } from 'enzyme'; import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { encodeIpv6 } from '../../lib/helpers'; import { useUiSetting$ } from '../../lib/kibana'; diff --git a/x-pack/plugins/security_solution/public/common/components/ml_popover/ml_popover.test.tsx b/x-pack/plugins/security_solution/public/common/components/ml_popover/ml_popover.test.tsx index cbd2fdf235ce5..bbf7b91514aeb 100644 --- a/x-pack/plugins/security_solution/public/common/components/ml_popover/ml_popover.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/ml_popover/ml_popover.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { MlPopover } from './ml_popover'; diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/step_define_rule/index.tsx b/x-pack/plugins/security_solution/public/detections/components/rules/step_define_rule/index.tsx index 8a5966c71aa28..f06d4bdef74cb 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/step_define_rule/index.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/rules/step_define_rule/index.tsx @@ -88,6 +88,17 @@ const stepDefineDefaultValue: DefineStepRule = { }, }; +/** + * This default query will be used for threat query/indicator matches + * as the default when the user swaps to using it by changing their + * rule type from any rule type to the "threatMatchRule" type. Only + * difference is that "*:*" is used instead of '' for its query. + */ +const threatQueryBarDefaultValue: DefineStepRule['queryBar'] = { + ...stepDefineDefaultValue.queryBar, + query: { ...stepDefineDefaultValue.queryBar.query, query: '*:*' }, +}; + const MyLabelButton = styled(EuiButtonEmpty)` height: 18px; font-size: 12px; @@ -171,6 +182,38 @@ const StepDefineRuleComponent: FC = ({ setIndexModified(!isEqual(index, indicesConfig)); }, [index, indicesConfig]); + /** + * When a rule type is changed to or from a threat match this will modify the + * default query string to either: + * * from the empty string '' to '*:*' if the rule type is "threatMatchRule" + * * from '*:*' back to the empty string '' if the rule type is not "threatMatchRule" + * This calls queryBar.reset() in both cases to not trigger validation errors as + * the user has not entered data into those areas yet. + * If the user has entered data then through reference compares we can detect reliably if + * the user has changed data. + * * queryBar.value === defaultQueryBar (Has the user changed the input of '' yet?) + * * queryBar.value === threatQueryBarDefaultValue (Has the user changed the input of '*:*' yet?) + * This is a stronger guarantee than "isPristine" off of the forms as that value can be reset + * if you go to step 2) and then back to step 1) or the form is reset in another way. Using + * the reference compare we know factually if the data is changed as the references must change + * in the form libraries form the initial defaults. + */ + useEffect(() => { + const { queryBar } = getFields(); + if (queryBar != null) { + const { queryBar: defaultQueryBar } = stepDefineDefaultValue; + if (isThreatMatchRule(ruleType) && queryBar.value === defaultQueryBar) { + queryBar.reset({ + defaultValue: threatQueryBarDefaultValue, + }); + } else if (queryBar.value === threatQueryBarDefaultValue) { + queryBar.reset({ + defaultValue: defaultQueryBar, + }); + } + } + }, [ruleType, getFields]); + const handleSubmit = useCallback(() => { if (onSubmit) { onSubmit(); diff --git a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/api.test.ts b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/api.test.ts index 0b708133d947b..e94cc8845c5a5 100644 --- a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/api.test.ts +++ b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/api.test.ts @@ -22,8 +22,10 @@ import { getPrePackagedRulesStatus, } from './api'; import { getRulesSchemaMock } from '../../../../../common/detection_engine/schemas/response/rules_schema.mocks'; -import { getCreateRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/create_rules_schema.mock'; -import { getUpdateRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/update_rules_schema.mock'; +import { + getCreateRulesSchemaMock, + getUpdateRulesSchemaMock, +} from '../../../../../common/detection_engine/schemas/request/rule_schemas.mock'; import { getPatchRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/patch_rules_schema.mock'; import { rulesMock } from './mock'; import { buildEsQuery } from 'src/plugins/data/common'; @@ -64,7 +66,7 @@ describe('Detections Rules API', () => { await updateRule({ rule: payload, signal: abortCtrl.signal }); expect(fetchMock).toHaveBeenCalledWith('/api/detection_engine/rules', { body: - '{"description":"some description","name":"Query with a rule id","query":"user.name: root or user.name: admin","severity":"high","type":"query","risk_score":55,"language":"kuery","rule_id":"rule-1"}', + '{"description":"Detecting root and admin users","name":"Query with a rule id","query":"user.name: root or user.name: admin","severity":"high","type":"query","risk_score":55,"language":"kuery","id":"04128c15-0d1b-4716-a4c5-46997ac7f3bd"}', method: 'PUT', signal: abortCtrl.signal, }); diff --git a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/api.ts b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/api.ts index ce1fdd18dbdef..9512ae6f2d6e0 100644 --- a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/api.ts +++ b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/api.ts @@ -3,6 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ +import { FullResponseSchema } from '../../../../../common/detection_engine/schemas/request'; import { HttpStart } from '../../../../../../../../src/core/public'; import { DETECTION_ENGINE_RULES_URL, @@ -42,8 +43,8 @@ import { RulesSchema } from '../../../../../common/detection_engine/schemas/resp * * @throws An error if response is not OK */ -export const createRule = async ({ rule, signal }: CreateRulesProps): Promise => - KibanaServices.get().http.fetch(DETECTION_ENGINE_RULES_URL, { +export const createRule = async ({ rule, signal }: CreateRulesProps): Promise => + KibanaServices.get().http.fetch(DETECTION_ENGINE_RULES_URL, { method: 'POST', body: JSON.stringify(rule), signal, diff --git a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/use_create_rule.test.tsx b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/use_create_rule.test.tsx index 42d6a2a92a4c2..0d0047dd06e3f 100644 --- a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/use_create_rule.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/use_create_rule.test.tsx @@ -7,7 +7,7 @@ import { renderHook, act } from '@testing-library/react-hooks'; import { useCreateRule, ReturnCreateRule } from './use_create_rule'; -import { getUpdateRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/update_rules_schema.mock'; +import { getCreateRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/rule_schemas.mock'; jest.mock('./api'); @@ -24,7 +24,7 @@ describe('useCreateRule', () => { useCreateRule() ); await waitForNextUpdate(); - result.current[1](getUpdateRulesSchemaMock()); + result.current[1](getCreateRulesSchemaMock()); rerender(); expect(result.current).toEqual([{ isLoading: true, isSaved: false }, result.current[1]]); }); @@ -36,7 +36,7 @@ describe('useCreateRule', () => { useCreateRule() ); await waitForNextUpdate(); - result.current[1](getUpdateRulesSchemaMock()); + result.current[1](getCreateRulesSchemaMock()); await waitForNextUpdate(); expect(result.current).toEqual([{ isLoading: false, isSaved: true }, result.current[1]]); }); diff --git a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/use_update_rule.test.tsx b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/use_update_rule.test.tsx index 9603a4151933a..95c5bef962a00 100644 --- a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/use_update_rule.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/use_update_rule.test.tsx @@ -7,7 +7,7 @@ import { renderHook, act } from '@testing-library/react-hooks'; import { useUpdateRule, ReturnUpdateRule } from './use_update_rule'; -import { getUpdateRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/update_rules_schema.mock'; +import { getUpdateRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/rule_schemas.mock'; jest.mock('./api'); diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/create/helpers.test.ts b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/create/helpers.test.ts index 11222a0a95a80..239d885bfc157 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/create/helpers.test.ts +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/create/helpers.test.ts @@ -5,7 +5,7 @@ */ import { List } from '../../../../../../common/detection_engine/schemas/types'; -import { CreateRulesSchema } from '../../../../../../common/detection_engine/schemas/request/create_rules_schema'; +import { CreateRulesSchema } from '../../../../../../common/detection_engine/schemas/request'; import { Rule } from '../../../../containers/detection_engine/rules'; import { getListMock, diff --git a/x-pack/plugins/security_solution/public/timelines/components/notes/note_card/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/notes/note_card/index.test.tsx index 8aebc8519bcb7..161671ed730f3 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/notes/note_card/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/notes/note_card/index.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { ThemeProvider } from 'styled-components'; import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; import '../../../../common/mock/formatted_relative'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/notes/note_card/note_card_header.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/notes/note_card/note_card_header.test.tsx index bc46c238c5ae8..4fbb7ce3f46eb 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/notes/note_card/note_card_header.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/notes/note_card/note_card_header.test.tsx @@ -6,7 +6,7 @@ import moment from 'moment-timezone'; import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import '../../../../common/mock/formatted_relative'; import * as i18n from '../translations'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/notes/note_card/note_created.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/notes/note_card/note_created.test.tsx index 7b51a9eaa1a2d..92d334a059ae9 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/notes/note_card/note_created.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/notes/note_card/note_created.test.tsx @@ -6,7 +6,7 @@ import moment from 'moment-timezone'; import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import '../../../../common/mock/formatted_relative'; import { NoteCreated } from './note_created'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/notes/note_cards/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/notes/note_cards/index.test.tsx index 54a074bb2adb7..731ff020457a2 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/notes/note_cards/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/notes/note_cards/index.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { ThemeProvider } from 'styled-components'; import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; import '../../../../common/mock/formatted_relative'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/delete_timeline_modal.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/delete_timeline_modal.test.tsx index aeca4641c3169..5d71814f23fe9 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/delete_timeline_modal.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/delete_timeline_modal.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { DeleteTimelineModal } from './delete_timeline_modal'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/index.test.tsx index 9acf0c829f321..86aec7d8dac17 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/delete_timeline_modal/index.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { DeleteTimelineModalOverlay } from '.'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/note_previews/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/note_previews/index.test.tsx index cb0eba910c342..d791e6ebe4366 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/note_previews/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/note_previews/index.test.tsx @@ -7,7 +7,7 @@ import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; import { cloneDeep } from 'lodash/fp'; import moment from 'moment'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ThemeProvider } from 'styled-components'; import '../../../../common/mock/formatted_relative'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/note_previews/note_preview.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/note_previews/note_preview.test.tsx index feabe46edfa82..484b3e5a60015 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/note_previews/note_preview.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/note_previews/note_preview.test.tsx @@ -5,7 +5,7 @@ */ import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ThemeProvider } from 'styled-components'; import '../../../../common/mock/formatted_relative'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline.test.tsx index 07f22bd47a9dd..7a927e2f11749 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline.test.tsx @@ -6,7 +6,7 @@ import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; import { cloneDeep } from 'lodash/fp'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ThemeProvider } from 'styled-components'; import { waitFor } from '@testing-library/react'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline_modal/open_timeline_modal_body.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline_modal/open_timeline_modal_body.test.tsx index 2744e0b42efce..d6214056c65dd 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline_modal/open_timeline_modal_body.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/open_timeline_modal/open_timeline_modal_body.test.tsx @@ -6,7 +6,7 @@ import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; import { cloneDeep } from 'lodash/fp'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ThemeProvider } from 'styled-components'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/search_row/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/search_row/index.test.tsx index 18c2e4cff16bf..65e962072eef7 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/search_row/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/search_row/index.test.tsx @@ -6,7 +6,7 @@ import { EuiFilterButtonProps } from '@elastic/eui'; import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ThemeProvider } from 'styled-components'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/actions_columns.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/actions_columns.test.tsx index 52b7a4293e847..336b8ebec2bb1 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/actions_columns.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/actions_columns.test.tsx @@ -7,7 +7,7 @@ import { EuiButtonIconProps } from '@elastic/eui'; import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; import { cloneDeep, omit } from 'lodash/fp'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ThemeProvider } from 'styled-components'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/common_columns.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/common_columns.test.tsx index 18270a30eb0e1..c467154a3de68 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/common_columns.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/common_columns.test.tsx @@ -9,7 +9,7 @@ import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; import { cloneDeep, omit } from 'lodash/fp'; import React from 'react'; import { ThemeProvider } from 'styled-components'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import '../../../../common/mock/match_media'; import '../../../../common/mock/formatted_relative'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/extended_columns.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/extended_columns.test.tsx index 0f2b3cdea4eec..a64521406f082 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/extended_columns.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/extended_columns.test.tsx @@ -6,7 +6,7 @@ import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; import { cloneDeep, omit } from 'lodash/fp'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ThemeProvider } from 'styled-components'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/icon_header_columns.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/icon_header_columns.test.tsx index 6e3f0037003b1..f3b0c2999a62c 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/icon_header_columns.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/icon_header_columns.test.tsx @@ -6,7 +6,7 @@ import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; import { cloneDeep, omit } from 'lodash/fp'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ThemeProvider } from 'styled-components'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/index.test.tsx index 649e38865f907..d96a3d504f487 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/timelines_table/index.test.tsx @@ -6,7 +6,7 @@ import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; import { cloneDeep } from 'lodash/fp'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ThemeProvider } from 'styled-components'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/title_row/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/title_row/index.test.tsx index da4b804528a0f..78a1d7b17a201 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/title_row/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/title_row/index.test.tsx @@ -6,7 +6,7 @@ import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; import { EuiButtonProps } from '@elastic/eui'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ThemeProvider } from 'styled-components'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/index.test.tsx index cdedca23e85af..a6740a0cdb0f3 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/index.test.tsx @@ -21,7 +21,7 @@ import { createStore, State } from '../../../../common/store'; import { useThrottledResizeObserver } from '../../../../common/components/utils'; import { Properties, showDescriptionThreshold, showNotesThreshold } from '.'; import { setInsertTimeline } from '../../../store/timeline/actions'; -export { nextTick } from '../../../../../../../test_utils'; +export { nextTick } from '@kbn/test/jest'; import { waitFor } from '@testing-library/react'; jest.mock('../../../../common/components/link_to'); diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/__mocks__/request_responses.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/__mocks__/request_responses.ts index 773e84d9c88fc..fd29be0e81f3c 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/__mocks__/request_responses.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/__mocks__/request_responses.ts @@ -26,7 +26,7 @@ import { requestMock } from './request'; import { RuleNotificationAlertType } from '../../notifications/types'; import { QuerySignalsSchemaDecoded } from '../../../../../common/detection_engine/schemas/request/query_signals_index_schema'; import { SetSignalsStatusSchemaDecoded } from '../../../../../common/detection_engine/schemas/request/set_signal_status_schema'; -import { getCreateRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/create_rules_schema.mock'; +import { getCreateRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/rule_schemas.mock'; import { getListArrayMock } from '../../../../../common/detection_engine/schemas/types/lists.mock'; import { EqlSearchResponse } from '../../../../../common/detection_engine/types'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/create_rules_bulk_route.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/create_rules_bulk_route.test.ts index 06fcba36642ca..55317fc28afca 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/create_rules_bulk_route.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/create_rules_bulk_route.test.ts @@ -18,7 +18,7 @@ import { } from '../__mocks__/request_responses'; import { requestContextMock, serverMock, requestMock } from '../__mocks__'; import { createRulesBulkRoute } from './create_rules_bulk_route'; -import { getCreateRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/create_rules_schema.mock'; +import { getCreateRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/rule_schemas.mock'; jest.mock('../../../machine_learning/authz', () => mockMlAuthzFactory.create()); @@ -180,9 +180,7 @@ describe('create_rules_bulk', () => { }); const result = server.validate(request); - expect(result.badRequest).toHaveBeenCalledWith( - 'Invalid value "unexpected_type" supplied to "type"' - ); + expect(result.badRequest).toHaveBeenCalled(); }); test('disallows invalid "from" param on rule', async () => { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/create_rules_bulk_route.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/create_rules_bulk_route.ts index aa409580df965..b185b8780abe2 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/create_rules_bulk_route.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/create_rules_bulk_route.ts @@ -6,18 +6,13 @@ import { validate } from '../../../../../common/validate'; import { createRuleValidateTypeDependents } from '../../../../../common/detection_engine/schemas/request/create_rules_type_dependents'; -import { RuleAlertAction } from '../../../../../common/detection_engine/types'; -import { - CreateRulesBulkSchemaDecoded, - createRulesBulkSchema, -} from '../../../../../common/detection_engine/schemas/request/create_rules_bulk_schema'; +import { createRulesBulkSchema } from '../../../../../common/detection_engine/schemas/request/create_rules_bulk_schema'; import { rulesBulkSchema } from '../../../../../common/detection_engine/schemas/response/rules_bulk_schema'; import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_RULES_URL } from '../../../../../common/constants'; import { SetupPlugins } from '../../../../plugin'; import { buildMlAuthz } from '../../../machine_learning/authz'; import { throwHttpError } from '../../../machine_learning/validation'; -import { createRules } from '../../rules/create_rules'; import { readRules } from '../../rules/read_rules'; import { getDuplicates } from './utils'; import { transformValidateBulkError } from './validate'; @@ -26,17 +21,14 @@ import { buildRouteValidation } from '../../../../utils/build_validation/route_v import { transformBulkError, createBulkErrorObject, buildSiemResponse } from '../utils'; import { updateRulesNotifications } from '../../rules/update_rules_notifications'; -import { PartialFilter } from '../../types'; -import { isMlRule } from '../../../../../common/machine_learning/helpers'; +import { convertCreateAPIToInternalSchema } from '../../schemas/rule_converters'; export const createRulesBulkRoute = (router: IRouter, ml: SetupPlugins['ml']) => { router.post( { path: `${DETECTION_ENGINE_RULES_URL}/_bulk_create`, validate: { - body: buildRouteValidation( - createRulesBulkSchema - ), + body: buildRouteValidation(createRulesBulkSchema), }, options: { tags: ['access:securitySolution'], @@ -67,158 +59,63 @@ export const createRulesBulkRoute = (router: IRouter, ml: SetupPlugins['ml']) => ruleDefinitions .filter((rule) => rule.rule_id == null || !dupes.includes(rule.rule_id)) .map(async (payloadRule) => { - const { - actions: actionsRest, - anomaly_threshold: anomalyThreshold, - author, - building_block_type: buildingBlockType, - description, - enabled, - event_category_override: eventCategoryOverride, - false_positives: falsePositives, - from, - query: queryOrUndefined, - language: languageOrUndefined, - license, - machine_learning_job_id: machineLearningJobId, - output_index: outputIndex, - saved_id: savedId, - meta, - filters: filtersRest, - rule_id: ruleId, - index, - interval, - max_signals: maxSignals, - risk_score: riskScore, - risk_score_mapping: riskScoreMapping, - rule_name_override: ruleNameOverride, - name, - severity, - severity_mapping: severityMapping, - tags, - threat, - threat_filters: threatFilters, - threat_index: threatIndex, - threat_mapping: threatMapping, - threat_query: threatQuery, - threat_language: threatLanguage, - concurrent_searches: concurrentSearches, - items_per_search: itemsPerSearch, - threshold, - throttle, - timestamp_override: timestampOverride, - to, - type, - references, - note, - timeline_id: timelineId, - timeline_title: timelineTitle, - version, - exceptions_list: exceptionsList, - } = payloadRule; + if (payloadRule.rule_id != null) { + const rule = await readRules({ + alertsClient, + ruleId: payloadRule.rule_id, + id: undefined, + }); + if (rule != null) { + return createBulkErrorObject({ + ruleId: payloadRule.rule_id, + statusCode: 409, + message: `rule_id: "${payloadRule.rule_id}" already exists`, + }); + } + } + const internalRule = convertCreateAPIToInternalSchema(payloadRule, siemClient); try { const validationErrors = createRuleValidateTypeDependents(payloadRule); if (validationErrors.length) { return createBulkErrorObject({ - ruleId, + ruleId: internalRule.params.ruleId, statusCode: 400, message: validationErrors.join(), }); } - const query = !isMlRule(type) && queryOrUndefined == null ? '' : queryOrUndefined; - - const language = - !isMlRule(type) && languageOrUndefined == null ? 'kuery' : languageOrUndefined; - - // TODO: Fix these either with an is conversion or by better typing them within io-ts - const actions: RuleAlertAction[] = actionsRest as RuleAlertAction[]; - const filters: PartialFilter[] | undefined = filtersRest as PartialFilter[]; - throwHttpError(await mlAuthz.validateRuleType(type)); - - const finalIndex = outputIndex ?? siemClient.getSignalsIndex(); + throwHttpError(await mlAuthz.validateRuleType(internalRule.params.type)); + const finalIndex = internalRule.params.outputIndex; const indexExists = await getIndexExists(clusterClient.callAsCurrentUser, finalIndex); if (!indexExists) { return createBulkErrorObject({ - ruleId, + ruleId: internalRule.params.ruleId, statusCode: 400, message: `To create a rule, the index must exist first. Index ${finalIndex} does not exist`, }); } - if (ruleId != null) { - const rule = await readRules({ alertsClient, ruleId, id: undefined }); - if (rule != null) { - return createBulkErrorObject({ - ruleId, - statusCode: 409, - message: `rule_id: "${ruleId}" already exists`, - }); - } - } - const createdRule = await createRules({ - alertsClient, - anomalyThreshold, - author, - buildingBlockType, - description, - enabled, - eventCategoryOverride, - falsePositives, - from, - immutable: false, - query, - language, - license, - machineLearningJobId, - outputIndex: finalIndex, - savedId, - timelineId, - timelineTitle, - meta, - filters, - ruleId, - index, - interval, - maxSignals, - name, - riskScore, - riskScoreMapping, - ruleNameOverride, - severity, - severityMapping, - tags, - to, - type, - threat, - threatFilters, - threatMapping, - threatQuery, - threatIndex, - threatLanguage, - concurrentSearches, - itemsPerSearch, - threshold, - timestampOverride, - references, - note, - version, - exceptionsList, - actions: throttle === 'rule' ? actions : [], // Only enable actions if throttle is set to rule, otherwise we are a notification and should not enable it, + + const createdRule = await alertsClient.create({ + data: internalRule, }); const ruleActions = await updateRulesNotifications({ ruleAlertId: createdRule.id, alertsClient, savedObjectsClient, - enabled, - actions, - throttle, - name, + enabled: createdRule.enabled, + actions: payloadRule.actions, + throttle: payloadRule.throttle ?? null, + name: createdRule.name, }); - return transformValidateBulkError(ruleId, createdRule, ruleActions); + return transformValidateBulkError( + internalRule.params.ruleId, + createdRule, + ruleActions + ); } catch (err) { - return transformBulkError(ruleId, err); + return transformBulkError(internalRule.params.ruleId, err); } }) ); diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/create_rules_route.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/create_rules_route.test.ts index 26febb0999ac7..40465f4dc7456 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/create_rules_route.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/create_rules_route.test.ts @@ -20,7 +20,7 @@ import { buildMlAuthz } from '../../../machine_learning/authz'; import { requestContextMock, serverMock, requestMock } from '../__mocks__'; import { createRulesRoute } from './create_rules_route'; import { updateRulesNotifications } from '../../rules/update_rules_notifications'; -import { getCreateRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/create_rules_schema.mock'; +import { getCreateRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/rule_schemas.mock'; jest.mock('../../rules/update_rules_notifications'); jest.mock('../../../machine_learning/authz', () => mockMlAuthzFactory.create()); @@ -160,9 +160,7 @@ describe('create_rules', () => { }); const result = server.validate(request); - expect(result.badRequest).toHaveBeenCalledWith( - 'Invalid value "unexpected_type" supplied to "type"' - ); + expect(result.badRequest).toHaveBeenCalled(); }); test('allows rule type of query and custom from and interval', async () => { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/create_rules_route.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/create_rules_route.ts index 97c05b4626ddc..b52248f670188 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/create_rules_route.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/create_rules_route.ts @@ -4,37 +4,28 @@ * you may not use this file except in compliance with the Elastic License. */ -import { isEqlRule } from '../../../../../common/detection_engine/utils'; -import { createRuleValidateTypeDependents } from '../../../../../common/detection_engine/schemas/request/create_rules_type_dependents'; -import { RuleAlertAction } from '../../../../../common/detection_engine/types'; import { buildRouteValidation } from '../../../../utils/build_validation/route_validation'; -import { - createRulesSchema, - CreateRulesSchemaDecoded, -} from '../../../../../common/detection_engine/schemas/request/create_rules_schema'; import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_RULES_URL } from '../../../../../common/constants'; import { SetupPlugins } from '../../../../plugin'; import { buildMlAuthz } from '../../../machine_learning/authz'; import { throwHttpError } from '../../../machine_learning/validation'; -import { createRules } from '../../rules/create_rules'; import { readRules } from '../../rules/read_rules'; -import { transformValidate } from './validate'; import { getIndexExists } from '../../index/get_index_exists'; import { transformError, buildSiemResponse } from '../utils'; import { updateRulesNotifications } from '../../rules/update_rules_notifications'; import { ruleStatusSavedObjectsClientFactory } from '../../signals/rule_status_saved_objects_client'; -import { PartialFilter } from '../../types'; -import { isMlRule } from '../../../../../common/machine_learning/helpers'; +import { createRulesSchema } from '../../../../../common/detection_engine/schemas/request'; +import { newTransformValidate } from './validate'; +import { createRuleValidateTypeDependents } from '../../../../../common/detection_engine/schemas/request/create_rules_type_dependents'; +import { convertCreateAPIToInternalSchema } from '../../schemas/rule_converters'; export const createRulesRoute = (router: IRouter, ml: SetupPlugins['ml']): void => { router.post( { path: DETECTION_ENGINE_RULES_URL, validate: { - body: buildRouteValidation( - createRulesSchema - ), + body: buildRouteValidation(createRulesSchema), }, options: { tags: ['access:securitySolution'], @@ -46,66 +37,7 @@ export const createRulesRoute = (router: IRouter, ml: SetupPlugins['ml']): void if (validationErrors.length) { return siemResponse.error({ statusCode: 400, body: validationErrors }); } - - const { - actions: actionsRest, - anomaly_threshold: anomalyThreshold, - author, - building_block_type: buildingBlockType, - description, - enabled, - event_category_override: eventCategoryOverride, - false_positives: falsePositives, - from, - query: queryOrUndefined, - language: languageOrUndefined, - license, - output_index: outputIndex, - saved_id: savedId, - timeline_id: timelineId, - timeline_title: timelineTitle, - meta, - machine_learning_job_id: machineLearningJobId, - filters: filtersRest, - rule_id: ruleId, - index, - interval, - max_signals: maxSignals, - risk_score: riskScore, - risk_score_mapping: riskScoreMapping, - rule_name_override: ruleNameOverride, - name, - severity, - severity_mapping: severityMapping, - tags, - threat, - threshold, - threat_filters: threatFilters, - threat_index: threatIndex, - threat_query: threatQuery, - threat_mapping: threatMapping, - threat_language: threatLanguage, - concurrent_searches: concurrentSearches, - items_per_search: itemsPerSearch, - throttle, - timestamp_override: timestampOverride, - to, - type, - references, - note, - exceptions_list: exceptionsList, - } = request.body; try { - const query = !isMlRule(type) && queryOrUndefined == null ? '' : queryOrUndefined; - - const language = - !isMlRule(type) && !isEqlRule(type) && languageOrUndefined == null - ? 'kuery' - : languageOrUndefined; - - // TODO: Fix these either with an is conversion or by better typing them within io-ts - const actions: RuleAlertAction[] = actionsRest as RuleAlertAction[]; - const filters: PartialFilter[] | undefined = filtersRest as PartialFilter[]; const alertsClient = context.alerting?.getAlertsClient(); const clusterClient = context.core.elasticsearch.legacy.client; const savedObjectsClient = context.core.savedObjects.client; @@ -115,93 +47,56 @@ export const createRulesRoute = (router: IRouter, ml: SetupPlugins['ml']): void return siemResponse.error({ statusCode: 404 }); } + if (request.body.rule_id != null) { + const rule = await readRules({ + alertsClient, + ruleId: request.body.rule_id, + id: undefined, + }); + if (rule != null) { + return siemResponse.error({ + statusCode: 409, + body: `rule_id: "${request.body.rule_id}" already exists`, + }); + } + } + + const internalRule = convertCreateAPIToInternalSchema(request.body, siemClient); + const mlAuthz = buildMlAuthz({ license: context.licensing.license, ml, request, savedObjectsClient, }); - throwHttpError(await mlAuthz.validateRuleType(type)); + throwHttpError(await mlAuthz.validateRuleType(internalRule.params.type)); - const finalIndex = outputIndex ?? siemClient.getSignalsIndex(); - const indexExists = await getIndexExists(clusterClient.callAsCurrentUser, finalIndex); + const indexExists = await getIndexExists( + clusterClient.callAsCurrentUser, + internalRule.params.outputIndex + ); if (!indexExists) { return siemResponse.error({ statusCode: 400, - body: `To create a rule, the index must exist first. Index ${finalIndex} does not exist`, + body: `To create a rule, the index must exist first. Index ${internalRule.params.outputIndex} does not exist`, }); } - if (ruleId != null) { - const rule = await readRules({ alertsClient, ruleId, id: undefined }); - if (rule != null) { - return siemResponse.error({ - statusCode: 409, - body: `rule_id: "${ruleId}" already exists`, - }); - } - } + // This will create the endpoint list if it does not exist yet await context.lists?.getExceptionListClient().createEndpointList(); - const createdRule = await createRules({ - alertsClient, - anomalyThreshold, - author, - buildingBlockType, - description, - enabled, - eventCategoryOverride, - falsePositives, - from, - immutable: false, - query, - language, - license, - outputIndex: finalIndex, - savedId, - timelineId, - timelineTitle, - meta, - machineLearningJobId, - filters, - ruleId, - index, - interval, - maxSignals, - name, - riskScore, - riskScoreMapping, - ruleNameOverride, - severity, - severityMapping, - tags, - to, - type, - threat, - threshold, - threatFilters, - threatIndex, - threatQuery, - threatMapping, - threatLanguage, - concurrentSearches, - itemsPerSearch, - timestampOverride, - references, - note, - version: 1, - exceptionsList, - actions: throttle === 'rule' ? actions : [], // Only enable actions if throttle is rule, otherwise we are a notification and should not enable it, + const createdRule = await alertsClient.create({ + data: internalRule, }); const ruleActions = await updateRulesNotifications({ ruleAlertId: createdRule.id, alertsClient, savedObjectsClient, - enabled, - actions, - throttle, - name, + enabled: createdRule.enabled, + actions: request.body.actions, + throttle: request.body.throttle ?? null, + name: createdRule.name, }); const ruleStatuses = await ruleStatusSavedObjectsClientFactory(savedObjectsClient).find({ @@ -211,7 +106,7 @@ export const createRulesRoute = (router: IRouter, ml: SetupPlugins['ml']): void search: `${createdRule.id}`, searchFields: ['alertId'], }); - const [validated, errors] = transformValidate( + const [validated, errors] = newTransformValidate( createdRule, ruleActions, ruleStatuses.saved_objects[0] diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.test.ts index c162caa1278e6..e1ef22c453185 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.test.ts @@ -16,7 +16,7 @@ import { } from '../__mocks__/request_responses'; import { serverMock, requestContextMock, requestMock } from '../__mocks__'; import { patchRulesBulkRoute } from './patch_rules_bulk_route'; -import { getCreateRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/create_rules_schema.mock'; +import { getCreateRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/rule_schemas.mock'; jest.mock('../../../machine_learning/authz', () => mockMlAuthzFactory.create()); @@ -60,6 +60,7 @@ describe('patch_rules_bulk', () => { path: `${DETECTION_ENGINE_RULES_URL}/bulk_update`, body: [ { + type: 'machine_learning', rule_id: 'my-rule-id', anomaly_threshold: 4, machine_learning_job_id: 'some_job_id', diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/patch_rules_route.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/patch_rules_route.test.ts index a406de593652b..4d1d510e46a09 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/patch_rules_route.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/patch_rules_route.test.ts @@ -90,6 +90,7 @@ describe('patch_rules', () => { method: 'patch', path: DETECTION_ENGINE_RULES_URL, body: { + type: 'machine_learning', rule_id: 'my-rule-id', anomaly_threshold: 4, machine_learning_job_id: 'some_job_id', diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/update_rules_bulk_route.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/update_rules_bulk_route.test.ts index ec5a2be255a2c..72583a5a78709 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/update_rules_bulk_route.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/update_rules_bulk_route.test.ts @@ -18,7 +18,7 @@ import { import { serverMock, requestContextMock, requestMock } from '../__mocks__'; import { updateRulesBulkRoute } from './update_rules_bulk_route'; import { BulkError } from '../utils'; -import { getCreateRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/create_rules_schema.mock'; +import { getCreateRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/rule_schemas.mock'; jest.mock('../../../machine_learning/authz', () => mockMlAuthzFactory.create()); @@ -150,9 +150,7 @@ describe('update_rules_bulk', () => { }); const result = server.validate(request); - expect(result.badRequest).toHaveBeenCalledWith( - 'Invalid value "unknown_type" supplied to "type"' - ); + expect(result.badRequest).toHaveBeenCalled(); }); test('allows rule type of query and custom from and interval', async () => { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/update_rules_bulk_route.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/update_rules_bulk_route.ts index f4a31c2bb456d..5f9789220bc10 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/update_rules_bulk_route.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/update_rules_bulk_route.ts @@ -6,14 +6,9 @@ import { validate } from '../../../../../common/validate'; import { updateRuleValidateTypeDependents } from '../../../../../common/detection_engine/schemas/request/update_rules_type_dependents'; -import { RuleAlertAction } from '../../../../../common/detection_engine/types'; import { buildRouteValidation } from '../../../../utils/build_validation/route_validation'; -import { - updateRulesBulkSchema, - UpdateRulesBulkSchemaDecoded, -} from '../../../../../common/detection_engine/schemas/request/update_rules_bulk_schema'; +import { updateRulesBulkSchema } from '../../../../../common/detection_engine/schemas/request/update_rules_bulk_schema'; import { rulesBulkSchema } from '../../../../../common/detection_engine/schemas/response/rules_bulk_schema'; -import { isMlRule } from '../../../../../common/machine_learning/helpers'; import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_RULES_URL } from '../../../../../common/constants'; import { SetupPlugins } from '../../../../plugin'; @@ -25,16 +20,13 @@ import { transformBulkError, buildSiemResponse, createBulkErrorObject } from '.. import { updateRules } from '../../rules/update_rules'; import { updateRulesNotifications } from '../../rules/update_rules_notifications'; import { ruleStatusSavedObjectsClientFactory } from '../../signals/rule_status_saved_objects_client'; -import { PartialFilter } from '../../types'; export const updateRulesBulkRoute = (router: IRouter, ml: SetupPlugins['ml']) => { router.put( { path: `${DETECTION_ENGINE_RULES_URL}/_bulk_update`, validate: { - body: buildRouteValidation( - updateRulesBulkSchema - ), + body: buildRouteValidation(updateRulesBulkSchema), }, options: { tags: ['access:securitySolution'], @@ -61,139 +53,34 @@ export const updateRulesBulkRoute = (router: IRouter, ml: SetupPlugins['ml']) => const ruleStatusClient = ruleStatusSavedObjectsClientFactory(savedObjectsClient); const rules = await Promise.all( request.body.map(async (payloadRule) => { - const { - actions: actionsRest, - anomaly_threshold: anomalyThreshold, - author, - building_block_type: buildingBlockType, - description, - enabled, - event_category_override: eventCategoryOverride, - false_positives: falsePositives, - from, - query: queryOrUndefined, - language: languageOrUndefined, - license, - machine_learning_job_id: machineLearningJobId, - output_index: outputIndex, - saved_id: savedId, - timeline_id: timelineId, - timeline_title: timelineTitle, - meta, - filters: filtersRest, - rule_id: ruleId, - id, - index, - interval, - max_signals: maxSignals, - risk_score: riskScore, - risk_score_mapping: riskScoreMapping, - rule_name_override: ruleNameOverride, - name, - severity, - severity_mapping: severityMapping, - tags, - to, - type, - threat, - threshold, - threat_filters: threatFilters, - threat_index: threatIndex, - threat_query: threatQuery, - threat_mapping: threatMapping, - threat_language: threatLanguage, - concurrent_searches: concurrentSearches, - items_per_search: itemsPerSearch, - throttle, - timestamp_override: timestampOverride, - references, - note, - version, - exceptions_list: exceptionsList, - } = payloadRule; - const finalIndex = outputIndex ?? siemClient.getSignalsIndex(); - const idOrRuleIdOrUnknown = id ?? ruleId ?? '(unknown id)'; + const idOrRuleIdOrUnknown = payloadRule.id ?? payloadRule.rule_id ?? '(unknown id)'; try { const validationErrors = updateRuleValidateTypeDependents(payloadRule); if (validationErrors.length) { return createBulkErrorObject({ - ruleId, + ruleId: payloadRule.rule_id, statusCode: 400, message: validationErrors.join(), }); } - const query = !isMlRule(type) && queryOrUndefined == null ? '' : queryOrUndefined; - - const language = - !isMlRule(type) && languageOrUndefined == null ? 'kuery' : languageOrUndefined; - - // TODO: Fix these either with an is conversion or by better typing them within io-ts - const actions: RuleAlertAction[] = actionsRest as RuleAlertAction[]; - const filters: PartialFilter[] | undefined = filtersRest as PartialFilter[]; - - throwHttpError(await mlAuthz.validateRuleType(type)); + throwHttpError(await mlAuthz.validateRuleType(payloadRule.type)); const rule = await updateRules({ alertsClient, - anomalyThreshold, - author, - buildingBlockType, - description, - enabled, - eventCategoryOverride, - falsePositives, - from, - query, - language, - license, - machineLearningJobId, - outputIndex: finalIndex, - savedId, savedObjectsClient, - timelineId, - timelineTitle, - meta, - filters, - id, - ruleId, - index, - interval, - maxSignals, - riskScore, - riskScoreMapping, - ruleNameOverride, - name, - severity, - severityMapping, - tags, - to, - type, - threat, - threshold, - threatFilters, - threatIndex, - threatQuery, - threatMapping, - threatLanguage, - concurrentSearches, - itemsPerSearch, - timestampOverride, - references, - note, - version, - exceptionsList, - actions, + defaultOutputIndex: siemClient.getSignalsIndex(), + ruleUpdate: payloadRule, }); if (rule != null) { const ruleActions = await updateRulesNotifications({ ruleAlertId: rule.id, alertsClient, savedObjectsClient, - enabled, - actions, - throttle, - name, + enabled: payloadRule.enabled ?? true, + actions: payloadRule.actions, + throttle: payloadRule.throttle, + name: payloadRule.name, }); const ruleStatuses = await ruleStatusClient.find({ perPage: 1, @@ -204,7 +91,7 @@ export const updateRulesBulkRoute = (router: IRouter, ml: SetupPlugins['ml']) => }); return transformValidateBulkError(rule.id, rule, ruleActions, ruleStatuses); } else { - return getIdBulkError({ id, ruleId }); + return getIdBulkError({ id: payloadRule.id, ruleId: payloadRule.rule_id }); } } catch (err) { return transformBulkError(idOrRuleIdOrUnknown, err); diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/update_rules_route.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/update_rules_route.test.ts index fd077c18b7983..96710b6f1d763 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/update_rules_route.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/update_rules_route.test.ts @@ -19,7 +19,7 @@ import { requestContextMock, serverMock, requestMock } from '../__mocks__'; import { DETECTION_ENGINE_RULES_URL } from '../../../../../common/constants'; import { updateRulesNotifications } from '../../rules/update_rules_notifications'; import { updateRulesRoute } from './update_rules_route'; -import { getUpdateRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/update_rules_schema.mock'; +import { getUpdateRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/rule_schemas.mock'; jest.mock('../../../machine_learning/authz', () => mockMlAuthzFactory.create()); jest.mock('../../rules/update_rules_notifications'); @@ -131,7 +131,7 @@ describe('update_rules', () => { path: DETECTION_ENGINE_RULES_URL, body: { ...getUpdateRulesSchemaMock(), - rule_id: undefined, + id: undefined, }, }); const response = await server.inject(noIdRequest, context); @@ -160,9 +160,7 @@ describe('update_rules', () => { }); const result = await server.validate(request); - expect(result.badRequest).toHaveBeenCalledWith( - 'Invalid value "unknown type" supplied to "type"' - ); + expect(result.badRequest).toHaveBeenCalled(); }); test('allows rule type of query and custom from and interval', async () => { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/update_rules_route.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/update_rules_route.ts index 7ad525b67f7aa..aa85747e3ce41 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/update_rules_route.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/update_rules_route.ts @@ -4,13 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ +import { updateRulesSchema } from '../../../../../common/detection_engine/schemas/request'; import { updateRuleValidateTypeDependents } from '../../../../../common/detection_engine/schemas/request/update_rules_type_dependents'; -import { RuleAlertAction } from '../../../../../common/detection_engine/types'; -import { - updateRulesSchema, - UpdateRulesSchemaDecoded, -} from '../../../../../common/detection_engine/schemas/request/update_rules_schema'; -import { isMlRule } from '../../../../../common/machine_learning/helpers'; import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_RULES_URL } from '../../../../../common/constants'; import { SetupPlugins } from '../../../../plugin'; @@ -23,16 +18,13 @@ import { updateRules } from '../../rules/update_rules'; import { updateRulesNotifications } from '../../rules/update_rules_notifications'; import { ruleStatusSavedObjectsClientFactory } from '../../signals/rule_status_saved_objects_client'; import { buildRouteValidation } from '../../../../utils/build_validation/route_validation'; -import { PartialFilter } from '../../types'; export const updateRulesRoute = (router: IRouter, ml: SetupPlugins['ml']) => { router.put( { path: DETECTION_ENGINE_RULES_URL, validate: { - body: buildRouteValidation( - updateRulesSchema - ), + body: buildRouteValidation(updateRulesSchema), }, options: { tags: ['access:securitySolution'], @@ -44,67 +36,7 @@ export const updateRulesRoute = (router: IRouter, ml: SetupPlugins['ml']) => { if (validationErrors.length) { return siemResponse.error({ statusCode: 400, body: validationErrors }); } - - const { - actions: actionsRest, - anomaly_threshold: anomalyThreshold, - author, - building_block_type: buildingBlockType, - description, - enabled, - event_category_override: eventCategoryOverride, - false_positives: falsePositives, - from, - query: queryOrUndefined, - language: languageOrUndefined, - license, - machine_learning_job_id: machineLearningJobId, - output_index: outputIndex, - saved_id: savedId, - timeline_id: timelineId, - timeline_title: timelineTitle, - meta, - filters: filtersRest, - rule_id: ruleId, - id, - index, - interval, - max_signals: maxSignals, - risk_score: riskScore, - risk_score_mapping: riskScoreMapping, - rule_name_override: ruleNameOverride, - name, - severity, - severity_mapping: severityMapping, - tags, - to, - type, - threat, - threshold, - threat_filters: threatFilters, - threat_index: threatIndex, - threat_query: threatQuery, - threat_mapping: threatMapping, - threat_language: threatLanguage, - concurrent_searches: concurrentSearches, - items_per_search: itemsPerSearch, - throttle, - timestamp_override: timestampOverride, - references, - note, - version, - exceptions_list: exceptionsList, - } = request.body; try { - const query = !isMlRule(type) && queryOrUndefined == null ? '' : queryOrUndefined; - - const language = - !isMlRule(type) && languageOrUndefined == null ? 'kuery' : languageOrUndefined; - - // TODO: Fix these either with an is conversion or by better typing them within io-ts - const actions: RuleAlertAction[] = actionsRest as RuleAlertAction[]; - const filters: PartialFilter[] | undefined = filtersRest as PartialFilter[]; - const alertsClient = context.alerting?.getAlertsClient(); const savedObjectsClient = context.core.savedObjects.client; const siemClient = context.securitySolution?.getAppClient(); @@ -120,59 +52,13 @@ export const updateRulesRoute = (router: IRouter, ml: SetupPlugins['ml']) => { request, savedObjectsClient, }); - throwHttpError(await mlAuthz.validateRuleType(type)); + throwHttpError(await mlAuthz.validateRuleType(request.body.type)); - const finalIndex = outputIndex ?? siemClient.getSignalsIndex(); const rule = await updateRules({ alertsClient, - anomalyThreshold, - author, - buildingBlockType, - description, - enabled, - eventCategoryOverride, - falsePositives, - from, - query, - language, - license, - machineLearningJobId, - outputIndex: finalIndex, - savedId, savedObjectsClient, - timelineId, - timelineTitle, - meta, - filters, - id, - ruleId, - index, - interval, - maxSignals, - riskScore, - riskScoreMapping, - ruleNameOverride, - name, - severity, - severityMapping, - tags, - to, - type, - threat, - threshold, - threatFilters, - threatIndex, - threatQuery, - threatMapping, - threatLanguage, - concurrentSearches, - itemsPerSearch, - timestampOverride, - references, - note, - version, - exceptionsList, - actions: throttle === 'rule' ? actions : [], // Only enable actions if throttle is rule, otherwise we are a notification and should not enable it + defaultOutputIndex: siemClient.getSignalsIndex(), + ruleUpdate: request.body, }); if (rule != null) { @@ -180,10 +66,10 @@ export const updateRulesRoute = (router: IRouter, ml: SetupPlugins['ml']) => { ruleAlertId: rule.id, alertsClient, savedObjectsClient, - enabled, - actions, - throttle, - name, + enabled: request.body.enabled ?? true, + actions: request.body.actions, + throttle: request.body.throttle, + name: request.body.name, }); const ruleStatuses = await ruleStatusClient.find({ perPage: 1, @@ -203,7 +89,7 @@ export const updateRulesRoute = (router: IRouter, ml: SetupPlugins['ml']) => { return response.ok({ body: validated ?? {} }); } } else { - const error = getIdError({ id, ruleId }); + const error = getIdError({ id: request.body.id, ruleId: request.body.rule_id }); return siemResponse.error({ body: error.message, statusCode: error.statusCode, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/utils.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/utils.test.ts index 13eb7495a898a..0bd6d43cab464 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/utils.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/utils.test.ts @@ -27,10 +27,10 @@ import { PartialAlert } from '../../../../../../alerts/server'; import { SanitizedAlert } from '../../../../../../alerts/server/types'; import { createRulesStreamFromNdJson } from '../../rules/create_rules_stream_from_ndjson'; import { RuleAlertType } from '../../rules/types'; -import { CreateRulesBulkSchemaDecoded } from '../../../../../common/detection_engine/schemas/request/create_rules_bulk_schema'; import { ImportRulesSchemaDecoded } from '../../../../../common/detection_engine/schemas/request/import_rules_schema'; -import { getCreateRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/create_rules_schema.mock'; +import { getCreateRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/rule_schemas.mock'; import { ThreatMapping } from '../../../../../common/detection_engine/schemas/types/threat_mapping'; +import { CreateRulesBulkSchema } from '../../../../../common/detection_engine/schemas/request'; type PromiseFromStreams = ImportRulesSchemaDecoded | Error; @@ -548,7 +548,7 @@ describe('utils', () => { { rule_id: 'value3' }, {}, {}, - ] as CreateRulesBulkSchemaDecoded, + ] as CreateRulesBulkSchema, 'rule_id' ); const expected = ['value2', 'value3']; @@ -562,7 +562,7 @@ describe('utils', () => { { rule_id: 'value3' }, {}, {}, - ] as CreateRulesBulkSchemaDecoded, + ] as CreateRulesBulkSchema, 'rule_id' ); const expected: string[] = []; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/utils.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/utils.ts index 7360dc77aac22..7a6cd707eb185 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/utils.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/utils.ts @@ -10,7 +10,7 @@ import uuid from 'uuid'; import { RulesSchema } from '../../../../../common/detection_engine/schemas/response/rules_schema'; import { ImportRulesSchemaDecoded } from '../../../../../common/detection_engine/schemas/request/import_rules_schema'; -import { CreateRulesBulkSchemaDecoded } from '../../../../../common/detection_engine/schemas/request/create_rules_bulk_schema'; +import { CreateRulesBulkSchema } from '../../../../../common/detection_engine/schemas/request/create_rules_bulk_schema'; import { PartialAlert, FindResult } from '../../../../../../alerts/server'; import { INTERNAL_IDENTIFIER } from '../../../../../common/constants'; import { @@ -256,10 +256,7 @@ export const transformOrImportError = ( } }; -export const getDuplicates = ( - ruleDefinitions: CreateRulesBulkSchemaDecoded, - by: 'rule_id' -): string[] => { +export const getDuplicates = (ruleDefinitions: CreateRulesBulkSchema, by: 'rule_id'): string[] => { const mappedDuplicates = countBy( by, ruleDefinitions.filter((r) => r[by] != null) diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/validate.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/validate.ts index 27100eaebea15..382186df16cd1 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/validate.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/validate.ts @@ -9,6 +9,10 @@ import { fold } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import * as t from 'io-ts'; +import { + FullResponseSchema, + fullResponseSchema, +} from '../../../../../common/detection_engine/schemas/request'; import { validate } from '../../../../../common/validate'; import { findRulesSchema } from '../../../../../common/detection_engine/schemas/response/find_rules_schema'; import { @@ -71,6 +75,19 @@ export const transformValidate = ( } }; +export const newTransformValidate = ( + alert: PartialAlert, + ruleActions?: RuleActions | null, + ruleStatus?: SavedObject +): [FullResponseSchema | null, string | null] => { + const transformed = transform(alert, ruleActions, ruleStatus); + if (transformed == null) { + return [null, 'Internal error transforming']; + } else { + return validate(transformed, fullResponseSchema); + } +}; + export const transformValidateBulkError = ( ruleId: string, alert: PartialAlert, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/patch_rules.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/patch_rules.ts index 22b2593283696..8e10fc21f040c 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/patch_rules.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/patch_rules.ts @@ -5,12 +5,22 @@ */ import { defaults } from 'lodash/fp'; +import { validate } from '../../../../common/validate'; import { PartialAlert } from '../../../../../alerts/server'; import { transformRuleToAlertAction } from '../../../../common/detection_engine/transform_actions'; import { PatchRulesOptions } from './types'; import { addTags } from './add_tags'; -import { calculateVersion, calculateName, calculateInterval } from './utils'; +import { calculateVersion, calculateName, calculateInterval, removeUndefined } from './utils'; import { ruleStatusSavedObjectsClientFactory } from '../signals/rule_status_saved_objects_client'; +import { internalRuleUpdate } from '../schemas/rule_schemas'; + +class PatchError extends Error { + public readonly statusCode: number; + constructor(message: string, statusCode: number) { + super(message); + this.statusCode = statusCode; + } +} export const patchRules = async ({ alertsClient, @@ -159,18 +169,24 @@ export const patchRules = async ({ } ); + const newRule = { + tags: addTags(tags ?? rule.tags, rule.params.ruleId, rule.params.immutable), + throttle: null, + name: calculateName({ updatedName: name, originalName: rule.name }), + schedule: { + interval: calculateInterval(interval, rule.schedule.interval), + }, + actions: actions?.map(transformRuleToAlertAction) ?? rule.actions, + params: removeUndefined(nextParams), + }; + const [validated, errors] = validate(newRule, internalRuleUpdate); + if (errors != null || validated === null) { + throw new PatchError(`Applying patch would create invalid rule: ${errors}`, 400); + } + const update = await alertsClient.update({ id: rule.id, - data: { - tags: addTags(tags ?? rule.tags, rule.params.ruleId, rule.params.immutable), - throttle: null, - name: calculateName({ updatedName: name, originalName: rule.name }), - schedule: { - interval: calculateInterval(interval, rule.schedule.interval), - }, - actions: actions?.map(transformRuleToAlertAction) ?? rule.actions, - params: nextParams, - }, + data: validated, }); if (rule.enabled && enabled === false) { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/types.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/types.ts index f6ab3fb0c3ed2..45186f9978650 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/types.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/types.ts @@ -13,6 +13,7 @@ import { SavedObjectsFindResponse, SavedObjectsClientContract, } from 'kibana/server'; +import { UpdateRulesSchema } from '../../../../common/detection_engine/schemas/request'; import { RuleAlertAction } from '../../../../common/detection_engine/types'; import { FalsePositives, @@ -250,55 +251,10 @@ export interface CreateRulesOptions { } export interface UpdateRulesOptions { - id: IdOrUndefined; savedObjectsClient: SavedObjectsClientContract; alertsClient: AlertsClient; - anomalyThreshold: AnomalyThresholdOrUndefined; - author: Author; - buildingBlockType: BuildingBlockTypeOrUndefined; - description: Description; - enabled: Enabled; - eventCategoryOverride: EventCategoryOverrideOrUndefined; - falsePositives: FalsePositives; - from: From; - query: QueryOrUndefined; - language: LanguageOrUndefined; - savedId: SavedIdOrUndefined; - timelineId: TimelineIdOrUndefined; - timelineTitle: TimelineTitleOrUndefined; - meta: MetaOrUndefined; - machineLearningJobId: MachineLearningJobIdOrUndefined; - filters: PartialFilter[]; - ruleId: RuleIdOrUndefined; - index: IndexOrUndefined; - interval: Interval; - license: LicenseOrUndefined; - maxSignals: MaxSignals; - riskScore: RiskScore; - riskScoreMapping: RiskScoreMapping; - ruleNameOverride: RuleNameOverrideOrUndefined; - outputIndex: OutputIndex; - name: Name; - severity: Severity; - severityMapping: SeverityMapping; - tags: Tags; - threat: Threat; - threshold: ThresholdOrUndefined; - threatFilters: ThreatFiltersOrUndefined; - threatIndex: ThreatIndexOrUndefined; - threatQuery: ThreatQueryOrUndefined; - threatMapping: ThreatMappingOrUndefined; - itemsPerSearch: ItemsPerSearchOrUndefined; - concurrentSearches: ConcurrentSearchesOrUndefined; - threatLanguage: ThreatLanguageOrUndefined; - timestampOverride: TimestampOverrideOrUndefined; - to: To; - type: Type; - references: References; - note: NoteOrUndefined; - version: VersionOrUndefined; - exceptionsList: ListArray; - actions: RuleAlertAction[]; + defaultOutputIndex: string; + ruleUpdate: UpdateRulesSchema; } export interface PatchRulesOptions { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/update_rules.mock.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/update_rules.mock.ts index 34be0f6ad843d..ab71110072bfd 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/update_rules.mock.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/update_rules.mock.ts @@ -7,107 +7,21 @@ import { UpdateRulesOptions } from './types'; import { alertsClientMock } from '../../../../../alerts/server/mocks'; import { savedObjectsClientMock } from '../../../../../../../src/core/server/mocks'; +import { + getUpdateRulesSchemaMock, + getUpdateMachineLearningSchemaMock, +} from '../../../../common/detection_engine/schemas/request/rule_schemas.mock'; export const getUpdateRulesOptionsMock = (): UpdateRulesOptions => ({ - author: ['Elastic'], - buildingBlockType: undefined, - id: '04128c15-0d1b-4716-a4c5-46997ac7f3bd', alertsClient: alertsClientMock.create(), savedObjectsClient: savedObjectsClientMock.create(), - anomalyThreshold: undefined, - description: 'some description', - enabled: true, - eventCategoryOverride: undefined, - falsePositives: ['false positive 1', 'false positive 2'], - from: 'now-6m', - query: 'user.name: root or user.name: admin', - language: 'kuery', - license: 'Elastic License', - savedId: 'savedId-123', - timelineId: 'timelineid-123', - timelineTitle: 'timeline-title-123', - meta: {}, - machineLearningJobId: undefined, - filters: [], - ruleId: undefined, - index: ['index-123'], - interval: '5m', - maxSignals: 100, - riskScore: 80, - riskScoreMapping: [], - ruleNameOverride: undefined, - outputIndex: 'output-1', - name: 'Query with a rule id', - severity: 'high', - severityMapping: [], - tags: [], - threat: [], - threshold: undefined, - threatFilters: undefined, - threatIndex: undefined, - threatQuery: undefined, - threatMapping: undefined, - threatLanguage: undefined, - timestampOverride: undefined, - concurrentSearches: undefined, - itemsPerSearch: undefined, - to: 'now', - type: 'query', - references: ['http://www.example.com'], - note: '# sample markdown', - version: 1, - exceptionsList: [], - actions: [], + defaultOutputIndex: '.siem-signals-default', + ruleUpdate: getUpdateRulesSchemaMock(), }); export const getUpdateMlRulesOptionsMock = (): UpdateRulesOptions => ({ - author: ['Elastic'], - buildingBlockType: undefined, - id: '04128c15-0d1b-4716-a4c5-46997ac7f3bd', alertsClient: alertsClientMock.create(), savedObjectsClient: savedObjectsClientMock.create(), - anomalyThreshold: 55, - description: 'some description', - enabled: true, - eventCategoryOverride: undefined, - falsePositives: ['false positive 1', 'false positive 2'], - from: 'now-6m', - query: undefined, - language: undefined, - license: 'Elastic License', - savedId: 'savedId-123', - timelineId: 'timelineid-123', - timelineTitle: 'timeline-title-123', - meta: {}, - machineLearningJobId: 'new_job_id', - filters: [], - ruleId: undefined, - index: ['index-123'], - interval: '5m', - maxSignals: 100, - riskScore: 80, - riskScoreMapping: [], - ruleNameOverride: undefined, - outputIndex: 'output-1', - name: 'Machine Learning Job', - severity: 'high', - severityMapping: [], - tags: [], - threat: [], - threshold: undefined, - threatFilters: undefined, - threatIndex: undefined, - threatQuery: undefined, - threatMapping: undefined, - threatLanguage: undefined, - timestampOverride: undefined, - concurrentSearches: undefined, - itemsPerSearch: undefined, - to: 'now', - type: 'machine_learning', - references: ['http://www.example.com'], - note: '# sample markdown', - version: 1, - exceptionsList: [], - actions: [], + defaultOutputIndex: '.siem-signals-default', + ruleUpdate: getUpdateMachineLearningSchemaMock(), }); diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/update_rules.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/update_rules.test.ts index cf59d2bb5e8c4..31212f4fa9d6b 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/update_rules.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/update_rules.test.ts @@ -12,61 +12,54 @@ import { AlertsClientMock } from '../../../../../alerts/server/alerts_client.moc describe('updateRules', () => { it('should call alertsClient.disable if the rule was enabled and enabled is false', async () => { const rulesOptionsMock = getUpdateRulesOptionsMock(); - const ruleOptions = { - ...rulesOptionsMock, - enabled: false, - }; - ((ruleOptions.alertsClient as unknown) as AlertsClientMock).get.mockResolvedValue(getResult()); + rulesOptionsMock.ruleUpdate.enabled = false; + ((rulesOptionsMock.alertsClient as unknown) as AlertsClientMock).get.mockResolvedValue( + getResult() + ); - await updateRules(ruleOptions); + await updateRules(rulesOptionsMock); - expect(ruleOptions.alertsClient.disable).toHaveBeenCalledWith( + expect(rulesOptionsMock.alertsClient.disable).toHaveBeenCalledWith( expect.objectContaining({ - id: rulesOptionsMock.id, + id: rulesOptionsMock.ruleUpdate.id, }) ); }); it('should call alertsClient.enable if the rule was disabled and enabled is true', async () => { const rulesOptionsMock = getUpdateRulesOptionsMock(); - const ruleOptions = { - ...rulesOptionsMock, - enabled: true, - }; + rulesOptionsMock.ruleUpdate.enabled = true; - ((ruleOptions.alertsClient as unknown) as AlertsClientMock).get.mockResolvedValue({ + ((rulesOptionsMock.alertsClient as unknown) as AlertsClientMock).get.mockResolvedValue({ ...getResult(), enabled: false, }); - await updateRules(ruleOptions); + await updateRules(rulesOptionsMock); - expect(ruleOptions.alertsClient.enable).toHaveBeenCalledWith( + expect(rulesOptionsMock.alertsClient.enable).toHaveBeenCalledWith( expect.objectContaining({ - id: rulesOptionsMock.id, + id: rulesOptionsMock.ruleUpdate.id, }) ); }); - it('calls the alertsClient with ML params', async () => { + it('calls the alertsClient with params', async () => { const rulesOptionsMock = getUpdateMlRulesOptionsMock(); - const ruleOptions = { - ...rulesOptionsMock, - enabled: true, - }; + rulesOptionsMock.ruleUpdate.enabled = true; - ((ruleOptions.alertsClient as unknown) as AlertsClientMock).get.mockResolvedValue( + ((rulesOptionsMock.alertsClient as unknown) as AlertsClientMock).get.mockResolvedValue( getMlResult() ); - await updateRules(ruleOptions); + await updateRules(rulesOptionsMock); - expect(ruleOptions.alertsClient.update).toHaveBeenCalledWith( + expect(rulesOptionsMock.alertsClient.update).toHaveBeenCalledWith( expect.objectContaining({ data: expect.objectContaining({ params: expect.objectContaining({ - anomalyThreshold: rulesOptionsMock.anomalyThreshold, - machineLearningJobId: rulesOptionsMock.machineLearningJobId, + type: 'machine_learning', + severity: 'high', }), }), }) diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/update_rules.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/update_rules.ts index 5168affca5c62..dab8769bcaa65 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/update_rules.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/update_rules.ts @@ -4,179 +4,94 @@ * you may not use this file except in compliance with the Elastic License. */ +/* eslint-disable complexity */ + +import { DEFAULT_MAX_SIGNALS } from '../../../../common/constants'; import { transformRuleToAlertAction } from '../../../../common/detection_engine/transform_actions'; import { PartialAlert } from '../../../../../alerts/server'; import { readRules } from './read_rules'; import { UpdateRulesOptions } from './types'; import { addTags } from './add_tags'; -import { calculateVersion } from './utils'; import { ruleStatusSavedObjectsClientFactory } from '../signals/rule_status_saved_objects_client'; +import { typeSpecificSnakeToCamel } from '../schemas/rule_converters'; +import { InternalRuleUpdate } from '../schemas/rule_schemas'; export const updateRules = async ({ alertsClient, - author, - buildingBlockType, savedObjectsClient, - description, - eventCategoryOverride, - falsePositives, - enabled, - query, - language, - license, - outputIndex, - savedId, - timelineId, - timelineTitle, - meta, - filters, - from, - id, - ruleId, - index, - interval, - maxSignals, - riskScore, - riskScoreMapping, - ruleNameOverride, - name, - severity, - severityMapping, - tags, - threat, - threshold, - threatFilters, - threatIndex, - threatQuery, - threatMapping, - threatLanguage, - concurrentSearches, - itemsPerSearch, - timestampOverride, - to, - type, - references, - version, - note, - exceptionsList, - anomalyThreshold, - machineLearningJobId, - actions, + defaultOutputIndex, + ruleUpdate, }: UpdateRulesOptions): Promise => { - const rule = await readRules({ alertsClient, ruleId, id }); - if (rule == null) { + const existingRule = await readRules({ + alertsClient, + ruleId: ruleUpdate.rule_id, + id: ruleUpdate.id, + }); + if (existingRule == null) { return null; } - const calculatedVersion = calculateVersion(rule.params.immutable, rule.params.version, { - author, - buildingBlockType, - description, - eventCategoryOverride, - falsePositives, - query, - language, - license, - outputIndex, - savedId, - timelineId, - timelineTitle, - meta, - filters, - from, - index, - interval, - maxSignals, - riskScore, - riskScoreMapping, - ruleNameOverride, - name, - severity, - severityMapping, - tags, - threat, - threshold, - threatFilters, - threatIndex, - threatQuery, - threatMapping, - threatLanguage, - concurrentSearches, - itemsPerSearch, - timestampOverride, - to, - type, - references, - version, - note, - anomalyThreshold, - machineLearningJobId, - exceptionsList, - }); + const typeSpecificParams = typeSpecificSnakeToCamel(ruleUpdate); + const throttle = ruleUpdate.throttle ?? null; + const enabled = ruleUpdate.enabled ?? true; + const newInternalRule: InternalRuleUpdate = { + name: ruleUpdate.name, + tags: addTags(ruleUpdate.tags ?? [], existingRule.params.ruleId, false), + params: { + author: ruleUpdate.author ?? [], + buildingBlockType: ruleUpdate.building_block_type, + description: ruleUpdate.description, + ruleId: existingRule.params.ruleId, + falsePositives: ruleUpdate.false_positives ?? [], + from: ruleUpdate.from ?? 'now-6m', + // Unlike the create route, immutable comes from the existing rule here + immutable: existingRule.params.immutable, + license: ruleUpdate.license, + outputIndex: ruleUpdate.output_index ?? defaultOutputIndex, + timelineId: ruleUpdate.timeline_id, + timelineTitle: ruleUpdate.timeline_title, + meta: ruleUpdate.meta, + maxSignals: ruleUpdate.max_signals ?? DEFAULT_MAX_SIGNALS, + riskScore: ruleUpdate.risk_score, + riskScoreMapping: ruleUpdate.risk_score_mapping ?? [], + ruleNameOverride: ruleUpdate.rule_name_override, + severity: ruleUpdate.severity, + severityMapping: ruleUpdate.severity_mapping ?? [], + threat: ruleUpdate.threat ?? [], + timestampOverride: ruleUpdate.timestamp_override, + to: ruleUpdate.to ?? 'now', + references: ruleUpdate.references ?? [], + note: ruleUpdate.note, + // Always use the version from the request if specified. If it isn't specified, leave immutable rules alone and + // increment the version of mutable rules by 1. + version: + ruleUpdate.version ?? existingRule.params.immutable + ? existingRule.params.version + : existingRule.params.version + 1, + exceptionsList: ruleUpdate.exceptions_list ?? [], + ...typeSpecificParams, + }, + schedule: { interval: ruleUpdate.interval ?? '5m' }, + actions: throttle === 'rule' ? (ruleUpdate.actions ?? []).map(transformRuleToAlertAction) : [], + throttle: null, + }; const update = await alertsClient.update({ - id: rule.id, - data: { - tags: addTags(tags, rule.params.ruleId, rule.params.immutable), - name, - schedule: { interval }, - actions: actions.map(transformRuleToAlertAction), - throttle: null, - params: { - author, - buildingBlockType, - description, - ruleId: rule.params.ruleId, - falsePositives, - from, - immutable: rule.params.immutable, - query, - language, - license, - outputIndex, - savedId, - timelineId, - timelineTitle, - meta, - filters, - index, - maxSignals, - riskScore, - riskScoreMapping, - ruleNameOverride, - severity, - severityMapping, - threat, - threshold, - threatFilters, - threatIndex, - threatQuery, - threatMapping, - threatLanguage, - timestampOverride, - to, - type, - references, - note, - version: calculatedVersion, - anomalyThreshold, - machineLearningJobId, - exceptionsList, - }, - }, + id: existingRule.id, + data: newInternalRule, }); - if (rule.enabled && enabled === false) { - await alertsClient.disable({ id: rule.id }); - } else if (!rule.enabled && enabled === true) { - await alertsClient.enable({ id: rule.id }); + if (existingRule.enabled && enabled === false) { + await alertsClient.disable({ id: existingRule.id }); + } else if (!existingRule.enabled && enabled === true) { + await alertsClient.enable({ id: existingRule.id }); const ruleStatusClient = ruleStatusSavedObjectsClientFactory(savedObjectsClient); const ruleCurrentStatus = await ruleStatusClient.find({ perPage: 1, sortField: 'statusDate', sortOrder: 'desc', - search: rule.id, + search: existingRule.id, searchFields: ['alertId'], }); @@ -189,6 +104,5 @@ export const updateRules = async ({ }); } } - return { ...update, enabled }; }; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/utils.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/utils.ts index 83d9e3fd3e59f..613e8e474079c 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/utils.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/utils.ts @@ -136,10 +136,7 @@ export const calculateVersion = ( // the version number if only the enabled/disabled flag is being set. Likewise if we get other // properties we are not expecting such as updatedAt we do not to cause a version number bump // on that either. - const removedNullValues = pickBy( - (value: unknown) => value != null, - updateProperties - ); + const removedNullValues = removeUndefined(updateProperties); if (isEmpty(removedNullValues)) { return currentVersion; } else { @@ -147,6 +144,10 @@ export const calculateVersion = ( } }; +export const removeUndefined = (obj: object) => { + return pickBy((value: unknown) => value != null, obj); +}; + export const calculateName = ({ updatedName, originalName, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/schemas/rule_converters.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/schemas/rule_converters.ts new file mode 100644 index 0000000000000..86d85cd2a066e --- /dev/null +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/schemas/rule_converters.ts @@ -0,0 +1,266 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import uuid from 'uuid'; +import { InternalRuleCreate, InternalRuleResponse, TypeSpecificRuleParams } from './rule_schemas'; +import { assertUnreachable } from '../../../../common/utility_types'; +import { + CreateRulesSchema, + CreateTypeSpecific, + FullResponseSchema, + ResponseTypeSpecific, +} from '../../../../common/detection_engine/schemas/request'; +import { RuleActions } from '../rule_actions/types'; +import { AppClient } from '../../../types'; +import { addTags } from '../rules/add_tags'; +import { DEFAULT_MAX_SIGNALS, SERVER_APP_ID, SIGNALS_ID } from '../../../../common/constants'; +import { transformRuleToAlertAction } from '../../../../common/detection_engine/transform_actions'; + +// These functions provide conversions from the request API schema to the internal rule schema and from the internal rule schema +// to the response API schema. This provides static type-check assurances that the internal schema is in sync with the API schema for +// required and defaultable fields. However, it is still possible to add an optional field to the API schema +// without causing a type-check error here. + +// Converts params from the snake case API format to the internal camel case format AND applies default values where needed. +// Notice that params.language is possibly undefined for most rule types in the API but we default it to kuery to match +// the legacy API behavior +export const typeSpecificSnakeToCamel = (params: CreateTypeSpecific): TypeSpecificRuleParams => { + switch (params.type) { + case 'eql': { + return { + type: params.type, + language: params.language, + index: params.index, + query: params.query, + filters: params.filters, + eventCategoryOverride: params.event_category_override, + }; + } + case 'threat_match': { + return { + type: params.type, + language: params.language ?? 'kuery', + index: params.index, + query: params.query, + filters: params.filters, + savedId: params.saved_id, + threatFilters: params.threat_filters, + threatQuery: params.threat_query, + threatMapping: params.threat_mapping, + threatLanguage: params.threat_language, + threatIndex: params.threat_index, + concurrentSearches: params.concurrent_searches, + itemsPerSearch: params.items_per_search, + }; + } + case 'query': { + return { + type: params.type, + language: params.language ?? 'kuery', + index: params.index, + query: params.query ?? '', + filters: params.filters, + savedId: params.saved_id, + }; + } + case 'saved_query': { + return { + type: params.type, + language: params.language ?? 'kuery', + index: params.index, + query: params.query, + filters: params.filters, + savedId: params.saved_id, + }; + } + case 'threshold': { + return { + type: params.type, + language: params.language ?? 'kuery', + index: params.index, + query: params.query, + filters: params.filters, + savedId: params.saved_id, + threshold: params.threshold, + }; + } + case 'machine_learning': { + return { + type: params.type, + anomalyThreshold: params.anomaly_threshold, + machineLearningJobId: params.machine_learning_job_id, + }; + } + default: { + return assertUnreachable(params); + } + } +}; + +export const convertCreateAPIToInternalSchema = ( + input: CreateRulesSchema, + siemClient: AppClient +): InternalRuleCreate => { + const typeSpecificParams = typeSpecificSnakeToCamel(input); + const newRuleId = input.rule_id ?? uuid.v4(); + return { + name: input.name, + tags: addTags(input.tags ?? [], newRuleId, false), + alertTypeId: SIGNALS_ID, + consumer: SERVER_APP_ID, + params: { + author: input.author ?? [], + buildingBlockType: input.building_block_type, + description: input.description, + ruleId: newRuleId, + falsePositives: input.false_positives ?? [], + from: input.from ?? 'now-6m', + immutable: false, + license: input.license, + outputIndex: input.output_index ?? siemClient.getSignalsIndex(), + timelineId: input.timeline_id, + timelineTitle: input.timeline_title, + meta: input.meta, + maxSignals: input.max_signals ?? DEFAULT_MAX_SIGNALS, + riskScore: input.risk_score, + riskScoreMapping: input.risk_score_mapping ?? [], + ruleNameOverride: input.rule_name_override, + severity: input.severity, + severityMapping: input.severity_mapping ?? [], + threat: input.threat ?? [], + timestampOverride: input.timestamp_override, + to: input.to ?? 'now', + references: input.references ?? [], + note: input.note, + version: input.version ?? 1, + exceptionsList: input.exceptions_list ?? [], + ...typeSpecificParams, + }, + schedule: { interval: input.interval ?? '5m' }, + enabled: input.enabled ?? true, + actions: input.throttle === 'rule' ? (input.actions ?? []).map(transformRuleToAlertAction) : [], + throttle: null, + }; +}; + +// Converts the internal rule data structure to the response API schema +export const typeSpecificCamelToSnake = (params: TypeSpecificRuleParams): ResponseTypeSpecific => { + switch (params.type) { + case 'eql': { + return { + type: params.type, + language: params.language, + index: params.index, + query: params.query, + filters: params.filters, + event_category_override: params.eventCategoryOverride, + }; + } + case 'threat_match': { + return { + type: params.type, + language: params.language, + index: params.index, + query: params.query, + filters: params.filters, + saved_id: params.savedId, + threat_filters: params.threatFilters, + threat_query: params.threatQuery, + threat_mapping: params.threatMapping, + threat_language: params.threatLanguage, + threat_index: params.threatIndex, + concurrent_searches: params.concurrentSearches, + items_per_search: params.itemsPerSearch, + }; + } + case 'query': { + return { + type: params.type, + language: params.language, + index: params.index, + query: params.query, + filters: params.filters, + saved_id: params.savedId, + }; + } + case 'saved_query': { + return { + type: params.type, + language: params.language, + index: params.index, + query: params.query, + filters: params.filters, + saved_id: params.savedId, + }; + } + case 'threshold': { + return { + type: params.type, + language: params.language, + index: params.index, + query: params.query, + filters: params.filters, + saved_id: params.savedId, + threshold: params.threshold, + }; + } + case 'machine_learning': { + return { + type: params.type, + anomaly_threshold: params.anomalyThreshold, + machine_learning_job_id: params.machineLearningJobId, + }; + } + default: { + return assertUnreachable(params); + } + } +}; + +export const internalRuleToAPIResponse = ( + rule: InternalRuleResponse, + ruleActions: RuleActions +): FullResponseSchema => { + return { + id: rule.id, + immutable: rule.params.immutable, + updated_at: rule.updatedAt, + updated_by: rule.updatedBy, + created_at: rule.createdAt, + created_by: rule.createdBy, + name: rule.name, + tags: rule.tags, + interval: rule.schedule.interval, + enabled: rule.enabled, + throttle: ruleActions.ruleThrottle, + actions: ruleActions.actions, + description: rule.params.description, + risk_score: rule.params.riskScore, + severity: rule.params.severity, + building_block_type: rule.params.buildingBlockType, + note: rule.params.note, + license: rule.params.license, + output_index: rule.params.outputIndex, + timeline_id: rule.params.timelineId, + timeline_title: rule.params.timelineTitle, + meta: rule.params.meta, + rule_name_override: rule.params.ruleNameOverride, + timestamp_override: rule.params.timestampOverride, + author: rule.params.author ?? [], + false_positives: rule.params.falsePositives, + from: rule.params.from, + rule_id: rule.params.ruleId, + max_signals: rule.params.maxSignals, + risk_score_mapping: rule.params.riskScoreMapping ?? [], + severity_mapping: rule.params.severityMapping ?? [], + threat: rule.params.threat, + to: rule.params.to, + references: rule.params.references, + version: rule.params.version, + exceptions_list: rule.params.exceptionsList ?? [], + ...typeSpecificCamelToSnake(rule.params), + }; +}; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/schemas/rule_schemas.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/schemas/rule_schemas.ts new file mode 100644 index 0000000000000..5bb8d6d6746f9 --- /dev/null +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/schemas/rule_schemas.ts @@ -0,0 +1,210 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import * as t from 'io-ts'; + +import { listArrayOrUndefined } from '../../../../common/detection_engine/schemas/types/lists'; +import { + threat_mapping, + threat_index, + threat_query, + concurrentSearchesOrUndefined, + itemsPerSearchOrUndefined, +} from '../../../../common/detection_engine/schemas/types/threat_mapping'; +import { + authorOrUndefined, + buildingBlockTypeOrUndefined, + description, + enabled, + noteOrUndefined, + false_positives, + from, + rule_id, + immutable, + indexOrUndefined, + licenseOrUndefined, + output_index, + timelineIdOrUndefined, + timelineTitleOrUndefined, + metaOrUndefined, + name, + query, + queryOrUndefined, + filtersOrUndefined, + machine_learning_job_id, + max_signals, + risk_score, + riskScoreMappingOrUndefined, + ruleNameOverrideOrUndefined, + severity, + severityMappingOrUndefined, + tags, + timestampOverrideOrUndefined, + threat, + to, + references, + version, + eventCategoryOverrideOrUndefined, + savedIdOrUndefined, + saved_id, + threshold, + anomaly_threshold, + actionsCamel, + throttleOrNull, + createdByOrNull, + updatedByOrNull, + created_at, + updated_at, +} from '../../../../common/detection_engine/schemas/common/schemas'; +import { SIGNALS_ID, SERVER_APP_ID } from '../../../../common/constants'; + +const nonEqlLanguages = t.keyof({ kuery: null, lucene: null }); +export const baseRuleParams = t.exact( + t.type({ + author: authorOrUndefined, + buildingBlockType: buildingBlockTypeOrUndefined, + description, + note: noteOrUndefined, + falsePositives: false_positives, + from, + ruleId: rule_id, + immutable, + license: licenseOrUndefined, + outputIndex: output_index, + timelineId: timelineIdOrUndefined, + timelineTitle: timelineTitleOrUndefined, + meta: metaOrUndefined, + // maxSignals not used in ML rules but probably should be used + maxSignals: max_signals, + riskScore: risk_score, + riskScoreMapping: riskScoreMappingOrUndefined, + ruleNameOverride: ruleNameOverrideOrUndefined, + severity, + severityMapping: severityMappingOrUndefined, + timestampOverride: timestampOverrideOrUndefined, + threat, + to, + references, + version, + exceptionsList: listArrayOrUndefined, + }) +); +export type BaseRuleParams = t.TypeOf; + +const eqlSpecificRuleParams = t.type({ + type: t.literal('eql'), + language: t.literal('eql'), + index: indexOrUndefined, + query, + filters: filtersOrUndefined, + eventCategoryOverride: eventCategoryOverrideOrUndefined, +}); + +const threatSpecificRuleParams = t.type({ + type: t.literal('threat_match'), + language: nonEqlLanguages, + index: indexOrUndefined, + query, + filters: filtersOrUndefined, + savedId: savedIdOrUndefined, + threatFilters: filtersOrUndefined, + threatQuery: threat_query, + threatMapping: threat_mapping, + threatLanguage: t.union([nonEqlLanguages, t.undefined]), + threatIndex: threat_index, + concurrentSearches: concurrentSearchesOrUndefined, + itemsPerSearch: itemsPerSearchOrUndefined, +}); + +const querySpecificRuleParams = t.exact( + t.type({ + type: t.literal('query'), + language: nonEqlLanguages, + index: indexOrUndefined, + query, + filters: filtersOrUndefined, + savedId: savedIdOrUndefined, + }) +); + +const savedQuerySpecificRuleParams = t.type({ + type: t.literal('saved_query'), + // Having language, query, and filters possibly defined adds more code confusion and probably user confusion + // if the saved object gets deleted for some reason + language: nonEqlLanguages, + index: indexOrUndefined, + query: queryOrUndefined, + filters: filtersOrUndefined, + savedId: saved_id, +}); + +const thresholdSpecificRuleParams = t.type({ + type: t.literal('threshold'), + language: nonEqlLanguages, + index: indexOrUndefined, + query, + filters: filtersOrUndefined, + savedId: savedIdOrUndefined, + threshold, +}); + +const machineLearningSpecificRuleParams = t.type({ + type: t.literal('machine_learning'), + anomalyThreshold: anomaly_threshold, + machineLearningJobId: machine_learning_job_id, +}); + +export const typeSpecificRuleParams = t.union([ + eqlSpecificRuleParams, + threatSpecificRuleParams, + querySpecificRuleParams, + savedQuerySpecificRuleParams, + thresholdSpecificRuleParams, + machineLearningSpecificRuleParams, +]); +export type TypeSpecificRuleParams = t.TypeOf; + +export const ruleParams = t.intersection([baseRuleParams, typeSpecificRuleParams]); +export type RuleParams = t.TypeOf; + +export const internalRuleCreate = t.type({ + name, + tags, + alertTypeId: t.literal(SIGNALS_ID), + consumer: t.literal(SERVER_APP_ID), + schedule: t.type({ + interval: t.string, + }), + enabled, + actions: actionsCamel, + params: ruleParams, + throttle: throttleOrNull, +}); +export type InternalRuleCreate = t.TypeOf; + +export const internalRuleUpdate = t.type({ + name, + tags, + schedule: t.type({ + interval: t.string, + }), + actions: actionsCamel, + params: ruleParams, + throttle: throttleOrNull, +}); +export type InternalRuleUpdate = t.TypeOf; + +export const internalRuleResponse = t.intersection([ + internalRuleCreate, + t.type({ + id: t.string, + createdBy: createdByOrNull, + updatedBy: updatedByOrNull, + createdAt: created_at, + updatedAt: updated_at, + }), +]); +export type InternalRuleResponse = t.TypeOf; diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/home.helpers.ts b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/home.helpers.ts index a8e8117d85f5f..1b23bfcf51024 100644 --- a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/home.helpers.ts +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/home.helpers.ts @@ -5,13 +5,7 @@ */ import { act } from 'react-dom/test-utils'; -import { - registerTestBed, - findTestSubject, - TestBed, - TestBedConfig, - nextTick, -} from '../../../../../test_utils'; +import { registerTestBed, findTestSubject, TestBed, TestBedConfig, delay } from '@kbn/test/jest'; import { SnapshotRestoreHome } from '../../../public/application/sections/home/home'; import { BASE_PATH } from '../../../public/application/constants'; import { WithAppDependencies } from './setup_environment'; @@ -65,7 +59,7 @@ export const setup = async (): Promise => { await act(async () => { const { href } = repositoryLink.props(); router.navigateTo(href!); - await nextTick(10); + await delay(10); component.update(); }); }; @@ -89,7 +83,7 @@ export const setup = async (): Promise => { await act(async () => { const { href } = snapshotLink.props(); router.navigateTo(href!); - await nextTick(100); + await delay(100); component.update(); }); }; diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/index.ts b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/index.ts index 69d1423f5f8fb..8660edc26df3a 100644 --- a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/index.ts +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/index.ts @@ -11,7 +11,7 @@ import { setup as policyAddSetup } from './policy_add.helpers'; import { setup as policyEditSetup } from './policy_edit.helpers'; import { setup as restoreSnapshotSetup } from './restore_snapshot.helpers'; -export { nextTick, getRandomString, findTestSubject, TestBed } from '../../../../../test_utils'; +export { nextTick, getRandomString, findTestSubject, TestBed, delay } from '@kbn/test/jest'; export { setupEnvironment } from './setup_environment'; diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/policy_add.helpers.ts b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/policy_add.helpers.ts index e8528889eb231..69fdf7fa2aa6c 100644 --- a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/policy_add.helpers.ts +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/policy_add.helpers.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, TestBedConfig } from '../../../../../test_utils'; +import { registerTestBed, TestBedConfig } from '@kbn/test/jest'; import { PolicyAdd } from '../../../public/application/sections/policy_add'; import { formSetup, PolicyFormTestSubjects } from './policy_form.helpers'; import { WithAppDependencies } from './setup_environment'; diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/policy_edit.helpers.ts b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/policy_edit.helpers.ts index f009afbb2eacc..69f0391d53374 100644 --- a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/policy_edit.helpers.ts +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/policy_edit.helpers.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, TestBedConfig } from '../../../../../test_utils'; +import { registerTestBed, TestBedConfig } from '@kbn/test/jest'; import { PolicyEdit } from '../../../public/application/sections/policy_edit'; import { WithAppDependencies } from './setup_environment'; import { POLICY_NAME } from './constant'; diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/policy_form.helpers.ts b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/policy_form.helpers.ts index ab2963223f678..5f0e321b66e6e 100644 --- a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/policy_form.helpers.ts +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/policy_form.helpers.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { TestBed, SetupFunc } from '../../../../../test_utils'; +import { TestBed, SetupFunc } from '@kbn/test/jest'; export interface PolicyFormTestBed extends TestBed { actions: { diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/repository_add.helpers.ts b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/repository_add.helpers.ts index fa4421988740b..cedab7c3581b9 100644 --- a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/repository_add.helpers.ts +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/repository_add.helpers.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, TestBed } from '../../../../../test_utils'; +import { registerTestBed, TestBed } from '@kbn/test/jest'; import { RepositoryType } from '../../../common/types'; import { RepositoryAdd } from '../../../public/application/sections/repository_add'; import { WithAppDependencies } from './setup_environment'; diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/repository_edit.helpers.ts b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/repository_edit.helpers.ts index 043b21270cc8d..110c6f0f2cdf3 100644 --- a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/repository_edit.helpers.ts +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/repository_edit.helpers.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, TestBedConfig } from '../../../../../test_utils'; +import { registerTestBed, TestBedConfig } from '@kbn/test/jest'; import { RepositoryEdit } from '../../../public/application/sections/repository_edit'; import { WithAppDependencies } from './setup_environment'; import { REPOSITORY_NAME } from './constant'; diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/restore_snapshot.helpers.ts b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/restore_snapshot.helpers.ts index cfe3027b6d43f..a1b1129dd4b15 100644 --- a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/restore_snapshot.helpers.ts +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/restore_snapshot.helpers.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, TestBed, TestBedConfig } from '../../../../../test_utils'; +import { registerTestBed, TestBed, TestBedConfig } from '@kbn/test/jest'; import { RestoreSnapshot } from '../../../public/application/sections/restore_snapshot'; import { WithAppDependencies } from './setup_environment'; diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/home.test.ts b/x-pack/plugins/snapshot_restore/__jest__/client_integration/home.test.ts index 6021ab2a42c90..50a117f8b9885 100644 --- a/x-pack/plugins/snapshot_restore/__jest__/client_integration/home.test.ts +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/home.test.ts @@ -12,6 +12,7 @@ import { setupEnvironment, pageHelpers, nextTick, + delay, getRandomString, findTestSubject, } from './helpers'; @@ -397,7 +398,7 @@ describe('', () => { await act(async () => { testBed.actions.selectTab('snapshots'); - await nextTick(100); + await delay(100); testBed.component.update(); }); }); @@ -426,7 +427,7 @@ describe('', () => { await act(async () => { testBed.actions.selectTab('snapshots'); - await nextTick(2000); + await delay(2000); testBed.component.update(); }); }); @@ -466,7 +467,7 @@ describe('', () => { await act(async () => { testBed.actions.selectTab('snapshots'); - await nextTick(2000); + await delay(2000); testBed.component.update(); }); }); diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/repository_add.test.ts b/x-pack/plugins/snapshot_restore/__jest__/client_integration/repository_add.test.ts index e0c9aeffa09e8..593882643af58 100644 --- a/x-pack/plugins/snapshot_restore/__jest__/client_integration/repository_add.test.ts +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/repository_add.test.ts @@ -8,7 +8,7 @@ import { act } from 'react-dom/test-utils'; import { INVALID_NAME_CHARS } from '../../public/application/services/validation/validate_repository'; import { getRepository } from '../../test/fixtures'; import { RepositoryType } from '../../common/types'; -import { setupEnvironment, pageHelpers, nextTick } from './helpers'; +import { setupEnvironment, pageHelpers, nextTick, delay } from './helpers'; import { RepositoryAddTestBed } from './helpers/repository_add.helpers'; const { setup } = pageHelpers.repositoryAdd; @@ -176,7 +176,7 @@ describe('', () => { await act(async () => { actions.clickBackButton(); - await nextTick(100); + await delay(100); component.update(); }); }; diff --git a/x-pack/plugins/snapshot_restore/test/fixtures/policy.ts b/x-pack/plugins/snapshot_restore/test/fixtures/policy.ts index a293f505147e4..0f2d6c11db708 100644 --- a/x-pack/plugins/snapshot_restore/test/fixtures/policy.ts +++ b/x-pack/plugins/snapshot_restore/test/fixtures/policy.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getRandomString, getRandomNumber } from '../../../../test_utils'; +import { getRandomString, getRandomNumber } from '@kbn/test/jest'; import { SlmPolicy } from '../../common/types'; import { DEFAULT_POLICY_SCHEDULE } from '../../public/application/constants'; diff --git a/x-pack/plugins/snapshot_restore/test/fixtures/repository.ts b/x-pack/plugins/snapshot_restore/test/fixtures/repository.ts index f8b30f3c5d362..6045976180987 100644 --- a/x-pack/plugins/snapshot_restore/test/fixtures/repository.ts +++ b/x-pack/plugins/snapshot_restore/test/fixtures/repository.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getRandomString } from '../../../../test_utils'; +import { getRandomString } from '@kbn/test/jest'; import { RepositoryType } from '../../common/types'; const defaultSettings: any = { chunkSize: '10mb', location: '/tmp/es-backups' }; diff --git a/x-pack/plugins/snapshot_restore/test/fixtures/snapshot.ts b/x-pack/plugins/snapshot_restore/test/fixtures/snapshot.ts index e59f4689d9e3f..f31a884f3207c 100644 --- a/x-pack/plugins/snapshot_restore/test/fixtures/snapshot.ts +++ b/x-pack/plugins/snapshot_restore/test/fixtures/snapshot.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getRandomString, getRandomNumber } from '../../../../test_utils'; +import { getRandomString, getRandomNumber } from '@kbn/test/jest'; export const getSnapshot = ({ repository = 'my-repo', diff --git a/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_subtitle/advanced_settings_subtitle.test.tsx b/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_subtitle/advanced_settings_subtitle.test.tsx index 7134049c4cf8f..218c04ebfdf83 100644 --- a/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_subtitle/advanced_settings_subtitle.test.tsx +++ b/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_subtitle/advanced_settings_subtitle.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { AdvancedSettingsSubtitle } from './advanced_settings_subtitle'; import { EuiCallOut } from '@elastic/eui'; import { act } from '@testing-library/react'; diff --git a/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_title/advanced_settings_title.test.tsx b/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_title/advanced_settings_title.test.tsx index b772ff433abec..3d49d48a987e5 100644 --- a/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_title/advanced_settings_title.test.tsx +++ b/x-pack/plugins/spaces/public/advanced_settings/components/advanced_settings_title/advanced_settings_title.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { AdvancedSettingsTitle } from './advanced_settings_title'; import { SpaceAvatar } from '../../../space_avatar'; import { act } from '@testing-library/react'; diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_mode_control.test.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_mode_control.test.tsx index 4e49a2da3e534..cf406653990c8 100644 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_mode_control.test.tsx +++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_mode_control.test.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { ReactWrapper } from 'enzyme'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { CopyModeControl, CopyModeControlProps } from './copy_mode_control'; describe('CopyModeControl', () => { diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout.test.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout.test.tsx index f484b738bd222..ac45db40a3810 100644 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout.test.tsx +++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout.test.tsx @@ -5,12 +5,12 @@ */ import React from 'react'; import Boom from '@hapi/boom'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { CopySavedObjectsToSpaceFlyout } from './copy_to_space_flyout'; import { CopyToSpaceForm } from './copy_to_space_form'; import { EuiLoadingSpinner, EuiEmptyPrompt } from '@elastic/eui'; import { Space } from '../../../common/model/space'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { findTestSubject } from '@kbn/test/jest'; import { SelectableSpacesControl } from './selectable_spaces_control'; import { act } from '@testing-library/react'; import { ProcessingCopyToSpace } from './processing_copy_to_space'; diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/resolve_all_conflicts.test.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/resolve_all_conflicts.test.tsx index 7da265d8f9958..f2d5009cb9f44 100644 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/resolve_all_conflicts.test.tsx +++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/resolve_all_conflicts.test.tsx @@ -7,8 +7,8 @@ import React from 'react'; import { ReactWrapper } from 'enzyme'; import { act } from '@testing-library/react'; -import { shallowWithIntl, mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { shallowWithIntl, mountWithIntl, nextTick } from '@kbn/test/jest'; +import { findTestSubject } from '@kbn/test/jest'; import { ResolveAllConflicts, ResolveAllConflictsProps } from './resolve_all_conflicts'; import { SummarizedCopyToSpaceResult } from '..'; import { ImportRetry } from '../types'; diff --git a/x-pack/plugins/spaces/public/management/components/confirm_delete_modal/confirm_delete_modal.test.tsx b/x-pack/plugins/spaces/public/management/components/confirm_delete_modal/confirm_delete_modal.test.tsx index 331435b54edb7..68801bfbb2ec8 100644 --- a/x-pack/plugins/spaces/public/management/components/confirm_delete_modal/confirm_delete_modal.test.tsx +++ b/x-pack/plugins/spaces/public/management/components/confirm_delete_modal/confirm_delete_modal.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { ConfirmDeleteModal } from './confirm_delete_modal'; import { spacesManagerMock } from '../../../spaces_manager/mocks'; import { SpacesManager } from '../../../spaces_manager'; diff --git a/x-pack/plugins/spaces/public/management/components/unauthorized_prompt/unauthorized_prompt.test.tsx b/x-pack/plugins/spaces/public/management/components/unauthorized_prompt/unauthorized_prompt.test.tsx index a2b4c008ac175..3d614cbc10d20 100644 --- a/x-pack/plugins/spaces/public/management/components/unauthorized_prompt/unauthorized_prompt.test.tsx +++ b/x-pack/plugins/spaces/public/management/components/unauthorized_prompt/unauthorized_prompt.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { UnauthorizedPrompt } from './unauthorized_prompt'; describe('UnauthorizedPrompt', () => { diff --git a/x-pack/plugins/spaces/public/management/edit_space/confirm_alter_active_space_modal/confirm_alter_active_space_modal.test.tsx b/x-pack/plugins/spaces/public/management/edit_space/confirm_alter_active_space_modal/confirm_alter_active_space_modal.test.tsx index 4623378c8cee2..017363fe3da11 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/confirm_alter_active_space_modal/confirm_alter_active_space_modal.test.tsx +++ b/x-pack/plugins/spaces/public/management/edit_space/confirm_alter_active_space_modal/confirm_alter_active_space_modal.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { ConfirmAlterActiveSpaceModal } from './confirm_alter_active_space_modal'; describe('ConfirmAlterActiveSpaceModal', () => { diff --git a/x-pack/plugins/spaces/public/management/edit_space/customize_space/customize_space_avatar.test.tsx b/x-pack/plugins/spaces/public/management/edit_space/customize_space/customize_space_avatar.test.tsx index dc20a375ada1e..bfdef5171fc08 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/customize_space/customize_space_avatar.test.tsx +++ b/x-pack/plugins/spaces/public/management/edit_space/customize_space/customize_space_avatar.test.tsx @@ -6,7 +6,7 @@ // @ts-ignore import { EuiColorPicker, EuiFieldText, EuiLink } from '@elastic/eui'; import React from 'react'; -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { CustomizeSpaceAvatar } from './customize_space_avatar'; const space = { diff --git a/x-pack/plugins/spaces/public/management/edit_space/customize_space/space_identifier.test.tsx b/x-pack/plugins/spaces/public/management/edit_space/customize_space/space_identifier.test.tsx index 221dd0febe85a..0de6952b03278 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/customize_space/space_identifier.test.tsx +++ b/x-pack/plugins/spaces/public/management/edit_space/customize_space/space_identifier.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { SpaceValidator } from '../../lib'; import { SpaceIdentifier } from './space_identifier'; diff --git a/x-pack/plugins/spaces/public/management/edit_space/delete_spaces_button.test.tsx b/x-pack/plugins/spaces/public/management/edit_space/delete_spaces_button.test.tsx index fbb2a3d07a293..61a769b618dd7 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/delete_spaces_button.test.tsx +++ b/x-pack/plugins/spaces/public/management/edit_space/delete_spaces_button.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { DeleteSpacesButton } from './delete_spaces_button'; import { spacesManagerMock } from '../../spaces_manager/mocks'; import { SpacesManager } from '../../spaces_manager'; diff --git a/x-pack/plugins/spaces/public/management/edit_space/enabled_features/enabled_features.test.tsx b/x-pack/plugins/spaces/public/management/edit_space/enabled_features/enabled_features.test.tsx index 093c4fb02428b..aa47e439af95f 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/enabled_features/enabled_features.test.tsx +++ b/x-pack/plugins/spaces/public/management/edit_space/enabled_features/enabled_features.test.tsx @@ -5,11 +5,11 @@ */ import React from 'react'; -import { mountWithIntl, nextTick, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick, shallowWithIntl } from '@kbn/test/jest'; import { EnabledFeatures } from './enabled_features'; import { KibanaFeatureConfig } from '../../../../../features/public'; import { DEFAULT_APP_CATEGORIES } from '../../../../../../../src/core/public'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { findTestSubject } from '@kbn/test/jest'; import { EuiCheckboxProps } from '@elastic/eui'; const features: KibanaFeatureConfig[] = [ diff --git a/x-pack/plugins/spaces/public/management/edit_space/manage_space_page.test.tsx b/x-pack/plugins/spaces/public/management/edit_space/manage_space_page.test.tsx index 04d8dfb87cf95..54960fba731d2 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/manage_space_page.test.tsx +++ b/x-pack/plugins/spaces/public/management/edit_space/manage_space_page.test.tsx @@ -9,7 +9,7 @@ import { ReactWrapper } from 'enzyme'; import React from 'react'; import { wait } from '@testing-library/react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { ConfirmAlterActiveSpaceModal } from './confirm_alter_active_space_modal'; import { ManageSpacePage } from './manage_space_page'; import { spacesManagerMock } from '../../spaces_manager/mocks'; diff --git a/x-pack/plugins/spaces/public/management/edit_space/reserved_space_badge.test.tsx b/x-pack/plugins/spaces/public/management/edit_space/reserved_space_badge.test.tsx index d9ad63c30adde..51885c5559bae 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/reserved_space_badge.test.tsx +++ b/x-pack/plugins/spaces/public/management/edit_space/reserved_space_badge.test.tsx @@ -6,7 +6,7 @@ import { EuiBadge } from '@elastic/eui'; import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { ReservedSpaceBadge } from './reserved_space_badge'; const reservedSpace = { diff --git a/x-pack/plugins/spaces/public/management/edit_space/section_panel/section_panel.test.tsx b/x-pack/plugins/spaces/public/management/edit_space/section_panel/section_panel.test.tsx index 576881398a63c..37c54ea7b72aa 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/section_panel/section_panel.test.tsx +++ b/x-pack/plugins/spaces/public/management/edit_space/section_panel/section_panel.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { SectionPanel } from './section_panel'; test('it renders without blowing up', () => { diff --git a/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_pages.test.tsx b/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_pages.test.tsx index 34942221e53ee..606bb5cfbdcc9 100644 --- a/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_pages.test.tsx +++ b/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_pages.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { mountWithIntl, shallowWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl, nextTick } from '@kbn/test/jest'; import { SpaceAvatar } from '../../space_avatar'; import { spacesManagerMock } from '../../spaces_manager/mocks'; import { SpacesManager } from '../../spaces_manager'; diff --git a/x-pack/plugins/spaces/public/nav_control/components/manage_spaces_button.test.tsx b/x-pack/plugins/spaces/public/nav_control/components/manage_spaces_button.test.tsx index 009b6aa89d089..0f09b638a1d0b 100644 --- a/x-pack/plugins/spaces/public/nav_control/components/manage_spaces_button.test.tsx +++ b/x-pack/plugins/spaces/public/nav_control/components/manage_spaces_button.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { ManageSpacesButton } from './manage_spaces_button'; describe('ManageSpacesButton', () => { diff --git a/x-pack/plugins/spaces/public/nav_control/nav_control_popover.test.tsx b/x-pack/plugins/spaces/public/nav_control/nav_control_popover.test.tsx index be12550648a0a..b08c1c834ac4f 100644 --- a/x-pack/plugins/spaces/public/nav_control/nav_control_popover.test.tsx +++ b/x-pack/plugins/spaces/public/nav_control/nav_control_popover.test.tsx @@ -12,7 +12,7 @@ import { spacesManagerMock } from '../spaces_manager/mocks'; import { SpacesManager } from '../spaces_manager'; import { NavControlPopover } from './nav_control_popover'; import { EuiHeaderSectionItemButton } from '@elastic/eui'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { wait } from '@testing-library/react'; describe('NavControlPopover', () => { diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout.test.tsx b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout.test.tsx index 29571a17a19bd..2f4188f1e6ed8 100644 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout.test.tsx +++ b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout.test.tsx @@ -5,12 +5,12 @@ */ import React from 'react'; import Boom from '@hapi/boom'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { ShareSavedObjectsToSpaceFlyout } from './share_to_space_flyout'; import { ShareToSpaceForm } from './share_to_space_form'; import { EuiLoadingSpinner, EuiSelectable } from '@elastic/eui'; import { Space } from '../../../common/model/space'; -import { findTestSubject } from 'test_utils/find_test_subject'; +import { findTestSubject } from '@kbn/test/jest'; import { SelectableSpacesControl } from './selectable_spaces_control'; import { act } from '@testing-library/react'; import { spacesManagerMock } from '../../spaces_manager/mocks'; diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/share_saved_objects_to_space_column.test.tsx b/x-pack/plugins/spaces/public/share_saved_objects_to_space/share_saved_objects_to_space_column.test.tsx index 041728a3eac0d..b5ec4349eca12 100644 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/share_saved_objects_to_space_column.test.tsx +++ b/x-pack/plugins/spaces/public/share_saved_objects_to_space/share_saved_objects_to_space_column.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { SpacesManager } from '../spaces_manager'; import { spacesManagerMock } from '../spaces_manager/mocks'; import { ShareToSpaceSavedObjectsManagementColumn } from './share_saved_objects_to_space_column'; diff --git a/x-pack/plugins/spaces/public/space_selector/space_selector.test.tsx b/x-pack/plugins/spaces/public/space_selector/space_selector.test.tsx index 112a8a9a0a685..8ecc8e8200e47 100644 --- a/x-pack/plugins/spaces/public/space_selector/space_selector.test.tsx +++ b/x-pack/plugins/spaces/public/space_selector/space_selector.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { Space } from '../../common/model/space'; import { SpaceSelector } from './space_selector'; import { spacesManagerMock } from '../spaces_manager/mocks'; diff --git a/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.test.ts b/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.test.ts index 7f005e37d96e9..42f3d766adf85 100644 --- a/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.test.ts +++ b/x-pack/plugins/spaces/public/spaces_manager/spaces_manager.test.ts @@ -6,7 +6,7 @@ import { SpacesManager } from '.'; import { coreMock } from 'src/core/public/mocks'; -import { nextTick } from 'test_utils/enzyme_helpers'; +import { nextTick } from '@kbn/test/jest'; describe('SpacesManager', () => { describe('#constructor', () => { diff --git a/x-pack/plugins/spaces/server/default_space/default_space_service.test.ts b/x-pack/plugins/spaces/server/default_space/default_space_service.test.ts index 047dadb446289..25c5a6019b34a 100644 --- a/x-pack/plugins/spaces/server/default_space/default_space_service.test.ts +++ b/x-pack/plugins/spaces/server/default_space/default_space_service.test.ts @@ -21,7 +21,7 @@ import { coreMock, loggingSystemMock } from 'src/core/server/mocks'; import { licensingMock } from '../../../licensing/server/mocks'; import { SpacesLicenseService } from '../../common/licensing'; import { ILicense } from '../../../licensing/server'; -import { nextTick } from 'test_utils/enzyme_helpers'; +import { nextTick } from '@kbn/test/jest'; import { first } from 'rxjs/operators'; const advanceRetry = async (initializeCount: number) => { diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 238b3dccc698a..ba6ac32f2e3d0 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -4925,7 +4925,6 @@ "xpack.apm.jvmsTable.noJvmsLabel": "JVM が見つかりませんでした", "xpack.apm.jvmsTable.nonHeapMemoryColumnLabel": "非ヒープ領域の平均", "xpack.apm.jvmsTable.threadCountColumnLabel": "最大スレッド数", - "xpack.apm.kueryBar.disabledPlaceholder": "ここでは検索は利用できません", "xpack.apm.license.betaBadge": "ベータ", "xpack.apm.license.betaTooltipMessage": "現在、この機能はベータです。不具合を見つけた場合やご意見がある場合、サポートに問い合わせるか、またはディスカッションフォーラムにご報告ください。", "xpack.apm.license.button": "トライアルを開始", @@ -12271,7 +12270,6 @@ "xpack.ml.datavisualizer.page.fieldsPanelTitle": "フィールド", "xpack.ml.datavisualizer.page.metricsPanelTitle": "メトリック", "xpack.ml.datavisualizer.searchPanel.allOptionLabel": "すべて検索", - "xpack.ml.datavisualizer.searchPanel.documentsPerShardLabel": "合計ドキュメント数: {wrappedTotalCount}", "xpack.ml.datavisualizer.searchPanel.invalidKuerySyntaxErrorMessageQueryBar": "無効なクエリ", "xpack.ml.datavisualizer.searchPanel.queryBarPlaceholder": "小さいサンプルサイズを選択することで、クエリの実行時間を短縮しクラスターへの負荷を軽減できます。", "xpack.ml.datavisualizer.searchPanel.queryBarPlaceholderText": "検索… (例: status:200 AND extension:\"PHP\")", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 48654a5ec5ff4..822ccf5cc8409 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -4927,7 +4927,6 @@ "xpack.apm.jvmsTable.noJvmsLabel": "未找到任何 JVM", "xpack.apm.jvmsTable.nonHeapMemoryColumnLabel": "非堆内存平均值", "xpack.apm.jvmsTable.threadCountColumnLabel": "线程计数最大值", - "xpack.apm.kueryBar.disabledPlaceholder": "搜索在此不可用", "xpack.apm.kueryBar.placeholder": "搜索{event, select,\n transaction {事务}\n metric {指标}\n error {错误}\n other {事务、错误和指标}\n }(例如 {queryExample})", "xpack.apm.license.betaBadge": "公测版", "xpack.apm.license.betaTooltipMessage": "此功能当前为公测版。如果遇到任何错误或有任何反馈,请报告问题或访问我们的论坛。", @@ -12285,7 +12284,6 @@ "xpack.ml.datavisualizer.page.fieldsPanelTitle": "字段", "xpack.ml.datavisualizer.page.metricsPanelTitle": "指标", "xpack.ml.datavisualizer.searchPanel.allOptionLabel": "搜索全部", - "xpack.ml.datavisualizer.searchPanel.documentsPerShardLabel": "文档总数:{wrappedTotalCount}", "xpack.ml.datavisualizer.searchPanel.invalidKuerySyntaxErrorMessageQueryBar": "无效查询", "xpack.ml.datavisualizer.searchPanel.queryBarPlaceholder": "选择较小的样例大小将减少查询运行时间和集群上的负载。", "xpack.ml.datavisualizer.searchPanel.queryBarPlaceholderText": "搜索……(例如,status:200 AND extension:\"PHP\")", diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/email/email_connector.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/email/email_connector.test.tsx index 2ef887d0627cc..4fe76b9ff3c2c 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/email/email_connector.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/email/email_connector.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { EmailActionConnector } from '../types'; import EmailActionConnectorFields from './email_connector'; import { DocLinksStart } from 'kibana/public'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/email/email_params.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/email/email_params.test.tsx index ed7b9a19d9541..1198fc26df80d 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/email/email_params.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/email/email_params.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { DocLinksStart } from 'kibana/public'; import { coreMock } from 'src/core/public/mocks'; import EmailParamsFields from './email_params'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/email/email_params.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/email/email_params.tsx index a91cf3e7552bc..eacdf20747fdc 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/email/email_params.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/email/email_params.tsx @@ -11,6 +11,7 @@ import { ActionParamsProps } from '../../../../types'; import { EmailActionParams } from '../types'; import { TextFieldWithMessageVariables } from '../../text_field_with_message_variables'; import { TextAreaWithMessageVariables } from '../../text_area_with_message_variables'; +import { resolvedActionGroupMessage } from '../../../constants'; export const EmailParamsFields = ({ actionParams, @@ -28,11 +29,18 @@ export const EmailParamsFields = ({ const [addBCC, setAddBCC] = useState(false); useEffect(() => { - if (!message && defaultMessage && defaultMessage.length > 0) { + if (defaultMessage === resolvedActionGroupMessage) { + editAction('message', defaultMessage, index); + } else if ( + (!message || message === resolvedActionGroupMessage) && + defaultMessage && + defaultMessage.length > 0 + ) { editAction('message', defaultMessage, index); } + // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); + }, [defaultMessage]); return ( diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/es_index/es_index_connector.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/es_index/es_index_connector.test.tsx index f5f14cb041335..721cb18e1f360 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/es_index/es_index_connector.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/es_index/es_index_connector.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { act } from 'react-dom/test-utils'; import { EsIndexActionConnector } from '../types'; import { coreMock } from '../../../../../../../../src/core/public/mocks'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/es_index/es_index_params.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/es_index/es_index_params.test.tsx index 0e4215e503275..00ec687304427 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/es_index/es_index_params.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/es_index/es_index_params.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import ParamsFields from './es_index_params'; import { DocLinksStart } from 'kibana/public'; import { coreMock } from 'src/core/public/mocks'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/jira_connectors.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/jira_connectors.test.tsx index 6d055f4fdb9f2..1bcb528bbd6c7 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/jira_connectors.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/jira_connectors.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { DocLinksStart } from 'kibana/public'; import JiraConnectorFields from './jira_connectors'; import { JiraActionConnector } from './types'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/jira_params.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/jira_params.test.tsx index 0990baa30eb15..671a575695d69 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/jira_params.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/jira_params.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import JiraParamsFields from './jira_params'; import { DocLinksStart } from 'kibana/public'; import { coreMock } from 'src/core/public/mocks'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_connectors.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_connectors.test.tsx index 18978be7b4680..afd7c429805ac 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_connectors.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_connectors.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { act } from 'react-dom/test-utils'; import { PagerDutyActionConnector } from '.././types'; import PagerDutyActionConnectorFields from './pagerduty_connectors'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.test.tsx index ea947a159b893..6236d7a751e00 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty/pagerduty_params.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { EventActionOptions, SeverityActionOptions } from '.././types'; import PagerDutyParamsFields from './pagerduty_params'; import { DocLinksStart } from 'kibana/public'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/resilient/resilient_connectors.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/resilient/resilient_connectors.test.tsx index 6dede85736fcd..23eebcb4ac017 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/resilient/resilient_connectors.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/resilient/resilient_connectors.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { DocLinksStart } from 'kibana/public'; import ResilientConnectorFields from './resilient_connectors'; import { ResilientActionConnector } from './types'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/resilient/resilient_params.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/resilient/resilient_params.test.tsx index a04e213e04872..b12307e1fdd16 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/resilient/resilient_params.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/resilient/resilient_params.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import ResilientParamsFields from './resilient_params'; import { DocLinksStart } from 'kibana/public'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/server_log/server_log_params.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/server_log/server_log_params.test.tsx index 407cd70d4ad4c..e8429a54b618c 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/server_log/server_log_params.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/server_log/server_log_params.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { ServerLogLevelOptions } from '.././types'; import ServerLogParamsFields from './server_log_params'; import { DocLinksStart } from 'kibana/public'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/server_log/server_log_params.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/server_log/server_log_params.tsx index b79fa0ea94050..a3619f96a45b2 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/server_log/server_log_params.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/server_log/server_log_params.tsx @@ -9,6 +9,7 @@ import { EuiSelect, EuiFormRow } from '@elastic/eui'; import { ActionParamsProps } from '../../../../types'; import { ServerLogActionParams } from '.././types'; import { TextAreaWithMessageVariables } from '../../text_area_with_message_variables'; +import { resolvedActionGroupMessage } from '../../../constants'; export const ServerLogParamsFields: React.FunctionComponent { editAction('level', 'info', index); - if (!message && defaultMessage && defaultMessage.length > 0) { + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + useEffect(() => { + if (defaultMessage === resolvedActionGroupMessage) { + editAction('message', defaultMessage, index); + } else if ( + (!message || message === resolvedActionGroupMessage) && + defaultMessage && + defaultMessage.length > 0 + ) { editAction('message', defaultMessage, index); } + // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); + }, [defaultMessage]); return ( diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/servicenow_connectors.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/servicenow_connectors.test.tsx index b666db4024b12..8840045d6b726 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/servicenow_connectors.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/servicenow_connectors.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { DocLinksStart } from 'kibana/public'; import ServiceNowConnectorFields from './servicenow_connectors'; import { ServiceNowActionConnector } from './types'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/servicenow_params.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/servicenow_params.test.tsx index b4559e2e05b1e..88f76c760bdcf 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/servicenow_params.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/servicenow_params.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import ServiceNowParamsFields from './servicenow_params'; import { DocLinksStart } from 'kibana/public'; import { coreMock } from 'src/core/public/mocks'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/slack/slack_connectors.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/slack/slack_connectors.test.tsx index f87c2ad99fb4f..54ed912d63599 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/slack/slack_connectors.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/slack/slack_connectors.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { act } from '@testing-library/react'; import { SlackActionConnector } from '../types'; import SlackActionFields from './slack_connectors'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/slack/slack_params.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/slack/slack_params.test.tsx index c580424c05b95..cf35677721225 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/slack/slack_params.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/slack/slack_params.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import SlackParamsFields from './slack_params'; import { DocLinksStart } from 'kibana/public'; import { coreMock } from 'src/core/public/mocks'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/slack/slack_params.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/slack/slack_params.tsx index 80a2f9d7709cc..d1498567218d3 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/slack/slack_params.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/slack/slack_params.tsx @@ -8,6 +8,7 @@ import { i18n } from '@kbn/i18n'; import { ActionParamsProps } from '../../../../types'; import { SlackActionParams } from '../types'; import { TextAreaWithMessageVariables } from '../../text_area_with_message_variables'; +import { resolvedActionGroupMessage } from '../../../constants'; const SlackParamsFields: React.FunctionComponent> = ({ actionParams, @@ -19,11 +20,18 @@ const SlackParamsFields: React.FunctionComponent { const { message } = actionParams; useEffect(() => { - if (!message && defaultMessage && defaultMessage.length > 0) { + if (defaultMessage === resolvedActionGroupMessage) { + editAction('message', defaultMessage, index); + } else if ( + (!message || message === resolvedActionGroupMessage) && + defaultMessage && + defaultMessage.length > 0 + ) { editAction('message', defaultMessage, index); } + // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); + }, [defaultMessage]); return ( jest.resetAllMocks()); -describe('actionVariablesFromAlertType', () => { +describe('transformActionVariables', () => { test('should return correct variables when no state or context provided', async () => { const alertType = getAlertType({ context: [], state: [], params: [] }); - expect(actionVariablesFromAlertType(alertType)).toMatchInlineSnapshot(` + expect(transformActionVariables(alertType.actionVariables)).toMatchInlineSnapshot(` Array [ Object { "description": "The id of the alert.", @@ -48,7 +48,7 @@ describe('actionVariablesFromAlertType', () => { state: [], params: [], }); - expect(actionVariablesFromAlertType(alertType)).toMatchInlineSnapshot(` + expect(transformActionVariables(alertType.actionVariables)).toMatchInlineSnapshot(` Array [ Object { "description": "The id of the alert.", @@ -91,7 +91,7 @@ describe('actionVariablesFromAlertType', () => { ], params: [], }); - expect(actionVariablesFromAlertType(alertType)).toMatchInlineSnapshot(` + expect(transformActionVariables(alertType.actionVariables)).toMatchInlineSnapshot(` Array [ Object { "description": "The id of the alert.", @@ -137,7 +137,7 @@ describe('actionVariablesFromAlertType', () => { ], params: [{ name: 'fooP', description: 'fooP-description' }], }); - expect(actionVariablesFromAlertType(alertType)).toMatchInlineSnapshot(` + expect(transformActionVariables(alertType.actionVariables)).toMatchInlineSnapshot(` Array [ Object { "description": "The id of the alert.", diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_variables.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_variables.ts index 8bbe34847016d..2bdec1bea0c1d 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_variables.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_variables.ts @@ -5,14 +5,16 @@ */ import { i18n } from '@kbn/i18n'; -import { AlertType, ActionVariable } from '../../types'; +import { ActionVariable, ActionVariables } from '../../types'; // return a "flattened" list of action variables for an alertType -export function actionVariablesFromAlertType(alertType: AlertType): ActionVariable[] { +export function transformActionVariables(actionVariables: ActionVariables): ActionVariable[] { const alwaysProvidedVars = getAlwaysProvidedActionVariables(); - const contextVars = prefixKeys(alertType.actionVariables.context, 'context.'); - const paramsVars = prefixKeys(alertType.actionVariables.params, 'params.'); - const stateVars = prefixKeys(alertType.actionVariables.state, 'state.'); + const contextVars = actionVariables.context + ? prefixKeys(actionVariables.context, 'context.') + : []; + const paramsVars = prefixKeys(actionVariables.params, 'params.'); + const stateVars = prefixKeys(actionVariables.state, 'state.'); return alwaysProvidedVars.concat(contextVars, paramsVars, stateVars); } diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_connector_form.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_connector_form.test.tsx index cf83062b5781e..cc42c6296e7b3 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_connector_form.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_connector_form.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import * as React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { coreMock } from '../../../../../../../src/core/public/mocks'; import { actionTypeRegistryMock } from '../../action_type_registry.mock'; import { ValidationResult, UserConfiguredActionConnector } from '../../../types'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.test.tsx index 94452e70e6bfa..38c9687ae581e 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.test.tsx @@ -4,12 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ import React, { Fragment, lazy } from 'react'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { coreMock } from '../../../../../../../src/core/public/mocks'; import { act } from 'react-dom/test-utils'; import { actionTypeRegistryMock } from '../../action_type_registry.mock'; import { ValidationResult, Alert, AlertAction } from '../../../types'; import ActionForm from './action_form'; +import { ResolvedActionGroup } from '../../../../../alerts/common'; jest.mock('../../lib/action_connector_api', () => ({ loadAllActions: jest.fn(), loadActionTypes: jest.fn(), @@ -217,15 +218,22 @@ describe('action_form', () => { const wrapper = mountWithIntl( { initialAlert.actions[index].id = id; }} - actionGroups={[{ id: 'default', name: 'Default' }]} + actionGroups={[ + { id: 'default', name: 'Default' }, + { id: 'resolved', name: 'Resolved' }, + ]} setActionGroupIdByIndex={(group: string, index: number) => { initialAlert.actions[index].group = group; }} @@ -346,10 +354,52 @@ describe('action_form', () => { "inputDisplay": "Default", "value": "default", }, + Object { + "data-test-subj": "addNewActionConnectorActionGroup-0-option-resolved", + "inputDisplay": "Resolved", + "value": "resolved", + }, ] `); }); + it('renders selected Resolved action group', async () => { + const wrapper = await setup([ + { + group: ResolvedActionGroup.id, + id: 'test', + actionTypeId: actionType.id, + params: { + message: '', + }, + }, + ]); + const actionOption = wrapper.find( + `[data-test-subj="${actionType.id}-ActionTypeSelectOption"]` + ); + actionOption.first().simulate('click'); + const actionGroupsSelect = wrapper.find( + `[data-test-subj="addNewActionConnectorActionGroup-0"]` + ); + expect((actionGroupsSelect.first().props() as any).options).toMatchInlineSnapshot(` + Array [ + Object { + "data-test-subj": "addNewActionConnectorActionGroup-0-option-default", + "inputDisplay": "Default", + "value": "default", + }, + Object { + "data-test-subj": "addNewActionConnectorActionGroup-0-option-resolved", + "inputDisplay": "Resolved", + "value": "resolved", + }, + ] + `); + expect(actionGroupsSelect.first().text()).toEqual( + 'Select an option: Resolved, is selectedResolved' + ); + }); + it('renders available connectors for the selected action type', async () => { const wrapper = await setup(); const actionOption = wrapper.find( diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx index 3a7341afe3e07..50f5167b9e5c2 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx @@ -27,7 +27,7 @@ import { ActionTypeIndex, ActionConnector, ActionType, - ActionVariable, + ActionVariables, } from '../../../types'; import { SectionLoading } from '../../components/section_loading'; import { ConnectorAddModal } from './connector_add_modal'; @@ -51,7 +51,7 @@ export interface ActionAccordionFormProps { toastNotifications: ToastsSetup; docLinks: DocLinksStart; actionTypes?: ActionType[]; - messageVariables?: ActionVariable[]; + messageVariables?: ActionVariables; defaultActionMessage?: string; setHasActionsDisabled?: (value: boolean) => void; setHasActionsWithBrokenConnector?: (value: boolean) => void; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_form.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_form.tsx index 38468283b9c19..bd40d35b15b2d 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_form.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_form.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { Fragment, Suspense, useState } from 'react'; +import React, { Fragment, Suspense, useEffect, useState } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { @@ -25,10 +25,20 @@ import { EuiLoadingSpinner, EuiBadge, } from '@elastic/eui'; -import { IErrorObject, AlertAction, ActionTypeIndex, ActionConnector } from '../../../types'; +import { ResolvedActionGroup } from '../../../../../alerts/common'; +import { + IErrorObject, + AlertAction, + ActionTypeIndex, + ActionConnector, + ActionVariables, + ActionVariable, +} from '../../../types'; import { checkActionFormActionTypeEnabled } from '../../lib/check_action_type_enabled'; import { hasSaveActionsCapability } from '../../lib/capabilities'; import { ActionAccordionFormProps } from './action_form'; +import { transformActionVariables } from '../../lib/action_variables'; +import { resolvedActionGroupMessage } from '../../constants'; export type ActionTypeFormProps = { actionItem: AlertAction; @@ -88,6 +98,20 @@ export const ActionTypeForm = ({ setActionGroupIdByIndex, }: ActionTypeFormProps) => { const [isOpen, setIsOpen] = useState(true); + const [availableActionVariables, setAvailableActionVariables] = useState([]); + const [availableDefaultActionMessage, setAvailableDefaultActionMessage] = useState< + string | undefined + >(undefined); + + useEffect(() => { + setAvailableActionVariables(getAvailableActionVariables(messageVariables, actionItem.group)); + const res = + actionItem.group === ResolvedActionGroup.id + ? resolvedActionGroupMessage + : defaultActionMessage; + setAvailableDefaultActionMessage(res); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [actionItem.group]); const canSave = hasSaveActionsCapability(capabilities); const getSelectedOptions = (actionItemId: string) => { @@ -244,8 +268,8 @@ export const ActionTypeForm = ({ index={index} errors={actionParamsErrors.errors} editAction={setActionParamsProperty} - messageVariables={messageVariables} - defaultMessage={defaultActionMessage ?? undefined} + messageVariables={availableActionVariables} + defaultMessage={availableDefaultActionMessage} docLinks={docLinks} http={http} toastNotifications={toastNotifications} @@ -337,3 +361,20 @@ export const ActionTypeForm = ({ ); }; + +function getAvailableActionVariables( + actionVariables: ActionVariables | undefined, + actionGroup: string +) { + if (!actionVariables) { + return []; + } + const filteredActionVariables = + actionGroup === ResolvedActionGroup.id + ? { params: actionVariables.params, state: actionVariables.state } + : actionVariables; + + return transformActionVariables(filteredActionVariables).sort((a, b) => + a.name.toUpperCase().localeCompare(b.name.toUpperCase()) + ); +} diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_menu.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_menu.test.tsx index 2fe068536f4a1..8102b4d393a19 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_menu.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_menu.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import * as React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { coreMock } from '../../../../../../../src/core/public/mocks'; import { ActionsConnectorsContextProvider } from '../../context/actions_connectors_context'; import { actionTypeRegistryMock } from '../../action_type_registry.mock'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_flyout.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_flyout.test.tsx index 551bcf658e87f..68d5d1e7d9573 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_flyout.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_flyout.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import * as React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { coreMock } from '../../../../../../../src/core/public/mocks'; import ConnectorAddFlyout from './connector_add_flyout'; import { ActionsConnectorsContextProvider } from '../../context/actions_connectors_context'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_modal.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_modal.test.tsx index 71a3936ed5055..0d634729002eb 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_modal.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_add_modal.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import * as React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { coreMock } from '../../../../../../../src/core/public/mocks'; import { ConnectorAddModal } from './connector_add_modal'; import { actionTypeRegistryMock } from '../../action_type_registry.mock'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_edit_flyout.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_edit_flyout.test.tsx index ab58b2430fa1a..5833c3a9a37bf 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_edit_flyout.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_edit_flyout.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import * as React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { coreMock } from '../../../../../../../src/core/public/mocks'; import { ActionsConnectorsContextProvider } from '../../context/actions_connectors_context'; import { actionTypeRegistryMock } from '../../action_type_registry.mock'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/test_connector_form.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/test_connector_form.test.tsx index 482bccb5517f1..f4a1aca7f8f24 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/test_connector_form.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/test_connector_form.test.tsx @@ -12,7 +12,7 @@ import { ActionConnector, ValidationResult } from '../../../types'; import { actionTypeRegistryMock } from '../../action_type_registry.mock'; import { ActionsConnectorsContextProvider } from '../../context/actions_connectors_context'; import { EuiFormRow, EuiFieldText, EuiText, EuiLink, EuiForm, EuiSelect } from '@elastic/eui'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; const mockedActionParamsFields = lazy(async () => ({ default() { diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.test.tsx index e946e881def10..65d5389078880 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import * as React from 'react'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { ActionsConnectorsList } from './actions_connectors_list'; import { coreMock, scopedHistoryMock } from '../../../../../../../../src/core/public/mocks'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_add.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_add.test.tsx index 4b5f8596501e1..aae0c6ea7e9e4 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_add.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_add.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import * as React from 'react'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { act } from 'react-dom/test-utils'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiFormLabel } from '@elastic/eui'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_edit.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_edit.test.tsx index 31c61f0bba768..77941d5c2bca1 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_edit.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_edit.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import * as React from 'react'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { act } from 'react-dom/test-utils'; import { coreMock } from '../../../../../../../src/core/public/mocks'; import { actionTypeRegistryMock } from '../../action_type_registry.mock'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_form.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_form.test.tsx index 493b870a1a6d5..6b5f0a31d345c 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_form.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_form.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React, { Fragment } from 'react'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { ReactWrapper } from 'enzyme'; import { act } from 'react-dom/test-utils'; import { actionTypeRegistryMock } from '../../action_type_registry.mock'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_form.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_form.tsx index 213d1d7ad36df..c571520988509 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_form.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_form.tsx @@ -40,7 +40,6 @@ import { getDurationUnitValue, } from '../../../../../alerts/common/parse_duration'; import { loadAlertTypes } from '../../lib/alert_api'; -import { actionVariablesFromAlertType } from '../../lib/action_variables'; import { AlertReducerAction } from './alert_reducer'; import { AlertTypeModel, @@ -458,9 +457,7 @@ export const AlertForm = ({ actions={alert.actions} setHasActionsDisabled={setHasActionsDisabled} setHasActionsWithBrokenConnector={setHasActionsWithBrokenConnector} - messageVariables={actionVariablesFromAlertType( - alertTypesIndex.get(alert.alertTypeId)! - ).sort((a, b) => a.name.toUpperCase().localeCompare(b.name.toUpperCase()))} + messageVariables={alertTypesIndex.get(alert.alertTypeId)!.actionVariables} defaultActionGroupId={defaultActionGroupId} actionGroups={alertTypesIndex.get(alert.alertTypeId)!.actionGroups} setActionIdByIndex={(id: string, index: number) => setActionProperty('id', id, index)} diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.test.tsx index c434ca9d21402..611846cf4a521 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.test.tsx @@ -5,7 +5,7 @@ */ import * as React from 'react'; -import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, nextTick } from '@kbn/test/jest'; import { coreMock, scopedHistoryMock } from '../../../../../../../../src/core/public/mocks'; import { ReactWrapper } from 'enzyme'; import { act } from 'react-dom/test-utils'; diff --git a/x-pack/plugins/triggers_actions_ui/public/common/expression_items/threshold.test.tsx b/x-pack/plugins/triggers_actions_ui/public/common/expression_items/threshold.test.tsx index 73efba6929b71..c8d2b10274cd0 100644 --- a/x-pack/plugins/triggers_actions_ui/public/common/expression_items/threshold.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/common/expression_items/threshold.test.tsx @@ -5,7 +5,7 @@ */ import * as React from 'react'; import { shallow } from 'enzyme'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { ThresholdExpression } from './threshold'; describe('threshold expression', () => { diff --git a/x-pack/plugins/triggers_actions_ui/public/types.ts b/x-pack/plugins/triggers_actions_ui/public/types.ts index 1a6b68080c9a4..16c6bbc215ddc 100644 --- a/x-pack/plugins/triggers_actions_ui/public/types.ts +++ b/x-pack/plugins/triggers_actions_ui/public/types.ts @@ -133,7 +133,7 @@ export interface ActionVariable { } export interface ActionVariables { - context: ActionVariable[]; + context?: ActionVariable[]; state: ActionVariable[]; params: ActionVariable[]; } diff --git a/x-pack/plugins/ui_actions_enhanced/public/custom_time_range_action.test.ts b/x-pack/plugins/ui_actions_enhanced/public/custom_time_range_action.test.ts index 99971c42e5512..fde21b18f2593 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/custom_time_range_action.test.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/custom_time_range_action.test.ts @@ -18,7 +18,7 @@ import { HELLO_WORLD_EMBEDDABLE, } from '../../../../examples/embeddable_examples/public'; -import { nextTick } from 'test_utils/enzyme_helpers'; +import { nextTick } from '@kbn/test/jest'; import { ReactElement } from 'react'; const createOpenModalMock = () => { diff --git a/x-pack/plugins/ui_actions_enhanced/public/custom_time_range_badge.test.ts b/x-pack/plugins/ui_actions_enhanced/public/custom_time_range_badge.test.ts index a839079137905..addc969913fce 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/custom_time_range_badge.test.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/custom_time_range_badge.test.ts @@ -11,7 +11,7 @@ import { mount } from 'enzyme'; import { TimeRangeEmbeddable, TimeRangeContainer, TIME_RANGE_EMBEDDABLE } from './test_helpers'; import { CustomTimeRangeBadge } from './custom_time_range_badge'; import { ReactElement } from 'react'; -import { nextTick } from 'test_utils/enzyme_helpers'; +import { nextTick } from '@kbn/test/jest'; test('Removing custom time range from badge resets embeddable back to container time', async () => { const container = new TimeRangeContainer( diff --git a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.stories.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.stories.tsx index a909d2a27f454..570882bcf9ce1 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.stories.tsx +++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.stories.tsx @@ -7,10 +7,10 @@ import * as React from 'react'; import { EuiFlyout } from '@elastic/eui'; import { storiesOf } from '@storybook/react'; +import { StubBrowserStorage } from '@kbn/test/jest'; import { createFlyoutManageDrilldowns } from './connected_flyout_manage_drilldowns'; import { mockActionFactories } from '../../../components/action_wizard/test_data'; import { Storage } from '../../../../../../../src/plugins/kibana_utils/public'; -import { StubBrowserStorage } from '../../../../../../../src/test_utils/public/stub_browser_storage'; import { mockDynamicActionManager } from './test_data'; const FlyoutManageDrilldowns = createFlyoutManageDrilldowns({ diff --git a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.test.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.test.tsx index bef6834ed4c47..eec3696a5a8cc 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.test.tsx +++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.test.tsx @@ -12,7 +12,7 @@ import { mockSupportedTriggers, mockActionFactories, } from '../../../components/action_wizard/test_data'; -import { StubBrowserStorage } from '../../../../../../../src/test_utils/public/stub_browser_storage'; +import { StubBrowserStorage } from '@kbn/test/jest'; import { Storage } from '../../../../../../../src/plugins/kibana_utils/public'; import { mockDynamicActionManager } from './test_data'; import { TEST_SUBJ_DRILLDOWN_ITEM } from '../list_manage_drilldowns'; diff --git a/x-pack/plugins/upgrade_assistant/common/version.ts b/x-pack/plugins/upgrade_assistant/common/version.ts index 744ec4e87a49b..231614dc38c6d 100644 --- a/x-pack/plugins/upgrade_assistant/common/version.ts +++ b/x-pack/plugins/upgrade_assistant/common/version.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SemVer } from 'semver'; +import SemVer from 'semver/classes/semver'; import pkg from '../../../../package.json'; export const CURRENT_VERSION = new SemVer(pkg.version as string); diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/tabs.test.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/tabs.test.tsx index 09ca30a854f6f..463c0c9d016b3 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/tabs.test.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/tabs.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { httpServiceMock } from 'src/core/public/mocks'; import { UpgradeAssistantTabs } from './tabs'; import { LoadingState } from './types'; diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/grouped.test.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/grouped.test.tsx index affeeb84f35d7..6bdb5df036224 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/grouped.test.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/grouped.test.tsx @@ -6,7 +6,7 @@ import { range } from 'lodash'; import React from 'react'; -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { EuiBadge, EuiPagination } from '@elastic/eui'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/index_table.test.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/index_table.test.tsx index 25e3842291ff5..1c9a079bcf1eb 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/index_table.test.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/index_table.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { IndexDeprecationTableProps, IndexDeprecationTableUI } from './index_table'; diff --git a/x-pack/plugins/uptime/public/components/common/__tests__/location_link.test.tsx b/x-pack/plugins/uptime/public/components/common/__tests__/location_link.test.tsx index c84e9d12cc4ca..b2220da9789fc 100644 --- a/x-pack/plugins/uptime/public/components/common/__tests__/location_link.test.tsx +++ b/x-pack/plugins/uptime/public/components/common/__tests__/location_link.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { LocationLink } from '../location_link'; diff --git a/x-pack/plugins/uptime/public/components/common/__tests__/monitor_page_link.test.tsx b/x-pack/plugins/uptime/public/components/common/__tests__/monitor_page_link.test.tsx index 36ebeb6615648..31d126f183393 100644 --- a/x-pack/plugins/uptime/public/components/common/__tests__/monitor_page_link.test.tsx +++ b/x-pack/plugins/uptime/public/components/common/__tests__/monitor_page_link.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { MonitorPageLink } from '../monitor_page_link'; describe('MonitorPageLink component', () => { diff --git a/x-pack/plugins/uptime/public/components/common/charts/__tests__/chart_empty_state.test.tsx b/x-pack/plugins/uptime/public/components/common/charts/__tests__/chart_empty_state.test.tsx index 2e25dddc0b4ed..8f78e640a988a 100644 --- a/x-pack/plugins/uptime/public/components/common/charts/__tests__/chart_empty_state.test.tsx +++ b/x-pack/plugins/uptime/public/components/common/charts/__tests__/chart_empty_state.test.tsx @@ -5,7 +5,7 @@ */ import { ChartEmptyState } from '../chart_empty_state'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; diff --git a/x-pack/plugins/uptime/public/components/common/charts/__tests__/chart_wrapper.test.tsx b/x-pack/plugins/uptime/public/components/common/charts/__tests__/chart_wrapper.test.tsx index 39d530d90db42..2f11707bb3ab9 100644 --- a/x-pack/plugins/uptime/public/components/common/charts/__tests__/chart_wrapper.test.tsx +++ b/x-pack/plugins/uptime/public/components/common/charts/__tests__/chart_wrapper.test.tsx @@ -7,8 +7,8 @@ import React from 'react'; import { EuiSpacer } from '@elastic/eui'; import { mount } from 'enzyme'; -import { nextTick } from 'test_utils/enzyme_helpers'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { nextTick } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test/jest'; import { ChartWrapper } from '../chart_wrapper'; import { SnapshotHeading } from '../../../overview/snapshot/snapshot_heading'; import { DonutChart } from '../donut_chart'; diff --git a/x-pack/plugins/uptime/public/components/common/charts/__tests__/donut_chart.test.tsx b/x-pack/plugins/uptime/public/components/common/charts/__tests__/donut_chart.test.tsx index 31939c3dfdb56..56789b8e7374e 100644 --- a/x-pack/plugins/uptime/public/components/common/charts/__tests__/donut_chart.test.tsx +++ b/x-pack/plugins/uptime/public/components/common/charts/__tests__/donut_chart.test.tsx @@ -5,7 +5,7 @@ */ import { DonutChart } from '../donut_chart'; -import { renderWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl, shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; describe('DonutChart component', () => { diff --git a/x-pack/plugins/uptime/public/components/common/charts/__tests__/donut_chart_legend.test.tsx b/x-pack/plugins/uptime/public/components/common/charts/__tests__/donut_chart_legend.test.tsx index fd10706ff101b..1b71b87884fb8 100644 --- a/x-pack/plugins/uptime/public/components/common/charts/__tests__/donut_chart_legend.test.tsx +++ b/x-pack/plugins/uptime/public/components/common/charts/__tests__/donut_chart_legend.test.tsx @@ -5,7 +5,7 @@ */ import { DonutChartLegend } from '../donut_chart_legend'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; describe('DonutChartLegend', () => { diff --git a/x-pack/plugins/uptime/public/components/common/charts/__tests__/donut_chart_legend_row.test.tsx b/x-pack/plugins/uptime/public/components/common/charts/__tests__/donut_chart_legend_row.test.tsx index 49e887cc8f96c..868409ef831a8 100644 --- a/x-pack/plugins/uptime/public/components/common/charts/__tests__/donut_chart_legend_row.test.tsx +++ b/x-pack/plugins/uptime/public/components/common/charts/__tests__/donut_chart_legend_row.test.tsx @@ -5,7 +5,7 @@ */ import { DonutChartLegendRow } from '../donut_chart_legend_row'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; describe('DonutChartLegendRow', () => { diff --git a/x-pack/plugins/uptime/public/components/common/higher_order/__tests__/responsive_wrapper.test.tsx b/x-pack/plugins/uptime/public/components/common/higher_order/__tests__/responsive_wrapper.test.tsx index ae265ef1bb0c6..e5e2de8e6260e 100644 --- a/x-pack/plugins/uptime/public/components/common/higher_order/__tests__/responsive_wrapper.test.tsx +++ b/x-pack/plugins/uptime/public/components/common/higher_order/__tests__/responsive_wrapper.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { withResponsiveWrapper } from '../responsive_wrapper'; interface Prop { diff --git a/x-pack/plugins/uptime/public/components/monitor/ml/__tests__/confirm_delete.test.tsx b/x-pack/plugins/uptime/public/components/monitor/ml/__tests__/confirm_delete.test.tsx index 465369547d286..b598cb72ec21b 100644 --- a/x-pack/plugins/uptime/public/components/monitor/ml/__tests__/confirm_delete.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/ml/__tests__/confirm_delete.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { ConfirmJobDeletion } from '../confirm_delete'; describe('ML Confirm Job Delete', () => { diff --git a/x-pack/plugins/uptime/public/components/monitor/ml/__tests__/license_info.test.tsx b/x-pack/plugins/uptime/public/components/monitor/ml/__tests__/license_info.test.tsx index 55ca4d453d061..b2c700beaf343 100644 --- a/x-pack/plugins/uptime/public/components/monitor/ml/__tests__/license_info.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/ml/__tests__/license_info.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { renderWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { ShowLicenseInfo } from '../license_info'; import * as redux from 'react-redux'; diff --git a/x-pack/plugins/uptime/public/components/monitor/ml/__tests__/ml_flyout.test.tsx b/x-pack/plugins/uptime/public/components/monitor/ml/__tests__/ml_flyout.test.tsx index 4795042ed845f..f838ca63ef5f1 100644 --- a/x-pack/plugins/uptime/public/components/monitor/ml/__tests__/ml_flyout.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/ml/__tests__/ml_flyout.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { renderWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { MLFlyoutView } from '../ml_flyout'; import { UptimeSettingsContext } from '../../../../contexts'; import { CLIENT_DEFAULTS } from '../../../../../common/constants'; diff --git a/x-pack/plugins/uptime/public/components/monitor/ping_list/__tests__/doc_link_body.test.tsx b/x-pack/plugins/uptime/public/components/monitor/ping_list/__tests__/doc_link_body.test.tsx index a29f647a22613..f8895f44ea084 100644 --- a/x-pack/plugins/uptime/public/components/monitor/ping_list/__tests__/doc_link_body.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/ping_list/__tests__/doc_link_body.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { DocLinkForBody } from '../doc_link_body'; diff --git a/x-pack/plugins/uptime/public/components/monitor/ping_list/__tests__/expanded_row.test.tsx b/x-pack/plugins/uptime/public/components/monitor/ping_list/__tests__/expanded_row.test.tsx index 85d1362ed3766..8a5b8b942e016 100644 --- a/x-pack/plugins/uptime/public/components/monitor/ping_list/__tests__/expanded_row.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/ping_list/__tests__/expanded_row.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { mountWithIntl, renderWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, renderWithIntl, shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { PingListExpandedRowComponent } from '../expanded_row'; import { Ping } from '../../../../../common/runtime_types'; diff --git a/x-pack/plugins/uptime/public/components/monitor/ping_list/__tests__/ping_headers.test.tsx b/x-pack/plugins/uptime/public/components/monitor/ping_list/__tests__/ping_headers.test.tsx index 86394a0a4d841..240a71e95b0ed 100644 --- a/x-pack/plugins/uptime/public/components/monitor/ping_list/__tests__/ping_headers.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/ping_list/__tests__/ping_headers.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { PingHeaders } from '../headers'; diff --git a/x-pack/plugins/uptime/public/components/monitor/ping_list/__tests__/ping_list.test.tsx b/x-pack/plugins/uptime/public/components/monitor/ping_list/__tests__/ping_list.test.tsx index 8de4b89b7880d..db8012dbf0675 100644 --- a/x-pack/plugins/uptime/public/components/monitor/ping_list/__tests__/ping_list.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/ping_list/__tests__/ping_list.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { PingListComponent, rowShouldExpand, toggleDetails } from '../ping_list'; import { Ping, PingsResponse } from '../../../../../common/runtime_types'; import { ExpandedRowMap } from '../../../overview/monitor_list/types'; diff --git a/x-pack/plugins/uptime/public/components/monitor/status_details/__test__/status_by_location.test.tsx b/x-pack/plugins/uptime/public/components/monitor/status_details/__test__/status_by_location.test.tsx index b171a8bedb8a7..5017a132d18e6 100644 --- a/x-pack/plugins/uptime/public/components/monitor/status_details/__test__/status_by_location.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/status_details/__test__/status_by_location.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { renderWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { MonitorLocation } from '../../../../../common/runtime_types'; import { StatusByLocations } from '../index'; diff --git a/x-pack/plugins/uptime/public/components/monitor/status_details/availability_reporting/__tests__/availability_reporting.test.tsx b/x-pack/plugins/uptime/public/components/monitor/status_details/availability_reporting/__tests__/availability_reporting.test.tsx index 7a8ba3fd32cd9..d98f25df23dd9 100644 --- a/x-pack/plugins/uptime/public/components/monitor/status_details/availability_reporting/__tests__/availability_reporting.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/status_details/availability_reporting/__tests__/availability_reporting.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { renderWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { AvailabilityReporting } from '../availability_reporting'; import { StatusTag } from '../location_status_tags'; diff --git a/x-pack/plugins/uptime/public/components/monitor/status_details/availability_reporting/__tests__/location_status_tags.test.tsx b/x-pack/plugins/uptime/public/components/monitor/status_details/availability_reporting/__tests__/location_status_tags.test.tsx index d4aae6b022d9c..72919ff3c41bf 100644 --- a/x-pack/plugins/uptime/public/components/monitor/status_details/availability_reporting/__tests__/location_status_tags.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/status_details/availability_reporting/__tests__/location_status_tags.test.tsx @@ -6,7 +6,7 @@ import React from 'react'; import moment from 'moment'; -import { renderWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { MonitorLocation } from '../../../../../../common/runtime_types/monitor'; import { LocationStatusTags } from '../index'; diff --git a/x-pack/plugins/uptime/public/components/monitor/status_details/availability_reporting/__tests__/tag_label.test.tsx b/x-pack/plugins/uptime/public/components/monitor/status_details/availability_reporting/__tests__/tag_label.test.tsx index 8e46196ec3ab7..a44aa5db24867 100644 --- a/x-pack/plugins/uptime/public/components/monitor/status_details/availability_reporting/__tests__/tag_label.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/status_details/availability_reporting/__tests__/tag_label.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { renderWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { TagLabel } from '../tag_label'; describe('TagLabel component', () => { diff --git a/x-pack/plugins/uptime/public/components/monitor/status_details/location_availability/__tests__/location_availability.test.tsx b/x-pack/plugins/uptime/public/components/monitor/status_details/location_availability/__tests__/location_availability.test.tsx index 39c487bc3e151..c3af1e30911c5 100644 --- a/x-pack/plugins/uptime/public/components/monitor/status_details/location_availability/__tests__/location_availability.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/status_details/location_availability/__tests__/location_availability.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { LocationAvailability } from '../location_availability'; import { MonitorLocations } from '../../../../../../common/runtime_types'; import { LocationMissingWarning } from '../../location_map/location_missing'; diff --git a/x-pack/plugins/uptime/public/components/monitor/status_details/location_map/__tests__/location_map.test.tsx b/x-pack/plugins/uptime/public/components/monitor/status_details/location_map/__tests__/location_map.test.tsx index 39346ad645c00..8b8b8c4cd87f9 100644 --- a/x-pack/plugins/uptime/public/components/monitor/status_details/location_map/__tests__/location_map.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/status_details/location_map/__tests__/location_map.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { LocationMap } from '../location_map'; import { LocationPoint } from '../embeddables/embedded_map'; diff --git a/x-pack/plugins/uptime/public/components/monitor/status_details/location_map/__tests__/location_missing.test.tsx b/x-pack/plugins/uptime/public/components/monitor/status_details/location_map/__tests__/location_missing.test.tsx index 66e3b5952a3dc..2371034ef3288 100644 --- a/x-pack/plugins/uptime/public/components/monitor/status_details/location_map/__tests__/location_missing.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/status_details/location_map/__tests__/location_missing.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { renderWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { LocationMissingWarning } from '../location_missing'; describe('LocationMissingWarning component', () => { diff --git a/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/browser_expanded_row.test.tsx b/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/browser_expanded_row.test.tsx index 07c3afdf50eea..e4e4e62d754be 100644 --- a/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/browser_expanded_row.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/browser_expanded_row.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { BrowserExpandedRowComponent } from '../browser_expanded_row'; import { Ping } from '../../../../../common/runtime_types'; diff --git a/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/console_event.test.tsx b/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/console_event.test.tsx index ad905076a06cd..8146c0b2d0e78 100644 --- a/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/console_event.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/console_event.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ConsoleEvent } from '../console_event'; diff --git a/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/console_output_event_list.test.tsx b/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/console_output_event_list.test.tsx index 776fd0a5fb94d..2b09d15571940 100644 --- a/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/console_output_event_list.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/console_output_event_list.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ConsoleOutputEventList } from '../console_output_event_list'; diff --git a/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/empty_journey.test.tsx b/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/empty_journey.test.tsx index 0157229b3c212..793819e8b29e8 100644 --- a/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/empty_journey.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/empty_journey.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { EmptyJourney } from '../empty_journey'; diff --git a/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/executed_journey.test.tsx b/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/executed_journey.test.tsx index 9fec9439b3ad5..d6f422b5c7094 100644 --- a/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/executed_journey.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/executed_journey.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ExecutedJourney } from '../executed_journey'; import { Ping } from '../../../../../common/runtime_types'; diff --git a/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/executed_step.test.tsx b/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/executed_step.test.tsx index e3a8430cfa888..fb7394c4c92c6 100644 --- a/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/executed_step.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/executed_step.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { ExecutedStep } from '../executed_step'; import { Ping } from '../../../../../common/runtime_types'; diff --git a/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/status_badge.test.tsx b/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/status_badge.test.tsx index 1171c24ad899c..72ab53cd9667b 100644 --- a/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/status_badge.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/status_badge.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { StatusBadge } from '../status_badge'; diff --git a/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/step_screenshot_display.test.tsx b/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/step_screenshot_display.test.tsx index 9d94514aa48c5..735e79f565797 100644 --- a/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/step_screenshot_display.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/synthetics/__tests__/step_screenshot_display.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; import React from 'react'; import { StepScreenshotDisplay } from '../step_screenshot_display'; diff --git a/x-pack/plugins/uptime/public/components/overview/__tests__/parsing_error_callout.test.tsx b/x-pack/plugins/uptime/public/components/overview/__tests__/parsing_error_callout.test.tsx index 01204c33b79d5..bd52c33de2c58 100644 --- a/x-pack/plugins/uptime/public/components/overview/__tests__/parsing_error_callout.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/__tests__/parsing_error_callout.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { ParsingErrorCallout } from '../parsing_error_callout'; describe('OverviewPageParsingErrorCallout', () => { diff --git a/x-pack/plugins/uptime/public/components/overview/__tests__/snapshot.test.tsx b/x-pack/plugins/uptime/public/components/overview/__tests__/snapshot.test.tsx index cfcab673dcb35..06114ba9d962f 100644 --- a/x-pack/plugins/uptime/public/components/overview/__tests__/snapshot.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/__tests__/snapshot.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { Snapshot } from '../../../../common/runtime_types'; import { SnapshotComponent } from '../snapshot/snapshot'; diff --git a/x-pack/plugins/uptime/public/components/overview/__tests__/snapshot_heading.test.tsx b/x-pack/plugins/uptime/public/components/overview/__tests__/snapshot_heading.test.tsx index 805c116ef538a..061bccbdfed51 100644 --- a/x-pack/plugins/uptime/public/components/overview/__tests__/snapshot_heading.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/__tests__/snapshot_heading.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { SnapshotHeading } from '../snapshot/snapshot_heading'; diff --git a/x-pack/plugins/uptime/public/components/overview/__tests__/synthetics_callout.test.tsx b/x-pack/plugins/uptime/public/components/overview/__tests__/synthetics_callout.test.tsx index 980021b7d6073..b060890c613e3 100644 --- a/x-pack/plugins/uptime/public/components/overview/__tests__/synthetics_callout.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/__tests__/synthetics_callout.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { SyntheticsCallout } from '../synthetics_callout'; diff --git a/x-pack/plugins/uptime/public/components/overview/alerts/__tests__/add_filter_btn.test.tsx b/x-pack/plugins/uptime/public/components/overview/alerts/__tests__/add_filter_btn.test.tsx index ac465eca4c5e5..e8ac7cd4898ed 100644 --- a/x-pack/plugins/uptime/public/components/overview/alerts/__tests__/add_filter_btn.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/alerts/__tests__/add_filter_btn.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; import { AddFilterButton } from '../add_filter_btn'; import { EuiButtonEmpty, EuiContextMenuItem } from '@elastic/eui'; diff --git a/x-pack/plugins/uptime/public/components/overview/alerts/__tests__/alert_field_number.test.tsx b/x-pack/plugins/uptime/public/components/overview/alerts/__tests__/alert_field_number.test.tsx index e2564992c76d2..669d0ae391467 100644 --- a/x-pack/plugins/uptime/public/components/overview/alerts/__tests__/alert_field_number.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/alerts/__tests__/alert_field_number.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; import { AlertFieldNumber, handleAlertFieldNumberChange } from '../alert_field_number'; describe('AlertFieldNumber', () => { diff --git a/x-pack/plugins/uptime/public/components/overview/alerts/__tests__/alert_monitor_status.test.tsx b/x-pack/plugins/uptime/public/components/overview/alerts/__tests__/alert_monitor_status.test.tsx index f26da59238b20..1b742f04b0126 100644 --- a/x-pack/plugins/uptime/public/components/overview/alerts/__tests__/alert_monitor_status.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/alerts/__tests__/alert_monitor_status.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { AlertMonitorStatusComponent, AlertMonitorStatusProps } from '../alert_monitor_status'; describe('alert monitor status component', () => { diff --git a/x-pack/plugins/uptime/public/components/overview/alerts/__tests__/old_alert_callout.test.tsx b/x-pack/plugins/uptime/public/components/overview/alerts/__tests__/old_alert_callout.test.tsx index 2942a5e503573..26cebba1a715e 100644 --- a/x-pack/plugins/uptime/public/components/overview/alerts/__tests__/old_alert_callout.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/alerts/__tests__/old_alert_callout.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { OldAlertCallOut } from '../old_alert_call_out'; describe('OldAlertCallOut', () => { diff --git a/x-pack/plugins/uptime/public/components/overview/alerts/monitor_expressions/__tests__/down_number_select.test.tsx b/x-pack/plugins/uptime/public/components/overview/alerts/monitor_expressions/__tests__/down_number_select.test.tsx index 31503252a8990..26908afa4dca2 100644 --- a/x-pack/plugins/uptime/public/components/overview/alerts/monitor_expressions/__tests__/down_number_select.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/alerts/monitor_expressions/__tests__/down_number_select.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { renderWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { DownNoExpressionSelect } from '../down_number_select'; describe('DownNoExpressionSelect component', () => { diff --git a/x-pack/plugins/uptime/public/components/overview/alerts/monitor_expressions/__tests__/filters_expression_select.test.tsx b/x-pack/plugins/uptime/public/components/overview/alerts/monitor_expressions/__tests__/filters_expression_select.test.tsx index e41dfea82c2fb..9d57021d02702 100644 --- a/x-pack/plugins/uptime/public/components/overview/alerts/monitor_expressions/__tests__/filters_expression_select.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/alerts/monitor_expressions/__tests__/filters_expression_select.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { FiltersExpressionsSelect } from '../filters_expression_select'; describe('filters expression select component', () => { diff --git a/x-pack/plugins/uptime/public/components/overview/alerts/monitor_expressions/__tests__/time_expression_select.test.tsx b/x-pack/plugins/uptime/public/components/overview/alerts/monitor_expressions/__tests__/time_expression_select.test.tsx index d5ac82136710e..157602f717f47 100644 --- a/x-pack/plugins/uptime/public/components/overview/alerts/monitor_expressions/__tests__/time_expression_select.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/alerts/monitor_expressions/__tests__/time_expression_select.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { renderWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { TimeExpressionSelect } from '../time_expression_select'; describe('TimeExpressionSelect component', () => { diff --git a/x-pack/plugins/uptime/public/components/overview/empty_state/__tests__/data_or_index_missing.test.tsx b/x-pack/plugins/uptime/public/components/overview/empty_state/__tests__/data_or_index_missing.test.tsx index 333802962fd3e..37ddb34fa6c54 100644 --- a/x-pack/plugins/uptime/public/components/overview/empty_state/__tests__/data_or_index_missing.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/empty_state/__tests__/data_or_index_missing.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { FormattedMessage } from '@kbn/i18n/react'; import { DataOrIndexMissing } from '../data_or_index_missing'; diff --git a/x-pack/plugins/uptime/public/components/overview/filter_group/__tests__/filter_popover.test.tsx b/x-pack/plugins/uptime/public/components/overview/filter_group/__tests__/filter_popover.test.tsx index 7fbc9ad733b0e..465ed3bdae51a 100644 --- a/x-pack/plugins/uptime/public/components/overview/filter_group/__tests__/filter_popover.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/filter_group/__tests__/filter_popover.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; import { FilterPopoverProps, FilterPopover } from '../filter_popover'; import { UptimeFilterButton } from '../uptime_filter_button'; import { EuiFilterSelectItem } from '@elastic/eui'; diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list_page_size_select.test.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list_page_size_select.test.tsx index 0642712d951fe..38dc0ccbda5c4 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list_page_size_select.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list_page_size_select.test.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { MonitorListPageSizeSelectComponent } from '../monitor_list_page_size_select'; -import { mountWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl } from '@kbn/test/jest'; describe('MonitorListPageSizeSelect', () => { it('updates the state when selection changes', () => { diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list_status_column.test.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list_status_column.test.tsx index 9696ecc2c237b..cc91f9ccc20a6 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list_status_column.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list_status_column.test.tsx @@ -6,7 +6,7 @@ import React from 'react'; import moment from 'moment'; -import { renderWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { renderWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { getLocationStatus, MonitorListStatusColumn } from '../monitor_list_status_column'; import { Ping } from '../../../../../common/runtime_types'; import { STATUS } from '../../../../../common/constants'; diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/integration_group.test.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/integration_group.test.tsx index df9f1febd40c3..3e7860e4e6ab4 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/integration_group.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/integration_group.test.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { MonitorSummary, makePing } from '../../../../../../common/runtime_types'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import { IntegrationGroup, extractSummaryValues } from '../actions_popover/integration_group'; describe('IntegrationGroup', () => { diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/integration_link.test.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/integration_link.test.tsx index 8ee83bc38957b..88f49f87881e0 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/integration_link.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/integration_link.test.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { IntegrationLink } from '../actions_popover/integration_link'; -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; describe('IntegrationLink component', () => { it('renders without errors', () => { diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/monitor_status_list.test.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/monitor_status_list.test.tsx index c0143828dc69d..da518a9f27164 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/monitor_status_list.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/monitor_status_list.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import moment from 'moment'; import { MonitorStatusList } from '../monitor_status_list'; diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/monitor_status_row.test.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/monitor_status_row.test.tsx index 0353d0197f7f7..e8c9c2d687bb3 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/monitor_status_row.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/monitor_status_row.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl } from '@kbn/test/jest'; import React from 'react'; import { MonitorStatusRow } from '../monitor_status_row'; diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/most_recent_error.test.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/most_recent_error.test.tsx index 173809b2d7f73..e0b4c0dbd78f7 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/most_recent_error.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/most_recent_error.test.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallowWithIntl, renderWithIntl } from 'test_utils/enzyme_helpers'; +import { shallowWithIntl, renderWithIntl } from '@kbn/test/jest'; import React from 'react'; import moment from 'moment'; import { BrowserRouter as Router } from 'react-router-dom'; diff --git a/x-pack/plugins/uptime/public/lib/helper/helper_with_router.tsx b/x-pack/plugins/uptime/public/lib/helper/helper_with_router.tsx index 5219fb3242539..132552ef61a69 100644 --- a/x-pack/plugins/uptime/public/lib/helper/helper_with_router.tsx +++ b/x-pack/plugins/uptime/public/lib/helper/helper_with_router.tsx @@ -9,7 +9,7 @@ import React, { ReactElement } from 'react'; import { Router } from 'react-router-dom'; import { MemoryHistory } from 'history/createMemoryHistory'; import { createMemoryHistory } from 'history'; -import { mountWithIntl, renderWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { mountWithIntl, renderWithIntl, shallowWithIntl } from '@kbn/test/jest'; import { AppState } from '../../state'; import { MountWithReduxProvider } from './helper_with_redux'; diff --git a/x-pack/plugins/watcher/__jest__/client_integration/helpers/index.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/index.ts index 7c5ec0917494a..a39affd7c37c3 100644 --- a/x-pack/plugins/watcher/__jest__/client_integration/helpers/index.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/index.ts @@ -10,7 +10,7 @@ import { setup as watchCreateJsonSetup } from './watch_create_json.helpers'; import { setup as watchCreateThresholdSetup } from './watch_create_threshold.helpers'; import { setup as watchEditSetup } from './watch_edit.helpers'; -export { nextTick, getRandomString, findTestSubject, TestBed } from '../../../../../test_utils'; +export { nextTick, getRandomString, findTestSubject, TestBed } from '@kbn/test/jest'; export { wrapBodyResponse, unwrapBodyResponse } from './body_response'; export { setupEnvironment } from './setup_environment'; diff --git a/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_json.helpers.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_json.helpers.ts index caef4b378cf0a..2134268b096f2 100644 --- a/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_json.helpers.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_json.helpers.ts @@ -3,8 +3,8 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ +import { registerTestBed, TestBed, TestBedConfig } from '@kbn/test/jest'; import { withAppContext } from './app_context.mock'; -import { registerTestBed, TestBed, TestBedConfig } from '../../../../../test_utils'; import { WatchEdit } from '../../../public/application/sections/watch_edit/components/watch_edit'; import { registerRouter } from '../../../public/application/lib/navigation'; import { ROUTES, WATCH_TYPES } from '../../../common/constants'; diff --git a/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_threshold.helpers.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_threshold.helpers.ts index c76f31e744f8d..5d41fe5c53aac 100644 --- a/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_threshold.helpers.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_create_threshold.helpers.ts @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, TestBed, TestBedConfig } from '../../../../../test_utils'; +import { registerTestBed, TestBed, TestBedConfig } from '@kbn/test/jest'; import { WatchEdit } from '../../../public/application/sections/watch_edit/components/watch_edit'; import { registerRouter } from '../../../public/application/lib/navigation'; import { ROUTES, WATCH_TYPES } from '../../../common/constants'; diff --git a/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_edit.helpers.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_edit.helpers.ts index 5e6dbd0a40bfb..ca9fcdbebd490 100644 --- a/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_edit.helpers.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_edit.helpers.ts @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed, TestBed, TestBedConfig } from '../../../../../test_utils'; +import { registerTestBed, TestBed, TestBedConfig } from '@kbn/test/jest'; import { WatchEdit } from '../../../public/application/sections/watch_edit/components/watch_edit'; import { registerRouter } from '../../../public/application/lib/navigation'; import { ROUTES } from '../../../common/constants'; diff --git a/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_list.helpers.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_list.helpers.ts index ca5d962e4dd21..f5a9adc95f43c 100644 --- a/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_list.helpers.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_list.helpers.ts @@ -6,13 +6,7 @@ import { act } from 'react-dom/test-utils'; -import { - registerTestBed, - findTestSubject, - TestBed, - TestBedConfig, - nextTick, -} from '../../../../../test_utils'; +import { registerTestBed, findTestSubject, TestBed, TestBedConfig, nextTick } from '@kbn/test/jest'; import { WatchList } from '../../../public/application/sections/watch_list/components/watch_list'; import { ROUTES, REFRESH_INTERVALS } from '../../../common/constants'; import { withAppContext } from './app_context.mock'; diff --git a/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_status.helpers.ts b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_status.helpers.ts index b869e55aa3464..803b65ca8fff6 100644 --- a/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_status.helpers.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/watch_status.helpers.ts @@ -6,13 +6,7 @@ import { act } from 'react-dom/test-utils'; -import { - registerTestBed, - findTestSubject, - TestBed, - TestBedConfig, - nextTick, -} from '../../../../../test_utils'; +import { registerTestBed, findTestSubject, TestBed, TestBedConfig, delay } from '@kbn/test/jest'; import { WatchStatus } from '../../../public/application/sections/watch_status/components/watch_status'; import { ROUTES } from '../../../common/constants'; import { WATCH_ID } from './constants'; @@ -94,7 +88,7 @@ export const setup = async (): Promise => { await act(async () => { button.simulate('click'); - await nextTick(100); + await delay(100); component.update(); }); }; diff --git a/x-pack/plugins/watcher/__jest__/client_integration/watch_edit.test.ts b/x-pack/plugins/watcher/__jest__/client_integration/watch_edit.test.ts index c35bbcb171a30..b22074e4060eb 100644 --- a/x-pack/plugins/watcher/__jest__/client_integration/watch_edit.test.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/watch_edit.test.ts @@ -12,7 +12,7 @@ import { WatchEditTestBed } from './helpers/watch_edit.helpers'; import { WATCH } from './helpers/constants'; import defaultWatchJson from '../../public/application/models/watch/default_watch.json'; import { getWatch } from '../../test/fixtures'; -import { getRandomString } from '../../../../test_utils'; +import { getRandomString } from '@kbn/test/jest'; const mockHttpClient = axios.create({ adapter: axiosXhrAdapter }); diff --git a/x-pack/plugins/watcher/test/fixtures/watch.ts b/x-pack/plugins/watcher/test/fixtures/watch.ts index 3342ebc149770..74e071c4c1327 100644 --- a/x-pack/plugins/watcher/test/fixtures/watch.ts +++ b/x-pack/plugins/watcher/test/fixtures/watch.ts @@ -5,7 +5,7 @@ */ import { Moment } from 'moment'; -import { getRandomString } from '../../../../test_utils'; +import { getRandomString } from '@kbn/test/jest'; interface Watch { id: string; diff --git a/x-pack/plugins/watcher/test/fixtures/watch_history.ts b/x-pack/plugins/watcher/test/fixtures/watch_history.ts index b8f725aa84a18..7db4c64967de0 100644 --- a/x-pack/plugins/watcher/test/fixtures/watch_history.ts +++ b/x-pack/plugins/watcher/test/fixtures/watch_history.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getRandomString } from '../../../../test_utils'; +import { getRandomString } from '@kbn/test/jest'; interface WatchHistory { startTime: string; diff --git a/x-pack/tasks/helpers/pkg.ts b/x-pack/tasks/helpers/pkg.ts index 8411ebcf7186a..c7d55f6e458c1 100644 --- a/x-pack/tasks/helpers/pkg.ts +++ b/x-pack/tasks/helpers/pkg.ts @@ -5,7 +5,7 @@ */ import Fs from 'fs'; -import semver from 'semver'; +import semverValid from 'semver/functions/valid'; interface PackageJson { name: string; @@ -28,6 +28,6 @@ if (!PKG_NAME) { throw new Error('No "name" found in package.json'); } -if (!semver.valid(PKG_VERSION)) { +if (!semverValid(PKG_VERSION)) { throw new Error(`Version is not valid semver: ${PKG_VERSION}`); } diff --git a/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/server/alert_types.ts b/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/server/alert_types.ts index d43c3363f86b1..7ed864afac4cc 100644 --- a/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/server/alert_types.ts +++ b/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/server/alert_types.ts @@ -7,6 +7,7 @@ import { CoreSetup } from 'src/core/server'; import { schema, TypeOf } from '@kbn/config-schema'; import { times } from 'lodash'; +import { ES_TEST_INDEX_NAME } from '../../../../lib'; import { FixtureStartDeps, FixtureSetupDeps } from './plugin'; import { AlertType, @@ -330,6 +331,7 @@ function getValidationAlertType() { function getPatternFiringAlertType() { const paramsSchema = schema.object({ pattern: schema.recordOf(schema.string(), schema.arrayOf(schema.boolean())), + reference: schema.maybe(schema.string()), }); type ParamsType = TypeOf; interface State { @@ -353,6 +355,18 @@ function getPatternFiringAlertType() { maxPatternLength = Math.max(maxPatternLength, instancePattern.length); } + if (params.reference) { + await services.scopedClusterClient.index({ + index: ES_TEST_INDEX_NAME, + refresh: 'wait_for', + body: { + reference: params.reference, + source: 'alert:test.patternFiring', + ...alertExecutorOptions, + }, + }); + } + // get the pattern index, return if past it const patternIndex = state.patternIndex ?? 0; if (patternIndex >= maxPatternLength) { diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/list_alert_types.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/list_alert_types.ts index ad60ed6941caf..b3635b9f40e27 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/list_alert_types.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/list_alert_types.ts @@ -15,7 +15,10 @@ export default function listAlertTypes({ getService }: FtrProviderContext) { const supertestWithoutAuth = getService('supertestWithoutAuth'); const expectedNoOpType = { - actionGroups: [{ id: 'default', name: 'Default' }], + actionGroups: [ + { id: 'default', name: 'Default' }, + { id: 'resolved', name: 'Resolved' }, + ], defaultActionGroupId: 'default', id: 'test.noop', name: 'Test: Noop', @@ -28,7 +31,10 @@ export default function listAlertTypes({ getService }: FtrProviderContext) { }; const expectedRestrictedNoOpType = { - actionGroups: [{ id: 'default', name: 'Default' }], + actionGroups: [ + { id: 'default', name: 'Default' }, + { id: 'resolved', name: 'Resolved' }, + ], defaultActionGroupId: 'default', id: 'test.restricted-noop', name: 'Test: Restricted Noop', diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts index 75628f6c72487..26f52475a2d4e 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts @@ -6,6 +6,7 @@ import expect from '@kbn/expect'; import { Response as SupertestResponse } from 'supertest'; +import { ResolvedActionGroup } from '../../../../../plugins/alerts/common'; import { Space } from '../../../common/types'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; import { @@ -135,6 +136,133 @@ instanceStateValue: true await taskManagerUtils.waitForActionTaskParamsToBeCleanedUp(testStart); }); + it('should fire actions when an alert instance is resolved', async () => { + const reference = alertUtils.generateReference(); + + const { body: createdAction } = await supertestWithoutAuth + .post(`${getUrlPrefix(space.id)}/api/actions/action`) + .set('kbn-xsrf', 'foo') + .send({ + name: 'MY action', + actionTypeId: 'test.noop', + config: {}, + secrets: {}, + }) + .expect(200); + + // pattern of when the alert should fire. + const pattern = { + instance: [true, true], + }; + + const createdAlert = await supertestWithoutAuth + .post(`${getUrlPrefix(space.id)}/api/alerts/alert`) + .set('kbn-xsrf', 'foo') + .send( + getTestAlertData({ + alertTypeId: 'test.patternFiring', + schedule: { interval: '1s' }, + throttle: null, + params: { + pattern, + }, + actions: [ + { + id: createdAction.id, + group: 'default', + params: {}, + }, + { + group: ResolvedActionGroup.id, + id: indexRecordActionId, + params: { + index: ES_TEST_INDEX_NAME, + reference, + message: 'Resolved message', + }, + }, + ], + }) + ); + + expect(createdAlert.status).to.eql(200); + const alertId = createdAlert.body.id; + objectRemover.add(space.id, alertId, 'alert', 'alerts'); + + const actionTestRecord = ( + await esTestIndexTool.waitForDocs('action:test.index-record', reference) + )[0]; + + expect(actionTestRecord._source.params.message).to.eql('Resolved message'); + }); + + it('should not fire actions when an alert instance is resolved, but alert is muted', async () => { + const testStart = new Date(); + const reference = alertUtils.generateReference(); + + const { body: createdAction } = await supertestWithoutAuth + .post(`${getUrlPrefix(space.id)}/api/actions/action`) + .set('kbn-xsrf', 'foo') + .send({ + name: 'MY action', + actionTypeId: 'test.noop', + config: {}, + secrets: {}, + }) + .expect(200); + + // pattern of when the alert should fire. + const pattern = { + instance: [true, true], + }; + // created disabled alert + const createdAlert = await supertestWithoutAuth + .post(`${getUrlPrefix(space.id)}/api/alerts/alert`) + .set('kbn-xsrf', 'foo') + .send( + getTestAlertData({ + alertTypeId: 'test.patternFiring', + schedule: { interval: '1s' }, + enabled: false, + throttle: null, + params: { + pattern, + reference, + }, + actions: [ + { + id: createdAction.id, + group: 'default', + params: {}, + }, + { + group: ResolvedActionGroup.id, + id: indexRecordActionId, + params: { + index: ES_TEST_INDEX_NAME, + reference, + message: 'Resolved message', + }, + }, + ], + }) + ); + expect(createdAlert.status).to.eql(200); + const alertId = createdAlert.body.id; + + await alertUtils.muteAll(alertId); + + await alertUtils.enable(alertId); + + await esTestIndexTool.search('alert:test.patternFiring', reference); + + await taskManagerUtils.waitForActionTaskParamsToBeCleanedUp(testStart); + + const actionTestRecord = await esTestIndexTool.search('action:test.index-record', reference); + expect(actionTestRecord.hits.total.value).to.eql(0); + objectRemover.add(space.id, alertId, 'alert', 'alerts'); + }); + it('should reschedule failing alerts using the Task Manager retry logic with alert schedule interval', async () => { /* Alerts should set the Task Manager schedule interval with initial value. diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/list_alert_types.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/list_alert_types.ts index 6fb573c7344b3..3fb2cc40437d8 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/list_alert_types.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/list_alert_types.ts @@ -23,7 +23,10 @@ export default function listAlertTypes({ getService }: FtrProviderContext) { (alertType: any) => alertType.id === 'test.noop' ); expect(fixtureAlertType).to.eql({ - actionGroups: [{ id: 'default', name: 'Default' }], + actionGroups: [ + { id: 'default', name: 'Default' }, + { id: 'resolved', name: 'Resolved' }, + ], defaultActionGroupId: 'default', id: 'test.noop', name: 'Test: Noop', diff --git a/x-pack/test/detection_engine_api_integration/basic/tests/create_rules.ts b/x-pack/test/detection_engine_api_integration/basic/tests/create_rules.ts index 237feb84932d2..53a8f1f4ca5c0 100644 --- a/x-pack/test/detection_engine_api_integration/basic/tests/create_rules.ts +++ b/x-pack/test/detection_engine_api_integration/basic/tests/create_rules.ts @@ -5,6 +5,7 @@ */ import expect from '@kbn/expect'; +import { CreateRulesSchema } from '../../../../plugins/security_solution/common/detection_engine/schemas/request'; import { DETECTION_ENGINE_RULES_URL } from '../../../../plugins/security_solution/common/constants'; import { FtrProviderContext } from '../../common/ftr_provider_context'; @@ -65,13 +66,51 @@ export default ({ getService }: FtrProviderContext) => { }); it('should create a single rule without an input index', async () => { - const { index, ...payload } = getSimpleRule(); - const { index: _index, ...expected } = getSimpleRuleOutput(); + const rule: CreateRulesSchema = { + name: 'Simple Rule Query', + description: 'Simple Rule Query', + enabled: true, + risk_score: 1, + rule_id: 'rule-1', + severity: 'high', + type: 'query', + query: 'user.name: root or user.name: admin', + }; + const expected = { + actions: [], + author: [], + created_by: 'elastic', + description: 'Simple Rule Query', + enabled: true, + false_positives: [], + from: 'now-6m', + immutable: false, + interval: '5m', + rule_id: 'rule-1', + language: 'kuery', + output_index: '.siem-signals-default', + max_signals: 100, + risk_score: 1, + risk_score_mapping: [], + name: 'Simple Rule Query', + query: 'user.name: root or user.name: admin', + references: [], + severity: 'high', + severity_mapping: [], + updated_by: 'elastic', + tags: [], + to: 'now', + type: 'query', + threat: [], + throttle: 'no_actions', + exceptions_list: [], + version: 1, + }; const { body } = await supertest .post(DETECTION_ENGINE_RULES_URL) .set('kbn-xsrf', 'true') - .send(payload) + .send(rule) .expect(200); const bodyToCompare = removeServerGeneratedProperties(body); diff --git a/x-pack/test/detection_engine_api_integration/basic/tests/update_rules.ts b/x-pack/test/detection_engine_api_integration/basic/tests/update_rules.ts index a0fcac159a73e..2f5a043881eeb 100644 --- a/x-pack/test/detection_engine_api_integration/basic/tests/update_rules.ts +++ b/x-pack/test/detection_engine_api_integration/basic/tests/update_rules.ts @@ -19,6 +19,7 @@ import { getSimpleRuleUpdate, getSimpleMlRuleUpdate, createRule, + getSimpleRule, } from '../../utils'; // eslint-disable-next-line import/no-default-export @@ -38,7 +39,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should update a single rule property of name using a rule_id', async () => { - await createRule(supertest, getSimpleRuleUpdate('rule-1')); + await createRule(supertest, getSimpleRule('rule-1')); // update a simple rule's name const updatedRule = getSimpleRuleUpdate('rule-1'); @@ -60,7 +61,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should return a 403 forbidden if it is a machine learning job', async () => { - await createRule(supertest, getSimpleRuleUpdate('rule-1')); + await createRule(supertest, getSimpleRule('rule-1')); // update a simple rule's type to try to be a machine learning job type const updatedRule = getSimpleMlRuleUpdate('rule-1'); @@ -81,7 +82,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should update a single rule property of name using an auto-generated rule_id', async () => { - const rule = getSimpleRuleUpdate('rule-1'); + const rule = getSimpleRule('rule-1'); delete rule.rule_id; const createRuleBody = await createRule(supertest, rule); @@ -105,7 +106,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should update a single rule property of name using the auto-generated id', async () => { - const createdBody = await createRule(supertest, getSimpleRuleUpdate('rule-1')); + const createdBody = await createRule(supertest, getSimpleRule('rule-1')); // update a simple rule's name const updatedRule = getSimpleRuleUpdate('rule-1'); @@ -127,7 +128,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should change the version of a rule when it updates enabled and another property', async () => { - await createRule(supertest, getSimpleRuleUpdate('rule-1')); + await createRule(supertest, getSimpleRule('rule-1')); // update a simple rule's enabled to false and another property const updatedRule = getSimpleRuleUpdate('rule-1'); @@ -150,7 +151,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should change other properties when it does updates and effectively delete them such as timeline_title', async () => { - await createRule(supertest, getSimpleRuleUpdate('rule-1')); + await createRule(supertest, getSimpleRule('rule-1')); const ruleUpdate = getSimpleRuleUpdate('rule-1'); ruleUpdate.timeline_title = 'some title'; diff --git a/x-pack/test/detection_engine_api_integration/basic/tests/update_rules_bulk.ts b/x-pack/test/detection_engine_api_integration/basic/tests/update_rules_bulk.ts index a846771fe7683..22aa40b0721a4 100644 --- a/x-pack/test/detection_engine_api_integration/basic/tests/update_rules_bulk.ts +++ b/x-pack/test/detection_engine_api_integration/basic/tests/update_rules_bulk.ts @@ -18,6 +18,7 @@ import { removeServerGeneratedPropertiesIncludingRuleId, getSimpleRuleUpdate, createRule, + getSimpleRule, } from '../../utils'; // eslint-disable-next-line import/no-default-export @@ -37,7 +38,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should update a single rule property of name using a rule_id', async () => { - await createRule(supertest, getSimpleRuleUpdate('rule-1')); + await createRule(supertest, getSimpleRule('rule-1')); const updatedRule = getSimpleRuleUpdate('rule-1'); updatedRule.name = 'some other name'; @@ -57,7 +58,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should update two rule properties of name using the two rules rule_id', async () => { - await createRule(supertest, getSimpleRuleUpdate('rule-1')); + await createRule(supertest, getSimpleRule('rule-1')); // create a second simple rule await supertest @@ -94,7 +95,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should update a single rule property of name using an id', async () => { - const createRuleBody = await createRule(supertest, getSimpleRuleUpdate('rule-1')); + const createRuleBody = await createRule(supertest, getSimpleRule('rule-1')); // update a simple rule's name const updatedRule1 = getSimpleRuleUpdate('rule-1'); @@ -116,8 +117,8 @@ export default ({ getService }: FtrProviderContext) => { }); it('should update two rule properties of name using the two rules id', async () => { - const createRule1 = await createRule(supertest, getSimpleRuleUpdate('rule-1')); - const createRule2 = await createRule(supertest, getSimpleRuleUpdate('rule-2')); + const createRule1 = await createRule(supertest, getSimpleRule('rule-1')); + const createRule2 = await createRule(supertest, getSimpleRule('rule-2')); // update both rule names const updatedRule1 = getSimpleRuleUpdate('rule-1'); @@ -151,7 +152,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should update a single rule property of name using the auto-generated id', async () => { - const createdBody = await createRule(supertest, getSimpleRuleUpdate('rule-1')); + const createdBody = await createRule(supertest, getSimpleRule('rule-1')); // update a simple rule's name const updatedRule1 = getSimpleRuleUpdate('rule-1'); @@ -173,7 +174,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should change the version of a rule when it updates enabled and another property', async () => { - await createRule(supertest, getSimpleRuleUpdate('rule-1')); + await createRule(supertest, getSimpleRule('rule-1')); // update a simple rule's enabled to false and another property const updatedRule1 = getSimpleRuleUpdate('rule-1'); @@ -196,7 +197,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should change other properties when it does updates and effectively delete them such as timeline_title', async () => { - await createRule(supertest, getSimpleRuleUpdate('rule-1')); + await createRule(supertest, getSimpleRule('rule-1')); // update a simple rule's timeline_title const ruleUpdate = getSimpleRuleUpdate('rule-1'); @@ -269,7 +270,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should update one rule property and give an error about a second fake rule_id', async () => { - await createRule(supertest, getSimpleRuleUpdate('rule-1')); + await createRule(supertest, getSimpleRule('rule-1')); const ruleUpdate = getSimpleRuleUpdate('rule-1'); ruleUpdate.name = 'some other name'; @@ -304,7 +305,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should update one rule property and give an error about a second fake id', async () => { - const createdBody = await createRule(supertest, getSimpleRuleUpdate('rule-1')); + const createdBody = await createRule(supertest, getSimpleRule('rule-1')); // update one rule name and give a fake id for the second const rule1 = getSimpleRuleUpdate(); diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/add_actions.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/add_actions.ts index 75d5e47b7b990..d473863e7d028 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/add_actions.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/add_actions.ts @@ -6,6 +6,7 @@ import expect from '@kbn/expect'; +import { CreateRulesSchema } from '../../../../plugins/security_solution/common/detection_engine/schemas/request'; import { DETECTION_ENGINE_RULES_URL } from '../../../../plugins/security_solution/common/constants'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { @@ -19,7 +20,6 @@ import { waitForRuleSuccess, createRule, } from '../../utils'; -import { CreateRulesSchema } from '../../../../plugins/security_solution/common/detection_engine/schemas/request/create_rules_schema'; // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext) => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_exceptions.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_exceptions.ts index 238768e1feb8f..651a7601ca95a 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_exceptions.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_exceptions.ts @@ -7,10 +7,10 @@ /* eslint-disable @typescript-eslint/naming-convention */ import expect from '@kbn/expect'; +import { CreateRulesSchema } from '../../../../plugins/security_solution/common/detection_engine/schemas/request'; import { getCreateExceptionListItemMinimalSchemaMock } from '../../../../plugins/lists/common/schemas/request/create_exception_list_item_schema.mock'; import { deleteAllExceptions } from '../../../lists_api_integration/utils'; import { RulesSchema } from '../../../../plugins/security_solution/common/detection_engine/schemas/response'; -import { CreateRulesSchema } from '../../../../plugins/security_solution/common/detection_engine/schemas/request'; import { getCreateExceptionListMinimalSchemaMock } from '../../../../plugins/lists/common/schemas/request/create_exception_list_schema.mock'; import { CreateExceptionListItemSchema } from '../../../../plugins/lists/common'; import { EXCEPTION_LIST_URL } from '../../../../plugins/lists/common/constants'; @@ -422,7 +422,14 @@ export default ({ getService }: FtrProviderContext) => { await createExceptionListItem(supertest, exceptionListItem); const ruleWithException: CreateRulesSchema = { - ...getSimpleRule(), + name: 'Simple Rule Query', + description: 'Simple Rule Query', + enabled: true, + risk_score: 1, + rule_id: 'rule-1', + severity: 'high', + index: ['auditbeat-*'], + type: 'query', from: '1900-01-01T00:00:00.000Z', query: 'host.name: "suricata-sensor-amsterdam"', exceptions_list: [ @@ -460,9 +467,16 @@ export default ({ getService }: FtrProviderContext) => { await createExceptionListItem(supertest, exceptionListItem); const ruleWithException: CreateRulesSchema = { - ...getSimpleRule(), + name: 'Simple Rule Query', + description: 'Simple Rule Query', + enabled: true, + risk_score: 1, + rule_id: 'rule-1', + severity: 'high', + index: ['auditbeat-*'], + type: 'query', from: '1900-01-01T00:00:00.000Z', - query: 'host.name: "suricata-sensor-amsterdam"', // this matches all the exceptions we should exclude + query: 'host.name: "suricata-sensor-amsterdam"', exceptions_list: [ { id, diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules.ts index 4d9bff8b0f34e..a18faf8543042 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules.ts @@ -5,6 +5,7 @@ */ import expect from '@kbn/expect'; +import { CreateRulesSchema } from '../../../../plugins/security_solution/common/detection_engine/schemas/request'; import { DETECTION_ENGINE_RULES_URL, @@ -110,13 +111,51 @@ export default ({ getService }: FtrProviderContext) => { }); it('should create a single rule without an input index', async () => { - const { index, ...payload } = getSimpleRule(); - const { index: _index, ...expected } = getSimpleRuleOutput(); + const rule: CreateRulesSchema = { + name: 'Simple Rule Query', + description: 'Simple Rule Query', + enabled: true, + risk_score: 1, + rule_id: 'rule-1', + severity: 'high', + type: 'query', + query: 'user.name: root or user.name: admin', + }; + const expected = { + actions: [], + author: [], + created_by: 'elastic', + description: 'Simple Rule Query', + enabled: true, + false_positives: [], + from: 'now-6m', + immutable: false, + interval: '5m', + rule_id: 'rule-1', + language: 'kuery', + output_index: '.siem-signals-default', + max_signals: 100, + risk_score: 1, + risk_score_mapping: [], + name: 'Simple Rule Query', + query: 'user.name: root or user.name: admin', + references: [], + severity: 'high', + severity_mapping: [], + updated_by: 'elastic', + tags: [], + to: 'now', + type: 'query', + threat: [], + throttle: 'no_actions', + exceptions_list: [], + version: 1, + }; const { body } = await supertest .post(DETECTION_ENGINE_RULES_URL) .set('kbn-xsrf', 'true') - .send(payload) + .send(rule) .expect(200); const bodyToCompare = removeServerGeneratedProperties(body); diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_threat_matching.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_threat_matching.ts index 498c607121760..36cd8480998c5 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_threat_matching.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_threat_matching.ts @@ -23,7 +23,7 @@ import { waitForSignalsToBePresent, } from '../../utils'; -import { getCreateThreatMatchRulesSchemaMock } from '../../../../plugins/security_solution/common/detection_engine/schemas/request/create_rules_schema.mock'; +import { getCreateThreatMatchRulesSchemaMock } from '../../../../plugins/security_solution/common/detection_engine/schemas/request/rule_schemas.mock'; import { getThreatMatchingSchemaPartialMock } from '../../../../plugins/security_solution/common/detection_engine/schemas/response/rules_schema.mocks'; // eslint-disable-next-line import/no-default-export @@ -99,7 +99,13 @@ export default ({ getService }: FtrProviderContext) => { it('should be able to execute and get 10 signals when doing a specific query', async () => { const rule: CreateRulesSchema = { - ...getCreateThreatMatchRulesSchemaMock(), + description: 'Detecting root and admin users', + name: 'Query with a rule id', + severity: 'high', + type: 'threat_match', + risk_score: 55, + language: 'kuery', + rule_id: 'rule-1', from: '1900-01-01T00:00:00.000Z', query: '*:*', threat_query: 'source.ip: "188.166.120.93"', // narrow things down with a query to a specific source ip @@ -127,7 +133,13 @@ export default ({ getService }: FtrProviderContext) => { it('should return 0 matches if the mapping does not match against anything in the mapping', async () => { const rule: CreateRulesSchema = { - ...getCreateThreatMatchRulesSchemaMock(), + description: 'Detecting root and admin users', + name: 'Query with a rule id', + severity: 'high', + type: 'threat_match', + risk_score: 55, + language: 'kuery', + rule_id: 'rule-1', from: '1900-01-01T00:00:00.000Z', query: '*:*', threat_query: 'source.ip: "188.166.120.93"', // narrow things down with a query to a specific source ip @@ -155,7 +167,13 @@ export default ({ getService }: FtrProviderContext) => { it('should return 0 signals when using an AND and one of the clauses does not have data', async () => { const rule: CreateRulesSchema = { - ...getCreateThreatMatchRulesSchemaMock(), + description: 'Detecting root and admin users', + name: 'Query with a rule id', + severity: 'high', + type: 'threat_match', + risk_score: 55, + language: 'kuery', + rule_id: 'rule-1', from: '1900-01-01T00:00:00.000Z', query: '*:*', threat_query: 'source.ip: "188.166.120.93"', // narrow things down with a query to a specific source ip @@ -187,7 +205,13 @@ export default ({ getService }: FtrProviderContext) => { it('should return 0 signals when using an AND and one of the clauses has a made up value that does not exist', async () => { const rule: CreateRulesSchema = { - ...getCreateThreatMatchRulesSchemaMock(), + description: 'Detecting root and admin users', + name: 'Query with a rule id', + severity: 'high', + type: 'threat_match', + risk_score: 55, + language: 'kuery', + rule_id: 'rule-1', from: '1900-01-01T00:00:00.000Z', query: '*:*', threat_query: 'source.ip: "188.166.120.93"', // narrow things down with a query to a specific source ip diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/generating_signals.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/generating_signals.ts index 0cd1c21447dfe..0ba2abb466f7b 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/generating_signals.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/generating_signals.ts @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; -import { CreateRulesSchema } from '../../../../plugins/security_solution/common/detection_engine/schemas/request'; +import { QueryCreateSchema } from '../../../../plugins/security_solution/common/detection_engine/schemas/request'; import { DEFAULT_SIGNALS_INDEX } from '../../../../plugins/security_solution/common/constants'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { @@ -53,7 +53,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should have the specific audit record for _id or none of these tests below will pass', async () => { - const rule: CreateRulesSchema = { + const rule: QueryCreateSchema = { ...getSimpleRule(), from: '1900-01-01T00:00:00.000Z', query: `_id:${ID}`, @@ -65,7 +65,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should have recorded the rule_id within the signal', async () => { - const rule: CreateRulesSchema = { + const rule: QueryCreateSchema = { ...getSimpleRule(), from: '1900-01-01T00:00:00.000Z', query: `_id:${ID}`, @@ -77,7 +77,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should query and get back expected signal structure using a basic KQL query', async () => { - const rule: CreateRulesSchema = { + const rule: QueryCreateSchema = { ...getSimpleRule(), from: '1900-01-01T00:00:00.000Z', query: `_id:${ID}`, @@ -124,7 +124,7 @@ export default ({ getService }: FtrProviderContext) => { it('should query and get back expected signal structure when it is a signal on a signal', async () => { // create a 1 signal from 1 auditbeat record - const rule: CreateRulesSchema = { + const rule: QueryCreateSchema = { ...getSimpleRule(), from: '1900-01-01T00:00:00.000Z', query: `_id:${ID}`, @@ -133,7 +133,7 @@ export default ({ getService }: FtrProviderContext) => { await waitForSignalsToBePresent(supertest, 1); // Run signals on top of that 1 signal which should create a single signal (on top of) a signal - const ruleForSignals: CreateRulesSchema = { + const ruleForSignals: QueryCreateSchema = { ...getSimpleRule(), rule_id: 'signal-on-signal', index: [`${DEFAULT_SIGNALS_INDEX}*`], @@ -209,7 +209,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should have the specific audit record for _id or none of these tests below will pass', async () => { - const rule: CreateRulesSchema = { + const rule: QueryCreateSchema = { ...getSimpleRule(), index: ['signal_name_clash'], from: '1900-01-01T00:00:00.000Z', @@ -222,7 +222,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should have recorded the rule_id within the signal', async () => { - const rule: CreateRulesSchema = { + const rule: QueryCreateSchema = { ...getSimpleRule(), index: ['signal_name_clash'], from: '1900-01-01T00:00:00.000Z', @@ -235,7 +235,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should query and get back expected signal structure using a basic KQL query', async () => { - const rule: CreateRulesSchema = { + const rule: QueryCreateSchema = { ...getSimpleRule(), index: ['signal_name_clash'], from: '1900-01-01T00:00:00.000Z', @@ -278,7 +278,7 @@ export default ({ getService }: FtrProviderContext) => { it('should query and get back expected signal structure when it is a signal on a signal', async () => { // create a 1 signal from 1 auditbeat record - const rule: CreateRulesSchema = { + const rule: QueryCreateSchema = { ...getSimpleRule(), index: ['signal_name_clash'], from: '1900-01-01T00:00:00.000Z', @@ -288,7 +288,7 @@ export default ({ getService }: FtrProviderContext) => { await waitForSignalsToBePresent(supertest, 1); // Run signals on top of that 1 signal which should create a single signal (on top of) a signal - const ruleForSignals: CreateRulesSchema = { + const ruleForSignals: QueryCreateSchema = { ...getSimpleRule(), rule_id: 'signal-on-signal', index: [`${DEFAULT_SIGNALS_INDEX}*`], @@ -362,7 +362,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should have the specific audit record for _id or none of these tests below will pass', async () => { - const rule: CreateRulesSchema = { + const rule: QueryCreateSchema = { ...getSimpleRule(), index: ['signal_object_clash'], from: '1900-01-01T00:00:00.000Z', @@ -375,7 +375,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should have recorded the rule_id within the signal', async () => { - const rule: CreateRulesSchema = { + const rule: QueryCreateSchema = { ...getSimpleRule(), index: ['signal_object_clash'], from: '1900-01-01T00:00:00.000Z', @@ -388,7 +388,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should query and get back expected signal structure using a basic KQL query', async () => { - const rule: CreateRulesSchema = { + const rule: QueryCreateSchema = { ...getSimpleRule(), index: ['signal_object_clash'], from: '1900-01-01T00:00:00.000Z', @@ -437,7 +437,7 @@ export default ({ getService }: FtrProviderContext) => { it('should query and get back expected signal structure when it is a signal on a signal', async () => { // create a 1 signal from 1 auditbeat record - const rule: CreateRulesSchema = { + const rule: QueryCreateSchema = { ...getSimpleRule(), index: ['signal_object_clash'], from: '1900-01-01T00:00:00.000Z', @@ -447,7 +447,7 @@ export default ({ getService }: FtrProviderContext) => { await waitForSignalsToBePresent(supertest, 1); // Run signals on top of that 1 signal which should create a single signal (on top of) a signal - const ruleForSignals: CreateRulesSchema = { + const ruleForSignals: QueryCreateSchema = { ...getSimpleRule(), rule_id: 'signal-on-signal', index: [`${DEFAULT_SIGNALS_INDEX}*`], diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules.ts index 3150e7c5b71c7..23a8776b14631 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules.ts @@ -21,6 +21,7 @@ import { getSimpleRuleUpdate, getSimpleMlRuleUpdate, createRule, + getSimpleRule, } from '../../utils'; // eslint-disable-next-line import/no-default-export @@ -40,7 +41,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should update a single rule property of name using a rule_id', async () => { - await createRule(supertest, getSimpleRuleUpdate('rule-1')); + await createRule(supertest, getSimpleRule('rule-1')); // update a simple rule's name const updatedRule = getSimpleRuleUpdate('rule-1'); @@ -84,7 +85,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should update a single rule property of name using an auto-generated rule_id', async () => { - const rule = getSimpleRuleUpdate('rule-1'); + const rule = getSimpleRule('rule-1'); delete rule.rule_id; const createRuleBody = await createRule(supertest, rule); @@ -108,7 +109,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should update a single rule property of name using the auto-generated id', async () => { - const createdBody = await createRule(supertest, getSimpleRuleUpdate('rule-1')); + const createdBody = await createRule(supertest, getSimpleRule('rule-1')); // update a simple rule's name const updatedRule = getSimpleRuleUpdate('rule-1'); @@ -130,7 +131,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should change the version of a rule when it updates enabled and another property', async () => { - await createRule(supertest, getSimpleRuleUpdate('rule-1')); + await createRule(supertest, getSimpleRule('rule-1')); // update a simple rule's enabled to false and another property const updatedRule = getSimpleRuleUpdate('rule-1'); @@ -153,7 +154,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should change other properties when it does updates and effectively delete them such as timeline_title', async () => { - await createRule(supertest, getSimpleRuleUpdate('rule-1')); + await createRule(supertest, getSimpleRule('rule-1')); const ruleUpdate = getSimpleRuleUpdate('rule-1'); ruleUpdate.timeline_title = 'some title'; diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules_bulk.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules_bulk.ts index a846771fe7683..22aa40b0721a4 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules_bulk.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules_bulk.ts @@ -18,6 +18,7 @@ import { removeServerGeneratedPropertiesIncludingRuleId, getSimpleRuleUpdate, createRule, + getSimpleRule, } from '../../utils'; // eslint-disable-next-line import/no-default-export @@ -37,7 +38,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should update a single rule property of name using a rule_id', async () => { - await createRule(supertest, getSimpleRuleUpdate('rule-1')); + await createRule(supertest, getSimpleRule('rule-1')); const updatedRule = getSimpleRuleUpdate('rule-1'); updatedRule.name = 'some other name'; @@ -57,7 +58,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should update two rule properties of name using the two rules rule_id', async () => { - await createRule(supertest, getSimpleRuleUpdate('rule-1')); + await createRule(supertest, getSimpleRule('rule-1')); // create a second simple rule await supertest @@ -94,7 +95,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should update a single rule property of name using an id', async () => { - const createRuleBody = await createRule(supertest, getSimpleRuleUpdate('rule-1')); + const createRuleBody = await createRule(supertest, getSimpleRule('rule-1')); // update a simple rule's name const updatedRule1 = getSimpleRuleUpdate('rule-1'); @@ -116,8 +117,8 @@ export default ({ getService }: FtrProviderContext) => { }); it('should update two rule properties of name using the two rules id', async () => { - const createRule1 = await createRule(supertest, getSimpleRuleUpdate('rule-1')); - const createRule2 = await createRule(supertest, getSimpleRuleUpdate('rule-2')); + const createRule1 = await createRule(supertest, getSimpleRule('rule-1')); + const createRule2 = await createRule(supertest, getSimpleRule('rule-2')); // update both rule names const updatedRule1 = getSimpleRuleUpdate('rule-1'); @@ -151,7 +152,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should update a single rule property of name using the auto-generated id', async () => { - const createdBody = await createRule(supertest, getSimpleRuleUpdate('rule-1')); + const createdBody = await createRule(supertest, getSimpleRule('rule-1')); // update a simple rule's name const updatedRule1 = getSimpleRuleUpdate('rule-1'); @@ -173,7 +174,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should change the version of a rule when it updates enabled and another property', async () => { - await createRule(supertest, getSimpleRuleUpdate('rule-1')); + await createRule(supertest, getSimpleRule('rule-1')); // update a simple rule's enabled to false and another property const updatedRule1 = getSimpleRuleUpdate('rule-1'); @@ -196,7 +197,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should change other properties when it does updates and effectively delete them such as timeline_title', async () => { - await createRule(supertest, getSimpleRuleUpdate('rule-1')); + await createRule(supertest, getSimpleRule('rule-1')); // update a simple rule's timeline_title const ruleUpdate = getSimpleRuleUpdate('rule-1'); @@ -269,7 +270,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should update one rule property and give an error about a second fake rule_id', async () => { - await createRule(supertest, getSimpleRuleUpdate('rule-1')); + await createRule(supertest, getSimpleRule('rule-1')); const ruleUpdate = getSimpleRuleUpdate('rule-1'); ruleUpdate.name = 'some other name'; @@ -304,7 +305,7 @@ export default ({ getService }: FtrProviderContext) => { }); it('should update one rule property and give an error about a second fake id', async () => { - const createdBody = await createRule(supertest, getSimpleRuleUpdate('rule-1')); + const createdBody = await createRule(supertest, getSimpleRule('rule-1')); // update one rule name and give a fake id for the second const rule1 = getSimpleRuleUpdate(); diff --git a/x-pack/test/detection_engine_api_integration/utils.ts b/x-pack/test/detection_engine_api_integration/utils.ts index c5e417c710283..f458fe118dcf7 100644 --- a/x-pack/test/detection_engine_api_integration/utils.ts +++ b/x-pack/test/detection_engine_api_integration/utils.ts @@ -9,6 +9,12 @@ import { SuperTest } from 'supertest'; import supertestAsPromised from 'supertest-as-promised'; import { Context } from '@elastic/elasticsearch/lib/Transport'; import { SearchResponse } from 'elasticsearch'; +import { + CreateRulesSchema, + UpdateRulesSchema, + FullResponseSchema, + QueryCreateSchema, +} from '../../plugins/security_solution/common/detection_engine/schemas/request'; import { EXCEPTION_LIST_ITEM_URL, EXCEPTION_LIST_URL } from '../../plugins/lists/common/constants'; import { CreateExceptionListItemSchema, @@ -21,8 +27,6 @@ import { Status, SignalIds, } from '../../plugins/security_solution/common/detection_engine/schemas/common/schemas'; -import { CreateRulesSchema } from '../../plugins/security_solution/common/detection_engine/schemas/request/create_rules_schema'; -import { UpdateRulesSchema } from '../../plugins/security_solution/common/detection_engine/schemas/request/update_rules_schema'; import { RulesSchema } from '../../plugins/security_solution/common/detection_engine/schemas/response/rules_schema'; import { DETECTION_ENGINE_INDEX_URL, @@ -37,8 +41,8 @@ import { * @param rule Rule to pass in to remove typical server generated properties */ export const removeServerGeneratedProperties = ( - rule: Partial -): Partial => { + rule: FullResponseSchema +): Partial => { const { /* eslint-disable @typescript-eslint/naming-convention */ created_at, @@ -61,8 +65,8 @@ export const removeServerGeneratedProperties = ( * @param rule Rule to pass in to remove typical server generated properties */ export const removeServerGeneratedPropertiesIncludingRuleId = ( - rule: Partial -): Partial => { + rule: FullResponseSchema +): Partial => { const ruleWithRemovedProperties = removeServerGeneratedProperties(rule); // eslint-disable-next-line @typescript-eslint/naming-convention const { rule_id, ...additionalRuledIdRemoved } = ruleWithRemovedProperties; @@ -74,7 +78,7 @@ export const removeServerGeneratedPropertiesIncludingRuleId = ( * @param ruleId * @param enabled Enables the rule on creation or not. Defaulted to false to enable it on import */ -export const getSimpleRule = (ruleId = 'rule-1', enabled = true): CreateRulesSchema => ({ +export const getSimpleRule = (ruleId = 'rule-1', enabled = true): QueryCreateSchema => ({ name: 'Simple Rule Query', description: 'Simple Rule Query', enabled, @@ -384,7 +388,7 @@ export const getSimpleRuleAsNdjson = (ruleIds: string[], enabled = false): Buffe * testing upload features. * @param rule The rule to convert to ndjson */ -export const ruleToNdjson = (rule: Partial): Buffer => { +export const ruleToNdjson = (rule: CreateRulesSchema): Buffer => { const stringified = JSON.stringify(rule); return Buffer.from(`${stringified}\n`); }; @@ -725,7 +729,7 @@ export const countDownTest = async ( export const createRule = async ( supertest: SuperTest, rule: CreateRulesSchema -): Promise => { +): Promise => { const { body } = await supertest .post(DETECTION_ENGINE_RULES_URL) .set('kbn-xsrf', 'true') diff --git a/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer.ts b/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer.ts index 1c1afd86fb7d7..a7660e68e93e1 100644 --- a/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer.ts +++ b/x-pack/test/functional/apps/ml/data_visualizer/index_data_visualizer.ts @@ -8,6 +8,17 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; import { ML_JOB_FIELD_TYPES } from '../../../../../plugins/ml/common/constants/field_types'; import { FieldVisConfig } from '../../../../../plugins/ml/public/application/datavisualizer/index_based/common'; +interface MetricFieldVisConfig extends FieldVisConfig { + statsMaxDecimalPlaces: number; + docCountFormatted: string; + selectedDetailsMode: 'distribution' | 'top_values'; + topValuesCount: number; +} + +interface NonMetricFieldVisConfig extends FieldVisConfig { + exampleCount?: number; +} + interface TestData { suiteTitle: string; sourceIndexOrSavedSearch: string; @@ -15,10 +26,11 @@ interface TestData { nonMetricFieldsFilter: string; nonMetricFieldsTypeFilter: string; expected: { - totalDocCount: number; + totalDocCountFormatted: string; fieldsPanelCount: number; - metricCards?: FieldVisConfig[]; - nonMetricCards?: FieldVisConfig[]; + documentCountCard: FieldVisConfig; + metricCards?: MetricFieldVisConfig[]; + nonMetricCards?: NonMetricFieldVisConfig[]; nonMetricFieldsTypeFilterCardCount: number; metricFieldsFilterCardCount: number; nonMetricFieldsFilterCardCount: number; @@ -48,21 +60,25 @@ export default function ({ getService }: FtrProviderContext) { nonMetricFieldsFilter: 'airline', nonMetricFieldsTypeFilter: 'keyword', expected: { - totalDocCount: 86274, + totalDocCountFormatted: '86,274', fieldsPanelCount: 2, // Metrics panel and Fields panel + documentCountCard: { + type: ML_JOB_FIELD_TYPES.NUMBER, + existsInDocs: true, + aggregatable: true, + loading: false, + }, metricCards: [ - { - type: ML_JOB_FIELD_TYPES.NUMBER, // document count card - existsInDocs: true, - aggregatable: true, - loading: false, - }, { fieldName: 'responsetime', type: ML_JOB_FIELD_TYPES.NUMBER, existsInDocs: true, aggregatable: true, loading: false, + docCountFormatted: '5,000', + statsMaxDecimalPlaces: 3, + selectedDetailsMode: 'distribution', + topValuesCount: 10, }, ], nonMetricCards: [ @@ -79,6 +95,7 @@ export default function ({ getService }: FtrProviderContext) { existsInDocs: true, aggregatable: false, loading: false, + exampleCount: 1, }, { fieldName: '@version.keyword', @@ -86,6 +103,7 @@ export default function ({ getService }: FtrProviderContext) { existsInDocs: true, aggregatable: true, loading: false, + exampleCount: 1, }, { fieldName: 'airline', @@ -93,6 +111,7 @@ export default function ({ getService }: FtrProviderContext) { existsInDocs: true, aggregatable: true, loading: false, + exampleCount: 10, }, { fieldName: 'type', @@ -100,6 +119,7 @@ export default function ({ getService }: FtrProviderContext) { existsInDocs: true, aggregatable: false, loading: false, + exampleCount: 1, }, { fieldName: 'type.keyword', @@ -107,6 +127,7 @@ export default function ({ getService }: FtrProviderContext) { existsInDocs: true, aggregatable: true, loading: false, + exampleCount: 1, }, ], nonMetricFieldsTypeFilterCardCount: 3, @@ -122,21 +143,25 @@ export default function ({ getService }: FtrProviderContext) { nonMetricFieldsFilter: 'airline', nonMetricFieldsTypeFilter: 'keyword', expected: { - totalDocCount: 34415, + totalDocCountFormatted: '34,415', fieldsPanelCount: 2, // Metrics panel and Fields panel + documentCountCard: { + type: ML_JOB_FIELD_TYPES.NUMBER, + existsInDocs: true, + aggregatable: true, + loading: false, + }, metricCards: [ - { - type: ML_JOB_FIELD_TYPES.NUMBER, // document count card - existsInDocs: true, - aggregatable: true, - loading: false, - }, { fieldName: 'responsetime', type: ML_JOB_FIELD_TYPES.NUMBER, existsInDocs: true, aggregatable: true, loading: false, + docCountFormatted: '5,000', + statsMaxDecimalPlaces: 3, + selectedDetailsMode: 'distribution', + topValuesCount: 10, }, ], nonMetricCards: [ @@ -153,6 +178,7 @@ export default function ({ getService }: FtrProviderContext) { existsInDocs: true, aggregatable: false, loading: false, + exampleCount: 1, }, { fieldName: '@version.keyword', @@ -160,6 +186,7 @@ export default function ({ getService }: FtrProviderContext) { existsInDocs: true, aggregatable: true, loading: false, + exampleCount: 1, }, { fieldName: 'airline', @@ -167,6 +194,7 @@ export default function ({ getService }: FtrProviderContext) { existsInDocs: true, aggregatable: true, loading: false, + exampleCount: 5, }, { fieldName: 'type', @@ -174,6 +202,7 @@ export default function ({ getService }: FtrProviderContext) { existsInDocs: true, aggregatable: false, loading: false, + exampleCount: 1, }, { fieldName: 'type.keyword', @@ -181,6 +210,7 @@ export default function ({ getService }: FtrProviderContext) { existsInDocs: true, aggregatable: true, loading: false, + exampleCount: 1, }, ], nonMetricFieldsTypeFilterCardCount: 3, @@ -196,21 +226,25 @@ export default function ({ getService }: FtrProviderContext) { nonMetricFieldsFilter: 'version', nonMetricFieldsTypeFilter: 'keyword', expected: { - totalDocCount: 34416, + totalDocCountFormatted: '34,416', fieldsPanelCount: 2, // Metrics panel and Fields panel + documentCountCard: { + type: ML_JOB_FIELD_TYPES.NUMBER, // document count card + existsInDocs: true, + aggregatable: true, + loading: false, + }, metricCards: [ - { - type: ML_JOB_FIELD_TYPES.NUMBER, // document count card - existsInDocs: true, - aggregatable: true, - loading: false, - }, { fieldName: 'responsetime', type: ML_JOB_FIELD_TYPES.NUMBER, existsInDocs: true, aggregatable: true, loading: false, + docCountFormatted: '5,000', + statsMaxDecimalPlaces: 3, + selectedDetailsMode: 'distribution', + topValuesCount: 10, }, ], nonMetricCards: [ @@ -227,6 +261,7 @@ export default function ({ getService }: FtrProviderContext) { existsInDocs: true, aggregatable: false, loading: false, + exampleCount: 1, }, { fieldName: '@version.keyword', @@ -234,6 +269,7 @@ export default function ({ getService }: FtrProviderContext) { existsInDocs: true, aggregatable: true, loading: false, + exampleCount: 1, }, { fieldName: 'airline', @@ -241,6 +277,7 @@ export default function ({ getService }: FtrProviderContext) { existsInDocs: true, aggregatable: true, loading: false, + exampleCount: 5, }, { fieldName: 'type', @@ -248,6 +285,7 @@ export default function ({ getService }: FtrProviderContext) { existsInDocs: true, aggregatable: false, loading: false, + exampleCount: 1, }, { fieldName: 'type.keyword', @@ -255,6 +293,7 @@ export default function ({ getService }: FtrProviderContext) { existsInDocs: true, aggregatable: true, loading: false, + exampleCount: 1, }, ], nonMetricFieldsTypeFilterCardCount: 3, @@ -283,22 +322,42 @@ export default function ({ getService }: FtrProviderContext) { await ml.dataVisualizerIndexBased.assertTimeRangeSelectorSectionExists(); await ml.testExecution.logTestStep(`${testData.suiteTitle} loads data for full time range`); - await ml.dataVisualizerIndexBased.clickUseFullDataButton(testData.expected.totalDocCount); + await ml.dataVisualizerIndexBased.clickUseFullDataButton( + testData.expected.totalDocCountFormatted + ); await ml.testExecution.logTestStep(`${testData.suiteTitle} displays the panels of fields`); await ml.dataVisualizerIndexBased.assertFieldsPanelsExist(testData.expected.fieldsPanelCount); - if (testData.expected.metricCards !== undefined && testData.expected.metricCards.length > 0) { - await ml.testExecution.logTestStep(`${testData.suiteTitle} displays the Metrics panel`); - await ml.dataVisualizerIndexBased.assertFieldsPanelForTypesExist([ - ML_JOB_FIELD_TYPES.NUMBER, - ]); // document_count not exposed as a type in the panel + await ml.testExecution.logTestStep(`${testData.suiteTitle} displays the Metrics panel`); + await ml.dataVisualizerIndexBased.assertFieldsPanelForTypesExist([ML_JOB_FIELD_TYPES.NUMBER]); + await ml.testExecution.logTestStep( + `${testData.suiteTitle} displays the expected document count card` + ); + await ml.dataVisualizerIndexBased.assertCardExists( + testData.expected.documentCountCard.type, + testData.expected.documentCountCard.fieldName + ); + await ml.dataVisualizerIndexBased.assertDocumentCountCardContents(); + + await ml.testExecution.logTestStep( + `${testData.suiteTitle} displays the expected metric field cards and contents` + ); + + if (testData.expected.metricCards !== undefined && testData.expected.metricCards.length > 0) { await ml.testExecution.logTestStep( - `${testData.suiteTitle} displays the expected metric field cards` + `${testData.suiteTitle} displays the expected metric field cards and contents` ); - for (const fieldCard of testData.expected.metricCards as FieldVisConfig[]) { + for (const fieldCard of testData.expected.metricCards as MetricFieldVisConfig[]) { await ml.dataVisualizerIndexBased.assertCardExists(fieldCard.type, fieldCard.fieldName); + await ml.dataVisualizerIndexBased.assertNumberCardContents( + fieldCard.fieldName!, + fieldCard.docCountFormatted, + fieldCard.statsMaxDecimalPlaces, + fieldCard.selectedDetailsMode, + fieldCard.topValuesCount + ); } await ml.testExecution.logTestStep( @@ -323,10 +382,15 @@ export default function ({ getService }: FtrProviderContext) { ); await ml.testExecution.logTestStep( - `${testData.suiteTitle} displays the expected non-metric field cards` + `${testData.suiteTitle} displays the expected non-metric field cards and contents` ); for (const fieldCard of testData.expected.nonMetricCards!) { await ml.dataVisualizerIndexBased.assertCardExists(fieldCard.type, fieldCard.fieldName); + await ml.dataVisualizerIndexBased.assertNonMetricCardContents( + fieldCard.type, + fieldCard.fieldName!, + fieldCard.exampleCount + ); } await ml.testExecution.logTestStep( @@ -346,10 +410,22 @@ export default function ({ getService }: FtrProviderContext) { `${testData.suiteTitle} filters non-metric fields cards with search` ); await ml.dataVisualizerIndexBased.filterFieldsPanelWithSearchString( - getFieldTypes(testData.expected.nonMetricCards as FieldVisConfig[]), + fieldTypes, testData.nonMetricFieldsFilter, testData.expected.nonMetricFieldsFilterCardCount ); + + await ml.testExecution.logTestStep( + `${testData.suiteTitle} sample size control changes non-metric field cards doc count` + ); + await ml.dataVisualizerIndexBased.clearFieldsPanelSearchInput(fieldTypes); + await ml.dataVisualizerIndexBased.assertSampleSizeInputExists(); + await ml.dataVisualizerIndexBased.setSampleSizeInputValue( + 1000, + ML_JOB_FIELD_TYPES.KEYWORD, + 'airline', + '1,000' + ); } }); } @@ -366,10 +442,6 @@ export default function ({ getService }: FtrProviderContext) { await ml.securityUI.loginAsMlPowerUser(); }); - // TODO - add tests for - // - validating metrics displayed inside the cards - // - selecting a document sample size - describe('with farequote', function () { // Run tests on full farequote index. it(`${farequoteIndexPatternTestData.suiteTitle} loads the data visualizer selector page`, async () => { diff --git a/x-pack/test/functional/apps/ml/permissions/full_ml_access.ts b/x-pack/test/functional/apps/ml/permissions/full_ml_access.ts index 4abf4dabf7939..285ea49419bbd 100644 --- a/x-pack/test/functional/apps/ml/permissions/full_ml_access.ts +++ b/x-pack/test/functional/apps/ml/permissions/full_ml_access.ts @@ -96,7 +96,7 @@ export default function ({ getService }: FtrProviderContext) { const filterItems = ['filter_item_permission']; const ecIndexPattern = 'ft_module_sample_ecommerce'; - const ecExpectedTotalCount = 287; + const ecExpectedTotalCount = '287'; const ecExpectedFieldPanelCount = 2; const ecExpectedModuleId = 'sample_data_ecommerce'; diff --git a/x-pack/test/functional/apps/ml/permissions/read_ml_access.ts b/x-pack/test/functional/apps/ml/permissions/read_ml_access.ts index 22dcc945acd5c..1557d2b4ec2fb 100644 --- a/x-pack/test/functional/apps/ml/permissions/read_ml_access.ts +++ b/x-pack/test/functional/apps/ml/permissions/read_ml_access.ts @@ -97,7 +97,7 @@ export default function ({ getService }: FtrProviderContext) { const filterItems = ['filter_item_permission']; const ecIndexPattern = 'ft_module_sample_ecommerce'; - const ecExpectedTotalCount = 287; + const ecExpectedTotalCount = '287'; const ecExpectedFieldPanelCount = 2; const uploadFilePath = path.join( diff --git a/x-pack/test/functional/services/ml/data_visualizer_index_based.ts b/x-pack/test/functional/services/ml/data_visualizer_index_based.ts index 31cd17e4df826..60677423a2aa1 100644 --- a/x-pack/test/functional/services/ml/data_visualizer_index_based.ts +++ b/x-pack/test/functional/services/ml/data_visualizer_index_based.ts @@ -7,10 +7,12 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; import { ML_JOB_FIELD_TYPES } from '../../../../plugins/ml/common/constants/field_types'; +import { MlCommonUI } from './common_ui'; -export function MachineLearningDataVisualizerIndexBasedProvider({ - getService, -}: FtrProviderContext) { +export function MachineLearningDataVisualizerIndexBasedProvider( + { getService }: FtrProviderContext, + mlCommonUI: MlCommonUI +) { const testSubjects = getService('testSubjects'); const retry = getService('retry'); const browser = getService('browser'); @@ -20,19 +22,19 @@ export function MachineLearningDataVisualizerIndexBasedProvider({ await testSubjects.existOrFail('mlDataVisualizerTimeRangeSelectorSection'); }, - async assertTotalDocumentCount(expectedTotalDocCount: number) { + async assertTotalDocumentCount(expectedFormattedTotalDocCount: string) { await retry.tryForTime(5000, async () => { const docCount = await testSubjects.getVisibleText('mlDataVisualizerTotalDocCount'); expect(docCount).to.eql( - expectedTotalDocCount, - `Expected total document count to be '${expectedTotalDocCount}' (got '${docCount}')` + expectedFormattedTotalDocCount, + `Expected total document count to be '${expectedFormattedTotalDocCount}' (got '${docCount}')` ); }); }, - async clickUseFullDataButton(expectedTotalDocCount: number) { + async clickUseFullDataButton(expectedFormattedTotalDocCount: string) { await testSubjects.clickWhenNotDisabled('mlButtonUseFullData'); - await this.assertTotalDocumentCount(expectedTotalDocCount); + await this.assertTotalDocumentCount(expectedFormattedTotalDocCount); }, async assertFieldsPanelsExist(expectedPanelCount: number) { @@ -51,6 +53,166 @@ export function MachineLearningDataVisualizerIndexBasedProvider({ await testSubjects.existOrFail(`mlFieldDataCard ${fieldName} ${cardType}`); }, + async assertCardContentsExists(cardType: string, fieldName?: string) { + await testSubjects.existOrFail( + `mlFieldDataCard ${fieldName} ${cardType} > mlFieldDataCardContent` + ); + }, + + async assertNonMetricCardContents(cardType: string, fieldName: string, exampleCount?: number) { + await this.assertCardContentsExists(cardType, fieldName); + + // Currently the data used in the data visualizer tests only contains these field types. + if (cardType === ML_JOB_FIELD_TYPES.DATE) { + await this.assertDateCardContents(fieldName); + } else if (cardType === ML_JOB_FIELD_TYPES.KEYWORD) { + await this.assertKeywordCardContents(fieldName, exampleCount!); + } else if (cardType === ML_JOB_FIELD_TYPES.TEXT) { + await this.assertTextCardContents(fieldName, exampleCount!); + } + }, + + async assertDocumentCountCardContents() { + await this.assertCardContentsExists('number', undefined); + await testSubjects.existOrFail( + 'mlFieldDataCard undefined number > mlFieldDataCardDocumentCountChart' + ); + }, + + async assertNumberCardContents( + fieldName: string, + docCountFormatted: string, + statsMaxDecimalPlaces: number, + selectedDetailsMode: 'distribution' | 'top_values', + topValuesCount: number + ) { + await this.assertCardContentsExists('number', fieldName); + await this.assertFieldDocCountExists('number', fieldName); + await this.assertFieldDocCountContents('number', fieldName, docCountFormatted); + await this.assertFieldCardinalityExists('number', fieldName); + + await this.assertNumberStatsContents(fieldName, 'Min', statsMaxDecimalPlaces); + await this.assertNumberStatsContents(fieldName, 'Median', statsMaxDecimalPlaces); + await this.assertNumberStatsContents(fieldName, 'Max', statsMaxDecimalPlaces); + + await testSubjects.existOrFail( + `mlFieldDataCard ${fieldName} number > mlFieldDataCardDetailsSelect` + ); + + if (selectedDetailsMode === 'distribution') { + await mlCommonUI.assertRadioGroupValue( + `mlFieldDataCard ${fieldName} number > mlFieldDataCardDetailsSelect`, + 'distribution' + ); + await testSubjects.existOrFail( + `mlFieldDataCard ${fieldName} number > mlFieldDataCardMetricDistributionChart` + ); + + await mlCommonUI.selectRadioGroupValue( + `mlFieldDataCard ${fieldName} number > mlFieldDataCardDetailsSelect`, + 'top_values' + ); + await this.assertTopValuesContents('number', fieldName, topValuesCount); + } else { + await mlCommonUI.assertRadioGroupValue( + `mlFieldDataCard ${fieldName} number > mlFieldDataCardDetailsSelect`, + 'top_values' + ); + await this.assertTopValuesContents('number', fieldName, topValuesCount); + + await mlCommonUI.selectRadioGroupValue( + `mlFieldDataCard ${fieldName} number > mlFieldDataCardDetailsSelect`, + 'distribution' + ); + await testSubjects.existOrFail( + `mlFieldDataCard ${fieldName} number > mlFieldDataCardMetricDistributionChart` + ); + } + }, + + async assertDateCardContents(fieldName: string) { + await this.assertFieldDocCountExists('date', fieldName); + await testSubjects.existOrFail(`mlFieldDataCard ${fieldName} date > mlFieldDataCardEarliest`); + await testSubjects.existOrFail(`mlFieldDataCard ${fieldName} date > mlFieldDataCardLatest`); + }, + + async assertKeywordCardContents(fieldName: string, expectedTopValuesCount: number) { + await this.assertFieldDocCountExists('keyword', fieldName); + await this.assertFieldCardinalityExists('keyword', fieldName); + await this.assertTopValuesContents('keyword', fieldName, expectedTopValuesCount); + }, + + async assertTextCardContents(fieldName: string, expectedExamplesCount: number) { + const examplesList = await testSubjects.find( + `mlFieldDataCard ${fieldName} text > mlFieldDataCardExamplesList` + ); + const examplesListItems = await examplesList.findAllByTagName('li'); + expect(examplesListItems).to.have.length( + expectedExamplesCount, + `Expected example list item count for field '${fieldName}' to be '${expectedExamplesCount}' (got '${examplesListItems.length}')` + ); + }, + + async assertFieldDocCountExists(cardType: string, fieldName: string) { + await testSubjects.existOrFail( + `mlFieldDataCard ${fieldName} ${cardType} > mlFieldDataCardDocCount` + ); + }, + + async assertFieldDocCountContents( + cardType: string, + fieldName: string, + docCountFormatted: string + ) { + const docCountText = await testSubjects.getVisibleText( + `mlFieldDataCard ${fieldName} ${cardType} > mlFieldDataCardDocCount` + ); + expect(docCountText).to.contain( + docCountFormatted, + `Expected doc count for '${fieldName}' to be '${docCountFormatted}' (got contents '${docCountText}')` + ); + }, + + async assertFieldCardinalityExists(cardType: string, fieldName: string) { + await testSubjects.existOrFail( + `mlFieldDataCard ${fieldName} ${cardType} > mlFieldDataCardCardinality` + ); + }, + + async assertNumberStatsContents( + fieldName: string, + stat: 'Min' | 'Median' | 'Max', + maxDecimalPlaces: number + ) { + const statElement = await testSubjects.find( + `mlFieldDataCard ${fieldName} number > mlFieldDataCard${stat}` + ); + const statValue = await statElement.getVisibleText(); + const dotIdx = statValue.indexOf('.'); + const numDecimalPlaces = dotIdx === -1 ? 0 : statValue.length - dotIdx - 1; + expect(numDecimalPlaces).to.be.lessThan( + maxDecimalPlaces + 1, + `Expected number of decimal places for '${fieldName}' '${stat}' to be less than or equal to '${maxDecimalPlaces}' (got '${numDecimalPlaces}')` + ); + }, + + async assertTopValuesContents( + cardType: string, + fieldName: string, + expectedTopValuesCount: number + ) { + const topValuesElement = await testSubjects.find( + `mlFieldDataCard ${fieldName} ${cardType} > mlFieldDataCardTopValues` + ); + const topValuesBars = await topValuesElement.findAllByTestSubject( + 'mlFieldDataCardTopValueBar' + ); + expect(topValuesBars).to.have.length( + expectedTopValuesCount, + `Expected top values count for field '${fieldName}' to be '${expectedTopValuesCount}' (got '${topValuesBars.length}')` + ); + }, + async assertFieldsPanelCardCount(panelFieldTypes: string[], expectedCardCount: number) { await retry.tryForTime(5000, async () => { const filteredCards = await testSubjects.findAll( @@ -75,6 +237,15 @@ export function MachineLearningDataVisualizerIndexBasedProvider({ ); }, + async clearFieldsPanelSearchInput(fieldTypes: string[]) { + const searchBar = await testSubjects.find( + `mlDataVisualizerFieldsPanel ${fieldTypes} > mlDataVisualizerFieldsSearchBarDiv` + ); + const searchBarInput = await searchBar.findByTagName('input'); + await searchBarInput.clearValueWithKeyboard(); + await searchBarInput.pressKeys(browser.keys.ENTER); + }, + async filterFieldsPanelWithSearchString( fieldTypes: string[], filter: string, @@ -119,6 +290,25 @@ export function MachineLearningDataVisualizerIndexBasedProvider({ await this.assertFieldsPanelCardCount(panelFieldTypes, expectedCardCount); }, + async assertSampleSizeInputExists() { + await testSubjects.existOrFail('mlDataVisualizerShardSizeSelect'); + }, + + async setSampleSizeInputValue( + sampleSize: number, + cardType: string, + fieldName: string, + docCountFormatted: string + ) { + await testSubjects.clickWhenNotDisabled('mlDataVisualizerShardSizeSelect'); + await testSubjects.existOrFail(`mlDataVisualizerShardSizeOption ${sampleSize}`); + await testSubjects.click(`mlDataVisualizerShardSizeOption ${sampleSize}`); + + await retry.tryForTime(5000, async () => { + await this.assertFieldDocCountContents(cardType, fieldName, docCountFormatted); + }); + }, + async assertActionsPanelExists() { await testSubjects.existOrFail('mlDataVisualizerActionsPanel'); }, diff --git a/x-pack/test/functional/services/ml/index.ts b/x-pack/test/functional/services/ml/index.ts index b9ff0692cb737..3744e3cad6471 100644 --- a/x-pack/test/functional/services/ml/index.ts +++ b/x-pack/test/functional/services/ml/index.ts @@ -62,7 +62,10 @@ export function MachineLearningProvider(context: FtrProviderContext) { const dataFrameAnalyticsTable = MachineLearningDataFrameAnalyticsTableProvider(context); const dataVisualizer = MachineLearningDataVisualizerProvider(context); const dataVisualizerFileBased = MachineLearningDataVisualizerFileBasedProvider(context, commonUI); - const dataVisualizerIndexBased = MachineLearningDataVisualizerIndexBasedProvider(context); + const dataVisualizerIndexBased = MachineLearningDataVisualizerIndexBasedProvider( + context, + commonUI + ); const jobManagement = MachineLearningJobManagementProvider(context, api); const jobSelection = MachineLearningJobSelectionProvider(context); const jobSourceSelection = MachineLearningJobSourceSelectionProvider(context); diff --git a/x-pack/test/functional_basic/apps/ml/permissions/full_ml_access.ts b/x-pack/test/functional_basic/apps/ml/permissions/full_ml_access.ts index 7a8a58a359b4e..8140b471fc6c8 100644 --- a/x-pack/test/functional_basic/apps/ml/permissions/full_ml_access.ts +++ b/x-pack/test/functional_basic/apps/ml/permissions/full_ml_access.ts @@ -20,7 +20,7 @@ export default function ({ getService }: FtrProviderContext) { for (const user of testUsers) { describe(`(${user})`, function () { const ecIndexPattern = 'ft_module_sample_ecommerce'; - const ecExpectedTotalCount = 287; + const ecExpectedTotalCount = '287'; const ecExpectedFieldPanelCount = 2; const ecExpectedModuleId = 'sample_data_ecommerce'; diff --git a/x-pack/test/functional_basic/apps/ml/permissions/read_ml_access.ts b/x-pack/test/functional_basic/apps/ml/permissions/read_ml_access.ts index 331f2c83639fc..522ca15934e22 100644 --- a/x-pack/test/functional_basic/apps/ml/permissions/read_ml_access.ts +++ b/x-pack/test/functional_basic/apps/ml/permissions/read_ml_access.ts @@ -20,7 +20,7 @@ export default function ({ getService }: FtrProviderContext) { for (const user of testUsers) { describe(`(${user})`, function () { const ecIndexPattern = 'ft_module_sample_ecommerce'; - const ecExpectedTotalCount = 287; + const ecExpectedTotalCount = '287'; const ecExpectedFieldPanelCount = 2; const ecExpectedModuleId = 'sample_data_ecommerce'; diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/background.js b/x-pack/test_utils/chrome_extension/test_subjects_finder/background.js deleted file mode 100644 index c57ba4458e646..0000000000000 --- a/x-pack/test_utils/chrome_extension/test_subjects_finder/background.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -/* eslint-disable no-undef */ -chrome.runtime.onInstalled.addListener(function () { - chrome.storage.sync.set({ outputType: 'typescript' }); - - chrome.declarativeContent.onPageChanged.removeRules(undefined, () => { - // Only activate the plugin on localhost - chrome.declarativeContent.onPageChanged.addRules([ - { - conditions: [ - new chrome.declarativeContent.PageStateMatcher({ - pageUrl: { hostEquals: 'localhost' }, - }), - new chrome.declarativeContent.PageStateMatcher({ - pageUrl: { hostEquals: 'kibana-dev' }, - }), - ], - actions: [new chrome.declarativeContent.ShowPageAction()], - }, - ]); - }); -}); diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana128.png b/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana128.png deleted file mode 100644 index d88ec6d8b4e42..0000000000000 Binary files a/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana128.png and /dev/null differ diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana16.png b/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana16.png deleted file mode 100644 index d88ec6d8b4e42..0000000000000 Binary files a/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana16.png and /dev/null differ diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana32.png b/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana32.png deleted file mode 100644 index d88ec6d8b4e42..0000000000000 Binary files a/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana32.png and /dev/null differ diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana48.png b/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana48.png deleted file mode 100644 index d88ec6d8b4e42..0000000000000 Binary files a/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana48.png and /dev/null differ diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana64.png b/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana64.png deleted file mode 100644 index d88ec6d8b4e42..0000000000000 Binary files a/x-pack/test_utils/chrome_extension/test_subjects_finder/images/kibana64.png and /dev/null differ diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/manifest.json b/x-pack/test_utils/chrome_extension/test_subjects_finder/manifest.json deleted file mode 100644 index a954a281257b0..0000000000000 --- a/x-pack/test_utils/chrome_extension/test_subjects_finder/manifest.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "Test subjects finder", - "version": "1.0", - "description": "Read and print the test subjects on the current page.", - "permissions": ["activeTab", "declarativeContent", "storage"], - "background": { - "scripts": ["background.js"], - "persistent": false - }, - "page_action": { - "default_popup": "popup.html", - "default_icon": { - "16": "images/kibana16.png", - "32": "images/kibana32.png", - "48": "images/kibana48.png", - "128": "images/kibana128.png" - } - }, - "icons": { - "16": "images/kibana16.png", - "32": "images/kibana32.png", - "48": "images/kibana48.png", - "128": "images/kibana128.png" - }, - "manifest_version": 2 -} diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/popup.html b/x-pack/test_utils/chrome_extension/test_subjects_finder/popup.html deleted file mode 100644 index a7fd489dcf86c..0000000000000 --- a/x-pack/test_utils/chrome_extension/test_subjects_finder/popup.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - -

Test subjects finder

-
-
-
- - -
- The DOM node you want to start to traverse from. If not specified, the "body" will be used. -
-
- -
- - -
- If you chose "typescript" you will get a Union Type ready to copy and paste in your test file. -
-
- -
- - -
- The dom traversal "depth" to be returned. In most cases 2 level depth is enough to access all your test subjects. - You can always add manually later other depths in your Typescript union string type. -
-
-
- -
- - -
-
- - - - diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/popup.js b/x-pack/test_utils/chrome_extension/test_subjects_finder/popup.js deleted file mode 100644 index 0944038b59370..0000000000000 --- a/x-pack/test_utils/chrome_extension/test_subjects_finder/popup.js +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -/* eslint-disable no-undef */ - -// const trace = (message) => { -// chrome.tabs.executeScript( -// undefined, -// { code: `console.log("${message}")` }, -// ); -// }; - -const isTrackingTestSubjects = () => - new Promise((resolve) => { - chrome.tabs.executeScript( - undefined, - { code: '(() => Boolean(window.__test_utils__ && window.__test_utils__.isTracking))()' }, - ([result]) => { - resolve(result); - } - ); - }); - -const onStartTracking = () => { - document.body.classList.add('is-tracking'); -}; - -const onStopTracking = () => { - document.body.classList.remove('is-tracking'); -}; - -chrome.storage.sync.get( - ['outputType', 'domTreeRoot', 'depth'], - async ({ outputType, domTreeRoot, depth }) => { - const domRootInput = document.getElementById('domRootInput'); - const outputTypeSelect = document.getElementById('outputTypeSelect'); - const depthInput = document.getElementById('depthInput'); - const startTrackButton = document.getElementById('startTrackingButton'); - const stopTrackButton = document.getElementById('stopTrackingButton'); - - const isTracking = await isTrackingTestSubjects(); - - // UI state - if (isTracking) { - document.body.classList.add('is-tracking'); - } else { - document.body.classList.remove('is-tracking'); - } - - // FORM state - if (domTreeRoot) { - domRootInput.value = domTreeRoot; - } - - if (depth) { - depthInput.value = depth; - } - - document.querySelectorAll('#outputTypeSelect option').forEach((node) => { - if (node.value === outputType) { - node.setAttribute('selected', 'selected'); - } - }); - - // FORM events - domRootInput.addEventListener('change', (e) => { - const { value } = e.target; - chrome.storage.sync.set({ domTreeRoot: value }); - }); - - depthInput.addEventListener('change', (e) => { - const { value } = e.target; - if (value) { - chrome.storage.sync.set({ depth: value }); - } - }); - - outputTypeSelect.addEventListener('change', (e) => { - const { value } = e.target; - chrome.storage.sync.set({ outputType: value }); - }); - - startTrackButton.addEventListener('click', () => { - onStartTracking(); - - chrome.tabs.executeScript(undefined, { file: 'start_tracking_test_subjects.js' }); - }); - - stopTrackButton.addEventListener('click', () => { - onStopTracking(); - - chrome.tabs.executeScript(undefined, { file: 'stop_tracking_test_subjects.js' }); - }); - } -); - -chrome.runtime.onMessage.addListener((request) => { - if (request === 'TRACK_SUBJECTS_ERROR') { - onStopTracking(); - } -}); diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/start_tracking_test_subjects.js b/x-pack/test_utils/chrome_extension/test_subjects_finder/start_tracking_test_subjects.js deleted file mode 100644 index 4c2612a2223e5..0000000000000 --- a/x-pack/test_utils/chrome_extension/test_subjects_finder/start_tracking_test_subjects.js +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -/* eslint-disable no-undef */ - -(function () { - /** - * Go from ['a', 'b', 'c', 'd', 'e'] - * To ['a.b.c.d.e', 'a.b.c.d', 'a.b.c', 'a.b'] - * @param arr The array to outpu - */ - const outputArray = (arr) => { - const output = []; - let i = 0; - while (i < arr.length - 1) { - const end = i ? i * -1 : undefined; - output.push(arr.slice(0, end).join('.')); - i++; - } - return output; - }; - - const getAllNestedPathsFromArray = (arr, computedArray = []) => { - // Output the array without skipping any item - let output = [...computedArray, ...outputArray(arr)]; - - // We remove the "head" and the "tail" of the array (pos 0 and arr.length -1) - // We go from ['a', 'b', 'c', 'd', 'e'] (5 items) - // To 3 modified arrays - // ['a', 'c', 'd', 'e'] => outputArray() - // ['a', 'd', 'e'] => outputArray() - // ['a', 'e'] => outputArray() - let itemsToSkip = arr.length - 2; - if (itemsToSkip > 0) { - while (itemsToSkip) { - const newArray = [...arr]; - newArray.splice(1, itemsToSkip); - output = [...output, ...outputArray(newArray)]; - itemsToSkip--; - } - } - - if (arr.length > 2) { - // Recursively call the function skipping the first array item - return getAllNestedPathsFromArray(arr.slice(1), output); - } - - return output.sort(); - }; - - chrome.storage.sync.get( - ['domTreeRoot', 'outputType', 'depth'], - ({ domTreeRoot, outputType, depth = 2 }) => { - const datasetKey = 'testSubj'; - - if (domTreeRoot && !document.querySelector(domTreeRoot)) { - // Let our popup extension know about this... - chrome.runtime.sendMessage('TRACK_SUBJECTS_ERROR'); - throw new Error(`DOM node "${domTreeRoot}" not found.`); - } - - const arrayToType = (array) => - array.reduce((string, subject) => { - return string === '' ? `'${subject}'` : `${string}\n | '${subject}'`; - }, ''); - - const arrayToList = (array) => - array.reduce((string, subject) => { - return string === '' ? `'${subject}'` : `${string}\n\'${subject}'`; - }, ''); - - const addTestSubject = (testSubject) => { - const subjectDepth = testSubject.split('.').length; - if (subjectDepth <= parseInt(depth, 10)) { - window.__test_utils__.dataTestSubjects.add(testSubject); - } - }; - - const findTestSubjects = ( - node = domTreeRoot ? document.querySelector(domTreeRoot) : document.querySelector('body'), - path = [] - ) => { - if (!node) { - // We probably navigated outside the initial DOM root - return; - } - const testSubjectOnNode = node.dataset[datasetKey]; - - const updatedPath = testSubjectOnNode ? [...path, testSubjectOnNode] : path; - - if (!node.children.length) { - const pathToString = updatedPath.join('.'); - - if (pathToString) { - // Add the complete nested path ('a.b.c.d') - addTestSubject(pathToString); - // Add each item separately - updatedPath.forEach(addTestSubject); - // Add all the combination ('a.b', 'a.c', 'a.e', ...) - const nestedPaths = getAllNestedPathsFromArray(updatedPath); - nestedPaths.forEach(addTestSubject); - } - - return; - } - - for (let i = 0; i < node.children.length; i++) { - findTestSubjects(node.children[i], updatedPath); - } - }; - - const output = () => { - const { dataTestSubjects } = window.__test_utils__; - const allTestSubjects = Array.from(dataTestSubjects).sort(); - - console.log(`------------- TEST SUBJECTS (${allTestSubjects.length}) ------------- `); - - const content = - outputType === 'list' - ? `${arrayToList(allTestSubjects)}` - : `export type TestSubjects = ${arrayToType(allTestSubjects)}`; - - console.log(content); - }; - - // Handler for the clicks on the document to keep tracking - // new test subjects - const documentClicksHandler = () => { - const { dataTestSubjects } = window.__test_utils__; - const total = dataTestSubjects.size; - - // Wait to be sure that the DOM has updated - setTimeout(() => { - findTestSubjects(); - if (dataTestSubjects.size === total) { - // No new test subject, nothing to output - return; - } - - output(); - }, 500); - }; - - // Add meta data on the window object - window.__test_utils__ = window.__test_utils__ || { - documentClicksHandler, - isTracking: false, - dataTestSubjects: new Set(), - }; - - // Handle "click" event on the document to update our test subjects - if (!window.__test_utils__.isTracking) { - document.addEventListener('click', window.__test_utils__.documentClicksHandler); - window.__test_utils__.isTracking = true; - } - - findTestSubjects(); - output(); - } - ); -})(); diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/stop_tracking_test_subjects.js b/x-pack/test_utils/chrome_extension/test_subjects_finder/stop_tracking_test_subjects.js deleted file mode 100644 index 94875a9d1b8d8..0000000000000 --- a/x-pack/test_utils/chrome_extension/test_subjects_finder/stop_tracking_test_subjects.js +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -if (window.__test_utils__ && window.__test_utils__.isTracking) { - document.removeEventListener('click', window.__test_utils__.documentClicksHandler); - window.__test_utils__.isTracking = false; - window.__test_utils__.dataTestSubjects = new Set(); -} diff --git a/x-pack/test_utils/chrome_extension/test_subjects_finder/style.css b/x-pack/test_utils/chrome_extension/test_subjects_finder/style.css deleted file mode 100644 index 7cf56cf14fcf8..0000000000000 --- a/x-pack/test_utils/chrome_extension/test_subjects_finder/style.css +++ /dev/null @@ -1,110 +0,0 @@ -* { - box-sizing: border-box; -} -body { - padding: 16px; - width: 300px; -} -h1 { - font-size: 1rem; - margin: 0 0 16px; - text-align: center; -} - -.form-control { - margin-bottom: 16px; -} - -.form-control__label { - display: block; - font-weight: 600; - margin-bottom: 4px; -} - -.form-control__input { - width: 100%; - height: 40px; - background-color: #fbfcfd; - background-repeat: no-repeat; - background-size: 0% 100%; - box-shadow: 0 1px 1px -1px rgba(152, 162, 179, 0.2), 0 3px 2px -2px rgba(152, 162, 179, 0.2), inset 0 0 0 1px rgba(0, 0, 0, 0.1); - transition: background-color 150ms ease-in, background-image 150ms ease-in, background-size 150ms ease-in, -webkit-box-shadow 150ms ease-in; - transition: box-shadow 150ms ease-in, background-color 150ms ease-in, background-image 150ms ease-in, background-size 150ms ease-in; - font-family: "Inter UI", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; - font-weight: 400; - letter-spacing: -.005em; - -webkit-text-size-adjust: 100%; - -webkit-font-kerning: normal; - font-kerning: normal; - font-size: 14px; - line-height: 1em; - color: #343741; - border: none; - border-radius: 0; - padding: 12px; - margin-bottom: 4px; -} - -.form-control__helper-text { - font-size: 0.7rem; - color: #666; -} - -.form-control__select { - width: 100%; - padding: 4px; - margin-bottom: 4px; -} - -.form-actions { - border-top: 1px solid #ddd; - padding-top: 24px; - text-align: center; -} - -button { - font-family: "Inter UI", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; - font-weight: 400; - letter-spacing: -.005em; - -webkit-text-size-adjust: 100%; - -webkit-font-kerning: normal; - font-kerning: normal; - font-size: 1rem; - line-height: 1.5; - display: inline-block; - -webkit-appearance: none; - appearance: none; - cursor: pointer; - height: 40px; - line-height: 40px; - text-decoration: none; - border: solid 1px transparent; - text-align: center; - transition: all 250ms cubic-bezier(0.34, 1.61, 0.7, 1); - white-space: nowrap; - max-width: 100%; - vertical-align: middle; - box-shadow: 0 2px 2px -1px rgba(152, 162, 179, 0.3); - border-radius: 4px; - min-width: 112px; - background-color: #017D73; - border-color: #017D73; - color: #FFF; - box-shadow: 0 2px 2px -1px rgba(39, 87, 83, 0.3); -} - -.is-tracking .track-config { - display: none; -} - -#stopTrackingButton { - display: none; -} - -.is-tracking #stopTrackingButton { - display: inline; -} - -.is-tracking #startTrackingButton { - display: none; -} diff --git a/x-pack/test_utils/find_test_subject.ts b/x-pack/test_utils/find_test_subject.ts deleted file mode 100644 index 6cfe38e991646..0000000000000 --- a/x-pack/test_utils/find_test_subject.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { ReactWrapper } from 'enzyme'; - -type Matcher = '=' | '~=' | '|=' | '^=' | '$=' | '*='; - -const MATCHERS: Matcher[] = [ - '=', // Exact match - '~=', // Exists in a space-separated list - '|=', // Begins with substring, followed by '-' - '^=', // Begins with substring - '$=', // Ends with substring - '*=', -]; - -/** - * Find node which matches a specific test subject selector. Returns ReactWrappers around DOM element, - * https://github.com/airbnb/enzyme/tree/master/docs/api/ReactWrapper. - * Common use cases include calling simulate or getDOMNode on the returned ReactWrapper. - * - * The ~= matcher looks for the value in space-separated list, allowing support for multiple data-test-subj - * values on a single element. See https://www.w3.org/TR/selectors-3/#attribute-selectors for more - * info on the other possible matchers. - * - * @param reactWrapper The React wrapper to search in - * @param testSubjectSelector The data test subject selector - * @param matcher optional matcher - */ -export const findTestSubject = ( - reactWrapper: ReactWrapper, - testSubjectSelector: T, - matcher: Matcher = '~=' -) => { - if (!MATCHERS.includes(matcher)) { - throw new Error( - 'Matcher ' - .concat(matcher, ' not found in list of allowed matchers: ') - .concat(MATCHERS.join(' ')) - ); - } - - const testSubject = reactWrapper.find(`[data-test-subj${matcher}"${testSubjectSelector}"]`); - // Restores Enzyme 2's find behavior, which was to only return ReactWrappers around DOM elements. - // Enzyme 3 returns ReactWrappers around both DOM elements and React components. - // https://github.com/airbnb/enzyme/issues/1174 - - return testSubject.hostNodes(); -}; diff --git a/x-pack/test_utils/get_config_schema.ts b/x-pack/test_utils/get_config_schema.ts deleted file mode 100644 index cca0bc07a4e91..0000000000000 --- a/x-pack/test_utils/get_config_schema.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import Joi from 'joi'; - -export async function getConfigSchema(pluginProvider: any): Promise { - class Plugin { - constructor(public readonly options: any) {} - } - - const plugin = pluginProvider({ Plugin }); - - return await plugin.options.config(Joi); -} diff --git a/x-pack/test_utils/index.ts b/x-pack/test_utils/index.ts deleted file mode 100644 index 57c96dfccc05c..0000000000000 --- a/x-pack/test_utils/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export * from './testbed'; -export * from './lib'; -export { findTestSubject } from './find_test_subject'; -export { getConfigSchema } from './get_config_schema'; diff --git a/x-pack/test_utils/jest/config.integration.js b/x-pack/test_utils/jest/config.integration.js deleted file mode 100644 index 16e05ea46e308..0000000000000 --- a/x-pack/test_utils/jest/config.integration.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { RESERVED_DIR_JEST_INTEGRATION_TESTS } from '../../../src/dev/constants'; -import config from './config'; - -export default { - ...config, - testMatch: [ - `**/${RESERVED_DIR_JEST_INTEGRATION_TESTS}/**/*.test.{js,mjs,ts,tsx}`, - // Tests within `__jest__` directories should be treated as regular unit tests. - `!**/__jest__/${RESERVED_DIR_JEST_INTEGRATION_TESTS}/**/*.test.{js,mjs,ts,tsx}`, - ], - testPathIgnorePatterns: config.testPathIgnorePatterns.filter( - (pattern) => !pattern.includes(RESERVED_DIR_JEST_INTEGRATION_TESTS) - ), - reporters: [ - 'default', - [ - '/../packages/kbn-test/target/jest/junit_reporter', - { reportName: 'Jest Integration Tests' }, - ], - ], - setupFilesAfterEnv: ['/../src/dev/jest/setup/after_env.integration.js'], -}; diff --git a/x-pack/test_utils/jest/config.js b/x-pack/test_utils/jest/config.js deleted file mode 100644 index fcd50717d3441..0000000000000 --- a/x-pack/test_utils/jest/config.js +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { RESERVED_DIR_JEST_INTEGRATION_TESTS } from '../../../src/dev/constants'; - -export default { - rootDir: '../../', - roots: [ - '/plugins', - '/legacy/plugins', - '/legacy/server', - '/legacy/common', - '/test_utils/jest/integration_tests', - ], - collectCoverageFrom: ['legacy/plugins/**/*.js', 'legacy/common/**/*.js', 'legacy/server/**/*.js'], - moduleNameMapper: { - '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': - '/src/dev/jest/mocks/file_mock.js', - '\\.(css|less|scss)$': '/../src/dev/jest/mocks/style_mock.js', - }, - setupFiles: [ - '/../src/dev/jest/setup/babel_polyfill.js', - '/../src/dev/jest/setup/polyfills.js', - '/../src/dev/jest/setup/enzyme.js', - ], - coverageDirectory: '/../target/kibana-coverage/jest', - coverageReporters: ['html'], - moduleFileExtensions: ['js', 'mjs', 'json', 'ts', 'tsx', 'node'], - modulePathIgnorePatterns: ['__fixtures__/', 'target/'], - testEnvironment: 'jest-environment-jsdom-thirteen', - testMatch: ['**/*.test.{js,mjs,ts,tsx}'], - testPathIgnorePatterns: [ - '/packages/kbn-ui-framework/(dist|doc_site|generator-kui)/', - '/packages/kbn-pm/dist/', - `${RESERVED_DIR_JEST_INTEGRATION_TESTS}/`, - ], - testRunner: 'jest-circus/runner', - transform: { - '^.+\\.(js|tsx?)$': '/../src/dev/jest/babel_transform.js', - '^.+\\.txt?$': 'jest-raw-loader', - '^.+\\.html?$': 'jest-raw-loader', - }, - transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.js$', 'packages/kbn-pm/dist/index.js'], - snapshotSerializers: ['/../node_modules/enzyme-to-json/serializer'], - reporters: ['default', '/../packages/kbn-test/target/jest/junit_reporter'], -}; diff --git a/x-pack/test_utils/kbn_server_config.ts b/x-pack/test_utils/kbn_server_config.ts deleted file mode 100644 index 3cac6ed5df014..0000000000000 --- a/x-pack/test_utils/kbn_server_config.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { resolve } from 'path'; - -type Licenses = 'oss' | 'basic' | 'gold' | 'trial'; - -export const TestKbnServerConfig = { - kbn: { - plugins: { paths: [resolve(__dirname, '../../x-pack')] }, - xpack: { - monitoring: { - tests: { - cloud_detector: { - enabled: false, - }, - }, - }, - }, - }, - es: { - license: 'trial' as Licenses, - }, - users: [ - { - username: 'kibana_admin', - password: 'x-pack-test-password', - roles: ['kibana_admin'], - }, - ], -}; diff --git a/x-pack/test_utils/lib/utils.ts b/x-pack/test_utils/lib/utils.ts deleted file mode 100644 index 0765a4cd88476..0000000000000 --- a/x-pack/test_utils/lib/utils.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import Chance from 'chance'; - -const chance = new Chance(); -const CHARS_POOL = 'abcdefghijklmnopqrstuvwxyz'; - -export const nextTick = (time = 0) => new Promise((resolve) => setTimeout(resolve, time)); - -export const getRandomNumber = (range: { min: number; max: number } = { min: 1, max: 20 }) => - chance.integer(range); - -export const getRandomString = (options = {}) => - `${chance.string({ pool: CHARS_POOL, ...options })}-${Date.now()}`; diff --git a/x-pack/test_utils/redux_helpers.tsx b/x-pack/test_utils/redux_helpers.tsx deleted file mode 100644 index d67c7b02148b5..0000000000000 --- a/x-pack/test_utils/redux_helpers.tsx +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { ComponentType } from 'react'; -import { Provider } from 'react-redux'; - -export const WithStore = (store: any) => (WrappedComponent: ComponentType) => (props: any) => ( - - - -); diff --git a/x-pack/test_utils/router_helpers.tsx b/x-pack/test_utils/router_helpers.tsx deleted file mode 100644 index f2099e1eb7c91..0000000000000 --- a/x-pack/test_utils/router_helpers.tsx +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { Component, ComponentType } from 'react'; -import { MemoryRouter, Route, withRouter } from 'react-router-dom'; -import * as H from 'history'; - -export const WithMemoryRouter = (initialEntries: string[] = ['/'], initialIndex: number = 0) => ( - WrappedComponent: ComponentType -) => (props: any) => ( - - - -); - -export const WithRoute = ( - componentRoutePath: string | string[] = '/', - onRouter = (router: any) => {} -) => (WrappedComponent: ComponentType) => { - // Create a class component that will catch the router - // and forward it to our "onRouter()" handler. - const CatchRouter = withRouter( - class extends Component { - componentDidMount() { - const { match, location, history } = this.props; - const router = { route: { match, location }, history }; - onRouter(router); - } - - render() { - return ; - } - } - ); - - return (props: any) => ( - } - /> - ); -}; - -interface Router { - history: Partial; - route: { - location: H.Location; - }; -} - -export const reactRouterMock: Router = { - history: { - push: () => {}, - createHref: (location) => location.pathname!, - location: { - pathname: '', - search: '', - state: '', - hash: '', - }, - }, - route: { - location: { - pathname: '', - search: '', - state: '', - hash: '', - }, - }, -}; diff --git a/x-pack/test_utils/stub_web_worker.ts b/x-pack/test_utils/stub_web_worker.ts deleted file mode 100644 index 10d0ee6517384..0000000000000 --- a/x-pack/test_utils/stub_web_worker.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -function stubWebWorker() { - if (!window.Worker) { - // @ts-ignore we aren't honoring the real Worker spec here - window.Worker = function Worker() { - this.postMessage = jest.fn(); - - // @ts-ignore TypeScript doesn't think this exists on the Worker interface - // https://developer.mozilla.org/en-US/docs/Web/API/Worker/terminate - this.terminate = jest.fn(); - }; - } -} - -stubWebWorker(); - -// Add an export to avoid TS complaining "stub_web_worker.ts" is not a module. -export { stubWebWorker }; diff --git a/x-pack/test_utils/testbed/index.ts b/x-pack/test_utils/testbed/index.ts deleted file mode 100644 index 70b055afd254d..0000000000000 --- a/x-pack/test_utils/testbed/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { registerTestBed } from './testbed'; -export { TestBed, TestBedConfig, SetupFunc, UnwrapPromise } from './types'; diff --git a/x-pack/test_utils/testbed/mount_component.tsx b/x-pack/test_utils/testbed/mount_component.tsx deleted file mode 100644 index 7b166684bc7ef..0000000000000 --- a/x-pack/test_utils/testbed/mount_component.tsx +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { ComponentType } from 'react'; -import { Store } from 'redux'; -import { ReactWrapper } from 'enzyme'; -import { act } from 'react-dom/test-utils'; - -import { mountWithIntl } from '../enzyme_helpers'; -import { WithMemoryRouter, WithRoute } from '../router_helpers'; -import { WithStore } from '../redux_helpers'; -import { MemoryRouterConfig } from './types'; - -interface Config { - Component: ComponentType; - memoryRouter: MemoryRouterConfig; - store: Store | null; - props: any; - onRouter: (router: any) => void; -} - -const getCompFromConfig = ({ Component, memoryRouter, store, onRouter }: Config): ComponentType => { - const wrapWithRouter = memoryRouter.wrapComponent !== false; - - let Comp: ComponentType = store !== null ? WithStore(store)(Component) : Component; - - if (wrapWithRouter) { - const { componentRoutePath, initialEntries, initialIndex } = memoryRouter!; - - // Wrap the componenet with a MemoryRouter and attach it to a react-router - Comp = WithMemoryRouter( - initialEntries, - initialIndex - )(WithRoute(componentRoutePath, onRouter)(Comp)); - } - - return Comp; -}; - -export const mountComponentSync = (config: Config): ReactWrapper => { - const Comp = getCompFromConfig(config); - return mountWithIntl(); -}; - -export const mountComponentAsync = async (config: Config): Promise => { - const Comp = getCompFromConfig(config); - - let component: ReactWrapper; - - await act(async () => { - component = mountWithIntl(); - }); - - // @ts-ignore - return component.update(); -}; - -export const getJSXComponentWithProps = (Component: ComponentType, props: any) => ( - -); diff --git a/x-pack/test_utils/testbed/types.ts b/x-pack/test_utils/testbed/types.ts deleted file mode 100644 index e2b6693ce77aa..0000000000000 --- a/x-pack/test_utils/testbed/types.ts +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { Store } from 'redux'; -import { ReactWrapper } from 'enzyme'; - -export type SetupFunc = (props?: any) => TestBed | Promise>; - -export interface EuiTableMetaData { - /** Array of rows of the table. Each row exposes its reactWrapper and its columns */ - rows: Array<{ - reactWrapper: ReactWrapper; - columns: Array<{ - reactWrapper: ReactWrapper; - value: string; - }>; - }>; - /** A 2 dimensional array of rows & columns containing - * the text content of each cell of the table */ - tableCellsValues: string[][]; -} - -export interface TestBed { - /** The comonent under test */ - component: ReactWrapper; - /** - * Pass it a `data-test-subj` and it will return true if it exists or false if it does not exist. - * - * @param testSubject The data test subject to look for (can be a nested path. e.g. "detailPanel.mySection"). - * @param count The number of times the subject needs to appear in order to return "true" - */ - exists: (testSubject: T, count?: number) => boolean; - /** - * Pass it a `data-test-subj` and it will return an Enzyme reactWrapper of the node. - * You can target a nested test subject by separating it with a dot ('.'); - * - * @param testSubject The data test subject to look for - * - * @example - * - ```typescript - find('nameInput'); - // or more specific, - // "nameInput" is a child of "myForm" - find('myForm.nameInput'); - ``` - */ - find: (testSubject: T, reactWrapper?: ReactWrapper) => ReactWrapper; - /** - * Update the props of the mounted component - * - * @param updatedProps The updated prop object - */ - setProps: (updatedProps: any) => void; - /** - * Helper to wait until an element appears in the DOM as hooks updates cycles are tricky. - * Useful when loading a component that fetches a resource from the server - * and we need to wait for the data to be fetched (and bypass any "loading" state). - */ - waitFor: (testSubject: T, count?: number) => Promise; - waitForFn: (predicate: () => Promise, errMessage: string) => Promise; - form: { - /** - * Set the value of a form text input. - * - * In some cases, changing an input value triggers an HTTP request to validate - * the field. Even if we return immediately the response on the mock server we - * still need to wait until the next tick before the DOM updates. - * Setting isAsync to "true" takes care of that. - * - * @param input The form input. Can either be a data-test-subj or a reactWrapper (can be a nested path. e.g. "myForm.myInput"). - * @param value The value to set - * @param isAsync If set to true will return a Promise that resolves on the next "tick" - */ - setInputValue: ( - input: T | ReactWrapper, - value: string, - isAsync?: boolean - ) => Promise | void; - /** - * Set the value of a or a mocked - * For the you need to mock it like this - * - ```typescript - jest.mock('@elastic/eui', () => { - const original = jest.requireActual('@elastic/eui'); - - return { - ...original, - EuiSuperSelect: (props: any) => ( - { - props.onChange(e.target.value); - }} - /> - ), - }; - }); - ``` - * @param select The form select. Can either be a data-test-subj or a reactWrapper (can be a nested path. e.g. "myForm.myInput"). - * @param value The value to set - * @param doUpdateComponent Call component.update() after changing the select value - */ - setSelectValue: (select: T | ReactWrapper, value: string, doUpdateComponent?: boolean) => void; - /** - * Select or unselect a form checkbox. - * - * @param dataTestSubject The test subject of the checkbox (can be a nested path. e.g. "myForm.mySelect"). - * @param isChecked Defines if the checkobx is active or not - */ - selectCheckBox: (checkboxTestSubject: T, isChecked?: boolean) => void; - /** - * Toggle the EuiSwitch - * - * @param switchTestSubject The test subject of the EuiSwitch (can be a nested path. e.g. "myForm.mySwitch"). - */ - toggleEuiSwitch: (switchTestSubject: T, isChecked?: boolean) => void; - /** - * The EUI ComboBox is a special input as it needs the ENTER key to be pressed - * in order to register the value set. This helpers automatically does that. - * - * @param comboBoxTestSubject The data test subject of the EuiComboBox (can be a nested path. e.g. "myForm.myComboBox"). - * @param value The value to set - */ - setComboBoxValue: (comboBoxTestSubject: T, value: string) => void; - /** - * Get a list of the form error messages that are visible in the DOM. - */ - getErrorsMessages: () => string[]; - }; - table: { - getMetaData: (tableTestSubject: T) => EuiTableMetaData; - }; - router: { - /** - * Navigate to another React router - */ - navigateTo: (url: string) => void; - }; -} - -export interface TestBedConfig { - /** The default props to pass to the mounted component. */ - defaultProps?: Record; - /** Configuration object for the react-router `MemoryRouter. */ - memoryRouter?: MemoryRouterConfig; - /** An optional redux store. You can also provide a function that returns a store. */ - store?: (() => Store) | Store | null; - /* Mount the component asynchronously. When using "hooked" components with _useEffect()_ calls, you need to set this to "true". */ - doMountAsync?: boolean; -} - -export interface MemoryRouterConfig { - /** Flag to add or not the `MemoryRouter`. If set to `false`, there won't be any router and the component won't be wrapped on a ``. */ - wrapComponent?: boolean; - /** The React Router **initial entries** setting ([see documentation](https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/api/MemoryRouter.md)) */ - initialEntries?: string[]; - /** The React Router **initial index** setting ([see documentation](https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/api/MemoryRouter.md)) */ - initialIndex?: number; - /** The route **path** for the mounted component (defaults to `"/"`) */ - componentRoutePath?: string | string[]; - /** A callBack that will be called with the React Router instance once mounted */ - onRouter?: (router: any) => void; -} - -/** - * Utility type: extracts returned type from a Promise. - */ -export type UnwrapPromise = T extends Promise ? P : T; diff --git a/yarn.lock b/yarn.lock index 367dd86f39077..1b01574ba66e7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5637,10 +5637,10 @@ resolved "https://registry.yarnpkg.com/@types/selenium-webdriver/-/selenium-webdriver-4.0.9.tgz#12621e55b2ef8f6c98bd17fe23fa720c6cba16bd" integrity sha512-HopIwBE7GUXsscmt/J0DhnFXLSmO04AfxT6b8HAprknwka7pqEWquWDMXxCjd+NUHK9MkCe1SDKKsMiNmCItbQ== -"@types/semver@^5.5.0": - version "5.5.0" - resolved "https://registry.yarnpkg.com/@types/semver/-/semver-5.5.0.tgz#146c2a29ee7d3bae4bf2fcb274636e264c813c45" - integrity sha512-41qEJgBH/TWgo5NFSvBCJ1qkoi3Q6ONSF2avrHq1LVEZfYpdHmj0y9SuTK+u9ZhG1sYQKBL1AWXKyLWP4RaUoQ== +"@types/semver@^7": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.4.tgz#43d7168fec6fa0988bb1a513a697b29296721afb" + integrity sha512-+nVsLKlcUCeMzD2ufHEYuJ9a2ovstb6Dp52A5VsoKxDXgvE051XgHI/33I1EymwkRGQkwnA0LkhnUzituGs4EQ== "@types/set-value@^2.0.0": version "2.0.0"