diff --git a/.backportrc.json b/.backportrc.json index 14cb04da188d4f..eab70a1fa4de17 100644 --- a/.backportrc.json +++ b/.backportrc.json @@ -3,6 +3,7 @@ "repoName": "kibana", "targetBranchChoices": [ "main", + "8.1", "8.0", "7.17", "7.16", @@ -37,7 +38,7 @@ "backport" ], "branchLabelMapping": { - "^v8.1.0$": "main", + "^v8.2.0$": "main", "^v(\\d+).(\\d+).\\d+$": "$1.$2" }, "autoMerge": true, diff --git a/.buildkite/pipelines/pull_request/deploy_cloud.yml b/.buildkite/pipelines/pull_request/deploy_cloud.yml new file mode 100644 index 00000000000000..c6a15ec32e179b --- /dev/null +++ b/.buildkite/pipelines/pull_request/deploy_cloud.yml @@ -0,0 +1,7 @@ +steps: + - command: .buildkite/scripts/steps/cloud/build_and_deploy.sh + label: 'Build and Deploy to Cloud' + agents: + queue: n2-2 + depends_on: build + timeout_in_minutes: 30 diff --git a/.buildkite/pipelines/purge_cloud_deployments.yml b/.buildkite/pipelines/purge_cloud_deployments.yml new file mode 100644 index 00000000000000..8287abf2ca5a25 --- /dev/null +++ b/.buildkite/pipelines/purge_cloud_deployments.yml @@ -0,0 +1,4 @@ +steps: + - command: .buildkite/scripts/steps/cloud/purge.sh + label: Purge old cloud deployments + timeout_in_minutes: 10 diff --git a/.buildkite/scripts/build_kibana.sh b/.buildkite/scripts/build_kibana.sh index d05fe178b72dba..a7fbcc0ea4b92d 100755 --- a/.buildkite/scripts/build_kibana.sh +++ b/.buildkite/scripts/build_kibana.sh @@ -13,30 +13,6 @@ else node scripts/build fi -if [[ "${GITHUB_PR_LABELS:-}" == *"ci:deploy-cloud"* ]]; then - echo "--- Build and push Kibana Cloud Distribution" - - echo "$KIBANA_DOCKER_PASSWORD" | docker login -u "$KIBANA_DOCKER_USERNAME" --password-stdin docker.elastic.co - trap 'docker logout docker.elastic.co' EXIT - - node scripts/build \ - --skip-initialize \ - --skip-generic-folders \ - --skip-platform-folders \ - --skip-archives \ - --docker-images \ - --docker-tag-qualifier="$GIT_COMMIT" \ - --docker-push \ - --skip-docker-ubi \ - --skip-docker-ubuntu \ - --skip-docker-contexts - - CLOUD_IMAGE=$(docker images --format "{{.Repository}}:{{.Tag}}" docker.elastic.co/kibana-ci/kibana-cloud) - cat << EOF | buildkite-agent annotate --style "info" --context cloud-image - Cloud image: $CLOUD_IMAGE -EOF -fi - echo "--- Archive Kibana Distribution" linuxBuild="$(find "$KIBANA_DIR/target" -name 'kibana-*-linux-x86_64.tar.gz')" installDir="$KIBANA_DIR/install/kibana" diff --git a/.buildkite/scripts/lifecycle/pre_command.sh b/.buildkite/scripts/lifecycle/pre_command.sh index b957203fc7912e..7adae7ff749048 100755 --- a/.buildkite/scripts/lifecycle/pre_command.sh +++ b/.buildkite/scripts/lifecycle/pre_command.sh @@ -92,6 +92,9 @@ export KIBANA_DOCKER_USERNAME KIBANA_DOCKER_PASSWORD="$(retry 5 5 vault read -field=password secret/kibana-issues/dev/container-registry)" export KIBANA_DOCKER_PASSWORD +EC_API_KEY="$(retry 5 5 vault read -field=pr_deploy_api_key secret/kibana-issues/dev/kibana-ci-cloud-deploy)" +export EC_API_KEY + SYNTHETICS_SERVICE_USERNAME="$(retry 5 5 vault read -field=username secret/kibana-issues/dev/kibana-ci-synthetics-credentials)" export SYNTHETICS_SERVICE_USERNAME diff --git a/.buildkite/scripts/pipelines/pull_request/pipeline.js b/.buildkite/scripts/pipelines/pull_request/pipeline.js index 1df3b5f64b1df5..882f76ebeedda3 100644 --- a/.buildkite/scripts/pipelines/pull_request/pipeline.js +++ b/.buildkite/scripts/pipelines/pull_request/pipeline.js @@ -103,6 +103,10 @@ const uploadPipeline = (pipelineContent) => { pipeline.push(getPipeline('.buildkite/pipelines/pull_request/uptime.yml')); } + if (process.env.GITHUB_PR_LABELS.includes('ci:deploy-cloud')) { + pipeline.push(getPipeline('.buildkite/pipelines/pull_request/deploy_cloud.yml')); + } + pipeline.push(getPipeline('.buildkite/pipelines/pull_request/post_build.yml')); uploadPipeline(pipeline.join('\n')); diff --git a/.buildkite/scripts/steps/cloud/build_and_deploy.sh b/.buildkite/scripts/steps/cloud/build_and_deploy.sh new file mode 100755 index 00000000000000..9ea6c4f4453287 --- /dev/null +++ b/.buildkite/scripts/steps/cloud/build_and_deploy.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash + +set -euo pipefail + +source .buildkite/scripts/common/util.sh + +.buildkite/scripts/bootstrap.sh + +export KBN_NP_PLUGINS_BUILT=true + +VERSION="$(jq -r '.version' package.json)-SNAPSHOT" + +echo "--- Download kibana distribution" + +mkdir -p ./target +buildkite-agent artifact download "kibana-$VERSION-linux-x86_64.tar.gz" ./target --build "${KIBANA_BUILD_ID:-$BUILDKITE_BUILD_ID}" + +echo "--- Build and push Kibana Cloud Distribution" + +echo "$KIBANA_DOCKER_PASSWORD" | docker login -u "$KIBANA_DOCKER_USERNAME" --password-stdin docker.elastic.co +trap 'docker logout docker.elastic.co' EXIT + +node scripts/build \ + --skip-initialize \ + --skip-generic-folders \ + --skip-platform-folders \ + --skip-archives \ + --docker-images \ + --docker-tag-qualifier="$GIT_COMMIT" \ + --docker-push \ + --skip-docker-ubi \ + --skip-docker-ubuntu \ + --skip-docker-contexts + +CLOUD_IMAGE=$(docker images --format "{{.Repository}}:{{.Tag}}" docker.elastic.co/kibana-ci/kibana-cloud) +CLOUD_DEPLOYMENT_NAME="kibana-pr-$BUILDKITE_PULL_REQUEST" + +jq ' + .resources.kibana[0].plan.kibana.docker_image = "'$CLOUD_IMAGE'" | + .name = "'$CLOUD_DEPLOYMENT_NAME'" | + .resources.kibana[0].plan.kibana.version = "'$VERSION'" | + .resources.elasticsearch[0].plan.elasticsearch.version = "'$VERSION'" + ' .buildkite/scripts/steps/cloud/deploy.json > /tmp/deploy.json + +CLOUD_DEPLOYMENT_ID=$(ecctl deployment list --output json | jq -r '.deployments[] | select(.name == "'$CLOUD_DEPLOYMENT_NAME'") | .id') +JSON_FILE=$(mktemp --suffix ".json") +if [ -z "${CLOUD_DEPLOYMENT_ID}" ]; then + ecctl deployment create --track --output json --file /tmp/deploy.json &> "$JSON_FILE" + CLOUD_DEPLOYMENT_USERNAME=$(jq --slurp '.[]|select(.resources).resources[] | select(.credentials).credentials.username' "$JSON_FILE") + CLOUD_DEPLOYMENT_PASSWORD=$(jq --slurp '.[]|select(.resources).resources[] | select(.credentials).credentials.password' "$JSON_FILE") + CLOUD_DEPLOYMENT_ID=$(jq -r --slurp '.[0].id' "$JSON_FILE") + CLOUD_DEPLOYMENT_STATUS_MESSAGES=$(jq --slurp '[.[]|select(.resources == null)]' "$JSON_FILE") + + # Refresh vault token + VAULT_ROLE_ID="$(retry 5 15 gcloud secrets versions access latest --secret=kibana-buildkite-vault-role-id)" + VAULT_SECRET_ID="$(retry 5 15 gcloud secrets versions access latest --secret=kibana-buildkite-vault-secret-id)" + VAULT_TOKEN=$(retry 5 30 vault write -field=token auth/approle/login role_id="$VAULT_ROLE_ID" secret_id="$VAULT_SECRET_ID") + retry 5 30 vault login -no-print "$VAULT_TOKEN" + + retry 5 5 vault write "secret/kibana-issues/dev/cloud-deploy/$CLOUD_DEPLOYMENT_NAME" username="$CLOUD_DEPLOYMENT_USERNAME" password="$CLOUD_DEPLOYMENT_PASSWORD" +else + ecctl deployment update "$CLOUD_DEPLOYMENT_ID" --track --output json --file /tmp/deploy.json &> "$JSON_FILE" +fi + +CLOUD_DEPLOYMENT_KIBANA_URL=$(ecctl deployment show "$CLOUD_DEPLOYMENT_ID" | jq -r '.resources.kibana[0].info.metadata.aliased_url') +CLOUD_DEPLOYMENT_ELASTICSEARCH_URL=$(ecctl deployment show "$CLOUD_DEPLOYMENT_ID" | jq -r '.resources.elasticsearch[0].info.metadata.aliased_url') + +cat << EOF | buildkite-agent annotate --style "info" --context cloud + ### Cloud Deployment + + Kibana: $CLOUD_DEPLOYMENT_KIBANA_URL + + Elasticsearch: $CLOUD_DEPLOYMENT_ELASTICSEARCH_URL + + Credentials: \`vault read secret/kibana-issues/dev/cloud-deploy/$CLOUD_DEPLOYMENT_NAME\` + + Image: $CLOUD_IMAGE +EOF + +buildkite-agent meta-data set pr_comment:deploy_cloud:head "* [Cloud Deployment](${CLOUD_DEPLOYMENT_KIBANA_URL})" diff --git a/.buildkite/scripts/steps/cloud/deploy.json b/.buildkite/scripts/steps/cloud/deploy.json new file mode 100644 index 00000000000000..37768144f138ad --- /dev/null +++ b/.buildkite/scripts/steps/cloud/deploy.json @@ -0,0 +1,163 @@ +{ + "resources": { + "elasticsearch": [ + { + "region": "gcp-us-west2", + "settings": { + "dedicated_masters_threshold": 6 + }, + "plan": { + "autoscaling_enabled": false, + "cluster_topology": [ + { + "zone_count": 2, + "instance_configuration_id": "gcp.coordinating.1", + "node_roles": ["ingest", "remote_cluster_client"], + "id": "coordinating", + "size": { + "resource": "memory", + "value": 0 + }, + "elasticsearch": { + "enabled_built_in_plugins": [] + } + }, + { + "zone_count": 1, + "elasticsearch": { + "node_attributes": { + "data": "hot" + }, + "enabled_built_in_plugins": [] + }, + "instance_configuration_id": "gcp.data.highio.1", + "node_roles": [ + "master", + "ingest", + "transform", + "data_hot", + "remote_cluster_client", + "data_content" + ], + "id": "hot_content", + "size": { + "value": 1024, + "resource": "memory" + } + }, + { + "zone_count": 2, + "elasticsearch": { + "node_attributes": { + "data": "warm" + }, + "enabled_built_in_plugins": [] + }, + "instance_configuration_id": "gcp.data.highstorage.1", + "node_roles": ["data_warm", "remote_cluster_client"], + "id": "warm", + "size": { + "resource": "memory", + "value": 0 + } + }, + { + "zone_count": 1, + "elasticsearch": { + "node_attributes": { + "data": "cold" + }, + "enabled_built_in_plugins": [] + }, + "instance_configuration_id": "gcp.data.highstorage.1", + "node_roles": ["data_cold", "remote_cluster_client"], + "id": "cold", + "size": { + "resource": "memory", + "value": 0 + } + }, + { + "zone_count": 1, + "elasticsearch": { + "node_attributes": { + "data": "frozen" + }, + "enabled_built_in_plugins": [] + }, + "instance_configuration_id": "gcp.es.datafrozen.n1.64x10x95", + "node_roles": ["data_frozen"], + "id": "frozen", + "size": { + "resource": "memory", + "value": 0 + } + }, + { + "zone_count": 3, + "instance_configuration_id": "gcp.master.1", + "node_roles": ["master", "remote_cluster_client"], + "id": "master", + "size": { + "resource": "memory", + "value": 0 + }, + "elasticsearch": { + "enabled_built_in_plugins": [] + } + }, + { + "zone_count": 1, + "instance_configuration_id": "gcp.ml.1", + "node_roles": ["ml", "remote_cluster_client"], + "id": "ml", + "size": { + "resource": "memory", + "value": 0 + }, + "elasticsearch": { + "enabled_built_in_plugins": [] + } + } + ], + "elasticsearch": { + "version": null + }, + "deployment_template": { + "id": "gcp-io-optimized-v2" + } + }, + "ref_id": "main-elasticsearch" + } + ], + "enterprise_search": [], + "kibana": [ + { + "elasticsearch_cluster_ref_id": "main-elasticsearch", + "region": "gcp-us-west2", + "plan": { + "cluster_topology": [ + { + "instance_configuration_id": "gcp.kibana.1", + "zone_count": 1, + "size": { + "resource": "memory", + "value": 1024 + } + } + ], + "kibana": { + "version": null, + "docker_image": null + } + }, + "ref_id": "main-kibana" + } + ], + "apm": [] + }, + "name": null, + "metadata": { + "system_owned": false + } +} diff --git a/.buildkite/scripts/steps/cloud/purge.js b/.buildkite/scripts/steps/cloud/purge.js new file mode 100644 index 00000000000000..0eccb55cef830b --- /dev/null +++ b/.buildkite/scripts/steps/cloud/purge.js @@ -0,0 +1,56 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +const { execSync } = require('child_process'); + +const deploymentsListJson = execSync('ecctl deployment list --output json').toString(); +const { deployments } = JSON.parse(deploymentsListJson); + +const prDeployments = deployments.filter((deployment) => deployment.name.startsWith('kibana-pr-')); + +const deploymentsToPurge = []; + +const NOW = new Date().getTime() / 1000; + +for (const deployment of prDeployments) { + try { + const prNumber = deployment.name.match(/^kibana-pr-([0-9]+)$/)[1]; + const prJson = execSync(`gh pr view '${prNumber}' --json state,labels,commits`).toString(); + const pullRequest = JSON.parse(prJson); + + const lastCommit = pullRequest.commits.slice(-1)[0]; + const lastCommitTimestamp = new Date(lastCommit.committedDate).getTime() / 1000; + + if (pullRequest.state !== 'open') { + console.log(`Pull Request #${prNumber} is no longer open, will delete associated deployment`); + deploymentsToPurge.push(deployment); + } else if (!pullRequest.labels.filter((label) => label.name === 'ci:deploy-cloud')) { + console.log( + `Pull Request #${prNumber} no longer has the ci:deploy-cloud label, will delete associated deployment` + ); + deploymentsToPurge.push(deployment); + } else if (lastCommitTimestamp < NOW - 60 * 60 * 24 * 7) { + console.log( + `Pull Request #${prNumber} has not been updated in more than 7 days, will delete associated deployment` + ); + deploymentsToPurge.push(deployment); + } + } catch (ex) { + console.error(ex.toString()); + // deploymentsToPurge.push(deployment); // TODO should we delete on error? + } +} + +for (const deployment of deploymentsToPurge) { + console.log(`Scheduling deployment for deletion: ${deployment.name} / ${deployment.id}`); + try { + execSync(`ecctl deployment shutdown --force '${deployment.id}'`, { stdio: 'inherit' }); + } catch (ex) { + console.error(ex.toString()); + } +} diff --git a/.buildkite/scripts/steps/cloud/purge.sh b/.buildkite/scripts/steps/cloud/purge.sh new file mode 100755 index 00000000000000..265148c0134001 --- /dev/null +++ b/.buildkite/scripts/steps/cloud/purge.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -euo pipefail + +node .buildkite/scripts/steps/cloud/purge.js diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index dd39abe62d9fa6..f7709dbcfa8a96 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -141,10 +141,11 @@ /x-pack/test/functional/es_archives/uptime @elastic/uptime /x-pack/test/functional/services/uptime @elastic/uptime /x-pack/test/api_integration/apis/uptime @elastic/uptime +/x-pack/plugins/observability/public/components/shared/exploratory_view @elastic/uptime # Client Side Monitoring / Uptime (lives in APM directories but owned by Uptime) /x-pack/plugins/apm/public/application/uxApp.tsx @elastic/uptime -/x-pack/plugins/apm/public/components/app/RumDashboard @elastic/uptime +/x-pack/plugins/apm/public/components/app/rum_dashboard @elastic/uptime /x-pack/plugins/apm/server/lib/rum_client @elastic/uptime /x-pack/plugins/apm/server/routes/rum_client.ts @elastic/uptime /x-pack/plugins/apm/server/projections/rum_page_load_transactions.ts @elastic/uptime diff --git a/dev_docs/api_welcome.mdx b/dev_docs/api_welcome.mdx index cf88bf7eec0daf..1127ecc8603b65 100644 --- a/dev_docs/api_welcome.mdx +++ b/dev_docs/api_welcome.mdx @@ -2,7 +2,7 @@ id: kibDevDocsApiWelcome slug: /kibana-dev-docs/api-meta/welcome title: Welcome -summary: How to use our automatically generated API documentation +description: How to use our automatically generated API documentation date: 2021-02-25 tags: ['kibana','dev', 'contributor', 'api docs'] --- diff --git a/dev_docs/getting_started/add_data.mdx b/dev_docs/getting_started/add_data.mdx index 46822b82fc40df..a94ec511cda5e7 100644 --- a/dev_docs/getting_started/add_data.mdx +++ b/dev_docs/getting_started/add_data.mdx @@ -2,14 +2,14 @@ id: kibDevAddData slug: /kibana-dev-docs/getting-started/sample-data title: Add data -summary: Learn how to add data to Kibana +description: Learn how to add data to Kibana date: 2021-08-11 tags: ['kibana', 'onboarding', 'dev', 'architecture', 'tutorials'] --- Building a feature and need an easy way to test it out with some data? Below are three options. -## 1. Add Sample Data from the UI +## Sample data Kibana ships with sample data that you can install at the click of the button. If you are building a feature and need some data to test it out with, sample data is a great option. The only limitation is that this data will not work for Security or Observability solutions (see [#62962](https://github.com/elastic/kibana/issues/62962)). @@ -20,7 +20,7 @@ Kibana ships with sample data that you can install at the click of the button. I ![Sample Data](../assets/sample_data.png) -## CSV Upload +## CSV upload 1. If you don't have any data, navigate to Stack Management > Index Patterns and click the link to the uploader. If you do have data, navigate to the **Machine Learning** application. 2. Click on the **Data Visualizer** tab. @@ -35,3 +35,11 @@ The makelogs script generates sample web server logs. Make sure Elasticsearch is ```sh node scripts/makelogs --auth : ``` + +## Realistic solution data + + + +Security and Observability solution applications only work if data exists in particularly named indices, abiding by our [ECS format](https://www.elastic.co/guide/en/ecs/current/index.html). If you would like to use these applications with realistic data, check out the [oblt_cli tool](https://github.com/elastic/observability-test-environments/blob/master/tools/oblt_cli/README.md). This tool sets you up to connect to a remote Elasticsearch cluster that contains the appropriate data via CCS. + + diff --git a/dev_docs/kibana_server_core_components.mdx b/dev_docs/kibana_server_core_components.mdx index 503d8401d44925..c60e085144fff7 100644 --- a/dev_docs/kibana_server_core_components.mdx +++ b/dev_docs/kibana_server_core_components.mdx @@ -2,7 +2,7 @@ id: kibServerAndCoreComponents slug: /kibana-dev-docs/core-intro title: Kibana Server and Core components -summary: An introduction to the Kibana server and core components. +description: An introduction to the Kibana server and core components. date: 2021-02-26 tags: ['kibana','onboarding', 'dev', 'architecture'] --- diff --git a/docs/CHANGELOG.asciidoc b/docs/CHANGELOG.asciidoc index 03bccef3b822ef..446c305c03b95d 100644 --- a/docs/CHANGELOG.asciidoc +++ b/docs/CHANGELOG.asciidoc @@ -20,8 +20,6 @@ Review important information about the {kib} 8.0.0 releases. [[release-notes-8.0.0-rc2]] == {kib} 8.0.0-rc2 -coming::[8.0.0-rc2] - For information about the {kib} 8.0.0-rc2 release, review the following information. [float] diff --git a/docs/api/data-views/create.asciidoc b/docs/api/data-views/create.asciidoc index c1666589b7e2b5..5224a238ea8f40 100644 --- a/docs/api/data-views/create.asciidoc +++ b/docs/api/data-views/create.asciidoc @@ -6,12 +6,14 @@ experimental[] Create data views. + [[data-views-api-create-request]] ==== Request -`POST :/api/index_patterns/index_pattern` +`POST :/api/data_views/data_view` + +`POST :/s//api/data_views/data_view` -`POST :/s//api/index_patterns/index_pattern` [[data-views-api-create-path-params]] ==== Path parameters @@ -19,6 +21,7 @@ experimental[] Create data views. `space_id`:: (Optional, string) An identifier for the space. If `space_id` is not provided in the URL, the default space is used. + [[data-views-api-create-body-params]] ==== Request body @@ -28,7 +31,8 @@ data view with the provided title already exists. The default is `false`. `refresh_fields`:: (Optional, boolean) Reloads data view fields after the data view is stored. The default is `false`. -`index_pattern`:: (Required, object) The data view object. All fields are optional. +`data_view`:: (Required, object) The data view object. All fields are optional. + [[data-views-api-create-request-codes]] ==== Response code @@ -36,6 +40,7 @@ the data view is stored. The default is `false`. `200`:: Indicates a successful call. + [[data-views-api-create-example]] ==== Examples @@ -43,9 +48,9 @@ Create a data view with a custom title: [source,sh] -------------------------------------------------- -$ curl -X POST api/index_patterns/index_pattern +$ curl -X POST api/data_views/data_view { - "index_pattern": { + "data_view": { "title": "hello" } } @@ -56,11 +61,11 @@ Customize the creation behavior: [source,sh] -------------------------------------------------- -$ curl -X POST api/index_patterns/index_pattern +$ curl -X POST api/data_views/data_view { "override": false, "refresh_fields": true, - "index_pattern": { + "data_view": { "title": "hello" } } @@ -71,9 +76,9 @@ At creation, all data view fields are optional: [source,sh] -------------------------------------------------- -$ curl -X POST api/index_patterns/index_pattern +$ curl -X POST api/data_views/data_view { - "index_pattern": { + "data_view": { "id": "...", "version": "...", "title": "...", @@ -97,7 +102,6 @@ The API returns the data view object: [source,sh] -------------------------------------------------- { - "index_pattern": {...} + "data_view": {...} } -------------------------------------------------- - diff --git a/docs/api/data-views/default-get.asciidoc b/docs/api/data-views/default-get.asciidoc index 300a0612b18ea5..51e5bf60d7097f 100644 --- a/docs/api/data-views/default-get.asciidoc +++ b/docs/api/data-views/default-get.asciidoc @@ -6,12 +6,14 @@ experimental[] Retrieve a default data view ID. Kibana UI uses the default data view unless user picks a different one. + [[data-views-api-default-get-request]] ==== Request -`GET :/api/index_patterns/default` +`GET :/api/data_views/default` + +`GET :/s//api/data_views/default` -`GET :/s//api/index_patterns/default` [[data-views-api-default-get-params]] ==== Path parameters @@ -19,12 +21,14 @@ experimental[] Retrieve a default data view ID. Kibana UI uses the default data `space_id`:: (Optional, string) An identifier for the space. If `space_id` is not provided in the URL, the default space is used. + [[data-views-api-default-get-codes]] ==== Response code `200`:: Indicates a successful call. + [[data-views-api-default-get-example]] ==== Example @@ -32,7 +36,7 @@ Retrieve the default data view id: [source,sh] -------------------------------------------------- -$ curl -X GET api/index_patterns/default +$ curl -X GET api/data_views/default -------------------------------------------------- // KIBANA @@ -41,7 +45,7 @@ The API returns an ID of a default data view: [source,sh] -------------------------------------------------- { - "index_pattern_id": "..." + "data_view_id": "..." } -------------------------------------------------- @@ -50,6 +54,7 @@ In case there is no default data view, the API returns: [source,sh] -------------------------------------------------- { - "index_pattern_id": null + "data_view_id": null } -------------------------------------------------- + diff --git a/docs/api/data-views/default-set.asciidoc b/docs/api/data-views/default-set.asciidoc index 752054cfb17483..dd62f859f7220e 100644 --- a/docs/api/data-views/default-set.asciidoc +++ b/docs/api/data-views/default-set.asciidoc @@ -5,14 +5,16 @@ ++++ experimental[] Set a default data view ID. Kibana UI will use the default data view unless user picks a different one. -The API doesn't validate if given `index_pattern_id` is a valid id. +The API doesn't validate if given `data_view_id` is a valid id. + [[data-views-api-default-set-request]] ==== Request -`POST :/api/index_patterns/default` +`POST :/api/data_views/default` + +`POST :/s//api/data_views/default` -`POST :/s//api/index_patterns/default` [[data-views-api-default-set-params]] ==== Path parameters @@ -20,20 +22,23 @@ The API doesn't validate if given `index_pattern_id` is a valid id. `space_id`:: (Optional, string) An identifier for the space. If `space_id` is not provided in the URL, the default space is used. + [[data-views-api-default-set-body]] ==== Request body -`index_pattern_id`:: (Required, `string` or `null`) Sets a default data view id. Use `null` to unset a default data view. +`data_view_id`:: (Required, `string` or `null`) Sets a default data view id. Use `null` to unset a default data view. `force`:: (Optional, boolean) Updates existing default data view id. The default is `false`. + [[data-views-api-default-set-codes]] ==== Response code `200`:: Indicates a successful call. + [[data-views-api-default-set-example]] ==== Example @@ -41,9 +46,9 @@ Set the default data view id if none is set: [source,sh] -------------------------------------------------- -$ curl -X POST api/index_patterns/default +$ curl -X POST api/data_views/default { - "index_pattern_id": "..." + "data_view_id": "..." } -------------------------------------------------- // KIBANA @@ -53,9 +58,9 @@ Upsert the default data view: [source,sh] -------------------------------------------------- -$ curl -X POST api/index_patterns/default +$ curl -X POST api/data_views/default { - "index_pattern_id": "...", + "data_view_id": "...", "force": true } -------------------------------------------------- @@ -65,9 +70,9 @@ Unset the default data view: [source,sh] -------------------------------------------------- -$ curl -X POST api/index_patterns/default +$ curl -X POST api/data_views/default { - "index_pattern_id": null, + "data_view_id": null, "force": true } -------------------------------------------------- @@ -81,4 +86,3 @@ The API returns: "acknowledged": true } -------------------------------------------------- - diff --git a/docs/api/data-views/delete.asciidoc b/docs/api/data-views/delete.asciidoc index 9bc63c89365e7a..a3165c799243dc 100644 --- a/docs/api/data-views/delete.asciidoc +++ b/docs/api/data-views/delete.asciidoc @@ -8,12 +8,14 @@ experimental[] Delete data views. WARNING: Once you delete a data view, _it cannot be recovered_. + [[data-views-api-delete-request]] ==== Request -`DELETE :/api/index_patterns/index_pattern/` +`DELETE :/api/data_views/data_view/` + +`DELETE :/s//api/data_views/data_view/` -`DELETE :/s//api/index_patterns/index_pattern/` [[data-views-api-delete-path-params]] ==== Path parameters @@ -24,18 +26,20 @@ WARNING: Once you delete a data view, _it cannot be recovered_. `id`:: (Required, string) The ID of the data view you want to delete. + [[data-views-api-delete-response-codes]] ==== Response code `200`:: Indicates that data view is deleted. Returns an empty response body. + ==== Example -Delete a data view object with the `my-pattern` ID: +Delete a data view object with the `my-view` ID: [source,sh] -------------------------------------------------- -$ curl -X DELETE api/index_patterns/index_pattern/my-pattern +$ curl -X DELETE api/data_views/data_view/my-view -------------------------------------------------- // KIBANA diff --git a/docs/api/data-views/get.asciidoc b/docs/api/data-views/get.asciidoc index 0584dfeae1cd52..9d6a4160aeacf9 100644 --- a/docs/api/data-views/get.asciidoc +++ b/docs/api/data-views/get.asciidoc @@ -6,12 +6,14 @@ experimental[] Retrieve a single data view by ID. + [[data-views-api-get-request]] ==== Request -`GET :/api/index_patterns/index_pattern/` +`GET :/api/data_views/data_view/` + +`GET :/s//api/data_views/data_view/` -`GET :/s//api/index_patterns/index_pattern/` [[data-views-api-get-params]] ==== Path parameters @@ -22,6 +24,7 @@ experimental[] Retrieve a single data view by ID. `id`:: (Required, string) The ID of the data view you want to retrieve. + [[data-views-api-get-codes]] ==== Response code @@ -31,14 +34,15 @@ Indicates a successful call. `404`:: The specified data view and ID doesn't exist. + [[data-views-api-get-example]] ==== Example -Retrieve the data view object with the `my-pattern` ID: +Retrieve the data view object with the `my-view` ID: [source,sh] -------------------------------------------------- -$ curl -X GET api/index_patterns/index_pattern/my-pattern +$ curl -X GET api/data_views/data_view/my-view -------------------------------------------------- // KIBANA @@ -47,8 +51,8 @@ The API returns a data view object: [source,sh] -------------------------------------------------- { - "index_pattern": { - "id": "my-pattern", + "data_view": { + "id": "my-view", "version": "...", "title": "...", "type": "...", diff --git a/docs/api/data-views/runtime-fields/create.asciidoc b/docs/api/data-views/runtime-fields/create.asciidoc index 442bede9cba7a5..8f63de5bcf9e4f 100644 --- a/docs/api/data-views/runtime-fields/create.asciidoc +++ b/docs/api/data-views/runtime-fields/create.asciidoc @@ -9,9 +9,9 @@ experimental[] Create a runtime field [[data-views-runtime-field-create-request]] ==== Request -`POST :/api/index_patterns/index_pattern//runtime_field` +`POST :/api/data_views/data_view//runtime_field` -`POST :/s//api/index_patterns/index_pattern//runtime_field` +`POST :/s//api/data_views/data_view//runtime_field` [[data-views-runtime-field-create-params]] ==== Path parameters @@ -19,7 +19,7 @@ experimental[] Create a runtime field `space_id`:: (Optional, string) An identifier for the space. If `space_id` is not provided in the URL, the default space is used. -`index_pattern_id`:: +`data_view_id`:: (Required, string) The ID of the data view. [[data-views-runtime-field-create-body]] @@ -37,7 +37,7 @@ Create a runtime field on a data view: [source,sh] -------------------------------------------------- -$ curl -X POST api/index_patterns/index_pattern//runtime_field +$ curl -X POST api/data_views/data_view//runtime_field { "name": "runtimeFoo", "runtimeField": { @@ -50,12 +50,12 @@ $ curl -X POST api/index_patterns/index_pattern//runtime_field -------------------------------------------------- // KIBANA -The API returns created runtime field object and updated data view object: +The API returns created runtime field object array and updated data view object: [source,sh] -------------------------------------------------- { - "index_pattern": {...}, - "field": {...} + "data_view": {...}, + "fields": [...] } -------------------------------------------------- diff --git a/docs/api/data-views/runtime-fields/delete.asciidoc b/docs/api/data-views/runtime-fields/delete.asciidoc index b2a8e9f3104775..a57d8f73ce1403 100644 --- a/docs/api/data-views/runtime-fields/delete.asciidoc +++ b/docs/api/data-views/runtime-fields/delete.asciidoc @@ -9,9 +9,10 @@ experimental[] Delete a runtime field from a data view. [[data-views-runtime-field-api-delete-request]] ==== Request -`DELETE :/api/index_patterns/index_pattern//runtime_field/` +`DELETE :/api/data_views/data_view//runtime_field/` + +`DELETE :/s//api/data_views/data_view//runtime_field/` -`DELETE :/s//api/index_patterns/index_pattern//runtime_field/` [[data-views-runtime-field-api-delete-path-params]] ==== Path parameters @@ -19,19 +20,20 @@ experimental[] Delete a runtime field from a data view. `space_id`:: (Optional, string) An identifier for the space. If `space_id` is not provided in the URL, the default space is used. -`index_pattern_id`:: +`data_view_id`:: (Required, string) The ID of the data view your want to delete a runtime field from. `name`:: (Required, string) The name of the runtime field you want to delete. + ==== Example Delete a runtime field from a data view: [source,sh] -------------------------------------------------- -$ curl -X DELETE api/index_patterns/index_pattern//runtime_field/ +$ curl -X DELETE api/data_views/data_view//runtime_field/ -------------------------------------------------- // KIBANA diff --git a/docs/api/data-views/runtime-fields/get.asciidoc b/docs/api/data-views/runtime-fields/get.asciidoc index 66530ae5f3f3fe..831744fdc06b5c 100644 --- a/docs/api/data-views/runtime-fields/get.asciidoc +++ b/docs/api/data-views/runtime-fields/get.asciidoc @@ -6,12 +6,14 @@ experimental[] Get a runtime field + [[data-views-runtime-field-get-request]] ==== Request -`GET :/api/index_patterns/index_pattern//runtime_field/` +`GET :/api/data_views/data_view//runtime_field/` + +`GET :/s//api/data_views/data_view//runtime_field/` -`GET :/s//api/index_patterns/index_pattern//runtime_field/` [[data-views-runtime-field-get-params]] ==== Path parameters @@ -19,7 +21,7 @@ experimental[] Get a runtime field `space_id`:: (Optional, string) An identifier for the space. If `space_id` is not provided in the URL, the default space is used. -`index_pattern_id`:: +`data_view_id`:: (Required, string) The ID of the data view. `name`:: @@ -29,22 +31,22 @@ experimental[] Get a runtime field [[data-views-runtime-field-get-example]] ==== Example -Retrieve a runtime field named `foo` of data view with the `my-pattern` ID: +Retrieve a runtime field named `foo` of data view with the `my-view` ID: [source,sh] -------------------------------------------------- -$ curl -X GET api/index_patterns/index_pattern/my-pattern/runtime_field/foo +$ curl -X GET api/data_views/data_view/my-view/runtime_field/foo -------------------------------------------------- // KIBANA -The API returns a runtime `field` object, and a `runtimeField` definition object: +The API returns a runtime `field` object array, and a `runtimeField` definition object: [source,sh] -------------------------------------------------- { - "field": { + "fields": [ ... - }, + ], "runtimeField": { ... } diff --git a/docs/api/data-views/runtime-fields/update.asciidoc b/docs/api/data-views/runtime-fields/update.asciidoc index 970826560f4a8e..86ef4cae93e1eb 100644 --- a/docs/api/data-views/runtime-fields/update.asciidoc +++ b/docs/api/data-views/runtime-fields/update.asciidoc @@ -6,12 +6,14 @@ experimental[] Update an existing runtime field + [[data-views-runtime-field-update-request]] ==== Request -`POST :/api/index_patterns/index_pattern//runtime_field/` +`POST :/api/data_views/data_view//runtime_field/` + +`POST :/s//api/data_views/data_view//runtime_field/` -`POST :/s//api/index_patterns/index_pattern//runtime_field/` [[data-views-runtime-field-update-params]] ==== Path parameters @@ -19,12 +21,13 @@ experimental[] Update an existing runtime field `space_id`:: (Optional, string) An identifier for the space. If `space_id` is not provided in the URL, the default space is used. -`index_pattern_id`:: +`data_view_id`:: (Required, string) The ID of the data view. `name`:: (Required, string) The name of the runtime field you want to update. + [[data-views-runtime-field-update-body]] ==== Request body @@ -37,6 +40,7 @@ You can update following fields: + [[data-views-runtime-field-update-example]] ==== Examples @@ -44,7 +48,7 @@ Update an existing runtime field on a data view: [source,sh] -------------------------------------------------- -$ curl -X POST api/index_patterns/index_pattern//runtime_field/ +$ curl -X POST api/data_views/data_view//runtime_field/ { "runtimeField": { "script": { @@ -55,12 +59,13 @@ $ curl -X POST api/index_patterns/index_pattern//runtime_field -------------------------------------------------- // KIBANA -The API returns updated runtime field object and updated data view object: +The API returns updated runtime field object array and updated data view object: [source,sh] -------------------------------------------------- { - "index_pattern": {...}, - "field": {...} + "data_view": {...}, + "fields": [...] } -------------------------------------------------- + diff --git a/docs/api/data-views/runtime-fields/upsert.asciidoc b/docs/api/data-views/runtime-fields/upsert.asciidoc index 427aa30afa94a5..959e0f0846b858 100644 --- a/docs/api/data-views/runtime-fields/upsert.asciidoc +++ b/docs/api/data-views/runtime-fields/upsert.asciidoc @@ -6,12 +6,14 @@ experimental[] Create or update an existing runtime field + [[data-views-runtime-field-upsert-request]] ==== Request -`PUT :/api/index_patterns/index_pattern//runtime_field` +`PUT :/api/data_views/data_view//runtime_field` + +`PUT :/s//api/data_views/data_view//runtime_field` -`PUT :/s//api/index_patterns/index_pattern//runtime_field` [[data-views-runtime-field-upsert-params]] ==== Path parameters @@ -19,9 +21,10 @@ experimental[] Create or update an existing runtime field `space_id`:: (Optional, string) An identifier for the space. If `space_id` is not provided in the URL, the default space is used. -`index_pattern_id`:: +`data_view_id`:: (Required, string) The ID of the data view. + [[data-views-runtime-field-upsert-body]] ==== Request body @@ -30,6 +33,7 @@ experimental[] Create or update an existing runtime field `runtimeField`:: (Required, object) The runtime field definition object. + [[data-views-runtime-field-upsert-example]] ==== Examples @@ -37,7 +41,7 @@ Create or update an existing runtime field on a data view: [source,sh] -------------------------------------------------- -$ curl -X PUT api/index_patterns/index_pattern//runtime_field +$ curl -X PUT api/data_views/data_view//runtime_field { "name": "runtimeFoo", "runtimeField": { @@ -50,12 +54,13 @@ $ curl -X PUT api/index_patterns/index_pattern//runtime_field -------------------------------------------------- // KIBANA -The API returns created or updated runtime field object and updated data view object: +The API returns created or updated runtime field object array and updated data view object: [source,sh] -------------------------------------------------- { - "index_pattern": {...}, - "field": {...} + "data_view": {...}, + "fields": [...] } -------------------------------------------------- + diff --git a/docs/api/data-views/update-fields.asciidoc b/docs/api/data-views/update-fields.asciidoc index 929dee27b9da16..babe689ce6b237 100644 --- a/docs/api/data-views/update-fields.asciidoc +++ b/docs/api/data-views/update-fields.asciidoc @@ -8,12 +8,14 @@ experimental[] Update fields presentation metadata, such as `count`, `customLabel`, and `format`. You can update multiple fields in one request. Updates are merged with persisted metadata. To remove existing metadata, specify `null` as the value. + [[data-views-fields-api-update-request]] ==== Request -`POST :/api/index_patterns/index_pattern//fields` +`POST :/api/data_views/data_view//fields` + +`POST :/s//api/data_views/data_view//fields` -`POST :/s//api/index_patterns/index_pattern//fields` [[data-views-fields-api-update-path-params]] ==== Path parameters @@ -24,6 +26,7 @@ are merged with persisted metadata. To remove existing metadata, specify `null` `id`:: (Required, string) The ID of the data view fields you want to update. + [[data-views-fields-api-update-request-body]] ==== Request body @@ -31,12 +34,14 @@ are merged with persisted metadata. To remove existing metadata, specify `null` (Required, object) the field object + [[data-views-fields-api-update-errors-codes]] ==== Response code `200`:: Indicates a successful call. + [[data-views-fields-api-update-example]] ==== Examples @@ -44,7 +49,7 @@ Set popularity `count` for field `foo`: [source,sh] -------------------------------------------------- -$ curl -X POST api/saved_objects/index-pattern/my-pattern/fields +$ curl -X POST api/saved_objects/data-view/my-view/fields { "fields": { "foo": { @@ -59,7 +64,7 @@ Update multiple metadata fields in one request: [source,sh] -------------------------------------------------- -$ curl -X POST api/saved_objects/index-pattern/my-pattern/fields +$ curl -X POST api/saved_objects/data-view/my-view/fields { "fields": { "foo": { @@ -77,7 +82,7 @@ $ curl -X POST api/saved_objects/index-pattern/my-pattern/fields Use `null` value to delete metadata: [source,sh] -------------------------------------------------- -$ curl -X POST api/saved_objects/index-pattern/my-pattern/fields +$ curl -X POST api/saved_objects/data-view/my-pattern/fields { "fields": { "foo": { @@ -93,7 +98,7 @@ The endpoint returns the updated data view object: [source,sh] -------------------------------------------------- { - "index_pattern": { + "data_view": { } } diff --git a/docs/api/data-views/update.asciidoc b/docs/api/data-views/update.asciidoc index 6157d46888277b..b86a13682cb0b6 100644 --- a/docs/api/data-views/update.asciidoc +++ b/docs/api/data-views/update.asciidoc @@ -7,12 +7,14 @@ experimental[] Update part of an data view. Only the specified fields are updated in the data view. Unspecified fields stay as they are persisted. + [[data-views-api-update-request]] ==== Request -`POST :/api/index_patterns/index_pattern/` +`POST :/api/data_views/data_view/` + +`POST :/s//api/data_views/data_view/` -`POST :/s//api/index_patterns/index_pattern/` [[data-views-api-update-path-params]] ==== Path parameters @@ -23,13 +25,14 @@ data view. Unspecified fields stay as they are persisted. `id`:: (Required, string) The ID of the data view you want to update. + [[data-views-api-update-request-body]] ==== Request body `refresh_fields`:: (Optional, boolean) Reloads the data view fields after the data view is updated. The default is `false`. -`index_pattern`:: +`data_view`:: (Required, object) The data view fields you want to update. + @@ -43,23 +46,25 @@ You can partially update the following fields: * `type` * `typeMeta` + [[data-views-api-update-errors-codes]] ==== Response code `200`:: Indicates a successful call. + [[data-views-api-update-example]] ==== Examples -Update a title of the `` data view: +Update a title of the `` data view: [source,sh] -------------------------------------------------- -$ curl -X POST api/saved_objects/index-pattern/my-pattern +$ curl -X POST api/saved_objects/data-view/my-view { - "index_pattern": { - "title": "some-other-pattern-*" + "data_view": { + "title": "some-other-view-*" } } -------------------------------------------------- @@ -69,10 +74,10 @@ Customize the update behavior: [source,sh] -------------------------------------------------- -$ curl -X POST api/saved_objects/index-pattern/my-pattern +$ curl -X POST api/saved_objects/data-view/my-view { "refresh_fields": true, - "index_pattern": { + "data_view": { "fields": {} } } @@ -84,9 +89,9 @@ All update fields are optional, but you can specify the following fields: [source,sh] -------------------------------------------------- -$ curl -X POST api/saved_objects/index-pattern/my-pattern +$ curl -X POST api/saved_objects/data-view/my-view { - "index_pattern": { + "data_view": { "title": "...", "timeFieldName": "...", "sourceFilters": [], @@ -105,8 +110,9 @@ The API returns the updated data view object: [source,sh] -------------------------------------------------- { - "index_pattern": { + "data_view": { } } -------------------------------------------------- + diff --git a/docs/development/core/server/kibana-plugin-core-server.md b/docs/development/core/server/kibana-plugin-core-server.md index ede29f5e3d2c84..450af99a5b2340 100644 --- a/docs/development/core/server/kibana-plugin-core-server.md +++ b/docs/development/core/server/kibana-plugin-core-server.md @@ -244,7 +244,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | --- | --- | | [APP\_WRAPPER\_CLASS](./kibana-plugin-core-server.app_wrapper_class.md) | The class name for top level \*and\* nested application wrappers to ensure proper layout | | [kibanaResponseFactory](./kibana-plugin-core-server.kibanaresponsefactory.md) | Set of helpers used to create KibanaResponse to form HTTP response on an incoming request. Should be returned as a result of [RequestHandler](./kibana-plugin-core-server.requesthandler.md) execution. | -| [mergeSavedObjectMigrationMaps](./kibana-plugin-core-server.mergesavedobjectmigrationmaps.md) | Merges two saved object migration maps. | +| [mergeSavedObjectMigrationMaps](./kibana-plugin-core-server.mergesavedobjectmigrationmaps.md) | Merges two saved object migration maps.If there is a migration for a given version on only one of the maps, that migration function will be used:mergeSavedObjectMigrationMaps({ '1.2.3': f }, { '4.5.6': g }) -> { '1.2.3': f, '4.5.6': g }If there is a migration for a given version on both maps, the migrations will be composed:mergeSavedObjectMigrationMaps({ '1.2.3': f }, { '1.2.3': g }) -> { '1.2.3': (doc, context) => f(g(doc, context), context) } | | [pollEsNodesVersion](./kibana-plugin-core-server.pollesnodesversion.md) | | | [ServiceStatusLevels](./kibana-plugin-core-server.servicestatuslevels.md) | The current "level" of availability of a service. | | [validBodyOutput](./kibana-plugin-core-server.validbodyoutput.md) | The set of valid body.output | diff --git a/docs/development/core/server/kibana-plugin-core-server.mergesavedobjectmigrationmaps.md b/docs/development/core/server/kibana-plugin-core-server.mergesavedobjectmigrationmaps.md index 52d40097ca487b..68cd580b578829 100644 --- a/docs/development/core/server/kibana-plugin-core-server.mergesavedobjectmigrationmaps.md +++ b/docs/development/core/server/kibana-plugin-core-server.mergesavedobjectmigrationmaps.md @@ -6,6 +6,14 @@ Merges two saved object migration maps. +If there is a migration for a given version on only one of the maps, that migration function will be used: + +mergeSavedObjectMigrationMaps({ '1.2.3': f }, { '4.5.6': g }) -> { '1.2.3': f, '4.5.6': g } + +If there is a migration for a given version on both maps, the migrations will be composed: + +mergeSavedObjectMigrationMaps({ '1.2.3': f }, { '1.2.3': g }) -> { '1.2.3': (doc, context) => f(g(doc, context), context) } + Signature: ```typescript diff --git a/package.json b/package.json index 30221795a61772..00df514df765aa 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "dashboarding" ], "private": true, - "version": "8.1.0", + "version": "8.2.0", "branch": "main", "types": "./kibana.d.ts", "tsdocMetadata": "./build/tsdoc-metadata.json", @@ -455,6 +455,7 @@ "@emotion/babel-preset-css-prop": "^11.2.0", "@emotion/jest": "^11.3.0", "@istanbuljs/schema": "^0.1.2", + "@jest/console": "^26.6.2", "@jest/reporters": "^26.6.2", "@kbn/babel-code-parser": "link:bazel-bin/packages/kbn-babel-code-parser", "@kbn/babel-preset": "link:bazel-bin/packages/kbn-babel-preset", @@ -474,6 +475,7 @@ "@kbn/storybook": "link:bazel-bin/packages/kbn-storybook", "@kbn/telemetry-tools": "link:bazel-bin/packages/kbn-telemetry-tools", "@kbn/test": "link:bazel-bin/packages/kbn-test", + "@kbn/test-jest-helpers": "link:bazel-bin/packages/kbn-test-jest-helpers", "@kbn/test-subj-selector": "link:bazel-bin/packages/kbn-test-subj-selector", "@loaders.gl/polyfills": "^2.3.5", "@mapbox/vector-tile": "1.3.1", @@ -610,6 +612,8 @@ "@types/kbn__std": "link:bazel-bin/packages/kbn-std/npm_module_types", "@types/kbn__storybook": "link:bazel-bin/packages/kbn-storybook/npm_module_types", "@types/kbn__telemetry-tools": "link:bazel-bin/packages/kbn-telemetry-tools/npm_module_types", + "@types/kbn__test": "link:bazel-bin/packages/kbn-test/npm_module_types", + "@types/kbn__test-jest-helpers": "link:bazel-bin/packages/kbn-test-jest-helpers/npm_module_types", "@types/kbn__ui-shared-deps-npm": "link:bazel-bin/packages/kbn-ui-shared-deps-npm/npm_module_types", "@types/kbn__ui-shared-deps-src": "link:bazel-bin/packages/kbn-ui-shared-deps-src/npm_module_types", "@types/kbn__ui-theme": "link:bazel-bin/packages/kbn-ui-theme/npm_module_types", diff --git a/packages/BUILD.bazel b/packages/BUILD.bazel index 3b95f652f5bc53..7e6d06922aed2f 100644 --- a/packages/BUILD.bazel +++ b/packages/BUILD.bazel @@ -61,6 +61,7 @@ filegroup( "//packages/kbn-storybook:build", "//packages/kbn-telemetry-tools:build", "//packages/kbn-test:build", + "//packages/kbn-test-jest-helpers:build", "//packages/kbn-test-subj-selector:build", "//packages/kbn-timelion-grammar:build", "//packages/kbn-tinymath:build", @@ -126,6 +127,8 @@ filegroup( "//packages/kbn-std:build_types", "//packages/kbn-storybook:build_types", "//packages/kbn-telemetry-tools:build_types", + "//packages/kbn-test:build_types", + "//packages/kbn-test-jest-helpers:build_types", "//packages/kbn-ui-shared-deps-npm:build_types", "//packages/kbn-ui-shared-deps-src:build_types", "//packages/kbn-ui-theme:build_types", diff --git a/packages/elastic-eslint-config-kibana/.eslintrc.js b/packages/elastic-eslint-config-kibana/.eslintrc.js index 8193380d662d8c..d27192774e17d2 100644 --- a/packages/elastic-eslint-config-kibana/.eslintrc.js +++ b/packages/elastic-eslint-config-kibana/.eslintrc.js @@ -96,6 +96,11 @@ module.exports = { to: false, disallowedMessage: `Use "@kbn/ui-theme" to access theme vars.` })), + { + from: '@kbn/test/jest', + to: '@kbn/test-jest-helpers', + disallowedMessage: `import from @kbn/test-jest-helpers instead` + }, ], ], diff --git a/packages/kbn-dev-utils/BUILD.bazel b/packages/kbn-dev-utils/BUILD.bazel index 7d7ba29871ef0c..65e0957fe5d90f 100644 --- a/packages/kbn-dev-utils/BUILD.bazel +++ b/packages/kbn-dev-utils/BUILD.bazel @@ -45,6 +45,7 @@ NPM_MODULE_EXTRA_FILES = [ RUNTIME_DEPS = [ "//packages/kbn-utils", + "//packages/kbn-std", "@npm//@babel/core", "@npm//axios", "@npm//chalk", @@ -67,6 +68,7 @@ RUNTIME_DEPS = [ TYPES_DEPS = [ "//packages/kbn-utils:npm_module_types", + "//packages/kbn-std:npm_module_types", "@npm//@babel/parser", "@npm//@babel/types", "@npm//@types/babel__core", diff --git a/packages/kbn-dev-utils/src/ci_stats_reporter/ci_stats_reporter.ts b/packages/kbn-dev-utils/src/ci_stats_reporter/ci_stats_reporter.ts index 3dff5acdc228a4..f16cdcc80f286c 100644 --- a/packages/kbn-dev-utils/src/ci_stats_reporter/ci_stats_reporter.ts +++ b/packages/kbn-dev-utils/src/ci_stats_reporter/ci_stats_reporter.ts @@ -11,16 +11,28 @@ import Os from 'os'; import Fs from 'fs'; import Path from 'path'; import crypto from 'crypto'; + import execa from 'execa'; -import Axios from 'axios'; +import Axios, { AxiosRequestConfig } from 'axios'; // @ts-expect-error not "public", but necessary to prevent Jest shimming from breaking things import httpAdapter from 'axios/lib/adapters/http'; import { ToolingLog } from '../tooling_log'; import { parseConfig, Config } from './ci_stats_config'; +import type { CiStatsTestGroupInfo, CiStatsTestRun } from './ci_stats_test_group_types'; const BASE_URL = 'https://ci-stats.kibana.dev'; +/** Container for metadata that can be attached to different ci-stats objects */ +export interface CiStatsMetadata { + /** + * Arbitrary key-value pairs which can be attached to CiStatsTiming and CiStatsMetric + * objects stored in the ci-stats service + */ + [key: string]: string | string[] | number | boolean | undefined; +} + +/** A ci-stats metric record */ export interface CiStatsMetric { /** Top-level categorization for the metric, e.g. "page load bundle size" */ group: string; @@ -40,13 +52,7 @@ export interface CiStatsMetric { meta?: CiStatsMetadata; } -export interface CiStatsMetadata { - /** - * Arbitrary key-value pairs which can be attached to CiStatsTiming and CiStatsMetric - * objects stored in the ci-stats service - */ - [key: string]: string | string[] | number | boolean | undefined; -} +/** A ci-stats timing event */ export interface CiStatsTiming { /** Top-level categorization for the timing, e.g. "scripts/foo", process type, etc. */ group: string; @@ -58,13 +64,7 @@ export interface CiStatsTiming { meta?: CiStatsMetadata; } -interface ReqOptions { - auth: boolean; - path: string; - body: any; - bodyDesc: string; -} - +/** Options for reporting timings to ci-stats */ export interface TimingsOptions { /** list of timings to record */ timings: CiStatsTiming[]; @@ -74,10 +74,41 @@ export interface TimingsOptions { kibanaUuid?: string | null; } +/** Options for reporting metrics to ci-stats */ export interface MetricsOptions { /** Default metadata to add to each metric */ defaultMeta?: CiStatsMetadata; } + +/** Options for reporting tests to ci-stats */ +export interface CiStatsReportTestsOptions { + /** + * Information about the group of tests that were run + */ + group: CiStatsTestGroupInfo; + /** + * Information about each test that ran, including failure information + */ + testRuns: CiStatsTestRun[]; +} + +/* @internal */ +interface ReportTestsResponse { + buildId: string; + groupId: string; + testRunCount: number; +} + +/* @internal */ +interface ReqOptions { + auth: boolean; + path: string; + body: any; + bodyDesc: string; + query?: AxiosRequestConfig['params']; +} + +/** Object that helps report data to the ci-stats service */ export class CiStatsReporter { /** * Create a CiStatsReporter by inspecting the ENV for the necessary config @@ -86,7 +117,7 @@ export class CiStatsReporter { return new CiStatsReporter(parseConfig(log), log); } - constructor(private config: Config | undefined, private log: ToolingLog) {} + constructor(private readonly config: Config | undefined, private readonly log: ToolingLog) {} /** * Determine if CI_STATS is explicitly disabled by the environment. To determine @@ -165,7 +196,7 @@ export class CiStatsReporter { this.log.debug('CIStatsReporter committerHash: %s', defaultMeta.committerHash); - return await this.req({ + return !!(await this.req({ auth: !!buildId, path: '/v1/timings', body: { @@ -175,7 +206,7 @@ export class CiStatsReporter { timings, }, bodyDesc: timings.length === 1 ? `${timings.length} timing` : `${timings.length} timings`, - }); + })); } /** @@ -188,12 +219,11 @@ export class CiStatsReporter { } const buildId = this.config?.buildId; - if (!buildId) { - throw new Error(`CiStatsReporter can't be authorized without a buildId`); + throw new Error(`metrics can't be reported without a buildId`); } - return await this.req({ + return !!(await this.req({ auth: true, path: '/v1/metrics', body: { @@ -204,6 +234,30 @@ export class CiStatsReporter { bodyDesc: `metrics: ${metrics .map(({ group, id, value }) => `[${group}/${id}=${value}]`) .join(' ')}`, + })); + } + + /** + * Send test reports to ci-stats + */ + async reportTests({ group, testRuns }: CiStatsReportTestsOptions) { + if (!this.config?.buildId || !this.config?.apiToken) { + throw new Error( + 'unable to report tests unless buildId is configured and auth config available' + ); + } + + return await this.req({ + auth: true, + path: '/v1/test_group', + query: { + buildId: this.config?.buildId, + }, + bodyDesc: `[${group.name}/${group.type}] test groups with ${testRuns.length} tests`, + body: [ + JSON.stringify({ group }), + ...testRuns.map((testRun) => JSON.stringify({ testRun })), + ].join('\n'), }); } @@ -241,7 +295,7 @@ export class CiStatsReporter { } } - private async req({ auth, body, bodyDesc, path }: ReqOptions) { + private async req({ auth, body, bodyDesc, path, query }: ReqOptions) { let attempt = 0; const maxAttempts = 5; @@ -251,23 +305,24 @@ export class CiStatsReporter { Authorization: `token ${this.config.apiToken}`, }; } else if (auth) { - throw new Error('this.req() shouldnt be called with auth=true if this.config is defined'); + throw new Error('this.req() shouldnt be called with auth=true if this.config is not defined'); } while (true) { attempt += 1; try { - await Axios.request({ + const resp = await Axios.request({ method: 'POST', url: path, baseURL: BASE_URL, headers, data: body, + params: query, adapter: httpAdapter, }); - return true; + return resp.data; } catch (error) { if (!error?.request) { // not an axios error, must be a usage error that we should notify user about diff --git a/packages/kbn-dev-utils/src/ci_stats_reporter/ci_stats_test_group_types.ts b/packages/kbn-dev-utils/src/ci_stats_reporter/ci_stats_test_group_types.ts new file mode 100644 index 00000000000000..147d4e19325b2d --- /dev/null +++ b/packages/kbn-dev-utils/src/ci_stats_reporter/ci_stats_test_group_types.ts @@ -0,0 +1,90 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import type { CiStatsMetadata } from './ci_stats_reporter'; + +export type CiStatsTestResult = 'fail' | 'pass' | 'skip'; +export type CiStatsTestType = + | 'after all hook' + | 'after each hook' + | 'before all hook' + | 'before each hook' + | 'test'; + +export interface CiStatsTestRun { + /** + * ISO-8601 formatted datetime representing when the tests started running + */ + startTime: string; + /** + * Duration of the tests in milliseconds + */ + durationMs: number; + /** + * A sequence number, this is used to order the tests in a specific test run + */ + seq: number; + /** + * The type of this "test run", usually this is just "test" but when reporting issues in hooks it can be set to the type of hook + */ + type: CiStatsTestType; + /** + * "fail", "pass" or "skip", the result of the tests + */ + result: CiStatsTestResult; + /** + * The list of suite names containing this test, the first being the outermost suite + */ + suites: string[]; + /** + * The name of this specific test run + */ + name: string; + /** + * Relative path from the root of the repo contianing this test + */ + file: string; + /** + * Error message if the test failed + */ + error?: string; + /** + * Debug output/stdout produced by the test + */ + stdout?: string; + /** + * Screenshots captured during the test run + */ + screenshots?: Array<{ + name: string; + base64Png: string; + }>; +} + +export interface CiStatsTestGroupInfo { + /** + * ISO-8601 formatted datetime representing when the group of tests started running + */ + startTime: string; + /** + * The number of miliseconds that the tests ran for + */ + durationMs: number; + /** + * The type of tests run in this group, any value is valid but test groups are groupped by type in the UI so use something consistent + */ + type: string; + /** + * The name of this specific group (within the "type") + */ + name: string; + /** + * Arbitrary metadata associated with this group. We currently look for a ciGroup metadata property for highlighting that when appropriate + */ + meta: CiStatsMetadata; +} diff --git a/packages/kbn-dev-utils/src/ci_stats_reporter/index.ts b/packages/kbn-dev-utils/src/ci_stats_reporter/index.ts index 318a2921517f10..cf80d06613dbf0 100644 --- a/packages/kbn-dev-utils/src/ci_stats_reporter/index.ts +++ b/packages/kbn-dev-utils/src/ci_stats_reporter/index.ts @@ -10,3 +10,4 @@ export * from './ci_stats_reporter'; export type { Config } from './ci_stats_config'; export * from './ship_ci_stats_cli'; export { getTimeReporter } from './report_time'; +export * from './ci_stats_test_group_types'; diff --git a/packages/kbn-es-archiver/BUILD.bazel b/packages/kbn-es-archiver/BUILD.bazel index 06a0ca02da04a7..fed3f248c09957 100644 --- a/packages/kbn-es-archiver/BUILD.bazel +++ b/packages/kbn-es-archiver/BUILD.bazel @@ -45,7 +45,7 @@ RUNTIME_DEPS = [ TYPES_DEPS = [ "//packages/kbn-dev-utils:npm_module_types", - "//packages/kbn-test", + "//packages/kbn-test:npm_module_types", "//packages/kbn-utils:npm_module_types", "@npm//@elastic/elasticsearch", "@npm//aggregate-error", diff --git a/packages/kbn-i18n/GUIDELINE.md b/packages/kbn-i18n/GUIDELINE.md index 7ffc4b078c79b7..98f6f176d0be88 100644 --- a/packages/kbn-i18n/GUIDELINE.md +++ b/packages/kbn-i18n/GUIDELINE.md @@ -506,7 +506,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 `@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`. +When testing such component, use the `shallowWithIntl` helper function defined in `@kbn/test-jest-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`. 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 d4105a5edd7a55..d0fe0f269f6fa5 100644 --- a/packages/kbn-pm/dist/index.js +++ b/packages/kbn-pm/dist/index.js @@ -9049,7 +9049,9 @@ var _ci_stats_config = __webpack_require__(218); */ // @ts-expect-error not "public", but necessary to prevent Jest shimming from breaking things const BASE_URL = 'https://ci-stats.kibana.dev'; +/** Container for metadata that can be attached to different ci-stats objects */ +/** Object that helps report data to the ci-stats service */ class CiStatsReporter { /** * Create a CiStatsReporter by inspecting the ENV for the necessary config @@ -9146,7 +9148,7 @@ class CiStatsReporter { totalMem: _os.default.totalmem() }; this.log.debug('CIStatsReporter committerHash: %s', defaultMeta.committerHash); - return await this.req({ + return !!(await this.req({ auth: !!buildId, path: '/v1/timings', body: { @@ -9156,7 +9158,7 @@ class CiStatsReporter { timings }, bodyDesc: timings.length === 1 ? `${timings.length} timing` : `${timings.length} timings` - }); + })); } /** * Report metrics data to the ci-stats service. If running outside of CI this method @@ -9174,10 +9176,10 @@ class CiStatsReporter { const buildId = (_this$config4 = this.config) === null || _this$config4 === void 0 ? void 0 : _this$config4.buildId; if (!buildId) { - throw new Error(`CiStatsReporter can't be authorized without a buildId`); + throw new Error(`metrics can't be reported without a buildId`); } - return await this.req({ + return !!(await this.req({ auth: true, path: '/v1/metrics', body: { @@ -9190,6 +9192,35 @@ class CiStatsReporter { id, value }) => `[${group}/${id}=${value}]`).join(' ')}` + })); + } + /** + * Send test reports to ci-stats + */ + + + async reportTests({ + group, + testRuns + }) { + var _this$config5, _this$config6, _this$config7; + + if (!((_this$config5 = this.config) !== null && _this$config5 !== void 0 && _this$config5.buildId) || !((_this$config6 = this.config) !== null && _this$config6 !== void 0 && _this$config6.apiToken)) { + throw new Error('unable to report tests unless buildId is configured and auth config available'); + } + + return await this.req({ + auth: true, + path: '/v1/test_group', + query: { + buildId: (_this$config7 = this.config) === null || _this$config7 === void 0 ? void 0 : _this$config7.buildId + }, + bodyDesc: `[${group.name}/${group.type}] test groups with ${testRuns.length} tests`, + body: [JSON.stringify({ + group + }), ...testRuns.map(testRun => JSON.stringify({ + testRun + }))].join('\n') }); } /** @@ -9239,7 +9270,8 @@ class CiStatsReporter { auth, body, bodyDesc, - path + path, + query }) { let attempt = 0; const maxAttempts = 5; @@ -9250,22 +9282,23 @@ class CiStatsReporter { Authorization: `token ${this.config.apiToken}` }; } else if (auth) { - throw new Error('this.req() shouldnt be called with auth=true if this.config is defined'); + throw new Error('this.req() shouldnt be called with auth=true if this.config is not defined'); } while (true) { attempt += 1; try { - await _axios.default.request({ + const resp = await _axios.default.request({ method: 'POST', url: path, baseURL: BASE_URL, headers, data: body, + params: query, adapter: _http.default }); - return true; + return resp.data; } catch (error) { var _error$response; diff --git a/packages/kbn-test-jest-helpers/BUILD.bazel b/packages/kbn-test-jest-helpers/BUILD.bazel new file mode 100644 index 00000000000000..c713e245929449 --- /dev/null +++ b/packages/kbn-test-jest-helpers/BUILD.bazel @@ -0,0 +1,182 @@ +load("@npm//@bazel/typescript:index.bzl", "ts_config") +load("@npm//@babel/cli:index.bzl", "babel") +load("@build_bazel_rules_nodejs//:index.bzl", "js_library") +load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project") + +PKG_BASE_NAME = "kbn-test-jest-helpers" +PKG_REQUIRE_NAME = "@kbn/test-jest-helpers" +TYPES_PKG_REQUIRE_NAME = "@types/kbn__test-jest-helpers" + +SOURCE_FILES = glob( + [ + "src/**/*" + ], + exclude = [ + "**/*.test.*", + "**/*.snap", + "**/__fixture__/**", + "**/__fixtures__/**", + "**/__snapshots__/**", + ] +) + +SRCS = SOURCE_FILES + +filegroup( + name = "srcs", + srcs = SRCS, +) + +NPM_MODULE_EXTRA_FILES = [ + "jest.config.js", + "package.json", +] + +RUNTIME_DEPS = [ + "//packages/kbn-dev-utils", + "//packages/kbn-i18n-react", + "//packages/kbn-std", + "//packages/kbn-utils", + "@npm//@elastic/elasticsearch", + "@npm//axios", + "@npm//@babel/traverse", + "@npm//chance", + "@npm//dedent", + "@npm//del", + "@npm//enzyme", + "@npm//execa", + "@npm//exit-hook", + "@npm//form-data", + "@npm//getopts", + "@npm//globby", + "@npm//he", + "@npm//history", + "@npm//jest", + "@npm//jest-cli", + "@npm//jest-snapshot", + "@npm//jest-styled-components", + "@npm//@jest/reporters", + "@npm//joi", + "@npm//mustache", + "@npm//normalize-path", + "@npm//parse-link-header", + "@npm//prettier", + "@npm//react", + "@npm//react-dom", + "@npm//react-redux", + "@npm//react-router-dom", + "@npm//redux", + "@npm//rxjs", + "@npm//semver", + "@npm//strip-ansi", + "@npm//xmlbuilder", + "@npm//xml2js", +] + +TYPES_DEPS = [ + "//packages/kbn-dev-utils:npm_module_types", + "//packages/kbn-i18n-react:npm_module_types", + "//packages/kbn-std:npm_module_types", + "//packages/kbn-utils:npm_module_types", + "@npm//@elastic/elasticsearch", + "@npm//axios", + "@npm//elastic-apm-node", + "@npm//del", + "@npm//exit-hook", + "@npm//form-data", + "@npm//getopts", + "@npm//jest", + "@npm//jest-cli", + "@npm//jest-snapshot", + "@npm//redux", + "@npm//rxjs", + "@npm//xmlbuilder", + "@npm//@types/chance", + "@npm//@types/dedent", + "@npm//@types/enzyme", + "@npm//@types/he", + "@npm//@types/history", + "@npm//@types/jest", + "@npm//@types/joi", + "@npm//@types/lodash", + "@npm//@types/mustache", + "@npm//@types/normalize-path", + "@npm//@types/node", + "@npm//@types/parse-link-header", + "@npm//@types/prettier", + "@npm//@types/react", + "@npm//@types/react-dom", + "@npm//@types/react-redux", + "@npm//@types/react-router-dom", + "@npm//@types/semver", + "@npm//@types/xml2js", +] + +jsts_transpiler( + name = "target_node", + srcs = SRCS, + build_pkg_name = package_name(), +) + +ts_config( + name = "tsconfig", + src = "tsconfig.json", + deps = [ + "//:tsconfig.base.json", + "//:tsconfig.bazel.json", + ], +) + +ts_project( + name = "tsc_types", + args = ['--pretty'], + srcs = SRCS, + deps = TYPES_DEPS, + declaration = True, + declaration_map = True, + emit_declaration_only = True, + out_dir = "target_types", + source_map = True, + root_dir = "src", + tsconfig = ":tsconfig", +) + +js_library( + name = PKG_BASE_NAME, + srcs = NPM_MODULE_EXTRA_FILES, + deps = RUNTIME_DEPS + [":target_node"], + package_name = PKG_REQUIRE_NAME, + visibility = ["//visibility:public"], +) + +pkg_npm( + name = "npm_module", + deps = [ + ":%s" % PKG_BASE_NAME, + ] +) + +filegroup( + name = "build", + srcs = [ + ":npm_module", + ], + visibility = ["//visibility:public"], +) + +pkg_npm_types( + name = "npm_module_types", + srcs = SRCS, + deps = [":tsc_types"], + package_name = TYPES_PKG_REQUIRE_NAME, + tsconfig = ":tsconfig", + visibility = ["//visibility:public"], +) + +filegroup( + name = "build_types", + srcs = [ + ":npm_module_types", + ], + visibility = ["//visibility:public"], +) diff --git a/packages/kbn-test/src/jest/index.ts b/packages/kbn-test-jest-helpers/jest.config.js similarity index 74% rename from packages/kbn-test/src/jest/index.ts rename to packages/kbn-test-jest-helpers/jest.config.js index a50ff5c59e7986..5c5d5c63959992 100644 --- a/packages/kbn-test/src/jest/index.ts +++ b/packages/kbn-test-jest-helpers/jest.config.js @@ -6,4 +6,8 @@ * Side Public License, v 1. */ -export * from './utils'; +module.exports = { + preset: '@kbn/test', + rootDir: '../..', + roots: ['/packages/kbn-test-jest-helpers'], +}; diff --git a/packages/kbn-test-jest-helpers/package.json b/packages/kbn-test-jest-helpers/package.json new file mode 100644 index 00000000000000..afab6001d605dd --- /dev/null +++ b/packages/kbn-test-jest-helpers/package.json @@ -0,0 +1,10 @@ +{ + "name": "@kbn/test-jest-helpers", + "version": "1.0.0", + "private": true, + "license": "SSPL-1.0 OR Elastic License 2.0", + "main": "./target_node", + "kibana": { + "devOnly": true + } +} diff --git a/packages/kbn-test/src/jest/utils/enzyme_helpers.tsx b/packages/kbn-test-jest-helpers/src/enzyme_helpers.tsx similarity index 98% rename from packages/kbn-test/src/jest/utils/enzyme_helpers.tsx rename to packages/kbn-test-jest-helpers/src/enzyme_helpers.tsx index 696a1d1b63163d..222689d621b5dd 100644 --- a/packages/kbn-test/src/jest/utils/enzyme_helpers.tsx +++ b/packages/kbn-test-jest-helpers/src/enzyme_helpers.tsx @@ -14,6 +14,7 @@ */ import { I18nProvider, InjectedIntl, intlShape, __IntlProvider } from '@kbn/i18n-react'; +// eslint-disable-next-line import/no-extraneous-dependencies import { mount, ReactWrapper, render, shallow } from 'enzyme'; import React, { ReactElement, ValidationMap } from 'react'; import { act as reactAct } from 'react-dom/test-utils'; @@ -118,7 +119,7 @@ export function renderWithIntl( context?: any; childContextTypes?: ValidationMap; } = {} -) { +): any { const options = getOptions(context, childContextTypes, props); return render(nodeWithIntlProp(node), options); diff --git a/packages/kbn-test/src/jest/utils/find_test_subject.ts b/packages/kbn-test-jest-helpers/src/find_test_subject.ts similarity index 97% rename from packages/kbn-test/src/jest/utils/find_test_subject.ts rename to packages/kbn-test-jest-helpers/src/find_test_subject.ts index ef3a744fbd99c5..9d519f5197cd7b 100644 --- a/packages/kbn-test/src/jest/utils/find_test_subject.ts +++ b/packages/kbn-test-jest-helpers/src/find_test_subject.ts @@ -6,6 +6,7 @@ * Side Public License, v 1. */ +// eslint-disable-next-line import/no-extraneous-dependencies import { ReactWrapper } from 'enzyme'; type Matcher = '=' | '~=' | '|=' | '^=' | '$=' | '*='; diff --git a/packages/kbn-test/src/jest/utils/index.ts b/packages/kbn-test-jest-helpers/src/index.ts similarity index 96% rename from packages/kbn-test/src/jest/utils/index.ts rename to packages/kbn-test-jest-helpers/src/index.ts index a797a801eaf94b..3594df854cbe4a 100644 --- a/packages/kbn-test/src/jest/utils/index.ts +++ b/packages/kbn-test-jest-helpers/src/index.ts @@ -8,8 +8,6 @@ export * from './enzyme_helpers'; -export * from './get_url'; - export * from './find_test_subject'; export * from './jsdom_svg_mocks'; diff --git a/packages/kbn-test/src/jest/utils/jsdom_svg_mocks.ts b/packages/kbn-test-jest-helpers/src/jsdom_svg_mocks.ts similarity index 100% rename from packages/kbn-test/src/jest/utils/jsdom_svg_mocks.ts rename to packages/kbn-test-jest-helpers/src/jsdom_svg_mocks.ts diff --git a/packages/kbn-test/src/jest/utils/random.ts b/packages/kbn-test-jest-helpers/src/random.ts similarity index 91% rename from packages/kbn-test/src/jest/utils/random.ts rename to packages/kbn-test-jest-helpers/src/random.ts index 4aa8a30555e0c4..9f4efccf810f8b 100644 --- a/packages/kbn-test/src/jest/utils/random.ts +++ b/packages/kbn-test-jest-helpers/src/random.ts @@ -6,6 +6,7 @@ * Side Public License, v 1. */ +// eslint-disable-next-line import/no-extraneous-dependencies import Chance from 'chance'; const chance = new Chance(); diff --git a/packages/kbn-test/src/jest/utils/redux_helpers.tsx b/packages/kbn-test-jest-helpers/src/redux_helpers.tsx similarity index 100% rename from packages/kbn-test/src/jest/utils/redux_helpers.tsx rename to packages/kbn-test-jest-helpers/src/redux_helpers.tsx diff --git a/packages/kbn-test/src/jest/utils/router_helpers.tsx b/packages/kbn-test-jest-helpers/src/router_helpers.tsx similarity index 100% rename from packages/kbn-test/src/jest/utils/router_helpers.tsx rename to packages/kbn-test-jest-helpers/src/router_helpers.tsx diff --git a/packages/kbn-test/src/jest/utils/stub_browser_storage.test.ts b/packages/kbn-test-jest-helpers/src/stub_browser_storage.test.ts similarity index 100% rename from packages/kbn-test/src/jest/utils/stub_browser_storage.test.ts rename to packages/kbn-test-jest-helpers/src/stub_browser_storage.test.ts diff --git a/packages/kbn-test/src/jest/utils/stub_browser_storage.ts b/packages/kbn-test-jest-helpers/src/stub_browser_storage.ts similarity index 100% rename from packages/kbn-test/src/jest/utils/stub_browser_storage.ts rename to packages/kbn-test-jest-helpers/src/stub_browser_storage.ts diff --git a/packages/kbn-test/src/jest/utils/stub_web_worker.ts b/packages/kbn-test-jest-helpers/src/stub_web_worker.ts similarity index 100% rename from packages/kbn-test/src/jest/utils/stub_web_worker.ts rename to packages/kbn-test-jest-helpers/src/stub_web_worker.ts diff --git a/packages/kbn-test/src/jest/utils/testbed/README.md b/packages/kbn-test-jest-helpers/src/testbed/README.md similarity index 100% rename from packages/kbn-test/src/jest/utils/testbed/README.md rename to packages/kbn-test-jest-helpers/src/testbed/README.md diff --git a/packages/kbn-test/src/jest/utils/testbed/index.ts b/packages/kbn-test-jest-helpers/src/testbed/index.ts similarity index 96% rename from packages/kbn-test/src/jest/utils/testbed/index.ts rename to packages/kbn-test-jest-helpers/src/testbed/index.ts index a283bfc53f4efc..f063f5003fd1cb 100644 --- a/packages/kbn-test/src/jest/utils/testbed/index.ts +++ b/packages/kbn-test-jest-helpers/src/testbed/index.ts @@ -14,4 +14,5 @@ export type { SetupFunc, SyncSetupFunc, AsyncSetupFunc, + EuiTableMetaData, } from './types'; diff --git a/packages/kbn-test/src/jest/utils/testbed/mount_component.tsx b/packages/kbn-test-jest-helpers/src/testbed/mount_component.tsx similarity index 97% rename from packages/kbn-test/src/jest/utils/testbed/mount_component.tsx rename to packages/kbn-test-jest-helpers/src/testbed/mount_component.tsx index 2ac482abc0fb2e..5c5fd3f2237d1c 100644 --- a/packages/kbn-test/src/jest/utils/testbed/mount_component.tsx +++ b/packages/kbn-test-jest-helpers/src/testbed/mount_component.tsx @@ -8,6 +8,7 @@ import React, { ComponentType } from 'react'; import { Store } from 'redux'; +// eslint-disable-next-line import/no-extraneous-dependencies import { ReactWrapper } from 'enzyme'; import { act } from 'react-dom/test-utils'; diff --git a/packages/kbn-test/src/jest/utils/testbed/testbed.ts b/packages/kbn-test-jest-helpers/src/testbed/testbed.ts similarity index 98% rename from packages/kbn-test/src/jest/utils/testbed/testbed.ts rename to packages/kbn-test-jest-helpers/src/testbed/testbed.ts index b10f331da10d61..87efb9e61b3459 100644 --- a/packages/kbn-test/src/jest/utils/testbed/testbed.ts +++ b/packages/kbn-test-jest-helpers/src/testbed/testbed.ts @@ -7,6 +7,7 @@ */ import { Component as ReactComponent } from 'react'; +// eslint-disable-next-line import/no-extraneous-dependencies import { ComponentType, HTMLAttributes, ReactWrapper } from 'enzyme'; import { findTestSubject } from '../find_test_subject'; @@ -41,7 +42,7 @@ const defaultConfig: TestBedConfig = { * * @example ```typescript - import { registerTestBed } from '@kbn/test/jest'; + import { registerTestBed } from '@kbn/test-jest-helpers'; import { RemoteClusterList } from '../../app/sections/remote_cluster_list'; import { remoteClustersStore } from '../../app/store'; diff --git a/packages/kbn-test/src/jest/utils/testbed/types.ts b/packages/kbn-test-jest-helpers/src/testbed/types.ts similarity index 99% rename from packages/kbn-test/src/jest/utils/testbed/types.ts rename to packages/kbn-test-jest-helpers/src/testbed/types.ts index 11f8c802a97518..ff548f3af5f585 100644 --- a/packages/kbn-test/src/jest/utils/testbed/types.ts +++ b/packages/kbn-test-jest-helpers/src/testbed/types.ts @@ -7,6 +7,7 @@ */ import { Store } from 'redux'; +// eslint-disable-next-line import/no-extraneous-dependencies import { ReactWrapper as GenericReactWrapper } from 'enzyme'; import { LocationDescriptor } from 'history'; diff --git a/packages/kbn-test-jest-helpers/tsconfig.json b/packages/kbn-test-jest-helpers/tsconfig.json new file mode 100644 index 00000000000000..7a1121c9e91f13 --- /dev/null +++ b/packages/kbn-test-jest-helpers/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.bazel.json", + "compilerOptions": { + "declaration": true, + "declarationMap": true, + "emitDeclarationOnly": true, + "outDir": "./target_types", + "stripInternal": true, + "rootDir": "src", + "sourceMap": true, + "sourceRoot": "../../../../../../packages/kbn-test-jest-helpers/src", + "types": ["jest", "node"] + }, + "include": ["src/**/*"], + "exclude": ["**/__fixtures__/**/*"] +} diff --git a/packages/kbn-test/BUILD.bazel b/packages/kbn-test/BUILD.bazel index 69addd9e3c4c7c..33d299058168db 100644 --- a/packages/kbn-test/BUILD.bazel +++ b/packages/kbn-test/BUILD.bazel @@ -1,10 +1,11 @@ -load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project") +load("@npm//@bazel/typescript:index.bzl", "ts_config") load("@npm//@babel/cli:index.bzl", "babel") -load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm") -load("//src/dev/bazel:index.bzl", "jsts_transpiler") +load("@build_bazel_rules_nodejs//:index.bzl", "js_library") +load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project") PKG_BASE_NAME = "kbn-test" PKG_REQUIRE_NAME = "@kbn/test" +TYPES_PKG_REQUIRE_NAME = "@types/kbn__test" SOURCE_FILES = glob( [ @@ -27,7 +28,6 @@ filegroup( ) NPM_MODULE_EXTRA_FILES = [ - "jest/package.json", "jest-preset.js", "jest_integration/jest-preset.js", "jest.config.js", @@ -41,8 +41,10 @@ RUNTIME_DEPS = [ "//packages/kbn-std", "//packages/kbn-utils", "@npm//@elastic/elasticsearch", - "@npm//axios", "@npm//@babel/traverse", + "@npm//@jest/console", + "@npm//@jest/reporters", + "@npm//axios", "@npm//chance", "@npm//dedent", "@npm//del", @@ -58,7 +60,6 @@ RUNTIME_DEPS = [ "@npm//jest-cli", "@npm//jest-snapshot", "@npm//jest-styled-components", - "@npm//@jest/reporters", "@npm//joi", "@npm//mustache", "@npm//normalize-path", @@ -79,8 +80,10 @@ TYPES_DEPS = [ "//packages/kbn-dev-utils:npm_module_types", "//packages/kbn-i18n-react:npm_module_types", "//packages/kbn-std:npm_module_types", - "//packages/kbn-utils", + "//packages/kbn-utils:npm_module_types", "@npm//@elastic/elasticsearch", + "@npm//@jest/console", + "@npm//@jest/reporters", "@npm//axios", "@npm//elastic-apm-node", "@npm//del", @@ -145,7 +148,7 @@ ts_project( js_library( name = PKG_BASE_NAME, srcs = NPM_MODULE_EXTRA_FILES, - deps = RUNTIME_DEPS + [":target_node", ":tsc_types"], + deps = RUNTIME_DEPS + [":target_node"], package_name = PKG_REQUIRE_NAME, visibility = ["//visibility:public"], ) @@ -164,3 +167,20 @@ filegroup( ], visibility = ["//visibility:public"], ) + +pkg_npm_types( + name = "npm_module_types", + srcs = SRCS, + deps = [":tsc_types"], + package_name = TYPES_PKG_REQUIRE_NAME, + tsconfig = ":tsconfig", + visibility = ["//visibility:public"], +) + +filegroup( + name = "build_types", + srcs = [ + ":npm_module_types", + ], + visibility = ["//visibility:public"], +) diff --git a/packages/kbn-test/jest-preset.js b/packages/kbn-test/jest-preset.js index e2607100babc5a..3c9b222e98df5e 100644 --- a/packages/kbn-test/jest-preset.js +++ b/packages/kbn-test/jest-preset.js @@ -55,6 +55,12 @@ module.exports = { rootDirectory: '.', }, ], + [ + '@kbn/test/target_node/jest/ci_stats_jest_reporter', + { + testGroupType: 'Jest Unit Tests', + }, + ], ], // The paths to modules that run some code to configure or set up the testing environment before each test diff --git a/packages/kbn-test/jest/package.json b/packages/kbn-test/jest/package.json deleted file mode 100644 index aa0ba838736845..00000000000000 --- a/packages/kbn-test/jest/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "main": "../target_node/jest", - "types": "../target_types/jest/index.d.ts" -} diff --git a/packages/kbn-test/jest_integration/jest-preset.js b/packages/kbn-test/jest_integration/jest-preset.js index 7504dec9e7a20f..be007262477d32 100644 --- a/packages/kbn-test/jest_integration/jest-preset.js +++ b/packages/kbn-test/jest_integration/jest-preset.js @@ -21,6 +21,12 @@ module.exports = { reporters: [ 'default', ['@kbn/test/target_node/jest/junit_reporter', { reportName: 'Jest Integration Tests' }], + [ + '@kbn/test/target_node/jest/ci_stats_jest_reporter', + { + testGroupType: 'Jest Integration Tests', + }, + ], ], coverageReporters: !!process.env.CI ? [['json', { file: 'jest-integration.json' }]] diff --git a/packages/kbn-test/package.json b/packages/kbn-test/package.json index a94b3198e24a49..5f5e475e392c45 100644 --- a/packages/kbn-test/package.json +++ b/packages/kbn-test/package.json @@ -5,7 +5,6 @@ "private": true, "license": "SSPL-1.0 OR Elastic License 2.0", "main": "./target_node", - "types": "./target_types", "kibana": { "devOnly": true } diff --git a/packages/kbn-test/src/functional_test_runner/functional_test_runner.ts b/packages/kbn-test/src/functional_test_runner/functional_test_runner.ts index ea55a2672d670f..85c474c2f1bec8 100644 --- a/packages/kbn-test/src/functional_test_runner/functional_test_runner.ts +++ b/packages/kbn-test/src/functional_test_runner/functional_test_runner.ts @@ -13,7 +13,7 @@ import { Suite, Test } from './fake_mocha_types'; import { Lifecycle, LifecyclePhase, - FailureMetadata, + TestMetadata, readConfigFile, ProviderCollection, readProviderSpec, @@ -27,7 +27,7 @@ import { export class FunctionalTestRunner { public readonly lifecycle = new Lifecycle(); - public readonly failureMetadata = new FailureMetadata(this.lifecycle); + public readonly testMetadata = new TestMetadata(this.lifecycle); private closed = false; private readonly esVersion: EsVersion; @@ -181,7 +181,7 @@ export class FunctionalTestRunner { const coreProviders = readProviderSpec('Service', { lifecycle: () => this.lifecycle, log: () => this.log, - failureMetadata: () => this.failureMetadata, + testMetadata: () => this.testMetadata, config: () => config, dockerServers: () => dockerServers, esVersion: () => this.esVersion, diff --git a/packages/kbn-test/src/functional_test_runner/index.ts b/packages/kbn-test/src/functional_test_runner/index.ts index 1718b5f7a4bc57..e67e72fd5801ab 100644 --- a/packages/kbn-test/src/functional_test_runner/index.ts +++ b/packages/kbn-test/src/functional_test_runner/index.ts @@ -7,7 +7,8 @@ */ export { FunctionalTestRunner } from './functional_test_runner'; -export { readConfigFile, Config, EsVersion } from './lib'; +export { readConfigFile, Config, EsVersion, Lifecycle, LifecyclePhase } from './lib'; +export type { ScreenshotRecord } from './lib'; export { runFtrCli } from './cli'; export * from './lib/docker_servers'; export * from './public_types'; diff --git a/packages/kbn-test/src/functional_test_runner/integration_tests/__fixtures__/failure_hooks/config.js b/packages/kbn-test/src/functional_test_runner/integration_tests/__fixtures__/failure_hooks/config.js index 1375e5a3df2fd5..6e25e4c073ab0b 100644 --- a/packages/kbn-test/src/functional_test_runner/integration_tests/__fixtures__/failure_hooks/config.js +++ b/packages/kbn-test/src/functional_test_runner/integration_tests/__fixtures__/failure_hooks/config.js @@ -35,6 +35,7 @@ export default function () { }, mochaReporter: { captureLogOutput: false, + sendToCiStats: false, }, }; } diff --git a/packages/kbn-test/src/functional_test_runner/integration_tests/__fixtures__/simple_project/config.js b/packages/kbn-test/src/functional_test_runner/integration_tests/__fixtures__/simple_project/config.js index 7163058b785236..4c87b53b5753b2 100644 --- a/packages/kbn-test/src/functional_test_runner/integration_tests/__fixtures__/simple_project/config.js +++ b/packages/kbn-test/src/functional_test_runner/integration_tests/__fixtures__/simple_project/config.js @@ -10,4 +10,7 @@ import { resolve } from 'path'; export default () => ({ testFiles: [resolve(__dirname, 'tests.js')], + mochaReporter: { + sendToCiStats: false, + }, }); diff --git a/packages/kbn-test/src/functional_test_runner/lib/config/config.ts b/packages/kbn-test/src/functional_test_runner/lib/config/config.ts index 1d4af9c33fb79b..d6248b9628e732 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/config/config.ts +++ b/packages/kbn-test/src/functional_test_runner/lib/config/config.ts @@ -20,6 +20,7 @@ interface Options { } export class Config { + public readonly path: string; private [$values]: Record; constructor(options: Options) { @@ -29,6 +30,7 @@ export class Config { throw new TypeError('path is a required option'); } + this.path = path; const { error, value } = schema.validate(settings, { abortEarly: false, context: { diff --git a/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts b/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts index a9ceaa643a60f3..e51ebc45383432 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts +++ b/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts @@ -152,6 +152,7 @@ export const schema = Joi.object() mochaReporter: Joi.object() .keys({ captureLogOutput: Joi.boolean().default(!!process.env.CI), + sendToCiStats: Joi.boolean().default(!!process.env.CI), }) .default(), diff --git a/packages/kbn-test/src/functional_test_runner/lib/failure_metadata.test.ts b/packages/kbn-test/src/functional_test_runner/lib/failure_metadata.test.ts deleted file mode 100644 index b40f6a5c836880..00000000000000 --- a/packages/kbn-test/src/functional_test_runner/lib/failure_metadata.test.ts +++ /dev/null @@ -1,61 +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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import { Lifecycle } from './lifecycle'; -import { FailureMetadata } from './failure_metadata'; -import { Test } from '../fake_mocha_types'; - -it('collects metadata for the current test', async () => { - const lifecycle = new Lifecycle(); - const failureMetadata = new FailureMetadata(lifecycle); - - const test1 = {} as Test; - await lifecycle.beforeEachRunnable.trigger(test1); - failureMetadata.add({ foo: 'bar' }); - - expect(failureMetadata.get(test1)).toMatchInlineSnapshot(` - Object { - "foo": "bar", - } - `); - - const test2 = {} as Test; - await lifecycle.beforeEachRunnable.trigger(test2); - failureMetadata.add({ test: 2 }); - - expect(failureMetadata.get(test1)).toMatchInlineSnapshot(` - Object { - "foo": "bar", - } - `); - expect(failureMetadata.get(test2)).toMatchInlineSnapshot(` - Object { - "test": 2, - } - `); -}); - -it('adds messages to the messages state', () => { - const lifecycle = new Lifecycle(); - const failureMetadata = new FailureMetadata(lifecycle); - - const test1 = {} as Test; - lifecycle.beforeEachRunnable.trigger(test1); - failureMetadata.addMessages(['foo', 'bar']); - failureMetadata.addMessages(['baz']); - - expect(failureMetadata.get(test1)).toMatchInlineSnapshot(` - Object { - "messages": Array [ - "foo", - "bar", - "baz", - ], - } - `); -}); diff --git a/packages/kbn-test/src/functional_test_runner/lib/failure_metadata.ts b/packages/kbn-test/src/functional_test_runner/lib/failure_metadata.ts deleted file mode 100644 index a766c73f4c727f..00000000000000 --- a/packages/kbn-test/src/functional_test_runner/lib/failure_metadata.ts +++ /dev/null @@ -1,93 +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 - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import Path from 'path'; - -import { REPO_ROOT } from '@kbn/utils'; - -import { Lifecycle } from './lifecycle'; - -interface Metadata { - [key: string]: unknown; -} - -export class FailureMetadata { - // mocha's global types mean we can't import Mocha or it will override the global jest types.............. - private currentRunnable?: any; - private readonly allMetadata = new Map(); - - constructor(lifecycle: Lifecycle) { - if (!process.env.GCS_UPLOAD_PREFIX && process.env.CI) { - throw new Error( - 'GCS_UPLOAD_PREFIX environment variable is not set and must always be set on CI' - ); - } - - lifecycle.beforeEachRunnable.add((runnable) => { - this.currentRunnable = runnable; - }); - } - - add(metadata: Metadata | ((current: Metadata) => Metadata)) { - if (!this.currentRunnable) { - throw new Error('no current runnable to associate metadata with'); - } - - const current = this.allMetadata.get(this.currentRunnable); - this.allMetadata.set(this.currentRunnable, { - ...current, - ...(typeof metadata === 'function' ? metadata(current || {}) : metadata), - }); - } - - addMessages(messages: string[]) { - this.add((current) => ({ - messages: [...(Array.isArray(current.messages) ? current.messages : []), ...messages], - })); - } - - /** - * @param name Name to label the URL with - * @param repoPath absolute path, within the repo, that will be uploaded - */ - addScreenshot(name: string, repoPath: string) { - const prefix = process.env.GCS_UPLOAD_PREFIX; - - if (!prefix) { - return; - } - - const slash = prefix.endsWith('/') ? '' : '/'; - const urlPath = Path.relative(REPO_ROOT, repoPath) - .split(Path.sep) - .map((c) => encodeURIComponent(c)) - .join('/'); - - if (urlPath.startsWith('..')) { - throw new Error( - `Only call addUploadLink() with paths that are within the repo root, received ${repoPath} and repo root is ${REPO_ROOT}` - ); - } - - const url = `https://storage.googleapis.com/${prefix}${slash}${urlPath}`; - const screenshot = { - name, - url, - }; - - this.add((current) => ({ - screenshots: [...(Array.isArray(current.screenshots) ? current.screenshots : []), screenshot], - })); - - return screenshot; - } - - get(runnable: any) { - return this.allMetadata.get(runnable); - } -} diff --git a/packages/kbn-test/src/functional_test_runner/lib/index.ts b/packages/kbn-test/src/functional_test_runner/lib/index.ts index 98b5fec0597e4e..e387fd156fe8ab 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/index.ts +++ b/packages/kbn-test/src/functional_test_runner/lib/index.ts @@ -12,7 +12,7 @@ export { readConfigFile, Config } from './config'; export { readProviderSpec, ProviderCollection } from './providers'; // @internal export { runTests, setupMocha } from './mocha'; -export { FailureMetadata } from './failure_metadata'; +export * from './test_metadata'; export * from './docker_servers'; export { SuiteTracker } from './suite_tracker'; diff --git a/packages/kbn-test/src/functional_test_runner/lib/lifecycle.ts b/packages/kbn-test/src/functional_test_runner/lib/lifecycle.ts index 17dcaa8d7447d9..e683ec23a8d84b 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/lifecycle.ts +++ b/packages/kbn-test/src/functional_test_runner/lib/lifecycle.ts @@ -11,15 +11,23 @@ import { LifecyclePhase } from './lifecycle_phase'; import { Suite, Test } from '../fake_mocha_types'; export class Lifecycle { + /** lifecycle phase that will run handlers once before tests execute */ public readonly beforeTests = new LifecyclePhase<[Suite]>({ singular: true, }); + /** lifecycle phase that runs handlers before each runnable (test and hooks) */ public readonly beforeEachRunnable = new LifecyclePhase<[Test]>(); + /** lifecycle phase that runs handlers before each suite */ public readonly beforeTestSuite = new LifecyclePhase<[Suite]>(); + /** lifecycle phase that runs handlers before each test */ public readonly beforeEachTest = new LifecyclePhase<[Test]>(); + /** lifecycle phase that runs handlers after each suite */ public readonly afterTestSuite = new LifecyclePhase<[Suite]>(); + /** lifecycle phase that runs handlers after a test fails */ public readonly testFailure = new LifecyclePhase<[Error, Test]>(); + /** lifecycle phase that runs handlers after a hook fails */ public readonly testHookFailure = new LifecyclePhase<[Error, Test]>(); + /** lifecycle phase that runs handlers at the very end of execution */ public readonly cleanup = new LifecyclePhase<[]>({ singular: true, }); diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/ci_stats_ftr_reporter.ts b/packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/ci_stats_ftr_reporter.ts new file mode 100644 index 00000000000000..61eb7eccce4303 --- /dev/null +++ b/packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/ci_stats_ftr_reporter.ts @@ -0,0 +1,157 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import * as Path from 'path'; + +import { REPO_ROOT } from '@kbn/utils'; +import { CiStatsReporter, CiStatsReportTestsOptions, CiStatsTestType } from '@kbn/dev-utils'; + +import { Config } from '../../config'; +import { Runner } from '../../../fake_mocha_types'; +import { TestMetadata, ScreenshotRecord } from '../../test_metadata'; +import { Lifecycle } from '../../lifecycle'; +import { getSnapshotOfRunnableLogs } from '../../../../mocha'; + +interface Suite { + _beforeAll: Runnable[]; + _beforeEach: Runnable[]; + _afterEach: Runnable[]; + _afterAll: Runnable[]; +} + +interface Runnable { + isFailed(): boolean; + isPending(): boolean; + duration?: number; + titlePath(): string[]; + file: string; + title: string; + parent: Suite; + _screenshots?: ScreenshotRecord[]; +} + +function getHookType(hook: Runnable): CiStatsTestType { + if (hook.parent._afterAll.includes(hook)) { + return 'after all hook'; + } + if (hook.parent._afterEach.includes(hook)) { + return 'after each hook'; + } + if (hook.parent._beforeEach.includes(hook)) { + return 'before each hook'; + } + if (hook.parent._beforeAll.includes(hook)) { + return 'before all hook'; + } + + throw new Error(`unable to determine hook type, hook is not owned by it's parent`); +} + +export function setupCiStatsFtrTestGroupReporter({ + config, + lifecycle, + runner, + testMetadata, + reporter, +}: { + config: Config; + lifecycle: Lifecycle; + runner: Runner; + testMetadata: TestMetadata; + reporter: CiStatsReporter; +}) { + let startMs: number | undefined; + runner.on('start', () => { + startMs = Date.now(); + }); + + const start = Date.now(); + const group: CiStatsReportTestsOptions['group'] = { + startTime: new Date(start).toJSON(), + durationMs: 0, + type: config.path.startsWith('x-pack') ? 'X-Pack Functional Tests' : 'Functional Tests', + name: Path.relative(REPO_ROOT, config.path), + meta: { + ciGroup: config.get('suiteTags.include').find((t: string) => t.startsWith('ciGroup')), + tags: [ + ...config.get('suiteTags.include'), + ...config.get('suiteTags.exclude').map((t: string) => `-${t}`), + ].filter((t) => !t.startsWith('ciGroup')), + }, + }; + + const testRuns: CiStatsReportTestsOptions['testRuns'] = []; + function trackRunnable( + runnable: Runnable, + { error, type }: { error?: Error; type: CiStatsTestType } + ) { + testRuns.push({ + startTime: new Date(Date.now() - (runnable.duration ?? 0)).toJSON(), + durationMs: runnable.duration ?? 0, + seq: testRuns.length + 1, + file: Path.relative(REPO_ROOT, runnable.file), + name: runnable.title, + suites: runnable.titlePath().slice(0, -1), + result: runnable.isFailed() ? 'fail' : runnable.isPending() ? 'skip' : 'pass', + type, + error: error?.stack, + stdout: getSnapshotOfRunnableLogs(runnable), + screenshots: testMetadata.getScreenshots(runnable).map((s) => ({ + base64Png: s.base64Png, + name: s.name, + })), + }); + } + + const errors = new Map(); + runner.on('fail', (test: Runnable, error: Error) => { + errors.set(test, error); + }); + + runner.on('hook end', (hook: Runnable) => { + if (hook.isFailed()) { + const error = errors.get(hook); + if (!error) { + throw new Error(`no error recorded for failed hook`); + } + + trackRunnable(hook, { + type: getHookType(hook), + error, + }); + } + }); + + runner.on('test end', (test: Runnable) => { + const error = errors.get(test); + if (test.isFailed() && !error) { + throw new Error('no error recorded for failed test'); + } + + trackRunnable(test, { + type: 'test', + error, + }); + }); + + runner.on('end', () => { + if (!startMs) { + throw new Error('startMs was not defined'); + } + + // update the durationMs + group.durationMs = Date.now() - startMs; + }); + + lifecycle.cleanup.add(async () => { + await reporter.reportTests({ + group, + testRuns, + }); + }); +} diff --git a/packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/reporter.js b/packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/reporter.js index d6045b71bf3a78..84299cba14eaa9 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/reporter.js +++ b/packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/reporter.js @@ -9,7 +9,7 @@ import { format } from 'util'; import Mocha from 'mocha'; -import { ToolingLogTextWriter } from '@kbn/dev-utils'; +import { ToolingLogTextWriter, CiStatsReporter } from '@kbn/dev-utils'; import moment from 'moment'; import { recordLog, snapshotLogsForRunnable, setupJUnitReportGeneration } from '../../../../mocha'; @@ -17,11 +17,13 @@ import * as colors from './colors'; import * as symbols from './symbols'; import { ms } from './ms'; import { writeEpilogue } from './write_epilogue'; +import { setupCiStatsFtrTestGroupReporter } from './ci_stats_ftr_reporter'; export function MochaReporterProvider({ getService }) { const log = getService('log'); const config = getService('config'); - const failureMetadata = getService('failureMetadata'); + const lifecycle = getService('lifecycle'); + const testMetadata = getService('testMetadata'); let originalLogWriters; let reporterCaptureStartTime; @@ -45,9 +47,23 @@ export function MochaReporterProvider({ getService }) { if (config.get('junit.enabled') && config.get('junit.reportName')) { setupJUnitReportGeneration(runner, { reportName: config.get('junit.reportName'), - getTestMetadata: (t) => failureMetadata.get(t), }); } + + if (config.get('mochaReporter.sendToCiStats')) { + const reporter = CiStatsReporter.fromEnv(log); + if (!reporter.hasBuildConfig()) { + log.warning('ci-stats reporter config is not available so test results will not be sent'); + } else { + setupCiStatsFtrTestGroupReporter({ + reporter, + config, + lifecycle, + runner, + testMetadata, + }); + } + } } onStart = () => { diff --git a/packages/kbn-test/src/functional_test_runner/lib/test_metadata.ts b/packages/kbn-test/src/functional_test_runner/lib/test_metadata.ts new file mode 100644 index 00000000000000..5789231f87044d --- /dev/null +++ b/packages/kbn-test/src/functional_test_runner/lib/test_metadata.ts @@ -0,0 +1,41 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { Lifecycle } from './lifecycle'; + +export interface ScreenshotRecord { + name: string; + base64Png: string; + baselinePath?: string; + failurePath?: string; +} + +export class TestMetadata { + // mocha's global types mean we can't import Mocha or it will override the global jest types.............. + private currentRunnable?: any; + + constructor(lifecycle: Lifecycle) { + lifecycle.beforeEachRunnable.add((runnable) => { + this.currentRunnable = runnable; + }); + } + + addScreenshot(screenshot: ScreenshotRecord) { + this.currentRunnable._screenshots = (this.currentRunnable._screenshots || []).concat( + screenshot + ); + } + + getScreenshots(test: any): ScreenshotRecord[] { + if (!test || typeof test !== 'object' || !test._screenshots) { + return []; + } + + return test._screenshots.slice(); + } +} diff --git a/packages/kbn-test/src/functional_test_runner/public_types.ts b/packages/kbn-test/src/functional_test_runner/public_types.ts index 6cb6d5adf4b191..426fdda74d3130 100644 --- a/packages/kbn-test/src/functional_test_runner/public_types.ts +++ b/packages/kbn-test/src/functional_test_runner/public_types.ts @@ -8,10 +8,10 @@ import type { ToolingLog } from '@kbn/dev-utils'; -import type { Config, Lifecycle, FailureMetadata, DockerServersService, EsVersion } from './lib'; +import type { Config, Lifecycle, TestMetadata, DockerServersService, EsVersion } from './lib'; import type { Test, Suite } from './fake_mocha_types'; -export { Lifecycle, Config, FailureMetadata }; +export { Lifecycle, Config, TestMetadata }; export interface AsyncInstance { /** @@ -57,7 +57,7 @@ export interface GenericFtrProviderContext< * @param serviceName */ hasService( - serviceName: 'config' | 'log' | 'lifecycle' | 'failureMetadata' | 'dockerServers' | 'esVersion' + serviceName: 'config' | 'log' | 'lifecycle' | 'testMetadata' | 'dockerServers' | 'esVersion' ): true; hasService(serviceName: K): serviceName is K; hasService(serviceName: string): serviceName is Extract; @@ -71,7 +71,7 @@ export interface GenericFtrProviderContext< getService(serviceName: 'log'): ToolingLog; getService(serviceName: 'lifecycle'): Lifecycle; getService(serviceName: 'dockerServers'): DockerServersService; - getService(serviceName: 'failureMetadata'): FailureMetadata; + getService(serviceName: 'testMetadata'): TestMetadata; getService(serviceName: 'esVersion'): EsVersion; getService(serviceName: T): ServiceMap[T]; diff --git a/packages/kbn-test/src/index.ts b/packages/kbn-test/src/index.ts index a3772665b88910..b619a9eb9208ab 100644 --- a/packages/kbn-test/src/index.ts +++ b/packages/kbn-test/src/index.ts @@ -49,7 +49,7 @@ export { CI_PARALLEL_PROCESS_PREFIX } from './ci_parallel_process_prefix'; export * from './functional_test_runner'; -export { getUrl } from './jest/utils/get_url'; +export { getUrl } from './jest/get_url'; export { runCheckJestConfigsCli } from './jest/run_check_jest_configs_cli'; diff --git a/packages/kbn-test/src/jest/ci_stats_jest_reporter.ts b/packages/kbn-test/src/jest/ci_stats_jest_reporter.ts new file mode 100644 index 00000000000000..94675d87a3a24a --- /dev/null +++ b/packages/kbn-test/src/jest/ci_stats_jest_reporter.ts @@ -0,0 +1,120 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import * as Path from 'path'; + +import getopts from 'getopts'; +import { CiStatsReporter, ToolingLog, CiStatsReportTestsOptions } from '@kbn/dev-utils'; +import type { Config } from '@jest/types'; +import { BaseReporter, Test, TestResult } from '@jest/reporters'; +import { ConsoleBuffer } from '@jest/console'; + +type LogEntry = ConsoleBuffer[0]; + +interface ReporterOptions { + testGroupType: string; +} + +function formatConsoleLine({ type, message, origin }: LogEntry) { + const originLines = origin.split('\n'); + + return `console.${type}: ${message}${originLines[0] ? `\n ${originLines[0]}` : ''}`; +} + +/** + * Jest reporter that reports tests to CI Stats + * @class JestJUnitReporter + */ + +// eslint-disable-next-line import/no-default-export +export default class CiStatsJestReporter extends BaseReporter { + private reporter: CiStatsReporter | undefined; + private readonly testGroupType: string; + private readonly reportName: string; + private readonly rootDir: string; + private startTime: number | undefined; + + private group: CiStatsReportTestsOptions['group'] | undefined; + private readonly testRuns: CiStatsReportTestsOptions['testRuns'] = []; + + constructor(config: Config.GlobalConfig, options: ReporterOptions) { + super(); + + this.rootDir = config.rootDir; + this.testGroupType = options?.testGroupType; + if (!this.testGroupType) { + throw new Error('missing testGroupType reporter option'); + } + + const configArg = getopts(process.argv).config; + if (typeof configArg !== 'string') { + throw new Error('expected to find a single --config arg'); + } + this.reportName = configArg; + } + + async onRunStart() { + const reporter = CiStatsReporter.fromEnv( + new ToolingLog({ + level: 'info', + writeTo: process.stdout, + }) + ); + + if (!reporter.hasBuildConfig()) { + return; + } + + this.startTime = Date.now(); + this.reporter = reporter; + this.group = { + name: this.reportName, + type: this.testGroupType, + startTime: new Date(this.startTime).toJSON(), + meta: {}, + durationMs: 0, + }; + } + + async onTestFileResult(_: Test, testResult: TestResult) { + if (!this.reporter || !this.group) { + return; + } + + let elapsedTime = 0; + for (const t of testResult.testResults) { + const startTime = new Date(testResult.perfStats.start + elapsedTime).toJSON(); + elapsedTime += t.duration ?? 0; + this.testRuns.push({ + startTime, + durationMs: t.duration ?? 0, + seq: this.testRuns.length + 1, + file: Path.relative(this.rootDir, testResult.testFilePath), + name: t.title, + result: t.status === 'failed' ? 'fail' : t.status === 'passed' ? 'pass' : 'skip', + suites: t.ancestorTitles, + type: 'test', + error: t.failureMessages.join('\n\n'), + stdout: testResult.console?.map(formatConsoleLine).join('\n'), + }); + } + } + + async onRunComplete() { + if (!this.reporter || !this.group || !this.testRuns.length || !this.startTime) { + return; + } + + this.group.durationMs = Date.now() - this.startTime; + + await this.reporter.reportTests({ + group: this.group, + testRuns: this.testRuns, + }); + } +} diff --git a/packages/kbn-test/src/jest/utils/get_url.test.ts b/packages/kbn-test/src/jest/get_url.test.ts similarity index 100% rename from packages/kbn-test/src/jest/utils/get_url.test.ts rename to packages/kbn-test/src/jest/get_url.test.ts diff --git a/packages/kbn-test/src/jest/utils/get_url.ts b/packages/kbn-test/src/jest/get_url.ts similarity index 100% rename from packages/kbn-test/src/jest/utils/get_url.ts rename to packages/kbn-test/src/jest/get_url.ts diff --git a/packages/kbn-test/src/mocha/index.ts b/packages/kbn-test/src/mocha/index.ts index 4ada51c7ae0132..1be65d60a98422 100644 --- a/packages/kbn-test/src/mocha/index.ts +++ b/packages/kbn-test/src/mocha/index.ts @@ -11,7 +11,7 @@ export { setupJUnitReportGeneration } from './junit_report_generation'; // @ts-ignore not typed yet // @internal -export { recordLog, snapshotLogsForRunnable } from './log_cache'; +export { recordLog, snapshotLogsForRunnable, getSnapshotOfRunnableLogs } from './log_cache'; // @ts-ignore not typed yet // @internal export { escapeCdata } from './xml'; diff --git a/src/core/public/application/ui/app_container.test.tsx b/src/core/public/application/ui/app_container.test.tsx index 9fc07530a00959..4434f6c1751e0b 100644 --- a/src/core/public/application/ui/app_container.test.tsx +++ b/src/core/public/application/ui/app_container.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { themeServiceMock } from '../../theme/theme_service.mock'; import { AppContainer } from './app_container'; 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 abc2fb5cc3356f..0102343ca6eb7e 100644 --- a/src/core/public/chrome/ui/header/collapsible_nav.test.tsx +++ b/src/core/public/chrome/ui/header/collapsible_nav.test.tsx @@ -10,7 +10,7 @@ import { mount, ReactWrapper } from 'enzyme'; import React from 'react'; import { BehaviorSubject } from 'rxjs'; import sinon from 'sinon'; -import { StubBrowserStorage } from '@kbn/test/jest'; +import { StubBrowserStorage } from '@kbn/test-jest-helpers'; 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 2692f2dbd194f0..4790dec0f35159 100644 --- a/src/core/public/chrome/ui/header/header.test.tsx +++ b/src/core/public/chrome/ui/header/header.test.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; import { BehaviorSubject } from 'rxjs'; -import { StubBrowserStorage, mountWithIntl } from '@kbn/test/jest'; +import { StubBrowserStorage, mountWithIntl } from '@kbn/test-jest-helpers'; import { httpServiceMock } from '../../../http/http_service.mock'; import { applicationServiceMock } from '../../../mocks'; import { Header } from './header'; diff --git a/src/core/public/core_app/status/components/status_badge.test.tsx b/src/core/public/core_app/status/components/status_badge.test.tsx index b0870e51d98d1a..5c908cf5021cc4 100644 --- a/src/core/public/core_app/status/components/status_badge.test.tsx +++ b/src/core/public/core_app/status/components/status_badge.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { StatusBadge, StatusWithoutMessage } from './status_badge'; const getStatus = (parts: Partial = {}): StatusWithoutMessage => ({ diff --git a/src/core/public/core_app/status/components/version_header.test.tsx b/src/core/public/core_app/status/components/version_header.test.tsx index d51927f83550b8..172a720a517511 100644 --- a/src/core/public/core_app/status/components/version_header.test.tsx +++ b/src/core/public/core_app/status/components/version_header.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl, findTestSubject } from '@kbn/test/jest'; +import { mountWithIntl, findTestSubject } from '@kbn/test-jest-helpers'; import type { ServerVersion } from '../../../../types/status'; import { VersionHeader } from './version_header'; 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 7c9abed79f4b78..b460e62b1151de 100644 --- a/src/core/public/fatal_errors/fatal_errors_screen.test.tsx +++ b/src/core/public/fatal_errors/fatal_errors_screen.test.tsx @@ -10,7 +10,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 '@kbn/test/jest'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; 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 e0f917fb7f0788..2af342c2107a71 100644 --- a/src/core/public/notifications/toasts/error_toast.test.tsx +++ b/src/core/public/notifications/toasts/error_toast.test.tsx @@ -8,7 +8,7 @@ import { shallow } from 'enzyme'; import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ErrorToast } from './error_toast'; diff --git a/src/core/public/theme/core_theme_provider.test.tsx b/src/core/public/theme/core_theme_provider.test.tsx index a0f0faf13b9da1..1ce26650dcccd0 100644 --- a/src/core/public/theme/core_theme_provider.test.tsx +++ b/src/core/public/theme/core_theme_provider.test.tsx @@ -12,7 +12,7 @@ import type { ReactWrapper } from 'enzyme'; import { of, BehaviorSubject } from 'rxjs'; import { useEuiTheme } from '@elastic/eui'; import type { UseEuiTheme } from '@elastic/eui'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { CoreThemeProvider } from './core_theme_provider'; import type { CoreTheme } from './types'; diff --git a/src/core/server/core_usage_data/core_usage_data_service.mock.ts b/src/core/server/core_usage_data/core_usage_data_service.mock.ts index 331a3bbb9c028b..fd8f219fb2d556 100644 --- a/src/core/server/core_usage_data/core_usage_data_service.mock.ts +++ b/src/core/server/core_usage_data/core_usage_data_service.mock.ts @@ -140,6 +140,7 @@ const createStartContractMock = () => { alias: 'test_index', primaryStoreSizeBytes: 1, storeSizeBytes: 1, + savedObjectsDocsCount: 1, }, ], legacyUrlAliases: { diff --git a/src/core/server/core_usage_data/core_usage_data_service.test.ts b/src/core/server/core_usage_data/core_usage_data_service.test.ts index 59f673bbe3dfa2..e6e890b1a7dab8 100644 --- a/src/core/server/core_usage_data/core_usage_data_service.test.ts +++ b/src/core/server/core_usage_data/core_usage_data_service.test.ts @@ -218,6 +218,11 @@ describe('CoreUsageDataService', () => { }, ], } as any); + elasticsearch.client.asInternalUser.count.mockResolvedValueOnce({ + body: { + count: '15', + }, + } as any); elasticsearch.client.asInternalUser.cat.indices.mockResolvedValueOnce({ body: [ { @@ -229,6 +234,11 @@ describe('CoreUsageDataService', () => { }, ], } as any); + elasticsearch.client.asInternalUser.count.mockResolvedValueOnce({ + body: { + count: '10', + }, + } as any); elasticsearch.client.asInternalUser.search.mockResolvedValueOnce({ body: { hits: { total: { value: 6 } }, @@ -384,6 +394,7 @@ describe('CoreUsageDataService', () => { "docsCount": 10, "docsDeleted": 10, "primaryStoreSizeBytes": 2000, + "savedObjectsDocsCount": "15", "storeSizeBytes": 1000, }, Object { @@ -391,6 +402,7 @@ describe('CoreUsageDataService', () => { "docsCount": 20, "docsDeleted": 20, "primaryStoreSizeBytes": 4000, + "savedObjectsDocsCount": "10", "storeSizeBytes": 2000, }, ], diff --git a/src/core/server/core_usage_data/core_usage_data_service.ts b/src/core/server/core_usage_data/core_usage_data_service.ts index 0665aed0e1950f..824bfdffdceec5 100644 --- a/src/core/server/core_usage_data/core_usage_data_service.ts +++ b/src/core/server/core_usage_data/core_usage_data_service.ts @@ -131,11 +131,11 @@ export class CoreUsageDataService return acc.add(index); }, new Set()) .values() - ).map((index) => { + ).map(async (index) => { // The _cat/indices API returns the _index_ and doesn't return a way // to map back from the index to the alias. So we have to make an API - // call for every alias - return elasticsearch.client.asInternalUser.cat + // call for every alias. The document count is the lucene document count. + const catIndicesResults = await elasticsearch.client.asInternalUser.cat .indices({ index, format: 'JSON', @@ -143,6 +143,7 @@ export class CoreUsageDataService }) .then(({ body }) => { const stats = body[0]; + return { alias: kibanaOrTaskManagerIndex(index, kibanaIndex), docsCount: stats['docs.count'] ? parseInt(stats['docs.count'], 10) : 0, @@ -153,6 +154,27 @@ export class CoreUsageDataService : 0, }; }); + // We use the GET /_count API to get the number of saved objects + // to monitor if the cluster will hit the scalling limit of saved object migrations + const savedObjectsCounts = await elasticsearch.client.asInternalUser + .count({ + index, + }) + .then(({ body }) => { + return { + savedObjectsDocsCount: body.count ? body.count : 0, + }; + }); + this.logger.debug( + `Lucene documents count ${catIndicesResults.docsCount} from index ${catIndicesResults.alias}` + ); + this.logger.debug( + `Saved objects documents count ${savedObjectsCounts.savedObjectsDocsCount} from index ${catIndicesResults.alias}` + ); + return { + ...catIndicesResults, + ...savedObjectsCounts, + }; }) ); } diff --git a/src/core/server/core_usage_data/types.ts b/src/core/server/core_usage_data/types.ts index 59e220fac4efe0..0b09444da493d6 100644 --- a/src/core/server/core_usage_data/types.ts +++ b/src/core/server/core_usage_data/types.ts @@ -177,6 +177,7 @@ export interface CoreServicesUsageData { docsDeleted: number; storeSizeBytes: number; primaryStoreSizeBytes: number; + savedObjectsDocsCount: number; }[]; legacyUrlAliases: { activeCount: number; diff --git a/src/core/server/preboot/preboot_service.test.ts b/src/core/server/preboot/preboot_service.test.ts index 77242f0c5765ff..8a95f4bc9ab0e9 100644 --- a/src/core/server/preboot/preboot_service.test.ts +++ b/src/core/server/preboot/preboot_service.test.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { REPO_ROOT } from '@kbn/utils'; import { LoggerFactory } from '@kbn/logging'; import { Env } from '@kbn/config'; diff --git a/src/core/server/saved_objects/validation/integration_tests/validator.test.ts b/src/core/server/saved_objects/validation/integration_tests/validator.test.ts index d47b42e36ce812..21e8973769710a 100644 --- a/src/core/server/saved_objects/validation/integration_tests/validator.test.ts +++ b/src/core/server/saved_objects/validation/integration_tests/validator.test.ts @@ -191,7 +191,7 @@ describe('validates saved object types when a schema is provided', () => { { migrationVersion: { foo: '7.16.0' } } ); }).rejects.toThrowErrorMatchingInlineSnapshot( - `"Migration function for version 8.1.0 threw an error"` + `"Migration function for version 8.2.0 threw an error"` ); }); diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md index 2f68b82ac56359..a722e6eb98b02b 100644 --- a/src/core/server/server.api.md +++ b/src/core/server/server.api.md @@ -426,6 +426,7 @@ export interface CoreServicesUsageData { docsDeleted: number; storeSizeBytes: number; primaryStoreSizeBytes: number; + savedObjectsDocsCount: number; }[]; legacyUrlAliases: { activeCount: number; diff --git a/src/dev/i18n/extract_default_translations.js b/src/dev/i18n/extract_default_translations.js index a453b0bbae2fbf..7d86105fed7fd7 100644 --- a/src/dev/i18n/extract_default_translations.js +++ b/src/dev/i18n/extract_default_translations.js @@ -55,6 +55,7 @@ export async function matchEntriesWithExctractors(inputPath, options = {}) { '**/dist/**', '**/target/**', '**/vendor/**', + '**/build/**', '**/*.test.{js,jsx,ts,tsx}', '**/*.d.ts', ].concat(additionalIgnore); diff --git a/src/dev/i18n/tasks/extract_untracked_translations.ts b/src/dev/i18n/tasks/extract_untracked_translations.ts index 7afaa1ef71a069..1455a9a00f7661 100644 --- a/src/dev/i18n/tasks/extract_untracked_translations.ts +++ b/src/dev/i18n/tasks/extract_untracked_translations.ts @@ -38,7 +38,6 @@ export async function extractUntrackedMessagesTask({ '**/packages/kbn-i18n/**', '**/packages/kbn-i18n-react/**', '**/packages/kbn-plugin-generator/template/**', - '**/target/**', '**/test/**', '**/scripts/**', '**/src/dev/**', 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 dbe5db1ebe2eb2..b65c5c50205335 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider } from '@kbn/test/jest'; +import { shallowWithI18nProvider } from '@kbn/test-jest-helpers'; 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 0ffb9ae64e29fd..792721490256fd 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider } from '@kbn/test/jest'; +import { shallowWithI18nProvider } from '@kbn/test-jest-helpers'; 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 e6142fe916ca7f..05d44f3aee84d4 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider } from '@kbn/test/jest'; +import { shallowWithI18nProvider } from '@kbn/test-jest-helpers'; 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 91f4a5e6be471e..a804b559388618 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 @@ -9,7 +9,7 @@ import React from 'react'; import { Observable } from 'rxjs'; import { ReactWrapper } from 'enzyme'; -import { mountWithI18nProvider, shallowWithI18nProvider } from '@kbn/test/jest'; +import { mountWithI18nProvider, shallowWithI18nProvider } from '@kbn/test-jest-helpers'; 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 b77a687b50cd90..70d6a7a83d25f7 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 @@ -8,7 +8,7 @@ import React from 'react'; import { I18nProvider } from '@kbn/i18n-react'; -import { shallowWithI18nProvider, mountWithI18nProvider } from '@kbn/test/jest'; +import { shallowWithI18nProvider, mountWithI18nProvider } from '@kbn/test-jest-helpers'; import { mount, ReactWrapper } from 'enzyme'; import { FieldSetting } from '../../types'; import { UiSettingsType } 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 a371831dcb0070..7d598aa1826953 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider, mountWithI18nProvider } from '@kbn/test/jest'; +import { shallowWithI18nProvider, mountWithI18nProvider } from '@kbn/test-jest-helpers'; import { UiSettingsType } from '../../../../../../core/public'; import { themeServiceMock } from '../../../../../../core/public/mocks'; 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 18684fa45f3a73..cef5978945bc83 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider, mountWithI18nProvider } from '@kbn/test/jest'; +import { shallowWithI18nProvider, mountWithI18nProvider } from '@kbn/test-jest-helpers'; import { findTestSubject } from '@elastic/eui/lib/test'; diff --git a/src/plugins/chart_expressions/expression_gauge/public/components/gauge_component.test.tsx b/src/plugins/chart_expressions/expression_gauge/public/components/gauge_component.test.tsx index 0dbd4d2cade04b..ffb0328a1c97c7 100644 --- a/src/plugins/chart_expressions/expression_gauge/public/components/gauge_component.test.tsx +++ b/src/plugins/chart_expressions/expression_gauge/public/components/gauge_component.test.tsx @@ -11,7 +11,7 @@ import { chartPluginMock } from '../../../../charts/public/mocks'; import { fieldFormatsServiceMock } from '../../../../field_formats/public/mocks'; import type { Datatable } from '../../../../expressions/public'; import { DatatableColumn, DatatableRow } from 'src/plugins/expressions/common'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { GaugeRenderProps, GaugeArguments, GaugeLabelMajorMode, ColorStop } from '../../common'; import GaugeComponent from './gauge_component'; import { Chart, Goal } from '@elastic/charts'; @@ -212,7 +212,7 @@ describe('GaugeComponent', function () { stops: [10, 20, 30] as unknown as ColorStop[], range: 'number', rangeMin: 0, - rangeMax: 20, + rangeMax: 30, }, }; const customProps = { @@ -253,8 +253,8 @@ describe('GaugeComponent', function () { }, } as GaugeRenderProps; const goal = shallowWithIntl().find(Goal); - expect(goal.prop('ticks')).toEqual([0, 1, 2, 3, 10]); - expect(goal.prop('bands')).toEqual([0, 1, 2, 3, 10]); + expect(goal.prop('ticks')).toEqual([0, 1, 2, 3, 4, 10]); + expect(goal.prop('bands')).toEqual([0, 1, 2, 3, 4, 10]); }); it('sets proper color bands and ticks on color bands if palette steps are smaller than minimum', () => { const palette = { @@ -281,8 +281,8 @@ describe('GaugeComponent', function () { }, } as GaugeRenderProps; const goal = shallowWithIntl().find(Goal); - expect(goal.prop('ticks')).toEqual([0, 10]); - expect(goal.prop('bands')).toEqual([0, 10]); + expect(goal.prop('ticks')).toEqual([0, 4, 10]); + expect(goal.prop('bands')).toEqual([0, 4, 10]); }); it('sets proper color bands and ticks on color bands if percent palette steps are smaller than 0', () => { const palette = { @@ -294,7 +294,7 @@ describe('GaugeComponent', function () { stops: [-20, -60, 80], range: 'percent', rangeMin: 0, - rangeMax: 4, + rangeMax: 100, }, }; const customProps = { @@ -407,7 +407,7 @@ describe('GaugeComponent', function () { stops: [20, 60, 80], range: 'percent', rangeMin: 0, - rangeMax: 10, + rangeMax: 100, }, }; const customProps = { diff --git a/src/plugins/chart_expressions/expression_gauge/public/components/gauge_component.tsx b/src/plugins/chart_expressions/expression_gauge/public/components/gauge_component.tsx index 5b42290f2b05c1..593c18e5e9b05a 100644 --- a/src/plugins/chart_expressions/expression_gauge/public/components/gauge_component.tsx +++ b/src/plugins/chart_expressions/expression_gauge/public/components/gauge_component.tsx @@ -29,7 +29,11 @@ declare global { } } -function normalizeColors({ colors, stops, range }: CustomPaletteState, min: number) { +function normalizeColors( + { colors, stops, range, rangeMin, rangeMax }: CustomPaletteState, + min: number, + max: number +) { if (!colors) { return; } @@ -37,23 +41,61 @@ function normalizeColors({ colors, stops, range }: CustomPaletteState, min: numb stops.filter((stop, i) => (range === 'percent' ? stop < 0 : stop < min)).length, 0 ); - return colors.slice(colorsOutOfRangeSmaller); + let updatedColors = colors.slice(colorsOutOfRangeSmaller); + + let correctMin = rangeMin; + let correctMax = rangeMax; + if (range === 'percent') { + correctMin = min + rangeMin * ((max - min) / 100); + correctMax = min + rangeMax * ((max - min) / 100); + } + + if (correctMin > min && isFinite(correctMin)) { + updatedColors = [`rgba(255,255,255,0)`, ...updatedColors]; + } + + if (correctMax < max && isFinite(correctMax)) { + updatedColors = [...updatedColors, `rgba(255,255,255,0)`]; + } + + return updatedColors; } function normalizeBands( - { colors, stops, range }: CustomPaletteState, + { colors, stops, range, rangeMax, rangeMin }: CustomPaletteState, { min, max }: { min: number; max: number } ) { if (!stops.length) { const step = (max - min) / colors.length; return [min, ...colors.map((_, i) => min + (i + 1) * step)]; } + let firstRanges = [min]; + let lastRanges = [max]; + let correctMin = rangeMin; + let correctMax = rangeMax; + if (range === 'percent') { + correctMin = min + rangeMin * ((max - min) / 100); + correctMax = min + rangeMax * ((max - min) / 100); + } + + if (correctMin > min && isFinite(correctMin)) { + firstRanges = [min, correctMin]; + } + + if (correctMax < max && isFinite(correctMax)) { + lastRanges = [correctMax, max]; + } + if (range === 'percent') { - const filteredStops = stops.filter((stop) => stop >= 0 && stop <= 100); - return [min, ...filteredStops.map((step) => min + step * ((max - min) / 100)), max]; + const filteredStops = stops.filter((stop) => stop > 0 && stop < 100); + return [ + ...firstRanges, + ...filteredStops.map((step) => min + step * ((max - min) / 100)), + ...lastRanges, + ]; } const orderedStops = stops.filter((stop, i) => stop < max && stop > min); - return [min, ...orderedStops, max]; + return [...firstRanges, ...orderedStops, ...lastRanges]; } function getTitle( @@ -179,7 +221,7 @@ export const GaugeComponent: FC = memo( }, } ); - const colors = palette?.params?.colors ? normalizeColors(palette.params, min) : undefined; + const colors = palette?.params?.colors ? normalizeColors(palette.params, min, max) : undefined; const bands: number[] = (palette?.params as CustomPaletteState) ? normalizeBands(args.palette?.params as CustomPaletteState, { min, max }) : [min, max]; @@ -198,8 +240,8 @@ export const GaugeComponent: FC = memo( = min && goal <= max ? goal : undefined} + base={bands[0]} + target={goal && goal >= bands[0] && goal <= bands[bands.length - 1] ? goal : undefined} actual={formattedActual} tickValueFormatter={({ value: tickValue }) => tickFormatter.convert(tickValue)} bands={bands} @@ -210,6 +252,8 @@ export const GaugeComponent: FC = memo( const index = bands && bands.indexOf(val.value) - 1; return colors && index >= 0 && colors[index] ? colors[index] + : val.value <= bands[0] + ? colors[0] : colors[colors.length - 1]; } : () => `rgba(255,255,255,0)` diff --git a/src/plugins/chart_expressions/expression_heatmap/common/types/expression_renderers.ts b/src/plugins/chart_expressions/expression_heatmap/common/types/expression_renderers.ts index 1498c04ca1b79f..fa8bc5ee2e19d9 100644 --- a/src/plugins/chart_expressions/expression_heatmap/common/types/expression_renderers.ts +++ b/src/plugins/chart_expressions/expression_heatmap/common/types/expression_renderers.ts @@ -32,6 +32,7 @@ export type HeatmapRenderProps = HeatmapExpressionProps & { onSelectRange: (data: BrushEvent['data']) => void; paletteService: PaletteRegistry; uiState: PersistedState; + interactive: boolean; }; export interface ColorStop { diff --git a/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_component.test.tsx b/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_component.test.tsx index 59113e5826d24b..30d9e9d9b90f45 100644 --- a/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_component.test.tsx +++ b/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_component.test.tsx @@ -12,7 +12,7 @@ import { chartPluginMock } from '../../../../charts/public/mocks'; import { EmptyPlaceholder } from '../../../../charts/public'; import { fieldFormatsServiceMock } from '../../../../field_formats/public/mocks'; import type { Datatable } from '../../../../expressions/public'; -import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import { findTestSubject } from '@elastic/eui/lib/test'; import { act } from 'react-dom/test-utils'; import { HeatmapRenderProps, HeatmapArguments } from '../../common'; @@ -99,6 +99,7 @@ describe('HeatmapComponent', function () { onSelectRange: jest.fn(), paletteService: palettesRegistry, formatFactory: formatService.deserialize, + interactive: true, }; }); @@ -266,4 +267,10 @@ describe('HeatmapComponent', function () { ]); expect(wrapperProps.onClickValue).toHaveBeenCalled(); }); + + it('does not add callbacks when not interactive', () => { + const component = shallowWithIntl(); + expect(component.find(Settings).first().prop('onElementClick')).toBeUndefined(); + expect(component.find(Settings).first().prop('onBrushEnd')).toBeUndefined(); + }); }); diff --git a/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_component.tsx b/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_component.tsx index 152a3e79324a58..5e50fc09d7c8c2 100644 --- a/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_component.tsx +++ b/src/plugins/chart_expressions/expression_heatmap/public/components/heatmap_component.tsx @@ -29,7 +29,10 @@ import type { DatatableColumn } from '../../../../expressions/public'; import { ExpressionValueVisDimension } from '../../../../visualizations/public'; import type { HeatmapRenderProps, FilterEvent, BrushEvent } from '../../common'; import { applyPaletteParams, findMinMaxByColumnId, getSortPredicate } from './helpers'; -import { getColorPicker } from '../utils/get_color_picker'; +import { + LegendColorPickerWrapperContext, + LegendColorPickerWrapper, +} from '../utils/get_color_picker'; import { DEFAULT_PALETTE_NAME, defaultPaletteParams } from '../constants'; import { HeatmapIcon } from './heatmap_icon'; import './index.scss'; @@ -135,6 +138,7 @@ export const HeatmapComponent: FC = memo( onSelectRange, paletteService, uiState, + interactive, }) => { const chartTheme = chartsThemeService.useChartsTheme(); const isDarkTheme = chartsThemeService.useDarkMode(); @@ -145,12 +149,15 @@ export const HeatmapComponent: FC = memo( }); const toggleLegend = useCallback(() => { + if (!interactive) { + return; + } setShowLegend((value) => { const newValue = !value; uiState?.set?.('vis.legendOpen', newValue); return newValue; }); - }, [uiState]); + }, [uiState, interactive]); const setColor = useCallback( (newColor: string | null, seriesLabel: string | number) => { @@ -168,10 +175,6 @@ export const HeatmapComponent: FC = memo( [uiState] ); - const legendColorPicker = useMemo( - () => getColorPicker(args.legend.position, setColor, uiState), - [args.legend.position, setColor, uiState] - ); const table = data; const valueAccessor = args.valueAccessor ? getAccessor(args.valueAccessor, table.columns) @@ -271,8 +274,13 @@ export const HeatmapComponent: FC = memo( // adds a very small number to the max value to make sure the max value will be included const smattering = 0.00001; - const endValue = - (paletteParams?.range === 'number' ? paletteParams.rangeMax : max) + smattering; + let endValue = max + smattering; + if (paletteParams?.rangeMax || paletteParams?.rangeMax === 0) { + endValue = + (paletteParams?.range === 'number' + ? paletteParams.rangeMax + : min + ((max - min) * paletteParams.rangeMax) / 100) + smattering; + } const overwriteColors = uiState?.get('vis.colors') ?? null; @@ -297,77 +305,30 @@ export const HeatmapComponent: FC = memo( }; }); - const onElementClick = ((e: HeatmapElementEvent[]) => { - const cell = e[0][0]; - const { x, y } = cell.datum; - - const xAxisFieldName = xAxisColumn?.meta?.field; - const timeFieldName = isTimeBasedSwimLane ? xAxisFieldName : ''; - - const points = [ - { - row: table.rows.findIndex((r) => r[xAxisColumn.id] === x), - column: xAxisColumnIndex, - value: x, - }, - ...(yAxisColumn - ? [ - { - row: table.rows.findIndex((r) => r[yAxisColumn.id] === y), - column: yAxisColumnIndex, - value: y, - }, - ] - : []), - ]; - - const context: FilterEvent['data'] = { - data: points.map((point) => ({ - row: point.row, - column: point.column, - value: point.value, - table, - })), - timeFieldName, - }; - onClickValue(context); - }) as ElementClickListener; - - const onBrushEnd = (e: HeatmapBrushEvent) => { - const { x, y } = e; + const onElementClick = useCallback( + (e: HeatmapElementEvent[]) => { + const cell = e[0][0]; + const { x, y } = cell.datum; - const xAxisFieldName = xAxisColumn?.meta?.field; - const timeFieldName = isTimeBasedSwimLane ? xAxisFieldName : ''; + const xAxisFieldName = xAxisColumn?.meta?.field; + const timeFieldName = isTimeBasedSwimLane ? xAxisFieldName : ''; - if (isTimeBasedSwimLane) { - const context: BrushEvent['data'] = { - range: x as number[], - table, - column: xAxisColumnIndex, - timeFieldName, - }; - onSelectRange(context); - } else { - const points: Array<{ row: number; column: number; value: string | number }> = []; - - if (yAxisColumn) { - (y as string[]).forEach((v) => { - points.push({ - row: table.rows.findIndex((r) => r[yAxisColumn.id] === v), - column: yAxisColumnIndex, - value: v, - }); - }); - } - if (xAxisColumn) { - (x as string[]).forEach((v) => { - points.push({ - row: table.rows.findIndex((r) => r[xAxisColumn.id] === v), - column: xAxisColumnIndex, - value: v, - }); - }); - } + const points = [ + { + row: table.rows.findIndex((r) => r[xAxisColumn.id] === x), + column: xAxisColumnIndex, + value: x, + }, + ...(yAxisColumn + ? [ + { + row: table.rows.findIndex((r) => r[yAxisColumn.id] === y), + column: yAxisColumnIndex, + value: y, + }, + ] + : []), + ]; const context: FilterEvent['data'] = { data: points.map((point) => ({ @@ -379,8 +340,79 @@ export const HeatmapComponent: FC = memo( timeFieldName, }; onClickValue(context); - } - }; + }, + [ + isTimeBasedSwimLane, + onClickValue, + table, + xAxisColumn?.id, + xAxisColumn?.meta?.field, + xAxisColumnIndex, + yAxisColumn, + yAxisColumnIndex, + ] + ); + + const onBrushEnd = useCallback( + (e: HeatmapBrushEvent) => { + const { x, y } = e; + + const xAxisFieldName = xAxisColumn?.meta?.field; + const timeFieldName = isTimeBasedSwimLane ? xAxisFieldName : ''; + + if (isTimeBasedSwimLane) { + const context: BrushEvent['data'] = { + range: x as number[], + table, + column: xAxisColumnIndex, + timeFieldName, + }; + onSelectRange(context); + } else { + const points: Array<{ row: number; column: number; value: string | number }> = []; + + if (yAxisColumn) { + (y as string[]).forEach((v) => { + points.push({ + row: table.rows.findIndex((r) => r[yAxisColumn.id] === v), + column: yAxisColumnIndex, + value: v, + }); + }); + } + if (xAxisColumn) { + (x as string[]).forEach((v) => { + points.push({ + row: table.rows.findIndex((r) => r[xAxisColumn.id] === v), + column: xAxisColumnIndex, + value: v, + }); + }); + } + + const context: FilterEvent['data'] = { + data: points.map((point) => ({ + row: point.row, + column: point.column, + value: point.value, + table, + })), + timeFieldName, + }; + onClickValue(context); + } + }, + [ + isTimeBasedSwimLane, + onClickValue, + onSelectRange, + table, + xAxisColumn, + xAxisColumnIndex, + yAxisColumn, + yAxisColumnIndex, + ] + ); const themeOverrides: PartialTheme = { legend: { @@ -451,57 +483,65 @@ export const HeatmapComponent: FC = memo( legendPosition={args.legend.position} /> )} - - - `${xValuesFormatter.convert(v) ?? ''}`} - yAxisLabelFormatter={ - yAxisColumn - ? (v) => `${formatFactory(yAxisColumn.meta.params).convert(v) ?? ''}` - : undefined - } - /> - + + + + `${xValuesFormatter.convert(v) ?? ''}`} + yAxisLabelFormatter={ + yAxisColumn + ? (v) => `${formatFactory(yAxisColumn.meta.params).convert(v) ?? ''}` + : undefined + } + /> + + ); } diff --git a/src/plugins/chart_expressions/expression_heatmap/public/expression_renderers/heatmap_renderer.tsx b/src/plugins/chart_expressions/expression_heatmap/public/expression_renderers/heatmap_renderer.tsx index 2acb5942098b15..0d3d9dcf93be76 100644 --- a/src/plugins/chart_expressions/expression_heatmap/public/expression_renderers/heatmap_renderer.tsx +++ b/src/plugins/chart_expressions/expression_heatmap/public/expression_renderers/heatmap_renderer.tsx @@ -46,6 +46,7 @@ export const heatmapRenderer: ( const timeZone = getTimeZone(getUISettings()); const { HeatmapComponent } = await import('../components/heatmap_component'); + const { isInteractive } = handlers; render(
@@ -58,6 +59,7 @@ export const heatmapRenderer: ( chartsThemeService={getThemeService()} paletteService={getPaletteService()} uiState={handlers.uiState as PersistedState} + interactive={isInteractive()} />
, diff --git a/src/plugins/chart_expressions/expression_heatmap/public/utils/get_color_picker.tsx b/src/plugins/chart_expressions/expression_heatmap/public/utils/get_color_picker.tsx index 2f5297c5fd4754..771a633456e13e 100644 --- a/src/plugins/chart_expressions/expression_heatmap/public/utils/get_color_picker.tsx +++ b/src/plugins/chart_expressions/expression_heatmap/public/utils/get_color_picker.tsx @@ -6,9 +6,9 @@ * Side Public License, v 1. */ -import React, { useCallback } from 'react'; +import React, { createContext, useCallback, useContext } from 'react'; import { LegendColorPicker, Position } from '@elastic/charts'; -import { PopoverAnchorPosition, EuiPopover, EuiOutsideClickDetector } from '@elastic/eui'; +import { PopoverAnchorPosition, EuiWrappingPopover, EuiOutsideClickDetector } from '@elastic/eui'; import type { PersistedState } from '../../../../visualizations/public'; import { ColorPicker } from '../../../../charts/public'; @@ -27,59 +27,77 @@ function getAnchorPosition(legendPosition: Position): PopoverAnchorPosition { } } -export const getColorPicker = - ( - legendPosition: Position, - setColor: (newColor: string | null, seriesKey: string | number) => void, - uiState: PersistedState - ): LegendColorPicker => - ({ anchor, color, onClose, onChange, seriesIdentifiers: [seriesIdentifier] }) => { - const seriesName = seriesIdentifier.key; - const overwriteColors: Record = uiState?.get('vis.colors', {}) ?? {}; - const colorIsOverwritten = seriesName.toString() in overwriteColors; - let keyDownEventOn = false; - const handleChange = (newColor: string | null) => { - if (newColor) { - onChange(newColor); - } - setColor(newColor, seriesName); - // close the popover if no color is applied or the user has clicked a color - if (!newColor || !keyDownEventOn) { - onClose(); - } - }; +export interface LegendColorPickerWrapperContextType { + legendPosition: Position; + setColor: (newColor: string | null, seriesKey: string | number) => void; + uiState: PersistedState; +} - const onKeyDown = (e: React.KeyboardEvent) => { - if (e.keyCode === KEY_CODE_ENTER) { - onClose?.(); - } - keyDownEventOn = true; - }; +export const LegendColorPickerWrapperContext = createContext< + LegendColorPickerWrapperContextType | undefined +>(undefined); - const handleOutsideClick = useCallback(() => { - onClose?.(); - }, [onClose]); +export const LegendColorPickerWrapper: LegendColorPicker = ({ + anchor, + color, + onClose, + onChange, + seriesIdentifiers: [seriesIdentifier], +}) => { + const colorPickerWrappingContext = useContext(LegendColorPickerWrapperContext); + const handleOutsideClick = useCallback(() => { + onClose?.(); + }, [onClose]); + + if (!colorPickerWrappingContext) { + return null; + } + + const { legendPosition, setColor, uiState } = colorPickerWrappingContext; + const seriesName = seriesIdentifier.key; - return ( - - - - - - ); + const overwriteColors: Record = uiState?.get('vis.colors', {}) ?? {}; + const colorIsOverwritten = seriesName.toString() in overwriteColors; + let keyDownEventOn = false; + + const handleChange = (newColor: string | null) => { + if (newColor) { + onChange(newColor); + } + setColor(newColor, seriesName); + // close the popover if no color is applied or the user has clicked a color + if (!newColor || !keyDownEventOn) { + onClose(); + } }; + + const onKeyDown = (e: React.KeyboardEvent) => { + if (e.keyCode === KEY_CODE_ENTER) { + onClose?.(); + } + keyDownEventOn = true; + }; + + return ( + + + + + + ); +}; diff --git a/src/plugins/chart_expressions/expression_pie/public/components/pie_vis_component.tsx b/src/plugins/chart_expressions/expression_pie/public/components/pie_vis_component.tsx index af44f6fac1384d..51385398ab346d 100644 --- a/src/plugins/chart_expressions/expression_pie/public/components/pie_vis_component.tsx +++ b/src/plugins/chart_expressions/expression_pie/public/components/pie_vis_component.tsx @@ -42,7 +42,8 @@ import { PieContainerDimensions, } from '../../common/types/expression_renderers'; import { - getColorPicker, + LegendColorPickerWrapper, + LegendColorPickerWrapperContext, getLayers, getLegendActions, canFilter, @@ -261,28 +262,6 @@ const PieComponent = (props: PieComponentProps) => { }; const legendPosition = visParams.legendPosition ?? Position.Right; - const legendColorPicker = useMemo( - () => - getColorPicker( - legendPosition, - setColor, - bucketColumns, - visParams.palette.name, - visData.rows, - props.uiState, - visParams.distinctColors - ), - [ - legendPosition, - setColor, - bucketColumns, - visParams.palette.name, - visParams.distinctColors, - visData.rows, - props.uiState, - ] - ); - const splitChartColumnAccessor = visParams.dimensions.splitColumn ? getSplitDimensionAccessor( services.fieldFormats, @@ -332,83 +311,95 @@ const PieComponent = (props: PieComponentProps) => { ) : (
- - - - + { - handleSliceClick( - args[0][0] as LayerValue[], - bucketColumns, - visData, - splitChartDimension, - splitChartFormatter - ); - }} - legendAction={getLegendActions( - canFilter, - getLegendActionEventData(visData), - handleLegendAction, - visParams, - services.data.actions, - services.fieldFormats - )} - theme={[ - // Chart background should be transparent for the usage at Canvas. - { background: { color: 'transparent' } }, - themeOverrides, - chartTheme, - { - legend: { - labelOptions: { - maxLines: visParams.truncateLegend ? visParams.maxLegendLines ?? 1 : 0, + /> + + + { + handleSliceClick( + args[0][0] as LayerValue[], + bucketColumns, + visData, + splitChartDimension, + splitChartFormatter + ); + }} + legendAction={getLegendActions( + canFilter, + getLegendActionEventData(visData), + handleLegendAction, + visParams, + services.data.actions, + services.fieldFormats + )} + theme={[ + // Chart background should be transparent for the usage at Canvas. + { background: { color: 'transparent' } }, + themeOverrides, + chartTheme, + { + legend: { + labelOptions: { + maxLines: visParams.truncateLegend ? visParams.maxLegendLines ?? 1 : 0, + }, }, }, - }, - ]} - baseTheme={chartBaseTheme} - onRenderChange={onRenderChange} - ariaLabel={props.visParams.ariaLabel} - ariaUseDefaultSummary={!props.visParams.ariaLabel} - /> - getSliceValue(d, metricColumn)} - percentFormatter={(d: number) => percentFormatter.convert(d / 100)} - valueGetter={ - !visParams.labels.show || - visParams.labels.valuesFormat === ValueFormats.VALUE || - !visParams.labels.values - ? undefined - : 'percent' - } - valueFormatter={(d: number) => - !visParams.labels.show || !visParams.labels.values - ? '' - : metricFieldFormatter.convert(d) - } - layers={layers} - topGroove={!visParams.labels.show ? 0 : undefined} - /> - + ]} + baseTheme={chartBaseTheme} + onRenderChange={onRenderChange} + ariaLabel={props.visParams.ariaLabel} + ariaUseDefaultSummary={!props.visParams.ariaLabel} + /> + getSliceValue(d, metricColumn)} + percentFormatter={(d: number) => percentFormatter.convert(d / 100)} + valueGetter={ + !visParams.labels.show || + visParams.labels.valuesFormat === ValueFormats.VALUE || + !visParams.labels.values + ? undefined + : 'percent' + } + valueFormatter={(d: number) => + !visParams.labels.show || !visParams.labels.values + ? '' + : metricFieldFormatter.convert(d) + } + layers={layers} + topGroove={!visParams.labels.show ? 0 : undefined} + /> + +
)} diff --git a/src/plugins/chart_expressions/expression_pie/public/utils/get_color_picker.test.tsx b/src/plugins/chart_expressions/expression_pie/public/utils/get_color_picker.test.tsx index c129fdd356a66d..1a9c785ed6daec 100644 --- a/src/plugins/chart_expressions/expression_pie/public/utils/get_color_picker.test.tsx +++ b/src/plugins/chart_expressions/expression_pie/public/utils/get_color_picker.test.tsx @@ -9,9 +9,13 @@ import React from 'react'; import { LegendColorPickerProps } from '@elastic/charts'; import { EuiPopover } from '@elastic/eui'; -import { mountWithIntl } from '@kbn/test/jest'; -import { ComponentType, ReactWrapper } from 'enzyme'; -import { getColorPicker } from './get_color_picker'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; +import { ReactWrapper } from 'enzyme'; +import { + LegendColorPickerWrapper, + LegendColorPickerWrapperContext, + LegendColorPickerWrapperContextType, +} from './get_color_picker'; import { ColorPicker } from '../../../../charts/public'; import type { PersistedState } from '../../../../visualizations/public'; import { createMockBucketColumns, createMockVisData } from '../mocks'; @@ -28,7 +32,7 @@ jest.mock('@elastic/charts', () => { }; }); -describe('getColorPicker', function () { +describe('LegendColorPickerWrapper', () => { const mockState = new Map(); const uiState = { get: jest @@ -40,15 +44,6 @@ describe('getColorPicker', function () { } as unknown as PersistedState; let wrapperProps: LegendColorPickerProps; - const Component: ComponentType = getColorPicker( - 'left', - jest.fn(), - bucketColumns, - 'default', - visData.rows, - uiState, - false - ); let wrapper: ReactWrapper; beforeAll(() => { @@ -66,50 +61,73 @@ describe('getColorPicker', function () { }; }); + const mount = ( + props: LegendColorPickerProps = wrapperProps, + context: LegendColorPickerWrapperContextType = { + legendPosition: 'left', + setColor: jest.fn(), + bucketColumns, + palette: 'default', + data: visData.rows, + uiState, + distinctColors: false, + } + ) => + mountWithIntl( + + + + ); + it('renders the color picker for default palette and inner layer', () => { - wrapper = mountWithIntl(); + wrapper = mount(); expect(wrapper.find(ColorPicker).length).toBe(1); }); it('renders the picker on the correct position', () => { - wrapper = mountWithIntl(); + wrapper = mount(); expect(wrapper.find(EuiPopover).prop('anchorPosition')).toEqual('rightCenter'); }); it('converts the color to the right hex and passes it to the color picker', () => { - wrapper = mountWithIntl(); + wrapper = mount(); expect(wrapper.find(ColorPicker).prop('color')).toEqual('#6dccb1'); }); it('doesnt render the picker for default palette and not inner layer', () => { - const newProps = { ...wrapperProps, seriesIdentifier: { key: '1', specId: 'pie' } }; - wrapper = mountWithIntl(); + wrapper = mount({ + ...wrapperProps, + seriesIdentifier: { key: '1', specId: 'pie' }, + } as LegendColorPickerProps); + expect(wrapper).toEqual({}); }); it('renders the color picker with the colorIsOverwritten prop set to false if color is not overwritten for the specific series', () => { - wrapper = mountWithIntl(); + wrapper = mount(); expect(wrapper.find(ColorPicker).prop('colorIsOverwritten')).toBe(false); }); it('renders the color picker with the colorIsOverwritten prop set to true if color is overwritten for the specific series', () => { uiState.set('vis.colors', { 'Logstash Airways': '#6092c0' }); - wrapper = mountWithIntl(); + wrapper = mount(); expect(wrapper.find(ColorPicker).prop('colorIsOverwritten')).toBe(true); }); it('renders the picker for kibana palette and not distinctColors', () => { - const LegacyPaletteComponent: ComponentType = getColorPicker( - 'left', - jest.fn(), - bucketColumns, - 'kibana_palette', - visData.rows, - uiState, - true + wrapper = mount( + { ...wrapperProps, seriesIdentifier: { key: '1', specId: 'pie' } } as LegendColorPickerProps, + { + legendPosition: 'left', + setColor: jest.fn(), + bucketColumns, + palette: 'kibana_palette', + data: visData.rows, + uiState, + distinctColors: true, + } ); - const newProps = { ...wrapperProps, seriesIdentifier: { key: '1', specId: 'pie' } }; - wrapper = mountWithIntl(); + expect(wrapper.find(ColorPicker).length).toBe(1); expect(wrapper.find(ColorPicker).prop('useLegacyColors')).toBe(true); }); diff --git a/src/plugins/chart_expressions/expression_pie/public/utils/get_color_picker.tsx b/src/plugins/chart_expressions/expression_pie/public/utils/get_color_picker.tsx index 7a1438fac24581..3f95f77c7ec6c6 100644 --- a/src/plugins/chart_expressions/expression_pie/public/utils/get_color_picker.tsx +++ b/src/plugins/chart_expressions/expression_pie/public/utils/get_color_picker.tsx @@ -6,10 +6,10 @@ * Side Public License, v 1. */ -import React, { useCallback } from 'react'; +import React, { useCallback, createContext, useContext } from 'react'; import Color from 'color'; import { LegendColorPicker, Position } from '@elastic/charts'; -import { PopoverAnchorPosition, EuiPopover, EuiOutsideClickDetector } from '@elastic/eui'; +import { PopoverAnchorPosition, EuiWrappingPopover, EuiOutsideClickDetector } from '@elastic/eui'; import type { DatatableRow } from '../../../../expressions/public'; import type { PersistedState } from '../../../../visualizations/public'; import { ColorPicker } from '../../../../charts/public'; @@ -48,71 +48,90 @@ function isOnInnerLayer( return data.find((d) => firstBucket.id && d[firstBucket.id] === seriesKey); } -export const getColorPicker = - ( - legendPosition: Position, - setColor: (newColor: string | null, seriesKey: string | number) => void, - bucketColumns: Array>, - palette: string, - data: DatatableRow[], - uiState: PersistedState, - distinctColors: boolean - ): LegendColorPicker => - ({ anchor, color, onClose, onChange, seriesIdentifiers: [seriesIdentifier] }) => { - const seriesName = seriesIdentifier.key; - const overwriteColors: Record = uiState?.get('vis.colors', {}) ?? {}; - const colorIsOverwritten = Object.keys(overwriteColors).includes(seriesName.toString()); - let keyDownEventOn = false; - const handleChange = (newColor: string | null) => { - if (newColor) { - onChange(newColor); - } - setColor(newColor, seriesName); - // close the popover if no color is applied or the user has clicked a color - if (!newColor || !keyDownEventOn) { - onClose(); - } - }; +export interface LegendColorPickerWrapperContextType { + legendPosition: Position; + setColor: (newColor: string | null, seriesKey: string | number) => void; + bucketColumns: Array>; + palette: string; + data: DatatableRow[]; + uiState: PersistedState; + distinctColors: boolean; +} - const onKeyDown = (e: React.KeyboardEvent) => { - if (e.keyCode === KEY_CODE_ENTER) { - onClose?.(); - } - keyDownEventOn = true; - }; +export const LegendColorPickerWrapperContext = createContext< + LegendColorPickerWrapperContextType | undefined +>(undefined); - const handleOutsideClick = useCallback(() => { - onClose?.(); - }, [onClose]); +export const LegendColorPickerWrapper: LegendColorPicker = ({ + anchor, + color, + onClose, + onChange, + seriesIdentifiers: [seriesIdentifier], +}) => { + const seriesName = seriesIdentifier.key; + const colorPickerWrappingContext = useContext(LegendColorPickerWrapperContext); + + const handleOutsideClick = useCallback(() => { + onClose?.(); + }, [onClose]); + + if (!colorPickerWrappingContext) { + return null; + } + + const { legendPosition, setColor, bucketColumns, palette, data, uiState, distinctColors } = + colorPickerWrappingContext; + + const overwriteColors: Record = uiState?.get('vis.colors', {}) ?? {}; + const colorIsOverwritten = Object.keys(overwriteColors).includes(seriesName.toString()); + let keyDownEventOn = false; - if (!distinctColors) { - const enablePicker = - isOnInnerLayer(bucketColumns[0], data, seriesName) || !bucketColumns[0].id; - if (!enablePicker) return null; + const handleChange = (newColor: string | null) => { + if (newColor) { + onChange(newColor); + } + setColor(newColor, seriesName); + // close the popover if no color is applied or the user has clicked a color + if (!newColor || !keyDownEventOn) { + onClose(); } - const hexColor = new Color(color).hex(); - return ( - - - - - - ); }; + + const onKeyDown = (e: React.KeyboardEvent) => { + if (e.keyCode === KEY_CODE_ENTER) { + onClose?.(); + } + keyDownEventOn = true; + }; + + if (!distinctColors) { + const enablePicker = isOnInnerLayer(bucketColumns[0], data, seriesName) || !bucketColumns[0].id; + if (!enablePicker) return null; + } + const hexColor = new Color(color).hex(); + return ( + + + + + + ); +}; diff --git a/src/plugins/chart_expressions/expression_pie/public/utils/index.ts b/src/plugins/chart_expressions/expression_pie/public/utils/index.ts index e1b779c511bfcb..7fe499e7f4ab77 100644 --- a/src/plugins/chart_expressions/expression_pie/public/utils/index.ts +++ b/src/plugins/chart_expressions/expression_pie/public/utils/index.ts @@ -7,7 +7,7 @@ */ export { getLayers } from './get_layers'; -export { getColorPicker } from './get_color_picker'; +export { LegendColorPickerWrapper, LegendColorPickerWrapperContext } from './get_color_picker'; export { getLegendActions } from './get_legend_actions'; export { canFilter, getFilterClickData, getFilterEventData } from './filter_helpers'; export { getPartitionTheme } from './get_partition_theme'; 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 d39ffb9755445b..37da5f93ff675b 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 @@ -16,7 +16,7 @@ import * as sinon from 'sinon'; import { serviceContextMock } from '../../../../contexts/services_context.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { ServicesContextProvider, EditorContextProvider, 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 a2a55404072eb1..1dc490836808b1 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { DashboardContainer } from '../embeddable/dashboard_container'; import { embeddablePluginMock } from '../../../../embeddable/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 5f50cfd842b67a..761db3ca47ff8b 100644 --- a/src/plugins/dashboard/public/application/embeddable/dashboard_container.test.tsx +++ b/src/plugins/dashboard/public/application/embeddable/dashboard_container.test.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { mount } from 'enzyme'; -import { findTestSubject, nextTick } from '@kbn/test/jest'; +import { findTestSubject, nextTick } from '@kbn/test-jest-helpers'; import { DashboardContainer, DashboardContainerServices } from './dashboard_container'; import { getSampleDashboardInput, getSampleDashboardPanel } from '../test_helpers'; import { I18nProvider } from '@kbn/i18n-react'; diff --git a/src/plugins/dashboard/public/application/embeddable/empty_screen/dashboard_empty_screen.test.tsx b/src/plugins/dashboard/public/application/embeddable/empty_screen/dashboard_empty_screen.test.tsx index 3b4e2c06ab0a89..0b3a5698138457 100644 --- a/src/plugins/dashboard/public/application/embeddable/empty_screen/dashboard_empty_screen.test.tsx +++ b/src/plugins/dashboard/public/application/embeddable/empty_screen/dashboard_empty_screen.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { findTestSubject } from '@elastic/eui/lib/test'; import { DashboardEmptyScreen, DashboardEmptyScreenProps } from './dashboard_empty_screen'; import { coreMock } from '../../../../../../core/public/mocks'; 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 59f346caf4b0de..4717082cbe0d02 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 @@ -10,7 +10,7 @@ import sizeMe from 'react-sizeme'; import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { skip } from 'rxjs/operators'; import { DashboardGrid, DashboardGridProps } from './dashboard_grid'; import { DashboardContainer, DashboardContainerServices } 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 d9de67ee9455d7..9075a7f90b103d 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 @@ -11,7 +11,7 @@ import React from 'react'; import { skip } from 'rxjs/operators'; import { mount } from 'enzyme'; import { I18nProvider } from '@kbn/i18n-react'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { DashboardViewport, DashboardViewportProps } from './dashboard_viewport'; import { DashboardContainer, DashboardContainerServices } from '../dashboard_container'; import { getSampleDashboardInput } from '../../test_helpers'; 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 d7e35df65a7d27..0aab14334a9973 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 @@ -8,7 +8,7 @@ import React from 'react'; import sinon from 'sinon'; -import { shallowWithI18nProvider, mountWithI18nProvider } from '@kbn/test/jest'; +import { shallowWithI18nProvider, mountWithI18nProvider } from '@kbn/test-jest-helpers'; 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 a532506595a3d8..5a8cb8d56db693 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider } from '@kbn/test/jest'; +import { shallowWithI18nProvider } from '@kbn/test-jest-helpers'; jest.mock('../../../../saved_objects/public', () => ({ SavedObjectSaveModal: () => null, diff --git a/src/plugins/data/common/index.ts b/src/plugins/data/common/index.ts index 404249d56d638e..7bb4b78850dcda 100644 --- a/src/plugins/data/common/index.ts +++ b/src/plugins/data/common/index.ts @@ -35,7 +35,6 @@ export type { GetFieldsOptions, GetFieldsOptionsTimePattern, IDataViewsApiClient, - IIndexPatternsApiClient, SavedObject, AggregationRestrictions, TypeMeta, @@ -43,9 +42,7 @@ export type { FieldSpecExportFmt, FieldSpec, DataViewFieldMap, - IndexPatternFieldMap, DataViewSpec, - IndexPatternSpec, SourceFilter, IndexPatternExpressionType, IndexPatternLoadStartDependencies, diff --git a/src/plugins/data/public/index.ts b/src/plugins/data/public/index.ts index 7037af5ce54b11..4b7b447d2c8be0 100644 --- a/src/plugins/data/public/index.ts +++ b/src/plugins/data/public/index.ts @@ -78,7 +78,6 @@ export type { IFieldType, IndexPatternAttributes, AggregationRestrictions as IndexPatternAggRestrictions, - IndexPatternSpec, IndexPatternLoadExpressionFunctionDefinition, GetFieldsOptions, AggregationRestrictions, 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 54f0eb06fb04e1..32852b4fe7c32a 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 @@ -8,7 +8,7 @@ import { QueryStringManager } from './query_string_manager'; import { Storage } from '../../../../kibana_utils/public/storage'; -import { StubBrowserStorage } from '@kbn/test/jest'; +import { StubBrowserStorage } from '@kbn/test-jest-helpers'; 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 857a932d9157b9..32e9ec7fb374a9 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 @@ -13,7 +13,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 '@kbn/test/jest'; +import { StubBrowserStorage } from '@kbn/test-jest-helpers'; 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 2e48a11efd69cd..2442ca68f997d9 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 @@ -18,7 +18,7 @@ import { Storage, } from '../../../../kibana_utils/public'; import { QueryService, QueryStart } from '../query_service'; -import { StubBrowserStorage } from '@kbn/test/jest'; +import { StubBrowserStorage } from '@kbn/test-jest-helpers'; import { TimefilterContract } from '../timefilter'; import { syncQueryStateWithUrl } from './sync_state_with_url'; import { QueryState } from './types'; diff --git a/src/plugins/data/public/ui/filter_bar/filter_editor/filter_editor.test.tsx b/src/plugins/data/public/ui/filter_bar/filter_editor/filter_editor.test.tsx index 3a0c0db96c5de2..8f48bef8e0e540 100644 --- a/src/plugins/data/public/ui/filter_bar/filter_editor/filter_editor.test.tsx +++ b/src/plugins/data/public/ui/filter_bar/filter_editor/filter_editor.test.tsx @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { registerTestBed, TestBed } from '@kbn/test/jest'; +import { registerTestBed, TestBed } from '@kbn/test-jest-helpers'; import { FilterEditor, Props } from '.'; import React from 'react'; 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 acbd48718d92ea..67d36f465568d7 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 @@ -10,7 +10,7 @@ import React from 'react'; import { QueryLanguageSwitcher, QueryLanguageSwitcherProps } from './language_switcher'; import { KibanaContextProvider } from 'src/plugins/kibana_react/public'; import { coreMock } from '../../../../../core/public/mocks'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { EuiButtonEmpty, EuiIcon, 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 53edaa8d9bf4f4..f80fc684940912 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl as mount } from '@kbn/test/jest'; +import { mountWithIntl as mount } from '@kbn/test-jest-helpers'; 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 94efcefb719a8b..535b7ea66237bf 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 35933250276c70..d4b30d5a1923bf 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 b8289bc23cf016..0cb71f9097f9ec 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 @@ -9,7 +9,7 @@ import { openModal } from './shard_failure_open_modal_button.test.mocks'; import React from 'react'; import { themeServiceMock } from 'src/core/public/mocks'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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 32f245de53e7b7..c4a53f850ab6a6 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { ShardFailureTable } from './shard_failure_table'; import { shardFailureResponse } from './__mocks__/shard_failure_response'; import { ShardFailure } from './shard_failure_types'; diff --git a/src/plugins/data/public/utils/table_inspector_view/components/data_view.test.tsx b/src/plugins/data/public/utils/table_inspector_view/components/data_view.test.tsx index e6b40bcb5936c4..eb7f51aad8223e 100644 --- a/src/plugins/data/public/utils/table_inspector_view/components/data_view.test.tsx +++ b/src/plugins/data/public/utils/table_inspector_view/components/data_view.test.tsx @@ -8,7 +8,7 @@ import React, { Suspense } from 'react'; import { getTableViewDescription } from '../index'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { TablesAdapter } from '../../../../../expressions/common'; jest.mock('../../../../../share/public', () => ({ diff --git a/src/plugins/data_view_editor/public/components/data_view_editor_flyout_content.tsx b/src/plugins/data_view_editor/public/components/data_view_editor_flyout_content.tsx index c28b03de77adc1..0c5381e99b8fa9 100644 --- a/src/plugins/data_view_editor/public/components/data_view_editor_flyout_content.tsx +++ b/src/plugins/data_view_editor/public/components/data_view_editor_flyout_content.tsx @@ -51,7 +51,7 @@ export interface Props { /** * Handler for the "save" footer button */ - onSave: (indexPatternSpec: DataViewSpec) => void; + onSave: (dataViewSpec: DataViewSpec) => void; /** * Handler for the "cancel" footer button */ diff --git a/src/plugins/data_view_editor/public/components/empty_prompts/empty_index_list_prompt/empty_index_list_prompt.test.tsx b/src/plugins/data_view_editor/public/components/empty_prompts/empty_index_list_prompt/empty_index_list_prompt.test.tsx index f5a996a4415152..3de6995267bb35 100644 --- a/src/plugins/data_view_editor/public/components/empty_prompts/empty_index_list_prompt/empty_index_list_prompt.test.tsx +++ b/src/plugins/data_view_editor/public/components/empty_prompts/empty_index_list_prompt/empty_index_list_prompt.test.tsx @@ -11,7 +11,7 @@ import { EmptyIndexListPrompt } from './empty_index_list_prompt'; import { shallow } from 'enzyme'; import sinon from 'sinon'; import { findTestSubject } from '@elastic/eui/lib/test'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; jest.mock('react-router-dom', () => ({ useHistory: () => ({ diff --git a/src/plugins/data_view_editor/public/components/empty_prompts/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx b/src/plugins/data_view_editor/public/components/empty_prompts/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx index 4cf3c4b55acded..242f124b326b8f 100644 --- a/src/plugins/data_view_editor/public/components/empty_prompts/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx +++ b/src/plugins/data_view_editor/public/components/empty_prompts/empty_index_pattern_prompt/empty_index_pattern_prompt.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { EmptyIndexPatternPrompt } from '../empty_index_pattern_prompt'; -import { shallowWithI18nProvider } from '@kbn/test/jest'; +import { shallowWithI18nProvider } from '@kbn/test-jest-helpers'; describe('EmptyIndexPatternPrompt', () => { it('should render normally', () => { diff --git a/src/plugins/data_view_editor/public/test_utils/test_utils.ts b/src/plugins/data_view_editor/public/test_utils/test_utils.ts index 311d93d31b5935..1a553b74c19c80 100644 --- a/src/plugins/data_view_editor/public/test_utils/test_utils.ts +++ b/src/plugins/data_view_editor/public/test_utils/test_utils.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -export { getRandomString } from '@kbn/test/jest'; +export { getRandomString } from '@kbn/test-jest-helpers'; -export type { TestBed } from '@kbn/test/jest'; -export { registerTestBed } from '@kbn/test/jest'; +export type { TestBed } from '@kbn/test-jest-helpers'; +export { registerTestBed } from '@kbn/test-jest-helpers'; diff --git a/src/plugins/data_view_field_editor/__jest__/client_integration/field_editor.helpers.ts b/src/plugins/data_view_field_editor/__jest__/client_integration/field_editor.helpers.ts index 1fd280a937a031..f1cf9b862ebaa5 100644 --- a/src/plugins/data_view_field_editor/__jest__/client_integration/field_editor.helpers.ts +++ b/src/plugins/data_view_field_editor/__jest__/client_integration/field_editor.helpers.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ import { act } from 'react-dom/test-utils'; -import { registerTestBed, TestBed } from '@kbn/test/jest'; +import { registerTestBed, TestBed } from '@kbn/test-jest-helpers'; import { Context } from '../../public/components/field_editor_context'; import { FieldEditor, Props } from '../../public/components/field_editor/field_editor'; diff --git a/src/plugins/data_view_field_editor/__jest__/client_integration/field_editor_flyout_content.helpers.ts b/src/plugins/data_view_field_editor/__jest__/client_integration/field_editor_flyout_content.helpers.ts index 0e87756819bf20..c3816b0bfb8c3c 100644 --- a/src/plugins/data_view_field_editor/__jest__/client_integration/field_editor_flyout_content.helpers.ts +++ b/src/plugins/data_view_field_editor/__jest__/client_integration/field_editor_flyout_content.helpers.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ import { act } from 'react-dom/test-utils'; -import { registerTestBed, TestBed } from '@kbn/test/jest'; +import { registerTestBed, TestBed } from '@kbn/test-jest-helpers'; import { Context } from '../../public/components/field_editor_context'; import { diff --git a/src/plugins/data_view_field_editor/__jest__/client_integration/field_editor_flyout_preview.helpers.ts b/src/plugins/data_view_field_editor/__jest__/client_integration/field_editor_flyout_preview.helpers.ts index 305cf84d596225..9df7de5f65d620 100644 --- a/src/plugins/data_view_field_editor/__jest__/client_integration/field_editor_flyout_preview.helpers.ts +++ b/src/plugins/data_view_field_editor/__jest__/client_integration/field_editor_flyout_preview.helpers.ts @@ -7,7 +7,7 @@ */ import { act } from 'react-dom/test-utils'; import { ReactWrapper } from 'enzyme'; -import { registerTestBed, TestBed } from '@kbn/test/jest'; +import { registerTestBed, TestBed } from '@kbn/test-jest-helpers'; import { API_BASE_PATH } from '../../common/constants'; import { Context } from '../../public/components/field_editor_context'; diff --git a/src/plugins/data_view_field_editor/__jest__/client_integration/helpers/common_actions.ts b/src/plugins/data_view_field_editor/__jest__/client_integration/helpers/common_actions.ts index 9f8b52af5878ea..77e8e8834a0f4a 100644 --- a/src/plugins/data_view_field_editor/__jest__/client_integration/helpers/common_actions.ts +++ b/src/plugins/data_view_field_editor/__jest__/client_integration/helpers/common_actions.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ import { act } from 'react-dom/test-utils'; -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; /** * We often need to wait for both the documents & the preview to be fetched. diff --git a/src/plugins/data_view_field_editor/__jest__/client_integration/helpers/index.ts b/src/plugins/data_view_field_editor/__jest__/client_integration/helpers/index.ts index 2fc870bd42d66d..b29b76a9daf23d 100644 --- a/src/plugins/data_view_field_editor/__jest__/client_integration/helpers/index.ts +++ b/src/plugins/data_view_field_editor/__jest__/client_integration/helpers/index.ts @@ -6,8 +6,8 @@ * Side Public License, v 1. */ -export type { TestBed } from '@kbn/test/jest'; -export { findTestSubject } from '@kbn/test/jest'; +export type { TestBed } from '@kbn/test-jest-helpers'; +export { findTestSubject } from '@kbn/test-jest-helpers'; export { setupEnvironment, diff --git a/src/plugins/data_view_field_editor/public/components/field_format_editor/editors/color/color.test.tsx b/src/plugins/data_view_field_editor/public/components/field_format_editor/editors/color/color.test.tsx index 362fa0887b7809..750cf8378f3344 100644 --- a/src/plugins/data_view_field_editor/public/components/field_format_editor/editors/color/color.test.tsx +++ b/src/plugins/data_view_field_editor/public/components/field_format_editor/editors/color/color.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider } from '@kbn/test/jest'; +import { shallowWithI18nProvider } from '@kbn/test-jest-helpers'; import { ColorFormatEditor } from './color'; import { FieldFormat, DEFAULT_CONVERTER_COLOR } from '../../../../../../field_formats/common'; diff --git a/src/plugins/data_view_field_editor/public/components/field_format_editor/editors/static_lookup/static_lookup.test.tsx b/src/plugins/data_view_field_editor/public/components/field_format_editor/editors/static_lookup/static_lookup.test.tsx index 5142f11ae87e52..9f2bd59d7ceb46 100644 --- a/src/plugins/data_view_field_editor/public/components/field_format_editor/editors/static_lookup/static_lookup.test.tsx +++ b/src/plugins/data_view_field_editor/public/components/field_format_editor/editors/static_lookup/static_lookup.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider } from '@kbn/test/jest'; +import { shallowWithI18nProvider } from '@kbn/test-jest-helpers'; import { StaticLookupFormatEditorFormatParams } from './static_lookup'; import { FieldFormat } from 'src/plugins/field_formats/common'; diff --git a/src/plugins/data_view_field_editor/public/components/field_format_editor/samples/samples.test.tsx b/src/plugins/data_view_field_editor/public/components/field_format_editor/samples/samples.test.tsx index 433e08ad5bcd05..9b400dd4931e01 100644 --- a/src/plugins/data_view_field_editor/public/components/field_format_editor/samples/samples.test.tsx +++ b/src/plugins/data_view_field_editor/public/components/field_format_editor/samples/samples.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider } from '@kbn/test/jest'; +import { shallowWithI18nProvider } from '@kbn/test-jest-helpers'; import { FormatEditorSamples } from './samples'; diff --git a/src/plugins/data_view_field_editor/public/plugin.test.tsx b/src/plugins/data_view_field_editor/public/plugin.test.tsx index 4f609965171b56..fe7e8c57cd4ece 100644 --- a/src/plugins/data_view_field_editor/public/plugin.test.tsx +++ b/src/plugins/data_view_field_editor/public/plugin.test.tsx @@ -6,7 +6,7 @@ * Side Public License, v 1. */ import React from 'react'; -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; jest.mock('../../kibana_react/public', () => { const original = jest.requireActual('../../kibana_react/public'); diff --git a/src/plugins/data_views/common/data_views/data_views.ts b/src/plugins/data_views/common/data_views/data_views.ts index ddd7989eb59909..8ce6b00d131bb5 100644 --- a/src/plugins/data_views/common/data_views/data_views.ts +++ b/src/plugins/data_views/common/data_views/data_views.ts @@ -367,7 +367,7 @@ export class DataViewsService { /** * Converts index pattern saved object to index pattern spec * @param savedObject - * @returns IndexPatternSpec + * @returns DataViewSpec */ savedObjectToSpec = (savedObject: SavedObject): DataViewSpec => { diff --git a/src/plugins/data_views/common/index.ts b/src/plugins/data_views/common/index.ts index 4de8e98acef392..ece482ff79eaab 100644 --- a/src/plugins/data_views/common/index.ts +++ b/src/plugins/data_views/common/index.ts @@ -41,7 +41,6 @@ export type { GetFieldsOptions, GetFieldsOptionsTimePattern, IDataViewsApiClient, - IIndexPatternsApiClient, SavedObject, AggregationRestrictions, TypeMeta, @@ -49,9 +48,7 @@ export type { FieldSpecExportFmt, FieldSpec, DataViewFieldMap, - IndexPatternFieldMap, DataViewSpec, - IndexPatternSpec, SourceFilter, } from './types'; export { DataViewType } from './types'; diff --git a/src/plugins/data_views/common/types.ts b/src/plugins/data_views/common/types.ts index db0e19cca32b45..f991b61bfad5fb 100644 --- a/src/plugins/data_views/common/types.ts +++ b/src/plugins/data_views/common/types.ts @@ -32,7 +32,7 @@ export interface RuntimeField { /** * @deprecated * IIndexPattern allows for an IndexPattern OR an index pattern saved object - * Use IndexPattern or IndexPatternSpec instead + * Use DataView or DataViewSpec instead */ export interface IIndexPattern extends DataViewBase { title: string; @@ -145,11 +145,6 @@ export interface IDataViewsApiClient { hasUserIndexPattern: () => Promise; } -/** - * @deprecated Use IDataViewsApiClient. All index pattern interfaces were renamed. - */ -export type IIndexPatternsApiClient = IDataViewsApiClient; - export type { SavedObject }; export type AggregationRestrictions = Record< @@ -229,11 +224,6 @@ export interface FieldSpec extends DataViewFieldBase { export type DataViewFieldMap = Record; -/** - * @deprecated Use DataViewFieldMap. All index pattern interfaces were renamed. - */ -export type IndexPatternFieldMap = DataViewFieldMap; - /** * Static index pattern format * Serialized data object, representing index pattern attributes and state @@ -259,11 +249,6 @@ export interface DataViewSpec { allowNoIndex?: boolean; } -/** - * @deprecated Use DataViewSpec. All index pattern interfaces were renamed. - */ -export type IndexPatternSpec = DataViewSpec; - export interface SourceFilter { value: string; } diff --git a/src/plugins/data_views/server/index_patterns_api_client.ts b/src/plugins/data_views/server/index_patterns_api_client.ts index b40c0922589b13..4f036449fe7eee 100644 --- a/src/plugins/data_views/server/index_patterns_api_client.ts +++ b/src/plugins/data_views/server/index_patterns_api_client.ts @@ -9,14 +9,14 @@ import { ElasticsearchClient, SavedObjectsClientContract } from 'kibana/server'; import { GetFieldsOptions, - IIndexPatternsApiClient, GetFieldsOptionsTimePattern, + IDataViewsApiClient, } from '../common/types'; import { DataViewMissingIndices } from '../common/lib'; import { IndexPatternsFetcher } from './fetcher'; import { hasUserIndexPattern } from './has_user_index_pattern'; -export class IndexPatternsApiServer implements IIndexPatternsApiClient { +export class IndexPatternsApiServer implements IDataViewsApiClient { esClient: ElasticsearchClient; constructor( elasticsearchClient: ElasticsearchClient, diff --git a/src/plugins/data_views/server/rest_api_routes/create_data_view.ts b/src/plugins/data_views/server/rest_api_routes/create_data_view.ts index dba6b5584e9ae5..4b103ba87662c8 100644 --- a/src/plugins/data_views/server/rest_api_routes/create_data_view.ts +++ b/src/plugins/data_views/server/rest_api_routes/create_data_view.ts @@ -45,7 +45,7 @@ export const createDataView = async ({ return dataViewsService.createAndSave(spec, override, !refreshFields); }; -const indexPatternSpecSchema = schema.object({ +const dataViewSpecSchema = schema.object({ title: schema.string(), version: schema.maybe(schema.string()), id: schema.maybe(schema.string()), @@ -91,9 +91,8 @@ const registerCreateDataViewRouteFactory = body: schema.object({ override: schema.maybe(schema.boolean({ defaultValue: false })), refresh_fields: schema.maybe(schema.boolean({ defaultValue: false })), - data_view: serviceKey === SERVICE_KEY ? indexPatternSpecSchema : schema.never(), - index_pattern: - serviceKey === SERVICE_KEY_LEGACY ? indexPatternSpecSchema : schema.never(), + data_view: serviceKey === SERVICE_KEY ? dataViewSpecSchema : schema.never(), + index_pattern: serviceKey === SERVICE_KEY_LEGACY ? dataViewSpecSchema : schema.never(), }), }, }, diff --git a/src/plugins/discover/public/application/context/components/action_bar/action_bar.test.tsx b/src/plugins/discover/public/application/context/components/action_bar/action_bar.test.tsx index cce6c7fbe60539..5a4e959ccb5763 100644 --- a/src/plugins/discover/public/application/context/components/action_bar/action_bar.test.tsx +++ b/src/plugins/discover/public/application/context/components/action_bar/action_bar.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ActionBar, ActionBarProps } from './action_bar'; import { findTestSubject } from '@elastic/eui/lib/test'; import { MAX_CONTEXT_SIZE, MIN_CONTEXT_SIZE } from '../../services/constants'; diff --git a/src/plugins/discover/public/application/context/components/context_error_message/context_error_message.test.tsx b/src/plugins/discover/public/application/context/components/context_error_message/context_error_message.test.tsx index 47937058451fa9..049a3977b5b964 100644 --- a/src/plugins/discover/public/application/context/components/context_error_message/context_error_message.test.tsx +++ b/src/plugins/discover/public/application/context/components/context_error_message/context_error_message.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ReactWrapper } from 'enzyme'; import { ContextErrorMessage } from './context_error_message'; import { FailureReason, LoadingStatus } from '../../services/context_query_state'; diff --git a/src/plugins/discover/public/application/context/context_app.test.tsx b/src/plugins/discover/public/application/context/context_app.test.tsx index aa3428e52fa969..c9089a6c1111c1 100644 --- a/src/plugins/discover/public/application/context/context_app.test.tsx +++ b/src/plugins/discover/public/application/context/context_app.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { waitFor } from '@testing-library/react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { createFilterManagerMock } from '../../../../data/public/query/filter_manager/filter_manager.mock'; import { mockTopNavMenu } from './__mocks__/top_nav_menu'; import { ContextAppContent } from './context_app_content'; diff --git a/src/plugins/discover/public/application/context/context_app_content.test.tsx b/src/plugins/discover/public/application/context/context_app_content.test.tsx index a066dbe0deddbe..e57206bcba2c12 100644 --- a/src/plugins/discover/public/application/context/context_app_content.test.tsx +++ b/src/plugins/discover/public/application/context/context_app_content.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { findTestSubject } from '@elastic/eui/lib/test'; import { ActionBar } from './components/action_bar/action_bar'; import { GetStateReturn } from './services/context_state'; diff --git a/src/plugins/discover/public/application/doc/components/doc.test.tsx b/src/plugins/discover/public/application/doc/components/doc.test.tsx index f9b024b9c6835e..29453e7f83f19e 100644 --- a/src/plugins/discover/public/application/doc/components/doc.test.tsx +++ b/src/plugins/discover/public/application/doc/components/doc.test.tsx @@ -9,7 +9,7 @@ import { throwError, of } from 'rxjs'; import React from 'react'; import { act } from 'react-dom/test-utils'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ReactWrapper } from 'enzyme'; import { findTestSubject } from '@elastic/eui/lib/test'; import { Doc, DocProps } from './doc'; diff --git a/src/plugins/discover/public/application/main/components/chart/discover_chart.test.tsx b/src/plugins/discover/public/application/main/components/chart/discover_chart.test.tsx index 3feb8f2cea6b58..1be37081a01b5d 100644 --- a/src/plugins/discover/public/application/main/components/chart/discover_chart.test.tsx +++ b/src/plugins/discover/public/application/main/components/chart/discover_chart.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { Subject, BehaviorSubject } from 'rxjs'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { setHeaderActionMenuMounter } from '../../../../kibana_services'; import { esHits } from '../../../../__mocks__/es_hits'; import { savedSearchMock } from '../../../../__mocks__/saved_search'; diff --git a/src/plugins/discover/public/application/main/components/chart/histogram.test.tsx b/src/plugins/discover/public/application/main/components/chart/histogram.test.tsx index 547c6ffe42f483..d336cd2c092b6c 100644 --- a/src/plugins/discover/public/application/main/components/chart/histogram.test.tsx +++ b/src/plugins/discover/public/application/main/components/chart/histogram.test.tsx @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { BehaviorSubject } from 'rxjs'; import { FetchStatus } from '../../../types'; import { DataCharts$ } from '../../utils/use_saved_search'; diff --git a/src/plugins/discover/public/application/main/components/document_explorer_callout/document_explorere_callout.test.tsx b/src/plugins/discover/public/application/main/components/document_explorer_callout/document_explorere_callout.test.tsx index 37c9f2284aa20e..3e6b8e3973001f 100644 --- a/src/plugins/discover/public/application/main/components/document_explorer_callout/document_explorere_callout.test.tsx +++ b/src/plugins/discover/public/application/main/components/document_explorer_callout/document_explorere_callout.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { KibanaContextProvider } from '../../../../../../kibana_react/public'; import { CALLOUT_STATE_KEY, DocumentExplorerCallout } from './document_explorer_callout'; import { LocalStorageMock } from '../../../../__mocks__/local_storage_mock'; diff --git a/src/plugins/discover/public/application/main/components/hits_counter/hits_counter.test.tsx b/src/plugins/discover/public/application/main/components/hits_counter/hits_counter.test.tsx index d46600fca01f48..4ba4eda45d279d 100644 --- a/src/plugins/discover/public/application/main/components/hits_counter/hits_counter.test.tsx +++ b/src/plugins/discover/public/application/main/components/hits_counter/hits_counter.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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/main/components/layout/discover_documents.test.tsx b/src/plugins/discover/public/application/main/components/layout/discover_documents.test.tsx index cf547b42c72772..78f18e0218872d 100644 --- a/src/plugins/discover/public/application/main/components/layout/discover_documents.test.tsx +++ b/src/plugins/discover/public/application/main/components/layout/discover_documents.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { BehaviorSubject } from 'rxjs'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { setHeaderActionMenuMounter } from '../../../../kibana_services'; import { esHits } from '../../../../__mocks__/es_hits'; import { savedSearchMock } from '../../../../__mocks__/saved_search'; diff --git a/src/plugins/discover/public/application/main/components/layout/discover_layout.test.tsx b/src/plugins/discover/public/application/main/components/layout/discover_layout.test.tsx index aa2149abdde62f..7b0845cd199c00 100644 --- a/src/plugins/discover/public/application/main/components/layout/discover_layout.test.tsx +++ b/src/plugins/discover/public/application/main/components/layout/discover_layout.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { Subject, BehaviorSubject } from 'rxjs'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { setHeaderActionMenuMounter } from '../../../../kibana_services'; import { DiscoverLayout, SIDEBAR_CLOSED_KEY } from './discover_layout'; import { esHits } from '../../../../__mocks__/es_hits'; diff --git a/src/plugins/discover/public/application/main/components/loading_spinner/loading_spinner.test.tsx b/src/plugins/discover/public/application/main/components/loading_spinner/loading_spinner.test.tsx index 020c6d38398bad..36978a1f72684e 100644 --- a/src/plugins/discover/public/application/main/components/loading_spinner/loading_spinner.test.tsx +++ b/src/plugins/discover/public/application/main/components/loading_spinner/loading_spinner.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ReactWrapper } from 'enzyme'; import { LoadingSpinner } from './loading_spinner'; import { findTestSubject } from '@elastic/eui/lib/test'; diff --git a/src/plugins/discover/public/application/main/components/no_results/no_results.test.tsx b/src/plugins/discover/public/application/main/components/no_results/no_results.test.tsx index 2418416e5c2770..4dc1a5feda5dc2 100644 --- a/src/plugins/discover/public/application/main/components/no_results/no_results.test.tsx +++ b/src/plugins/discover/public/application/main/components/no_results/no_results.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { findTestSubject } from '@elastic/eui/lib/test'; import { DiscoverNoResults, DiscoverNoResultsProps } from './no_results'; diff --git a/src/plugins/discover/public/application/main/components/sidebar/change_indexpattern.test.tsx b/src/plugins/discover/public/application/main/components/sidebar/change_indexpattern.test.tsx index b61683c8de14a6..a5e93c1d895bce 100644 --- a/src/plugins/discover/public/application/main/components/sidebar/change_indexpattern.test.tsx +++ b/src/plugins/discover/public/application/main/components/sidebar/change_indexpattern.test.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { EuiSelectable } from '@elastic/eui'; import { ShallowWrapper } from 'enzyme'; import { act } from 'react-dom/test-utils'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { ChangeIndexPattern } from './change_indexpattern'; import { indexPatternMock } from '../../../../__mocks__/index_pattern'; import { indexPatternWithTimefieldMock } from '../../../../__mocks__/index_pattern_with_timefield'; diff --git a/src/plugins/discover/public/application/main/components/sidebar/discover_field.test.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_field.test.tsx index 758738a6cbc568..c2ba365ef5fdae 100644 --- a/src/plugins/discover/public/application/main/components/sidebar/discover_field.test.tsx +++ b/src/plugins/discover/public/application/main/components/sidebar/discover_field.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { findTestSubject } from '@elastic/eui/lib/test'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { DiscoverField } from './discover_field'; import { DataViewField } from '../../../../../../data/common'; diff --git a/src/plugins/discover/public/application/main/components/sidebar/discover_field_details.test.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_field_details.test.tsx index c63a50c17fa8fd..77f2d0fd89d25a 100644 --- a/src/plugins/discover/public/application/main/components/sidebar/discover_field_details.test.tsx +++ b/src/plugins/discover/public/application/main/components/sidebar/discover_field_details.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { findTestSubject } from '@elastic/eui/lib/test'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { DiscoverFieldDetails } from './discover_field_details'; import { DataViewField } from '../../../../../../data/common'; diff --git a/src/plugins/discover/public/application/main/components/sidebar/discover_field_search.test.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_field_search.test.tsx index e654d87ea2ba66..40474f3e4fc1db 100644 --- a/src/plugins/discover/public/application/main/components/sidebar/discover_field_search.test.tsx +++ b/src/plugins/discover/public/application/main/components/sidebar/discover_field_search.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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/main/components/sidebar/discover_index_pattern.test.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_index_pattern.test.tsx index 153f1cb4c7b3d9..73f460cccf784b 100644 --- a/src/plugins/discover/public/application/main/components/sidebar/discover_index_pattern.test.tsx +++ b/src/plugins/discover/public/application/main/components/sidebar/discover_index_pattern.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; -import { shallowWithIntl as shallow } from '@kbn/test/jest'; +import { shallowWithIntl as shallow } from '@kbn/test-jest-helpers'; import { ShallowWrapper } from 'enzyme'; import { ChangeIndexPattern } from './change_indexpattern'; import { SavedObject } from 'kibana/server'; diff --git a/src/plugins/discover/public/application/main/components/sidebar/discover_index_pattern_management.test.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_index_pattern_management.test.tsx index 272e8178aefc22..b511dc08f1e910 100644 --- a/src/plugins/discover/public/application/main/components/sidebar/discover_index_pattern_management.test.tsx +++ b/src/plugins/discover/public/application/main/components/sidebar/discover_index_pattern_management.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl, findTestSubject } from '@kbn/test/jest'; +import { mountWithIntl, findTestSubject } from '@kbn/test-jest-helpers'; import { EuiContextMenuPanel, EuiPopover, EuiContextMenuItem } from '@elastic/eui'; import { DiscoverServices } from '../../../../build_services'; import { DiscoverIndexPatternManagement } from './discover_index_pattern_management'; diff --git a/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.test.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.test.tsx index b6dbf40cc7b3df..8a9e9a0ee6872f 100644 --- a/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.test.tsx +++ b/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.test.tsx @@ -12,7 +12,7 @@ import { findTestSubject } from '@elastic/eui/lib/test'; // @ts-expect-error import realHits from '../../../../__fixtures__/real_hits.js'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; import { DiscoverSidebarProps } from './discover_sidebar'; import { flattenHit, IndexPatternAttributes } from '../../../../../../data/common'; diff --git a/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar_responsive.test.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar_responsive.test.tsx index eee09f4ef481e7..7f1f6b94eab166 100644 --- a/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar_responsive.test.tsx +++ b/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar_responsive.test.tsx @@ -13,7 +13,7 @@ import { findTestSubject } from '@elastic/eui/lib/test'; // @ts-expect-error import realHits from '../../../../__fixtures__/real_hits.js'; import { act } from 'react-dom/test-utils'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; import { flattenHit, IndexPatternAttributes } from '../../../../../../data/common'; import { SavedObject } from '../../../../../../../core/types'; diff --git a/src/plugins/discover/public/application/main/components/skip_bottom_button/skip_bottom_button.test.tsx b/src/plugins/discover/public/application/main/components/skip_bottom_button/skip_bottom_button.test.tsx index 0cdbbb7602e8cb..21456ca59dab1f 100644 --- a/src/plugins/discover/public/application/main/components/skip_bottom_button/skip_bottom_button.test.tsx +++ b/src/plugins/discover/public/application/main/components/skip_bottom_button/skip_bottom_button.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ReactWrapper } from 'enzyme'; import { SkipBottomButton, SkipBottomButtonProps } from './skip_bottom_button'; diff --git a/src/plugins/discover/public/application/main/components/top_nav/discover_topnav.test.tsx b/src/plugins/discover/public/application/main/components/top_nav/discover_topnav.test.tsx index ca5eacd4fdb8a4..2c5c5ffb37d69c 100644 --- a/src/plugins/discover/public/application/main/components/top_nav/discover_topnav.test.tsx +++ b/src/plugins/discover/public/application/main/components/top_nav/discover_topnav.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { indexPatternMock } from '../../../../__mocks__/index_pattern'; import { savedSearchMock } from '../../../../__mocks__/saved_search'; import { DiscoverTopNav, DiscoverTopNavProps } from './discover_topnav'; diff --git a/src/plugins/discover/public/application/main/components/top_nav/open_options_popover.test.tsx b/src/plugins/discover/public/application/main/components/top_nav/open_options_popover.test.tsx index c2059915b2af85..ef64e602280b43 100644 --- a/src/plugins/discover/public/application/main/components/top_nav/open_options_popover.test.tsx +++ b/src/plugins/discover/public/application/main/components/top_nav/open_options_popover.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { findTestSubject } from '@elastic/eui/lib/test'; import { OptionsPopover } from './open_options_popover'; diff --git a/src/plugins/discover/public/application/main/discover_main_app.test.tsx b/src/plugins/discover/public/application/main/discover_main_app.test.tsx index d1699900b14981..5d3b28bb35c5f9 100644 --- a/src/plugins/discover/public/application/main/discover_main_app.test.tsx +++ b/src/plugins/discover/public/application/main/discover_main_app.test.tsx @@ -6,7 +6,7 @@ * Side Public License, v 1. */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { indexPatternMock } from '../../__mocks__/index_pattern'; import { DiscoverMainApp } from './discover_main_app'; import { savedSearchMock } from '../../__mocks__/saved_search'; diff --git a/src/plugins/discover/public/components/discover_grid/discover_grid.test.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid.test.tsx index c4ef4ffef32341..f2b3b130e395c2 100644 --- a/src/plugins/discover/public/components/discover_grid/discover_grid.test.tsx +++ b/src/plugins/discover/public/components/discover_grid/discover_grid.test.tsx @@ -12,7 +12,7 @@ import { act } from 'react-dom/test-utils'; import { findTestSubject } from '@elastic/eui/lib/test'; import { esHits } from '../../__mocks__/es_hits'; import { indexPatternMock } from '../../__mocks__/index_pattern'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { DiscoverGrid, DiscoverGridProps } from './discover_grid'; import { getDocId } from './discover_grid_document_selection'; import { ElasticSearchHit } from '../../types'; diff --git a/src/plugins/discover/public/components/discover_grid/discover_grid_cell_actions.test.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid_cell_actions.test.tsx index 7568cb427e7b51..651004638a85eb 100644 --- a/src/plugins/discover/public/components/discover_grid/discover_grid_cell_actions.test.tsx +++ b/src/plugins/discover/public/components/discover_grid/discover_grid_cell_actions.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { findTestSubject } from '@elastic/eui/lib/test'; import { FilterInBtn, FilterOutBtn, buildCellActions } from './discover_grid_cell_actions'; import { DiscoverGridContext } from './discover_grid_context'; diff --git a/src/plugins/discover/public/components/discover_grid/discover_grid_document_selection.test.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid_document_selection.test.tsx index d57fba241a1e71..2afee7a6a48a32 100644 --- a/src/plugins/discover/public/components/discover_grid/discover_grid_document_selection.test.tsx +++ b/src/plugins/discover/public/components/discover_grid/discover_grid_document_selection.test.tsx @@ -6,7 +6,7 @@ * Side Public License, v 1. */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { findTestSubject } from '@elastic/eui/lib/test'; import { DiscoverGridDocumentToolbarBtn, diff --git a/src/plugins/discover/public/components/discover_grid/discover_grid_expand_button.test.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid_expand_button.test.tsx index de2117afe7bdb6..bb8341f746e851 100644 --- a/src/plugins/discover/public/components/discover_grid/discover_grid_expand_button.test.tsx +++ b/src/plugins/discover/public/components/discover_grid/discover_grid_expand_button.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { findTestSubject } from '@elastic/eui/lib/test'; import { ExpandButton } from './discover_grid_expand_button'; import { DiscoverGridContext } from './discover_grid_context'; diff --git a/src/plugins/discover/public/components/discover_grid/discover_grid_flyout.test.tsx b/src/plugins/discover/public/components/discover_grid/discover_grid_flyout.test.tsx index a6c5ecdcdf35c2..cc10da2dfc4645 100644 --- a/src/plugins/discover/public/components/discover_grid/discover_grid_flyout.test.tsx +++ b/src/plugins/discover/public/components/discover_grid/discover_grid_flyout.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { findTestSubject } from '@elastic/eui/lib/test'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { DiscoverGridFlyout, DiscoverGridFlyoutProps } from './discover_grid_flyout'; import { esHits } from '../../__mocks__/es_hits'; import { createFilterManagerMock } from '../../../../data/public/query/filter_manager/filter_manager.mock'; diff --git a/src/plugins/discover/public/components/doc_table/components/table_header/table_header.test.tsx b/src/plugins/discover/public/components/doc_table/components/table_header/table_header.test.tsx index 60e9c25cb45329..d29bd02e92d35d 100644 --- a/src/plugins/discover/public/components/doc_table/components/table_header/table_header.test.tsx +++ b/src/plugins/discover/public/components/doc_table/components/table_header/table_header.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import type { DataView, DataViewField } from 'src/plugins/data/common'; import { TableHeader } from './table_header'; import { findTestSubject } from '@elastic/eui/lib/test'; diff --git a/src/plugins/discover/public/components/doc_table/components/table_row.test.tsx b/src/plugins/discover/public/components/doc_table/components/table_row.test.tsx index 084fddc991f749..61e536129ffdb7 100644 --- a/src/plugins/discover/public/components/doc_table/components/table_row.test.tsx +++ b/src/plugins/discover/public/components/doc_table/components/table_row.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl, findTestSubject } from '@kbn/test/jest'; +import { mountWithIntl, findTestSubject } from '@kbn/test-jest-helpers'; import { TableRow, TableRowProps } from './table_row'; import { setDocViewsRegistry } from '../../../kibana_services'; import { createFilterManagerMock } from '../../../../../data/public/query/filter_manager/filter_manager.mock'; diff --git a/src/plugins/discover/public/components/doc_table/doc_table_wrapper.test.tsx b/src/plugins/discover/public/components/doc_table/doc_table_wrapper.test.tsx index 3634a47e3bcf10..9de67c340f8bda 100644 --- a/src/plugins/discover/public/components/doc_table/doc_table_wrapper.test.tsx +++ b/src/plugins/discover/public/components/doc_table/doc_table_wrapper.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { findTestSubject, mountWithIntl } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl } from '@kbn/test-jest-helpers'; import { indexPatternMock } from '../../__mocks__/index_pattern'; import { DocTableWrapper } from './doc_table_wrapper'; import { DocTableRow } from './components/table_row'; diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer_source/source.test.tsx b/src/plugins/discover/public/services/doc_views/components/doc_viewer_source/source.test.tsx index 70648b46d78045..986ad37384c920 100644 --- a/src/plugins/discover/public/services/doc_views/components/doc_viewer_source/source.test.tsx +++ b/src/plugins/discover/public/services/doc_views/components/doc_viewer_source/source.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import type { DataView } from 'src/plugins/data/common'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { DocViewerSource } from './source'; import * as hooks from '../../../../utils/use_es_doc_search'; import * as useUiSettingHook from '../../../../../../kibana_react/public/ui_settings/use_ui_setting'; diff --git a/src/plugins/discover/public/services/doc_views/components/doc_viewer_table/legacy/table.test.tsx b/src/plugins/discover/public/services/doc_views/components/doc_viewer_table/legacy/table.test.tsx index cb85315e7dd42d..26dbd76a1dc1a7 100644 --- a/src/plugins/discover/public/services/doc_views/components/doc_viewer_table/legacy/table.test.tsx +++ b/src/plugins/discover/public/services/doc_views/components/doc_viewer_table/legacy/table.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { findTestSubject } from '@elastic/eui/lib/test'; import { DocViewerLegacyTable } from './table'; import { DataView } from '../../../../../../../data/common'; diff --git a/src/plugins/discover/public/services/saved_searches/saved_search_url_conflict_callout.test.tsx b/src/plugins/discover/public/services/saved_searches/saved_search_url_conflict_callout.test.tsx index 0aac9aea621927..6bdea087fcf46c 100644 --- a/src/plugins/discover/public/services/saved_searches/saved_search_url_conflict_callout.test.tsx +++ b/src/plugins/discover/public/services/saved_searches/saved_search_url_conflict_callout.test.tsx @@ -9,7 +9,7 @@ import React from 'react'; import type { History } from 'history'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { SavedSearchURLConflictCallout } from './saved_search_url_conflict_callout'; import type { SavedSearch } from './types'; diff --git a/src/plugins/discover/public/utils/with_query_params.test.tsx b/src/plugins/discover/public/utils/with_query_params.test.tsx index 3d416d6a3e8b54..e23688c0031c78 100644 --- a/src/plugins/discover/public/utils/with_query_params.test.tsx +++ b/src/plugins/discover/public/utils/with_query_params.test.tsx @@ -9,7 +9,7 @@ import React, { ReactElement } from 'react'; import { Router } from 'react-router-dom'; import { createMemoryHistory } from 'history'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { withQueryParams } from './with_query_params'; const mountComponent = (children: ReactElement, query = '') => { 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 d5452870ed0def..07867476508a5b 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; 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 8d313030556c62..81ea83fe06d104 100644 --- a/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx +++ b/src/plugins/embeddable/public/lib/panel/embeddable_panel.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { mount } from 'enzyme'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; 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 1c96945f014c8b..c860fc7e770b93 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 @@ -16,7 +16,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 '@kbn/test/jest'; +import { mountWithIntl as mount } from '@kbn/test-jest-helpers'; 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 be8416da387000..79e68aabe577ac 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 @@ -10,7 +10,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 '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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 4d04778398938e..983f9ceedf3690 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 @@ -7,7 +7,7 @@ */ import { Container, isErrorEmbeddable } from '../../../..'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; 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 44cd93069bfb31..baae08b23cfa1f 100644 --- a/src/plugins/embeddable/public/tests/customize_panel_modal.test.tsx +++ b/src/plugins/embeddable/public/tests/customize_panel_modal.test.tsx @@ -24,7 +24,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 '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { OverlayStart } from 'kibana/public'; let api: EmbeddableStart; diff --git a/src/plugins/es_ui_shared/public/components/cron_editor/cron_editor.test.tsx b/src/plugins/es_ui_shared/public/components/cron_editor/cron_editor.test.tsx index 0ae82872124a43..cb8994b153bdd5 100644 --- a/src/plugins/es_ui_shared/public/components/cron_editor/cron_editor.test.tsx +++ b/src/plugins/es_ui_shared/public/components/cron_editor/cron_editor.test.tsx @@ -9,7 +9,7 @@ import React from 'react'; import sinon from 'sinon'; import { findTestSubject } from '@elastic/eui/lib/test'; -import { mountWithI18nProvider } from '@kbn/test/jest'; +import { mountWithI18nProvider } from '@kbn/test-jest-helpers'; import { Frequency } from './types'; import { CronEditor } from './cron_editor'; 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 cd9bb97cab8d91..113d33dba7100c 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 @@ -7,9 +7,6 @@ */ // eslint-disable-next-line import/no-extraneous-dependencies -export type { TestBed } from '@kbn/test/jest'; +export type { TestBed } from '@kbn/test-jest-helpers'; // eslint-disable-next-line import/no-extraneous-dependencies -export { registerTestBed } from '@kbn/test/jest'; - -// eslint-disable-next-line import/no-extraneous-dependencies -export { getRandomString } from '@kbn/test/jest'; +export { registerTestBed, getRandomString } from '@kbn/test-jest-helpers'; 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 3aa51f89c7d67a..009b72791263bb 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 @@ -8,7 +8,7 @@ import React from 'react'; import { AddData } from './add_data'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { ApplicationStart } from 'kibana/public'; jest.mock('../app_navigation_handler', () => { 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 fb222be6577861..f602ee5aa44396 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 @@ -8,7 +8,7 @@ import React from 'react'; import { ManageData } from './manage_data'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { ApplicationStart } from 'kibana/public'; import { FeatureCatalogueEntry, FeatureCatalogueCategory } from '../../../services'; 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 14611d26aa8e52..95f151923f425e 100644 --- a/src/plugins/home/public/application/components/recently_accessed.test.js +++ b/src/plugins/home/public/application/components/recently_accessed.test.js @@ -10,7 +10,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 '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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 6faadf275bea3d..8c0ce306d9c053 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 70b4856a8b2fd1..c599c8748e925c 100644 --- a/src/plugins/home/public/application/components/tutorial/introduction.test.js +++ b/src/plugins/home/public/application/components/tutorial/introduction.test.js @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { Introduction } from './introduction'; import { httpServiceMock } from '../../../../../../core/public/mocks'; 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 0efcd9bf9df9c7..67ae2d1dd2eed0 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 @@ -8,7 +8,7 @@ import React from 'react'; import { findTestSubject } from '@elastic/eui/lib/test'; -import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test-jest-helpers'; 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 73499c0dcb75fa..9bfe100c4ce600 100644 --- a/src/plugins/home/public/application/components/tutorial/tutorial.test.js +++ b/src/plugins/home/public/application/components/tutorial/tutorial.test.js @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test-jest-helpers'; import { Tutorial } from './tutorial'; diff --git a/src/plugins/home/server/services/sample_data/data_sets/ecommerce/saved_objects.ts b/src/plugins/home/server/services/sample_data/data_sets/ecommerce/saved_objects.ts index 25923f247ca8b4..c2f56c1d6049db 100644 --- a/src/plugins/home/server/services/sample_data/data_sets/ecommerce/saved_objects.ts +++ b/src/plugins/home/server/services/sample_data/data_sets/ecommerce/saved_objects.ts @@ -544,7 +544,7 @@ export const getSavedObjects = (): SavedObject[] => [ label: 'Tx. last week', operationType: 'count', scale: 'ratio', - sourceField: 'Records', + sourceField: '___records___', timeShift: '1w', }, 'ddc92e50-4d5c-413e-b91b-3e504889fa65': { @@ -554,7 +554,7 @@ export const getSavedObjects = (): SavedObject[] => [ label: 'Transactions', operationType: 'count', scale: 'ratio', - sourceField: 'Records', + sourceField: '___records___', }, 'eadae280-2da3-4d1d-a0e1-f9733f89c15b': { customLabel: true, @@ -743,7 +743,7 @@ export const getSavedObjects = (): SavedObject[] => [ label: 'Count of records', operationType: 'count', scale: 'ratio', - sourceField: 'Records', + sourceField: '___records___', }, '9f61a7df-198e-4754-b34c-81ed544136ba': { dataType: 'string', @@ -1070,7 +1070,7 @@ export const getSavedObjects = (): SavedObject[] => [ label: 'Items', operationType: 'count', scale: 'ratio', - sourceField: 'Records', + sourceField: '___records___', }, 'd77cdd24-dedc-48dd-9a4b-d34c6f1a6c46': { customLabel: true, @@ -1186,7 +1186,7 @@ export const getSavedObjects = (): SavedObject[] => [ label: 'Items', operationType: 'count', scale: 'ratio', - sourceField: 'Records', + sourceField: '___records___', }, 'd77cdd24-dedc-48dd-9a4b-d34c6f1a6c46': { customLabel: true, diff --git a/src/plugins/home/server/services/sample_data/data_sets/logs/saved_objects.ts b/src/plugins/home/server/services/sample_data/data_sets/logs/saved_objects.ts index 840fc6e2c175c5..aa2a0d077e30ac 100644 --- a/src/plugins/home/server/services/sample_data/data_sets/logs/saved_objects.ts +++ b/src/plugins/home/server/services/sample_data/data_sets/logs/saved_objects.ts @@ -249,7 +249,7 @@ export const getSavedObjects = (): SavedObject[] => [ label: 'Part of count() / overall_sum(count())', operationType: 'count', scale: 'ratio', - sourceField: 'Records', + sourceField: '___records___', }, 'b5f3dc78-dba8-4db8-87b6-24a0b9cca260X1': { customLabel: true, @@ -258,7 +258,7 @@ export const getSavedObjects = (): SavedObject[] => [ label: 'Part of count() / overall_sum(count())', operationType: 'count', scale: 'ratio', - sourceField: 'Records', + sourceField: '___records___', }, 'b5f3dc78-dba8-4db8-87b6-24a0b9cca260X2': { customLabel: true, 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 3257b7dab0825b..2182843d30975f 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test-jest-helpers'; import { findTestSubject } from '@elastic/eui/lib/test'; import { getDepsMock, getIndexPatternMock } from '../../test_utils'; import ControlsTab, { ControlsTabProps } 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 27597bb3a1e528..3192cd3db54ad3 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 @@ -12,7 +12,7 @@ import { shallow } from 'enzyme'; import { findTestSubject } from '@elastic/eui/lib/test'; -import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; 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 8b886134c11734..45907fc08e1c2e 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 @@ -8,7 +8,7 @@ import React from 'react'; import { shallow } from 'enzyme'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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 2494a0b57dbc5a..67ee222b3bae9a 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 @@ -9,7 +9,7 @@ import React from 'react'; import { shallow } from 'enzyme'; import { SinonSpy, spy, assert } from 'sinon'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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 3eb78cfe815448..6d9f2f9b05adee 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 @@ -9,7 +9,7 @@ import React from 'react'; import sinon from 'sinon'; import { shallow } from 'enzyme'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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 5f102b58a7b42c..cf90ad9837bfec 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 @@ -8,7 +8,7 @@ import React from 'react'; import sinon from 'sinon'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 4396da3df827ba..d51db16952f1ed 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 03b71219b1e9f3..254afca11c1da3 100644 --- a/src/plugins/inspector/public/ui/inspector_panel.test.tsx +++ b/src/plugins/inspector/public/ui/inspector_panel.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { InspectorPanel } from './inspector_panel'; import { InspectorViewDescription } from '../types'; import { Adapters } from '../../common'; diff --git a/src/plugins/interactive_setup/public/theme/kibana_theme_provider.test.tsx b/src/plugins/interactive_setup/public/theme/kibana_theme_provider.test.tsx index 21059bd4a8236c..5d1bc9798ee175 100644 --- a/src/plugins/interactive_setup/public/theme/kibana_theme_provider.test.tsx +++ b/src/plugins/interactive_setup/public/theme/kibana_theme_provider.test.tsx @@ -13,7 +13,7 @@ import React, { useEffect } from 'react'; import { act } from 'react-dom/test-utils'; import { BehaviorSubject, of } from 'rxjs'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import type { CoreTheme } from 'src/core/public'; import { KibanaThemeProvider } from './kibana_theme_provider'; diff --git a/src/plugins/interactive_setup/server/elasticsearch_service.test.ts b/src/plugins/interactive_setup/server/elasticsearch_service.test.ts index 5956bf3a2f64a6..e7b326a1d019d8 100644 --- a/src/plugins/interactive_setup/server/elasticsearch_service.test.ts +++ b/src/plugins/interactive_setup/server/elasticsearch_service.test.ts @@ -10,7 +10,7 @@ import { errors } from '@elastic/elasticsearch'; import { BehaviorSubject } from 'rxjs'; import tls from 'tls'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { elasticsearchServiceMock, loggingSystemMock } from 'src/core/server/mocks'; import { pollEsNodesVersion } from '../../../../src/core/server'; 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 4c58b034186c46..ed091ff96c5f24 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 @@ -8,7 +8,7 @@ import React from 'react'; import { AddData } from './add_data'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { FeatureCatalogueCategory } from 'src/plugins/home/public'; const mockFeatures = [ 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 2a028a7a53a119..f5e72a3e0a8676 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 @@ -8,7 +8,7 @@ import React from 'react'; import { ManageData } from './manage_data'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 0215242d0c078e..420230e7caef6e 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 @@ -9,7 +9,7 @@ import moment from 'moment'; import React from 'react'; import { NewsFeed } from './news_feed'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 b4804fe56f4701..85aee7411d7ad3 100644 --- a/src/plugins/kibana_overview/public/components/overview/overview.test.tsx +++ b/src/plugins/kibana_overview/public/components/overview/overview.test.tsx @@ -13,7 +13,7 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; import { ReactWrapper } from 'enzyme'; import { Overview } from './overview'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { FeatureCatalogueCategory } from 'src/plugins/home/public'; const mockNewsFetchResult = { diff --git a/src/plugins/kibana_react/public/code_editor/code_editor.test.tsx b/src/plugins/kibana_react/public/code_editor/code_editor.test.tsx index 62488809dd59b5..b66d136c507100 100644 --- a/src/plugins/kibana_react/public/code_editor/code_editor.test.tsx +++ b/src/plugins/kibana_react/public/code_editor/code_editor.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { ReactWrapper } from 'enzyme'; -import { mountWithIntl, findTestSubject } from '@kbn/test/jest'; +import { mountWithIntl, findTestSubject } from '@kbn/test-jest-helpers'; import { monaco } from '@kbn/monaco'; import { keys } from '@elastic/eui'; 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 1fbde1bb8bfe9b..ec48d3fda4c73d 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 @@ -8,7 +8,7 @@ import React from 'react'; import { OverviewPageFooter } from './overview_page_footer'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; jest.mock('../../app_links', () => ({ RedirectAppLinks: jest.fn((element: JSX.Element) => element), diff --git a/src/plugins/kibana_react/public/page_template/no_data_page/no_data_page.test.tsx b/src/plugins/kibana_react/public/page_template/no_data_page/no_data_page.test.tsx index 59d6e8280af98d..2c9f91be339f61 100644 --- a/src/plugins/kibana_react/public/page_template/no_data_page/no_data_page.test.tsx +++ b/src/plugins/kibana_react/public/page_template/no_data_page/no_data_page.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { NoDataPage } from './no_data_page'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; describe('NoDataPage', () => { test('render', () => { diff --git a/src/plugins/kibana_react/public/table_list_view/table_list_view.test.tsx b/src/plugins/kibana_react/public/table_list_view/table_list_view.test.tsx index bdc5ca30216bc4..cf8ff8ac8ec53e 100644 --- a/src/plugins/kibana_react/public/table_list_view/table_list_view.test.tsx +++ b/src/plugins/kibana_react/public/table_list_view/table_list_view.test.tsx @@ -7,7 +7,7 @@ */ import { EuiEmptyPrompt } from '@elastic/eui'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { ToastsStart } from 'kibana/public'; import React from 'react'; import { themeServiceMock } from '../../../../../src/core/public/mocks'; diff --git a/src/plugins/kibana_react/public/theme/kibana_theme_provider.test.tsx b/src/plugins/kibana_react/public/theme/kibana_theme_provider.test.tsx index ef7f79cdaa64e1..10c1f32e6ec267 100644 --- a/src/plugins/kibana_react/public/theme/kibana_theme_provider.test.tsx +++ b/src/plugins/kibana_react/public/theme/kibana_theme_provider.test.tsx @@ -12,7 +12,7 @@ import type { ReactWrapper } from 'enzyme'; import { of, BehaviorSubject } from 'rxjs'; import { useEuiTheme } from '@elastic/eui'; import type { UseEuiTheme } from '@elastic/eui'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import type { CoreTheme } from 'src/core/public'; import { KibanaThemeProvider } from './kibana_theme_provider'; diff --git a/src/plugins/kibana_usage_collection/server/collectors/core/core_usage_collector.ts b/src/plugins/kibana_usage_collection/server/collectors/core/core_usage_collector.ts index b1cf0ecd2213ee..a208832baf7198 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/core/core_usage_collector.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/core/core_usage_collector.ts @@ -355,14 +355,14 @@ export function getCoreUsageCollector( type: 'long', _meta: { description: - 'The number of documents in the index, including hidden nested documents.', + 'The number of lucene documents in the index, including hidden nested documents.', }, }, docsDeleted: { type: 'long', _meta: { description: - 'The number of deleted documents in the index, including hidden nested documents.', + 'The number of deleted lucene documents in the index, including hidden nested documents.', }, }, alias: { @@ -382,6 +382,12 @@ export function getCoreUsageCollector( description: 'The size in bytes of the index, for primaries and replicas.', }, }, + savedObjectsDocsCount: { + type: 'long', + _meta: { + description: 'The number of saved objects documents in the index.', + }, + }, }, }, legacyUrlAliases: { 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 8d22665fdf2cc2..3c748fab8e0c1b 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 @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { StubBrowserStorage } from '@kbn/test/jest'; +import { StubBrowserStorage } from '@kbn/test-jest-helpers'; 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 2bc1f1e57f117c..42a12c3fd0c5d2 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 @@ -7,7 +7,7 @@ */ import { createUrlTracker, IUrlTracker } from './url_tracker'; -import { StubBrowserStorage } from '@kbn/test/jest'; +import { StubBrowserStorage } from '@kbn/test-jest-helpers'; 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 6fac5731d50a37..f752c6e25c8ab5 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 @@ -22,7 +22,7 @@ import { IKbnUrlStateStorage, ISessionStorageStateStorage, } from './state_sync_state_storage'; -import { StubBrowserStorage } from '@kbn/test/jest'; +import { StubBrowserStorage } from '@kbn/test-jest-helpers'; 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 cad2fc2733f3cf..a0ab2b3f9da3dc 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 @@ -10,7 +10,7 @@ import { createSessionStorageStateStorage, ISessionStorageStateStorage, } from './create_session_storage_state_storage'; -import { StubBrowserStorage } from '@kbn/test/jest'; +import { StubBrowserStorage } from '@kbn/test-jest-helpers'; 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 b7ee08044b3234..20cc81bc3b75b8 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 @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { StubBrowserStorage } from '@kbn/test/jest'; +import { StubBrowserStorage } from '@kbn/test-jest-helpers'; 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 56408d2cbdb5be..0f2176b5d4ba90 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 @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { StubBrowserStorage } from '@kbn/test/jest'; +import { StubBrowserStorage } from '@kbn/test-jest-helpers'; import { HashedItemStore } from './hashed_item_store'; /** diff --git a/src/plugins/kibana_utils/public/theme/kibana_theme_provider.test.tsx b/src/plugins/kibana_utils/public/theme/kibana_theme_provider.test.tsx index 21059bd4a8236c..5d1bc9798ee175 100644 --- a/src/plugins/kibana_utils/public/theme/kibana_theme_provider.test.tsx +++ b/src/plugins/kibana_utils/public/theme/kibana_theme_provider.test.tsx @@ -13,7 +13,7 @@ import React, { useEffect } from 'react'; import { act } from 'react-dom/test-utils'; import { BehaviorSubject, of } from 'rxjs'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import type { CoreTheme } from 'src/core/public'; import { KibanaThemeProvider } from './kibana_theme_provider'; 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 45b9b4c7a885b8..682154dd5d5db4 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 @@ -12,7 +12,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 '@kbn/test/jest'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test-jest-helpers'; 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 8d62a3ebd96332..2211ae5db10528 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 @@ -9,7 +9,7 @@ import React from 'react'; import { TopNavMenuItem } from './top_nav_menu_item'; import { TopNavMenuData } from './top_nav_menu_data'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 2c530df7b93aea..8e939ec58a7925 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 @@ -10,7 +10,7 @@ import { shallow } from 'enzyme'; import React from 'react'; import { SavedObjectSaveModal } from './saved_object_save_modal'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; describe('SavedObjectSaveModal', () => { it('should render matching snapshot', () => { diff --git a/src/plugins/saved_objects_management/public/management_section/object_view/components/inspect.test.tsx b/src/plugins/saved_objects_management/public/management_section/object_view/components/inspect.test.tsx index 843468b78307cd..4e852de7ee7312 100644 --- a/src/plugins/saved_objects_management/public/management_section/object_view/components/inspect.test.tsx +++ b/src/plugins/saved_objects_management/public/management_section/object_view/components/inspect.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { ShallowWrapper } from 'enzyme'; -import { shallowWithI18nProvider } from '@kbn/test/jest'; +import { shallowWithI18nProvider } from '@kbn/test-jest-helpers'; import { Inspect, InspectProps } from './inspect'; import { SavedObjectWithMetadata } from '../../../../common'; diff --git a/src/plugins/saved_objects_management/public/management_section/object_view/saved_object_view.test.tsx b/src/plugins/saved_objects_management/public/management_section/object_view/saved_object_view.test.tsx index 554e34a9fc55a0..ba0a584a94074e 100644 --- a/src/plugins/saved_objects_management/public/management_section/object_view/saved_object_view.test.tsx +++ b/src/plugins/saved_objects_management/public/management_section/object_view/saved_object_view.test.tsx @@ -10,7 +10,7 @@ import { bulkGetObjectsMock } from './saved_object_view.test.mocks'; import React from 'react'; import { ShallowWrapper } from 'enzyme'; -import { shallowWithI18nProvider } from '@kbn/test/jest'; +import { shallowWithI18nProvider } from '@kbn/test-jest-helpers'; import { httpServiceMock, diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/delete_confirm_modal.test.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/components/delete_confirm_modal.test.tsx index 396ef209cc3968..3c24d68007222f 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/delete_confirm_modal.test.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/delete_confirm_modal.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { findTestSubject } from '@elastic/eui/lib/test'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import type { SavedObjectWithMetadata, SavedObjectManagementTypeInfo } from '../../../../common'; import { DeleteConfirmModal } from './delete_confirm_modal'; diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/export_modal.test.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/components/export_modal.test.tsx index eb364dbf691028..609338f7aed384 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/export_modal.test.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/export_modal.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ExportModal } from './export_modal'; describe('ExportModal', () => { 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 a084c26b04d2dc..04d45565487204 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 @@ -9,7 +9,7 @@ import { importFileMock, resolveImportErrorsMock } from './flyout.test.mocks'; import React from 'react'; -import { shallowWithI18nProvider } from '@kbn/test/jest'; +import { shallowWithI18nProvider } from '@kbn/test-jest-helpers'; import { coreMock, httpServiceMock } from '../../../../../../core/public/mocks'; import { Flyout, FlyoutProps, FlyoutState } from './flyout'; import { ShallowWrapper } from 'enzyme'; 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 fbf50e0ee0c864..481e8cd91903fe 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 @@ -8,7 +8,7 @@ import React from 'react'; import { ReactWrapper } from 'enzyme'; -import { shallowWithI18nProvider, mountWithIntl } from '@kbn/test/jest'; +import { shallowWithI18nProvider, mountWithIntl } from '@kbn/test-jest-helpers'; 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 4cbfcb06b35958..03d3631398cda4 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 @@ -8,7 +8,7 @@ import React from 'react'; import { ReactWrapper } from 'enzyme'; -import { mountWithI18nProvider } from '@kbn/test/jest'; +import { mountWithI18nProvider } from '@kbn/test-jest-helpers'; import { httpServiceMock } from '../../../../../../core/public/mocks'; 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 ef9020d231f315..c07ab70079ccfe 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider, mountWithIntl } from '@kbn/test/jest'; +import { shallowWithI18nProvider, mountWithIntl } from '@kbn/test-jest-helpers'; 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 a3db8af627d2fc..751335e4670d99 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider } from '@kbn/test/jest'; +import { shallowWithI18nProvider } from '@kbn/test-jest-helpers'; import { httpServiceMock } from '../../../../../../core/public/mocks'; import type { SavedObjectManagementTypeInfo } from '../../../../common/types'; 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 6fb153cb980ff1..c0b795f9e9610e 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithI18nProvider, mountWithI18nProvider } from '@kbn/test/jest'; +import { shallowWithI18nProvider, mountWithI18nProvider } from '@kbn/test-jest-helpers'; 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 173d8af0de04d5..5382cc39989ed2 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 @@ -19,7 +19,7 @@ import { import React from 'react'; import { Query } from '@elastic/eui'; import { ShallowWrapper } from 'enzyme'; -import { shallowWithI18nProvider } from '@kbn/test/jest'; +import { shallowWithI18nProvider } from '@kbn/test-jest-helpers'; import { httpServiceMock, overlayServiceMock, 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 b892633b66b9ac..1c4467db803c46 100644 --- a/src/plugins/telemetry/public/components/opt_in_banner.test.tsx +++ b/src/plugins/telemetry/public/components/opt_in_banner.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { EuiButton } from '@elastic/eui'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 c27e4326c66253..1196e36a1b4244 100644 --- a/src/plugins/telemetry/public/components/opt_in_message.test.tsx +++ b/src/plugins/telemetry/public/components/opt_in_message.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 ce5a42ed17ad8d..e4ec8e32c54560 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 @@ -8,7 +8,7 @@ import React from 'react'; import { EuiButton } from '@elastic/eui'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { OptedInNoticeBanner } from './opted_in_notice_banner'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { httpServiceMock } from '../../../../core/public/http/http_service.mock'; diff --git a/src/plugins/telemetry/schema/oss_plugins.json b/src/plugins/telemetry/schema/oss_plugins.json index 3269452ca8cc3d..dcbf919698243e 100644 --- a/src/plugins/telemetry/schema/oss_plugins.json +++ b/src/plugins/telemetry/schema/oss_plugins.json @@ -6248,13 +6248,13 @@ "docsCount": { "type": "long", "_meta": { - "description": "The number of documents in the index, including hidden nested documents." + "description": "The number of lucene documents in the index, including hidden nested documents." } }, "docsDeleted": { "type": "long", "_meta": { - "description": "The number of deleted documents in the index, including hidden nested documents." + "description": "The number of deleted lucene documents in the index, including hidden nested documents." } }, "alias": { @@ -6274,6 +6274,12 @@ "_meta": { "description": "The size in bytes of the index, for primaries and replicas." } + }, + "savedObjectsDocsCount": { + "type": "long", + "_meta": { + "description": "The number of saved objects documents in the index." + } } } } diff --git a/src/plugins/telemetry/server/routes/telemetry_usage_stats.test.ts b/src/plugins/telemetry/server/routes/telemetry_usage_stats.test.ts new file mode 100644 index 00000000000000..736367446d3c05 --- /dev/null +++ b/src/plugins/telemetry/server/routes/telemetry_usage_stats.test.ts @@ -0,0 +1,103 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { registerTelemetryUsageStatsRoutes } from './telemetry_usage_stats'; +import { coreMock, httpServerMock } from 'src/core/server/mocks'; +import type { RequestHandlerContext, IRouter } from 'kibana/server'; +import { telemetryCollectionManagerPluginMock } from '../../../telemetry_collection_manager/server/mocks'; + +async function runRequest( + mockRouter: IRouter, + body?: { unencrypted?: boolean; refreshCache?: boolean } +) { + expect(mockRouter.post).toBeCalled(); + const [, handler] = (mockRouter.post as jest.Mock).mock.calls[0]; + const mockResponse = httpServerMock.createResponseFactory(); + const mockRequest = httpServerMock.createKibanaRequest({ body }); + await handler(null, mockRequest, mockResponse); + + return { mockResponse, mockRequest }; +} + +describe('registerTelemetryUsageStatsRoutes', () => { + const router = { + handler: undefined, + config: undefined, + post: jest.fn().mockImplementation((config, handler) => { + router.config = config; + router.handler = handler; + }), + }; + const telemetryCollectionManager = telemetryCollectionManagerPluginMock.createSetupContract(); + const mockCoreSetup = coreMock.createSetup(); + const mockRouter = mockCoreSetup.http.createRouter(); + const mockStats = [{ clusterUuid: 'text', stats: 'enc_str' }]; + telemetryCollectionManager.getStats.mockResolvedValue(mockStats); + + describe('clusters/_stats POST route', () => { + it('registers _stats POST route and accepts body configs', () => { + registerTelemetryUsageStatsRoutes(mockRouter, telemetryCollectionManager, true); + expect(mockRouter.post).toBeCalledTimes(1); + const [routeConfig, handler] = (mockRouter.post as jest.Mock).mock.calls[0]; + expect(routeConfig.path).toMatchInlineSnapshot(`"/api/telemetry/v2/clusters/_stats"`); + expect(Object.keys(routeConfig.validate.body.props)).toEqual(['unencrypted', 'refreshCache']); + expect(handler).toBeInstanceOf(Function); + }); + + it('responds with encrypted stats with no cache refresh by default', async () => { + registerTelemetryUsageStatsRoutes(mockRouter, telemetryCollectionManager, true); + + const { mockRequest, mockResponse } = await runRequest(mockRouter); + expect(telemetryCollectionManager.getStats).toBeCalledWith({ + request: mockRequest, + unencrypted: undefined, + refreshCache: undefined, + }); + expect(mockResponse.ok).toBeCalled(); + expect(mockResponse.ok.mock.calls[0][0]).toEqual({ body: mockStats }); + }); + + it('when unencrypted is set getStats is called with unencrypted and refreshCache', async () => { + registerTelemetryUsageStatsRoutes(mockRouter, telemetryCollectionManager, true); + + const { mockRequest } = await runRequest(mockRouter, { unencrypted: true }); + expect(telemetryCollectionManager.getStats).toBeCalledWith({ + request: mockRequest, + unencrypted: true, + refreshCache: true, + }); + }); + + it('calls getStats with refreshCache when set in body', async () => { + registerTelemetryUsageStatsRoutes(mockRouter, telemetryCollectionManager, true); + const { mockRequest } = await runRequest(mockRouter, { refreshCache: true }); + expect(telemetryCollectionManager.getStats).toBeCalledWith({ + request: mockRequest, + unencrypted: undefined, + refreshCache: true, + }); + }); + + it('calls getStats with refreshCache:true even if set to false in body when unencrypted is set to true', async () => { + registerTelemetryUsageStatsRoutes(mockRouter, telemetryCollectionManager, true); + const { mockRequest } = await runRequest(mockRouter, { + refreshCache: false, + unencrypted: true, + }); + expect(telemetryCollectionManager.getStats).toBeCalledWith({ + request: mockRequest, + unencrypted: true, + refreshCache: true, + }); + }); + + it.todo('always returns an empty array on errors on encrypted payload'); + it.todo('returns the actual request error object when in development mode'); + it.todo('returns forbidden on unencrypted and ES returns 403 in getStats'); + }); +}); diff --git a/src/plugins/telemetry/server/routes/telemetry_usage_stats.ts b/src/plugins/telemetry/server/routes/telemetry_usage_stats.ts index e3ce8cbc5190a9..2f72ae818f1121 100644 --- a/src/plugins/telemetry/server/routes/telemetry_usage_stats.ts +++ b/src/plugins/telemetry/server/routes/telemetry_usage_stats.ts @@ -35,7 +35,7 @@ export function registerTelemetryUsageStatsRoutes( const statsConfig: StatsGetterConfig = { request: req, unencrypted, - refreshCache, + refreshCache: unencrypted || refreshCache, }; const stats = await telemetryCollectionManager.getStats(statsConfig); diff --git a/src/plugins/telemetry_collection_manager/server/mocks.ts b/src/plugins/telemetry_collection_manager/server/mocks.ts new file mode 100644 index 00000000000000..cbd9dac9cfaa67 --- /dev/null +++ b/src/plugins/telemetry_collection_manager/server/mocks.ts @@ -0,0 +1,39 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import type { + TelemetryCollectionManagerPluginSetup, + TelemetryCollectionManagerPluginStart, +} from './types'; + +export type Setup = jest.Mocked; +export type Start = jest.Mocked; + +export const telemetryCollectionManagerPluginMock = { + createSetupContract, + createStartContract, +}; + +function createSetupContract(): Setup { + const setupContract: Setup = { + getStats: jest.fn(), + getOptInStats: jest.fn(), + setCollectionStrategy: jest.fn(), + }; + + return setupContract; +} + +function createStartContract(): Start { + const startContract: Start = { + getOptInStats: jest.fn(), + getStats: jest.fn(), + }; + + return startContract; +} diff --git a/src/plugins/telemetry_collection_manager/server/plugin.test.ts b/src/plugins/telemetry_collection_manager/server/plugin.test.ts index 77cc2ac9ca5105..ca932e92d98bdb 100644 --- a/src/plugins/telemetry_collection_manager/server/plugin.test.ts +++ b/src/plugins/telemetry_collection_manager/server/plugin.test.ts @@ -135,6 +135,45 @@ describe('Telemetry Collection Manager', () => { collectionStrategy.clusterDetailsGetter.mock.calls[0][0].soClient ).toBeInstanceOf(TelemetrySavedObjectsClient); }); + + it('calls getStats with passed refreshCache config', async () => { + const getStatsCollectionConfig: jest.SpyInstance< + TelemetryCollectionManagerPlugin['getStatsCollectionConfig'] + // @ts-expect-error spying on private method. + > = jest.spyOn(telemetryCollectionManager, 'getStatsCollectionConfig'); + await setupApi.getStats(config); + await setupApi.getStats({ ...config, refreshCache: false }); + await setupApi.getStats({ ...config, refreshCache: true }); + + expect(getStatsCollectionConfig).toBeCalledTimes(3); + expect(getStatsCollectionConfig).toHaveBeenNthCalledWith(1, config, usageCollection); + expect(getStatsCollectionConfig).toHaveNthReturnedWith( + 1, + expect.objectContaining({ refreshCache: false }) + ); + + expect(getStatsCollectionConfig).toHaveBeenNthCalledWith( + 2, + expect.objectContaining({ refreshCache: false }), + usageCollection + ); + expect(getStatsCollectionConfig).toHaveNthReturnedWith( + 2, + expect.objectContaining({ refreshCache: false }) + ); + + expect(getStatsCollectionConfig).toHaveBeenNthCalledWith( + 3, + expect.objectContaining({ refreshCache: true }), + usageCollection + ); + expect(getStatsCollectionConfig).toHaveNthReturnedWith( + 3, + expect.objectContaining({ refreshCache: true }) + ); + + getStatsCollectionConfig.mockRestore(); + }); }); describe('getOptInStats', () => { @@ -178,9 +217,10 @@ describe('Telemetry Collection Manager', () => { }); }); describe('unencrypted: true', () => { + const mockRequest = httpServerMock.createKibanaRequest(); const config: StatsGetterConfig = { unencrypted: true, - request: httpServerMock.createKibanaRequest(), + request: mockRequest, }; describe('getStats', () => { @@ -212,23 +252,26 @@ describe('Telemetry Collection Manager', () => { ).not.toBeInstanceOf(TelemetrySavedObjectsClient); }); - test('returns cached object on multiple calls', async () => { - collectionStrategy.clusterDetailsGetter.mockResolvedValue([ - { clusterUuid: 'clusterUuid' }, - ]); - collectionStrategy.statsGetter.mockResolvedValue([basicStats]); + it('calls getStats with config { refreshCache: true } even if set to false', async () => { + const getStatsCollectionConfig: jest.SpyInstance< + TelemetryCollectionManagerPlugin['getStatsCollectionConfig'] + // @ts-expect-error spying on private method. + > = jest.spyOn(telemetryCollectionManager, 'getStatsCollectionConfig'); await setupApi.getStats(config); - await expect(setupApi.getStats(config)).resolves.toStrictEqual([ - { - clusterUuid: 'clusterUuid', - stats: { - ...basicStats, - cacheDetails: { updatedAt: expect.any(String), fetchedAt: expect.any(String) }, - collectionSource: 'test_collection', - }, - }, - ]); + expect(getStatsCollectionConfig).toBeCalledTimes(1); + expect(getStatsCollectionConfig).toBeCalledWith( + expect.not.objectContaining({ refreshCache: true }), + usageCollection + ); + expect(getStatsCollectionConfig).toReturnWith( + expect.objectContaining({ + refreshCache: true, + kibanaRequest: mockRequest, + }) + ); + + getStatsCollectionConfig.mockRestore(); }); }); diff --git a/src/plugins/telemetry_collection_manager/server/plugin.ts b/src/plugins/telemetry_collection_manager/server/plugin.ts index bdce2c8be31d8f..fad51ca1dbfde8 100644 --- a/src/plugins/telemetry_collection_manager/server/plugin.ts +++ b/src/plugins/telemetry_collection_manager/server/plugin.ts @@ -127,7 +127,7 @@ export class TelemetryCollectionManagerPlugin const soClient = this.getSavedObjectsClient(config); // Provide the kibanaRequest so opted-in plugins can scope their custom clients only if the request is not encrypted const kibanaRequest = config.unencrypted ? config.request : void 0; - const refreshCache = !!config.refreshCache; + const refreshCache = config.unencrypted ? true : !!config.refreshCache; if (esClient && soClient) { return { usageCollection, esClient, soClient, kibanaRequest, refreshCache }; 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 52c6ecfefbacfc..845d7d3fa0c8af 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { OptInExampleFlyout } from './opt_in_example_flyout'; describe('OptInDetailsComponent', () => { 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 8f27c340720a12..4b474f0cc7bddf 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import TelemetryManagementSection from './telemetry_management_section'; import { TelemetryService } from '../../../telemetry/public/services'; import { coreMock } from '../../../../core/public/mocks'; @@ -257,7 +257,7 @@ describe('TelemetryManagementSectionComponent', () => { await expect( toggleOptInComponent.prop('handleChange')() ).resolves.toBe(true); - // TODO: Fix `mountWithIntl` types in @kbn/test/jest to make testing easier + // TODO: Fix `mountWithIntl` types in @kbn/test-jest-helpers to make testing easier expect((component.state() as { enabled: boolean }).enabled).toBe(true); await expect( toggleOptInComponent.prop('handleChange')() 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 af363dbacaff72..87c74d0c497a73 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 @@ -8,7 +8,7 @@ import React from 'react'; import { shallow } from 'enzyme'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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 02cc0aadfff61a..00da70d7687f8a 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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/palette_picker.test.tsx b/src/plugins/vis_default_editor/public/components/controls/palette_picker.test.tsx index 21fdde725cd913..a02bdc6cdb6b40 100644 --- a/src/plugins/vis_default_editor/public/components/controls/palette_picker.test.tsx +++ b/src/plugins/vis_default_editor/public/components/controls/palette_picker.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ReactWrapper } from 'enzyme'; import { PalettePicker, PalettePickerProps } from './palette_picker'; import { chartPluginMock } from '../../../../charts/public/mocks'; diff --git a/src/plugins/vis_default_editor/public/components/controls/percentiles.test.tsx b/src/plugins/vis_default_editor/public/components/controls/percentiles.test.tsx index c009196c20d8ce..a94c68c944d121 100644 --- a/src/plugins/vis_default_editor/public/components/controls/percentiles.test.tsx +++ b/src/plugins/vis_default_editor/public/components/controls/percentiles.test.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { AggParamEditorProps } from '../agg_param_props'; import { IAggConfig } from 'src/plugins/data/public'; -import { mountWithIntl as mount } from '@kbn/test/jest'; +import { mountWithIntl as mount } from '@kbn/test-jest-helpers'; import { PercentilesEditor } from './percentiles'; import { EditorVisState } from '../sidebar/state/reducers'; 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 0d86b6074bce55..9081ed5745254b 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; 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 9c83403c60cb4f..95e3a74a66d703 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import { AggregateValueProp, TopAggregateParamEditor, diff --git a/src/plugins/vis_default_editor/public/components/options/long_legend_options.test.tsx b/src/plugins/vis_default_editor/public/components/options/long_legend_options.test.tsx index a95a47bf7af88d..0db6473d74d0e0 100644 --- a/src/plugins/vis_default_editor/public/components/options/long_legend_options.test.tsx +++ b/src/plugins/vis_default_editor/public/components/options/long_legend_options.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { LongLegendOptions, LongLegendOptionsProps } from './long_legend_options'; import { EuiFieldNumber } from '@elastic/eui'; diff --git a/src/plugins/vis_default_editor/public/components/options/percentage_mode.test.tsx b/src/plugins/vis_default_editor/public/components/options/percentage_mode.test.tsx index 05d321a7b465c4..5f45f619d2e4de 100644 --- a/src/plugins/vis_default_editor/public/components/options/percentage_mode.test.tsx +++ b/src/plugins/vis_default_editor/public/components/options/percentage_mode.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { PercentageModeOption, PercentageModeOptionProps } from './percentage_mode'; import { EuiFieldText } from '@elastic/eui'; diff --git a/src/plugins/vis_types/heatmap/public/editor/components/heatmap.test.tsx b/src/plugins/vis_types/heatmap/public/editor/components/heatmap.test.tsx index 5f57083072202c..bb1467c658f764 100644 --- a/src/plugins/vis_types/heatmap/public/editor/components/heatmap.test.tsx +++ b/src/plugins/vis_types/heatmap/public/editor/components/heatmap.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ReactWrapper } from 'enzyme'; import type { PersistedState } from '../../../../../visualizations/public'; import HeatmapOptions, { HeatmapOptionsProps } from './heatmap'; diff --git a/src/plugins/vis_types/pie/public/editor/components/pie.test.tsx b/src/plugins/vis_types/pie/public/editor/components/pie.test.tsx index d6dc4c0734e428..aac0c5aef60018 100644 --- a/src/plugins/vis_types/pie/public/editor/components/pie.test.tsx +++ b/src/plugins/vis_types/pie/public/editor/components/pie.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ReactWrapper } from 'enzyme'; import PieOptions, { PieOptionsProps } from './pie'; import { chartPluginMock } from '../../../../../charts/public/mocks'; diff --git a/src/plugins/vis_types/pie/public/editor/components/truncate_labels.test.tsx b/src/plugins/vis_types/pie/public/editor/components/truncate_labels.test.tsx index 1d4bb238dcb50e..fc5731dc6839f6 100644 --- a/src/plugins/vis_types/pie/public/editor/components/truncate_labels.test.tsx +++ b/src/plugins/vis_types/pie/public/editor/components/truncate_labels.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ReactWrapper } from 'enzyme'; import { TruncateLabelsOption, TruncateLabelsOptionProps } from './truncate_labels'; import { findTestSubject } from '@elastic/eui/lib/test'; diff --git a/src/plugins/vis_types/timeseries/common/constants.ts b/src/plugins/vis_types/timeseries/common/constants.ts index 30fb814990925f..cbaf275cc00924 100644 --- a/src/plugins/vis_types/timeseries/common/constants.ts +++ b/src/plugins/vis_types/timeseries/common/constants.ts @@ -11,6 +11,7 @@ export const UI_SETTINGS = { ALLOW_STRING_INDICES: 'metrics:allowStringIndices', ALLOW_CHECKING_FOR_FAILED_SHARDS: 'metrics:allowCheckingForFailedShards', }; +export const SERIES_SEPARATOR = '╰┄►'; export const INDEXES_SEPARATOR = ','; export const AUTO_INTERVAL = 'auto'; export const ROUTES = { diff --git a/src/plugins/vis_types/timeseries/public/application/_variables.scss b/src/plugins/vis_types/timeseries/public/application/_variables.scss index 0107c5569d7302..b3334c93a9bbea 100644 --- a/src/plugins/vis_types/timeseries/public/application/_variables.scss +++ b/src/plugins/vis_types/timeseries/public/application/_variables.scss @@ -1,7 +1,7 @@ $tvbLineColor: transparentize($euiColorFullShade, .8); $tvbLineColorReversed: transparentize($euiColorEmptyShade, .6); -$tvbTextColor: transparentize($euiColorFullShade, .6); +$tvbTextColor: transparentize($euiColorFullShade, .4); $tvbTextColorReversed: transparentize($euiColorEmptyShade, .4); $tvbValueColor: transparentize($euiColorFullShade, .3); diff --git a/src/plugins/vis_types/timeseries/public/application/components/add_delete_buttons.test.tsx b/src/plugins/vis_types/timeseries/public/application/components/add_delete_buttons.test.tsx index 43e59222e0e1e7..d6bd687d60055e 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/add_delete_buttons.test.tsx +++ b/src/plugins/vis_types/timeseries/public/application/components/add_delete_buttons.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { AddDeleteButtons } from './add_delete_buttons'; describe('AddDeleteButtons', () => { diff --git a/src/plugins/vis_types/timeseries/public/application/components/aggs/agg_select.test.tsx b/src/plugins/vis_types/timeseries/public/application/components/aggs/agg_select.test.tsx index 3dbeb257900b70..ccdf60ea9cf98b 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/aggs/agg_select.test.tsx +++ b/src/plugins/vis_types/timeseries/public/application/components/aggs/agg_select.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { AggSelect } from './agg_select'; import { METRIC, SERIES } from '../../../test_utils'; import { EuiComboBox } from '@elastic/eui'; diff --git a/src/plugins/vis_types/timeseries/public/application/components/aggs/filter_ratio.test.js b/src/plugins/vis_types/timeseries/public/application/components/aggs/filter_ratio.test.js index bd9ceeeb740282..38305395bfbb6b 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/aggs/filter_ratio.test.js +++ b/src/plugins/vis_types/timeseries/public/application/components/aggs/filter_ratio.test.js @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { FilterRatioAgg } from './filter_ratio'; import { FIELDS, METRIC, SERIES, PANEL } from '../../../test_utils'; import { EuiComboBox } from '@elastic/eui'; diff --git a/src/plugins/vis_types/timeseries/public/application/components/aggs/histogram_support.test.js b/src/plugins/vis_types/timeseries/public/application/components/aggs/histogram_support.test.js index ff96e476814ffa..b97968ff622413 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/aggs/histogram_support.test.js +++ b/src/plugins/vis_types/timeseries/public/application/components/aggs/histogram_support.test.js @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { Agg } from './agg'; import { FieldSelect } from './field_select'; import { FIELDS, METRIC, SERIES, PANEL } from '../../../test_utils'; diff --git a/src/plugins/vis_types/timeseries/public/application/components/aggs/percentile_rank/multi_value_row.test.tsx b/src/plugins/vis_types/timeseries/public/application/components/aggs/percentile_rank/multi_value_row.test.tsx index 7b08715ba1a934..d0a140a15b4882 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/aggs/percentile_rank/multi_value_row.test.tsx +++ b/src/plugins/vis_types/timeseries/public/application/components/aggs/percentile_rank/multi_value_row.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { MultiValueRow } from './multi_value_row'; import { ColorPicker } from '../../color_picker'; diff --git a/src/plugins/vis_types/timeseries/public/application/components/aggs/percentile_ui.test.tsx b/src/plugins/vis_types/timeseries/public/application/components/aggs/percentile_ui.test.tsx index b143c0bf6ceab8..edb0ae4d798848 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/aggs/percentile_ui.test.tsx +++ b/src/plugins/vis_types/timeseries/public/application/components/aggs/percentile_ui.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; // @ts-ignore not-typed yet import { Percentiles } from './percentile_ui'; import { ColorPicker } from '../color_picker'; diff --git a/src/plugins/vis_types/timeseries/public/application/components/color_rules.test.tsx b/src/plugins/vis_types/timeseries/public/application/components/color_rules.test.tsx index d6009a214941fd..6dafe5cd456fbb 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/color_rules.test.tsx +++ b/src/plugins/vis_types/timeseries/public/application/components/color_rules.test.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { keys } from '@elastic/eui'; import { findTestSubject } from '@elastic/eui/lib/test'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { collectionActions } from './lib/collection_actions'; import { diff --git a/src/plugins/vis_types/timeseries/public/application/components/lib/convert_series_to_datatable.test.ts b/src/plugins/vis_types/timeseries/public/application/components/lib/convert_series_to_datatable.test.ts index 3df52223c253ac..15151a9e21bc5a 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/lib/convert_series_to_datatable.test.ts +++ b/src/plugins/vis_types/timeseries/public/application/components/lib/convert_series_to_datatable.test.ts @@ -210,5 +210,26 @@ describe('convert series to datatables', () => { }); expect(tables.series1.rows).toEqual([...expected1, ...expected2]); }); + + test('for series aggregation split by terms, no column is added', async () => { + const updatedModel = { + ...model, + series: [ + { + ...model.series[0], + metrics: [ + { + field: 'test2', + id: 'series1', + function: 'sum', + type: 'series_agg', + }, + ], + }, + ], + } as TimeseriesVisParams; + const tables = await convertSeriesToDataTable(updatedModel, series, indexPattern); + expect(tables.series1.columns.length).toEqual(2); + }); }); }); diff --git a/src/plugins/vis_types/timeseries/public/application/components/lib/convert_series_to_datatable.ts b/src/plugins/vis_types/timeseries/public/application/components/lib/convert_series_to_datatable.ts index 19a1910afbe2fc..8e7c1694357c8f 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/lib/convert_series_to_datatable.ts +++ b/src/plugins/vis_types/timeseries/public/application/components/lib/convert_series_to_datatable.ts @@ -9,8 +9,8 @@ import { IndexPattern } from 'src/plugins/data/public'; import { DatatableRow, DatatableColumn, DatatableColumnType } from 'src/plugins/expressions/public'; import { Query } from 'src/plugins/data/common'; import { TimeseriesVisParams } from '../../../types'; -import type { PanelData } from '../../../../common/types'; -import { BUCKET_TYPES } from '../../../../common/enums'; +import type { PanelData, Metric } from '../../../../common/types'; +import { BUCKET_TYPES, TSVB_METRIC_TYPES } from '../../../../common/enums'; import { fetchIndexPattern } from '../../../../common/index_patterns_utils'; import { getDataStart } from '../../../services'; import { X_ACCESSOR_INDEX } from '../../visualizations/constants'; @@ -78,6 +78,10 @@ export const addMetaToColumns = ( }); }; +const hasSeriesAgg = (metrics: Metric[]) => { + return metrics.some((metric) => metric.type === TSVB_METRIC_TYPES.SERIES_AGG); +}; + export const convertSeriesToDataTable = async ( model: TimeseriesVisParams, series: PanelData[], @@ -96,7 +100,9 @@ export const convertSeriesToDataTable = async ( usedIndexPattern = indexPattern; } } - const isGroupedByTerms = layer.split_mode === BUCKET_TYPES.TERMS; + // series aggregation is a special case, splitting by terms doesn't create multiple series per term + const isGroupedByTerms = + layer.split_mode === BUCKET_TYPES.TERMS && !hasSeriesAgg(layer.metrics); const isGroupedByFilters = layer.split_mode === BUCKET_TYPES.FILTERS; const seriesPerLayer = series.filter((s) => s.seriesId === layer.id); let id = X_ACCESSOR_INDEX; diff --git a/src/plugins/vis_types/timeseries/public/application/components/lib/get_click_filter_data.test.ts b/src/plugins/vis_types/timeseries/public/application/components/lib/get_click_filter_data.test.ts index 80c84ff125817a..f79665fdca5ecc 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/lib/get_click_filter_data.test.ts +++ b/src/plugins/vis_types/timeseries/public/application/components/lib/get_click_filter_data.test.ts @@ -9,6 +9,7 @@ import { XYChartSeriesIdentifier, GeometryValue } from '@elastic/charts'; import { getClickFilterData } from './get_click_filter_data'; import type { TSVBTables } from './types'; import { TimeseriesVisParams } from '../../../types'; +import { SERIES_SEPARATOR } from '../../../../common/constants'; describe('getClickFilterData', () => { test('gets the correct data for a group by everything timeseries chart', () => { @@ -102,7 +103,7 @@ describe('getClickFilterData', () => { }, { key: 'groupId{yaxis_6e0353a0-ad9b-11eb-b112-89cce8e43380_main_group}spec{61ca57f1-469d-11e7-af02-69e470af7417:1}yAccessor{1}splitAccessors{}', - specId: '61ca57f1-469d-11e7-af02-69e470af7417:1', + specId: '61ca57f1-469d-11e7-af02-69e470af7417╰┄►1', }, ], ] as Array<[GeometryValue, XYChartSeriesIdentifier]>; @@ -199,7 +200,7 @@ describe('getClickFilterData', () => { expect(data[1].column).toEqual(2); expect(data[1].row).toEqual(10); // expect(data).toEqual([]); - const splitValue = points[0][1].specId.split(':'); + const splitValue = points[0][1].specId.split(SERIES_SEPARATOR); expect(data[1].value).toEqual(parseInt(splitValue[1], 10)); }); }); diff --git a/src/plugins/vis_types/timeseries/public/application/components/lib/get_click_filter_data.ts b/src/plugins/vis_types/timeseries/public/application/components/lib/get_click_filter_data.ts index a6e35aa6e10328..a3da470f6155c1 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/lib/get_click_filter_data.ts +++ b/src/plugins/vis_types/timeseries/public/application/components/lib/get_click_filter_data.ts @@ -11,6 +11,7 @@ import { X_ACCESSOR_INDEX } from '../../visualizations/constants'; import { BUCKET_TYPES } from '../../../../common/enums'; import { TimeseriesVisParams } from '../../../types'; import type { TSVBTables } from './types'; +import { SERIES_SEPARATOR } from '../../../../common/constants'; export const getClickFilterData = ( points: Array<[GeometryValue, XYChartSeriesIdentifier]>, @@ -23,7 +24,7 @@ export const getClickFilterData = ( const { specId } = point[1]; // specId for a split series has the format // 61ca57f1-469d-11e7-af02-69e470af7417:Men's Accessories, : - const [layerId, splitLabel] = specId.split(':'); + const [layerId, splitLabel] = specId.split(SERIES_SEPARATOR); const table = tables[layerId]; const layer = model.series.filter(({ id }) => id === layerId); diff --git a/src/plugins/vis_types/timeseries/public/application/components/palette_picker.test.tsx b/src/plugins/vis_types/timeseries/public/application/components/palette_picker.test.tsx index 81b33943f8b045..489896662033bb 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/palette_picker.test.tsx +++ b/src/plugins/vis_types/timeseries/public/application/components/palette_picker.test.tsx @@ -6,7 +6,7 @@ * Side Public License, v 1. */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ReactWrapper } from 'enzyme'; import { PalettePicker, PalettePickerProps } from './palette_picker'; import { chartPluginMock } from '../../../../../charts/public/mocks'; diff --git a/src/plugins/vis_types/timeseries/public/application/components/panel_config/timeseries.test.tsx b/src/plugins/vis_types/timeseries/public/application/components/panel_config/timeseries.test.tsx index b8af2e7ef85391..9a23d8513500c0 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/panel_config/timeseries.test.tsx +++ b/src/plugins/vis_types/timeseries/public/application/components/panel_config/timeseries.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithIntl as shallow } from '@kbn/test/jest'; +import { shallowWithIntl as shallow } from '@kbn/test-jest-helpers'; jest.mock('../lib/get_default_query_language', () => ({ getDefaultQueryLanguage: () => 'kuery', diff --git a/src/plugins/vis_types/timeseries/public/application/components/vis_types/gauge/series.test.js b/src/plugins/vis_types/timeseries/public/application/components/vis_types/gauge/series.test.js index 32904ba682768f..b2fb7bfff0b3ee 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/vis_types/gauge/series.test.js +++ b/src/plugins/vis_types/timeseries/public/application/components/vis_types/gauge/series.test.js @@ -8,7 +8,7 @@ import React from 'react'; import { GaugeSeries } from './series'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; const defaultProps = { disableAdd: true, diff --git a/src/plugins/vis_types/timeseries/public/application/components/vis_types/metric/series.test.js b/src/plugins/vis_types/timeseries/public/application/components/vis_types/metric/series.test.js index c33fa2d3f442d1..709ea8b23ca33f 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/vis_types/metric/series.test.js +++ b/src/plugins/vis_types/timeseries/public/application/components/vis_types/metric/series.test.js @@ -8,7 +8,7 @@ import React from 'react'; import { MetricSeries } from './series'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; const defaultProps = { disableAdd: false, diff --git a/src/plugins/vis_types/timeseries/public/application/components/vis_types/top_n/vis.js b/src/plugins/vis_types/timeseries/public/application/components/vis_types/top_n/vis.js index 5eb850a7533849..20caa14ea8cb60 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/vis_types/top_n/vis.js +++ b/src/plugins/vis_types/timeseries/public/application/components/vis_types/top_n/vis.js @@ -20,6 +20,7 @@ import { sortBy, first, get } from 'lodash'; import { DATA_FORMATTERS } from '../../../../../common/enums'; import { getOperator, shouldOperate } from '../../../../../common/operators_utils'; import { ExternalUrlErrorModal } from '../../lib/external_url_error_modal'; +import { SERIES_SEPARATOR } from '../../../../../common/constants'; function sortByDirection(data, direction, fn) { if (direction === 'desc') { @@ -32,7 +33,7 @@ function sortSeries(visData, model) { const series = get(visData, `${model.id}.series`, []); return model.series.reduce((acc, item) => { const itemSeries = series.filter((s) => { - const id = first(s.id.split(/:/)); + const id = first(s.id.split(SERIES_SEPARATOR)); return id === item.id; }); const direction = item.terms_direction || 'desc'; @@ -47,7 +48,7 @@ function TopNVisualization(props) { const { backgroundColor, model, visData, fieldFormatMap, getConfig } = props; const series = sortSeries(visData, model).map((item) => { - const id = first(item.id.split(/:/)); + const id = first(item.id.split(SERIES_SEPARATOR)); const seriesConfig = model.series.find((s) => s.id === id); if (seriesConfig) { const tickFormatter = diff --git a/src/plugins/vis_types/timeseries/public/application/components/vis_with_splits.js b/src/plugins/vis_types/timeseries/public/application/components/vis_with_splits.js index b8ce63bd35dca1..8f700228cc71e5 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/vis_with_splits.js +++ b/src/plugins/vis_types/timeseries/public/application/components/vis_with_splits.js @@ -13,6 +13,7 @@ import { labelDateFormatter } from './lib/label_date_formatter'; import { findIndex, first } from 'lodash'; import { getValueOrEmpty } from '../../../common/empty_label'; import { getSplitByTermsColor } from '../lib/get_split_by_terms_color'; +import { SERIES_SEPARATOR } from '../../../common/constants'; export function visWithSplits(WrappedComponent) { function SplitVisComponent(props) { @@ -43,12 +44,12 @@ export function visWithSplits(WrappedComponent) { ); if (!model || !visData || !visData[model.id]) return ; - if (visData[model.id].series.every((s) => s.id.split(':').length === 1)) { + if (visData[model.id].series.every((s) => s.id.split(SERIES_SEPARATOR).length === 1)) { return ; } const splitsVisData = visData[model.id].series.reduce((acc, series) => { - const [seriesId, splitId] = series.id.split(':'); + const [seriesId, splitId] = series.id.split(SERIES_SEPARATOR); const seriesModel = model.series.find((s) => s.id === seriesId); if (!seriesModel) return acc; diff --git a/src/plugins/vis_types/timeseries/public/application/visualizations/views/top_n.js b/src/plugins/vis_types/timeseries/public/application/visualizations/views/top_n.js index e9ffcd8bc5a861..6b2b25eed2a03b 100644 --- a/src/plugins/vis_types/timeseries/public/application/visualizations/views/top_n.js +++ b/src/plugins/vis_types/timeseries/public/application/visualizations/views/top_n.js @@ -74,10 +74,10 @@ export class TopN extends Component { return {}; }; - static calcInnerBarDivStyles = (item, width, isPositive) => { + static calcInnerBarDivStyles = (item, widthWithUnit, isPositive) => { return { backgroundColor: item.color, - width: width + '%', + width: widthWithUnit, float: isPositive ? 'left' : 'right', }; }; @@ -97,8 +97,7 @@ export class TopN extends Component { const renderMode = TopN.getRenderMode(min, max); const key = `${item.id || item.label}`; const lastValue = getLastValue(item.data); - // if result is empty, all bar need to be colored. - const lastValueFormatted = isEmptyValue(lastValue) ? 1 : lastValue; + const lastValueFormatted = isEmptyValue(lastValue) ? 0 : lastValue; const formatter = item.tickFormatter || this.props.tickFormatter; const isPositiveValue = lastValueFormatted >= 0; @@ -106,6 +105,7 @@ export class TopN extends Component { // if both are 0, the division returns NaN causing unexpected behavior. // For this it defaults to 0 const width = 100 * (Math.abs(lastValueFormatted) / intervalLength) || 0; + const widthWithUnit = isEmptyValue(lastValue) ? '1px' : `${width}%`; const label = item.labelFormatted ? labelDateFormatter(item.labelFormatted) : item.label; const styles = reactcss( { @@ -114,7 +114,7 @@ export class TopN extends Component { ...TopN.calcInnerBarStyles(renderMode, isPositiveValue), }, innerBarValue: { - ...TopN.calcInnerBarDivStyles(item, width, isPositiveValue), + ...TopN.calcInnerBarDivStyles(item, widthWithUnit, isPositiveValue), }, label: { maxWidth: this.state.labelMaxWidth, @@ -154,7 +154,7 @@ export class TopN extends Component { const intervalSettings = this.props.series.reduce( (acc, series, index) => { - const value = getLastValue(series.data) ?? 1; + const value = getLastValue(series.data) ?? 0; return { min: !index || value < acc.min ? value : acc.min, diff --git a/src/plugins/vis_types/timeseries/server/lib/vis_data/helpers/get_splits.test.ts b/src/plugins/vis_types/timeseries/server/lib/vis_data/helpers/get_splits.test.ts index 5dbeb915df28c4..d6bdd452825fd3 100644 --- a/src/plugins/vis_types/timeseries/server/lib/vis_data/helpers/get_splits.test.ts +++ b/src/plugins/vis_types/timeseries/server/lib/vis_data/helpers/get_splits.test.ts @@ -79,7 +79,7 @@ describe('getSplits(resp, panel, series)', () => { expect(await getSplits(resp, panel, series, undefined, () => [])).toEqual([ { - id: 'SERIES:example-01', + id: 'SERIES╰┄►example-01', key: 'example-01', label: 'example-01', labelFormatted: '', @@ -90,7 +90,7 @@ describe('getSplits(resp, panel, series)', () => { SIBAGG: { value: 1 }, }, { - id: 'SERIES:example-02', + id: 'SERIES╰┄►example-02', key: 'example-02', label: 'example-02', labelFormatted: '', @@ -138,7 +138,7 @@ describe('getSplits(resp, panel, series)', () => { const panel = { type: 'top_n' } as Panel; expect(await getSplits(resp, panel, series, undefined, () => [])).toEqual([ { - id: 'SERIES:example-01', + id: 'SERIES╰┄►example-01', key: 'example-01', label: '--example-01--', labelFormatted: '', @@ -149,7 +149,7 @@ describe('getSplits(resp, panel, series)', () => { SIBAGG: { value: 1 }, }, { - id: 'SERIES:example-02', + id: 'SERIES╰┄►example-02', key: 'example-02', label: '--example-02--', labelFormatted: '', @@ -200,7 +200,7 @@ describe('getSplits(resp, panel, series)', () => { expect(await getSplits(resp, panel, series, undefined, () => [])).toEqual([ { - id: 'SERIES:example-01', + id: 'SERIES╰┄►example-01', key: 'example-01', key_as_string: 'false', label: '--example-01--', @@ -212,7 +212,7 @@ describe('getSplits(resp, panel, series)', () => { SIBAGG: { value: 1 }, }, { - id: 'SERIES:example-02', + id: 'SERIES╰┄►example-02', key: 'example-02', key_as_string: 'true', label: '--example-02--', @@ -256,7 +256,7 @@ describe('getSplits(resp, panel, series)', () => { expect(await getSplits(resp, panel, series, undefined, () => [])).toEqual([ { - id: 'SERIES:filter-1', + id: 'SERIES╰┄►filter-1', key: 'filter-1', label: '200s', meta: { bucketSize: 10 }, @@ -265,7 +265,7 @@ describe('getSplits(resp, panel, series)', () => { timeseries: { buckets: [] }, }, { - id: 'SERIES:filter-2', + id: 'SERIES╰┄►filter-2', key: 'filter-2', label: '300s', splitByLabel: 'Count', diff --git a/src/plugins/vis_types/timeseries/server/lib/vis_data/helpers/get_splits.ts b/src/plugins/vis_types/timeseries/server/lib/vis_data/helpers/get_splits.ts index 6be53ef3f03ff3..1754fa6569dcd9 100644 --- a/src/plugins/vis_types/timeseries/server/lib/vis_data/helpers/get_splits.ts +++ b/src/plugins/vis_types/timeseries/server/lib/vis_data/helpers/get_splits.ts @@ -11,6 +11,7 @@ import { get, isPlainObject } from 'lodash'; import { overwrite } from '../helpers'; import { calculateLabel } from '../../../../common/calculate_label'; +import { SERIES_SEPARATOR } from '../../../../common/constants'; import { getLastMetric } from './get_last_metric'; import { formatKey } from './format_key'; @@ -66,7 +67,7 @@ export async function getSplits { const bucket = get(resp, `aggregations.${series.id}.buckets.${filter.id}`); - bucket.id = `${series.id}:${filter.id}`; + bucket.id = `${series.id}${SERIES_SEPARATOR}${filter.id}`; bucket.key = filter.id; bucket.splitByLabel = splitByLabel; bucket.color = filter.color; diff --git a/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/math.js b/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/math.js index a6addc8ba0e53b..46dde6653647d4 100644 --- a/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/math.js +++ b/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/math.js @@ -7,6 +7,7 @@ */ import { convertIntervalToUnit } from '../../helpers/unit_to_seconds'; +import { SERIES_SEPARATOR } from '../../../../../common/constants'; const percentileValueMatch = /\[([0-9\.]+)\]$/; import { startsWith, flatten, values, first, last } from 'lodash'; @@ -20,7 +21,7 @@ export function mathAgg(resp, panel, series, meta, extractFields) { // Filter the results down to only the ones that match the series.id. Sometimes // there will be data from other series mixed in. results = results.filter((s) => { - if (s.id.split(/:/)[0] === series.id) { + if (s.id.split(SERIES_SEPARATOR)[0] === series.id) { return false; } return true; diff --git a/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/math.test.js b/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/math.test.js index d8508f6b735a0f..14c66866d323a7 100644 --- a/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/math.test.js +++ b/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/math.test.js @@ -93,7 +93,7 @@ describe('math(resp, panel, series)', () => { expect(results).toHaveLength(1); expect(results[0]).toEqual({ - id: 'test:example-01', + id: 'test╰┄►example-01', label: 'example-01', color: 'rgb(255, 0, 0)', stack: false, diff --git a/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/percentile.js b/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/percentile.js index fe8a6ff9cd2f61..a0fe57ea5cfcf5 100644 --- a/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/percentile.js +++ b/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/percentile.js @@ -11,6 +11,7 @@ import { getDefaultDecoration } from '../../helpers/get_default_decoration'; import { getSplits } from '../../helpers/get_splits'; import { getLastMetric } from '../../helpers/get_last_metric'; import { TSVB_METRIC_TYPES } from '../../../../../common/enums'; +import { SERIES_SEPARATOR } from '../../../../../common/constants'; export function percentile(resp, panel, series, meta, extractFields) { return (next) => async (results) => { @@ -23,7 +24,7 @@ export function percentile(resp, panel, series, meta, extractFields) { (await getSplits(resp, panel, series, meta, extractFields)).forEach((split) => { metric.percentiles.forEach((percentile) => { const percentileValue = percentile.value ? percentile.value : 0; - const id = `${split.id}:${percentile.id}`; + const id = `${split.id}${SERIES_SEPARATOR}${percentile.id}`; const data = split.timeseries.buckets.map((bucket) => { const higherMetric = { ...metric, percent: percentileValue }; const serieData = [bucket.key, getAggValue(bucket, higherMetric)]; diff --git a/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/percentile.test.js b/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/percentile.test.js index de304913d6c694..ea1efdcd0c41b4 100644 --- a/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/percentile.test.js +++ b/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/percentile.test.js @@ -83,7 +83,7 @@ describe('percentile(resp, panel, series)', () => { expect(results).toHaveLength(2); - expect(results[0]).toHaveProperty('id', 'test:10-90'); + expect(results[0]).toHaveProperty('id', 'test╰┄►10-90'); expect(results[0]).toHaveProperty('color', '#000028'); expect(results[0]).toHaveProperty('label', 'Percentile of cpu'); expect(results[0]).toHaveProperty('lines'); @@ -100,7 +100,7 @@ describe('percentile(resp, panel, series)', () => { [2, 1.2, 5.3], ]); - expect(results[1]).toHaveProperty('id', 'test:50'); + expect(results[1]).toHaveProperty('id', 'test╰┄►50'); expect(results[1]).toHaveProperty('color', 'rgb(255, 0, 0)'); expect(results[1]).toHaveProperty('label', '(50) Percentile of cpu'); expect(results[1]).toHaveProperty('stack', false); diff --git a/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/percentile_rank.js b/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/percentile_rank.js index ce81ec46693e2e..0720c6e19a9c0f 100644 --- a/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/percentile_rank.js +++ b/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/percentile_rank.js @@ -12,6 +12,7 @@ import { getSplits } from '../../helpers/get_splits'; import { getLastMetric } from '../../helpers/get_last_metric'; import { toPercentileNumber } from '../../../../../common/to_percentile_number'; import { TSVB_METRIC_TYPES } from '../../../../../common/enums'; +import { SERIES_SEPARATOR } from '../../../../../common/constants'; export function percentileRank(resp, panel, series, meta, extractFields) { return (next) => async (results) => { @@ -33,7 +34,7 @@ export function percentileRank(resp, panel, series, meta, extractFields) { results.push({ data, - id: `${split.id}:${percentileRank}:${index}`, + id: `${split.id}${SERIES_SEPARATOR}${percentileRank}${SERIES_SEPARATOR}${index}`, label: `(${percentileRank || 0}) ${split.label}`, color: series.split_mode === 'everything' && metric.colors diff --git a/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/percentile_rank.test.ts b/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/percentile_rank.test.ts index 79c3eab91c3c92..758c37130cdd4a 100644 --- a/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/percentile_rank.test.ts +++ b/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/percentile_rank.test.ts @@ -75,7 +75,7 @@ describe('percentile_rank(resp, panel, series, meta, extractFields)', () => { expect(results).toHaveLength(2); - expect(results[0]).toHaveProperty('id', 'test:1000:0'); + expect(results[0]).toHaveProperty('id', 'test╰┄►1000╰┄►0'); expect(results[0]).toHaveProperty('color', '#000028'); expect(results[0]).toHaveProperty('label', '(1000) Percentile Rank of cpu'); expect(results[0].data).toEqual([ @@ -83,7 +83,7 @@ describe('percentile_rank(resp, panel, series, meta, extractFields)', () => { [2, 1], ]); - expect(results[1]).toHaveProperty('id', 'test:500:1'); + expect(results[1]).toHaveProperty('id', 'test╰┄►500╰┄►1'); expect(results[1]).toHaveProperty('color', '#0000FF'); expect(results[1]).toHaveProperty('label', '(500) Percentile Rank of cpu'); expect(results[1].data).toEqual([ diff --git a/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/series_agg.js b/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/series_agg.js index a803439c7581f2..532f5fd07f597d 100644 --- a/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/series_agg.js +++ b/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/series/series_agg.js @@ -9,6 +9,7 @@ import { last, first } from 'lodash'; import { SeriesAgg } from './_series_agg'; import { getDefaultDecoration } from '../../helpers/get_default_decoration'; import { calculateLabel } from '../../../../../common/calculate_label'; +import { SERIES_SEPARATOR } from '../../../../../common/constants'; export function seriesAgg(resp, panel, series, meta, extractFields) { return (next) => async (results) => { @@ -19,7 +20,7 @@ export function seriesAgg(resp, panel, series, meta, extractFields) { // Filter out the seires with the matching metric and store them // in targetSeries results = results.filter((s) => { - if (s.id.split(/:/)[0] === series.id) { + if (s.id.split(SERIES_SEPARATOR)[0] === series.id) { targetSeries.push(s.data); return false; } diff --git a/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/table/series_agg.ts b/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/table/series_agg.ts index d360bb97333c76..b4bc082bab849a 100644 --- a/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/table/series_agg.ts +++ b/src/plugins/vis_types/timeseries/server/lib/vis_data/response_processors/table/series_agg.ts @@ -9,6 +9,7 @@ import { last } from 'lodash'; import { calculateLabel } from '../../../../../common/calculate_label'; +import { SERIES_SEPARATOR } from '../../../../../common/constants'; // @ts-expect-error no typed yet import { SeriesAgg } from './_series_agg'; @@ -26,7 +27,7 @@ export const seriesAgg: TableResponseProcessorsFunction = // Filter out the seires with the matching metric and store them // in targetSeries results = results.filter((s) => { - if (s.id && s.id.split(/:/)[0] === series.id) { + if (s.id && s.id.split(SERIES_SEPARATOR)[0] === series.id) { targetSeries.push(s.data!); return false; } diff --git a/src/plugins/vis_types/vislib/public/vislib/lib/chart_title.test.js b/src/plugins/vis_types/vislib/public/vislib/lib/chart_title.test.js index 54b326a2928453..5c3fd271fc6ca5 100644 --- a/src/plugins/vis_types/vislib/public/vislib/lib/chart_title.test.js +++ b/src/plugins/vis_types/vislib/public/vislib/lib/chart_title.test.js @@ -12,7 +12,7 @@ import { setHTMLElementClientSizes, setSVGElementGetBBox, setSVGElementGetComputedTextLength, -} from '@kbn/test/jest'; +} from '@kbn/test-jest-helpers'; import { ChartTitle } from './chart_title'; import { VisConfig } from './vis_config'; diff --git a/src/plugins/vis_types/vislib/public/vislib/lib/dispatch.test.js b/src/plugins/vis_types/vislib/public/vislib/lib/dispatch.test.js index 21a3dc069d8c6d..a500aa00e6d215 100644 --- a/src/plugins/vis_types/vislib/public/vislib/lib/dispatch.test.js +++ b/src/plugins/vis_types/vislib/public/vislib/lib/dispatch.test.js @@ -13,7 +13,7 @@ import { setHTMLElementClientSizes, setSVGElementGetBBox, setSVGElementGetComputedTextLength, -} from '@kbn/test/jest'; +} from '@kbn/test-jest-helpers'; // Data import data from '../../fixtures/mock_data/date_histogram/_series'; diff --git a/src/plugins/vis_types/vislib/public/vislib/lib/handler.test.js b/src/plugins/vis_types/vislib/public/vislib/lib/handler.test.js index 60ffaf3f3d19c8..d82dbb1ae77d70 100644 --- a/src/plugins/vis_types/vislib/public/vislib/lib/handler.test.js +++ b/src/plugins/vis_types/vislib/public/vislib/lib/handler.test.js @@ -11,7 +11,7 @@ import { setHTMLElementClientSizes, setSVGElementGetBBox, setSVGElementGetComputedTextLength, -} from '@kbn/test/jest'; +} from '@kbn/test-jest-helpers'; // Data import series from '../../fixtures/mock_data/date_histogram/_series'; diff --git a/src/plugins/vis_types/vislib/public/vislib/lib/layout/layout.test.js b/src/plugins/vis_types/vislib/public/vislib/lib/layout/layout.test.js index af59f011515d0e..50fcdba6aa3604 100644 --- a/src/plugins/vis_types/vislib/public/vislib/lib/layout/layout.test.js +++ b/src/plugins/vis_types/vislib/public/vislib/lib/layout/layout.test.js @@ -12,7 +12,7 @@ import { setHTMLElementClientSizes, setSVGElementGetBBox, setSVGElementGetComputedTextLength, -} from '@kbn/test/jest'; +} from '@kbn/test-jest-helpers'; // Data import series from '../../../fixtures/mock_data/date_histogram/_series'; diff --git a/src/plugins/vis_types/vislib/public/vislib/vis.test.js b/src/plugins/vis_types/vislib/public/vislib/vis.test.js index 46afbd1c62f696..b20bbfc700c8b7 100644 --- a/src/plugins/vis_types/vislib/public/vislib/vis.test.js +++ b/src/plugins/vis_types/vislib/public/vislib/vis.test.js @@ -12,7 +12,7 @@ import { setHTMLElementClientSizes, setSVGElementGetBBox, setSVGElementGetComputedTextLength, -} from '@kbn/test/jest'; +} from '@kbn/test-jest-helpers'; 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_types/vislib/public/vislib/visualizations/chart.test.js b/src/plugins/vis_types/vislib/public/vislib/visualizations/chart.test.js index 21ec67707126c1..12fc0e9a5e4b82 100644 --- a/src/plugins/vis_types/vislib/public/vislib/visualizations/chart.test.js +++ b/src/plugins/vis_types/vislib/public/vislib/visualizations/chart.test.js @@ -12,7 +12,7 @@ import { setHTMLElementClientSizes, setSVGElementGetBBox, setSVGElementGetComputedTextLength, -} from '@kbn/test/jest'; +} from '@kbn/test-jest-helpers'; import { Chart } from './_chart'; import { getMockUiState } from '../../fixtures/mocks'; import { getVis } from './_vis_fixture'; diff --git a/src/plugins/vis_types/vislib/public/vislib/visualizations/gauge_chart.test.js b/src/plugins/vis_types/vislib/public/vislib/visualizations/gauge_chart.test.js index 76830c66f3aa56..47cd2833464e82 100644 --- a/src/plugins/vis_types/vislib/public/vislib/visualizations/gauge_chart.test.js +++ b/src/plugins/vis_types/vislib/public/vislib/visualizations/gauge_chart.test.js @@ -8,7 +8,7 @@ import $ from 'jquery'; import _ from 'lodash'; -import { setHTMLElementClientSizes, setSVGElementGetBBox } from '@kbn/test/jest'; +import { setHTMLElementClientSizes, setSVGElementGetBBox } from '@kbn/test-jest-helpers'; import data from '../../fixtures/mock_data/terms/_series_multiple'; import { getMockUiState } from '../../fixtures/mocks'; diff --git a/src/plugins/vis_types/vislib/public/vislib/visualizations/pie_chart.test.js b/src/plugins/vis_types/vislib/public/vislib/visualizations/pie_chart.test.js index 8ad9bf56cb0201..ba11df923b8a65 100644 --- a/src/plugins/vis_types/vislib/public/vislib/visualizations/pie_chart.test.js +++ b/src/plugins/vis_types/vislib/public/vislib/visualizations/pie_chart.test.js @@ -13,7 +13,7 @@ import { setHTMLElementClientSizes, setSVGElementGetBBox, setSVGElementGetComputedTextLength, -} from '@kbn/test/jest'; +} from '@kbn/test-jest-helpers'; import { getMockUiState } from '../../fixtures/mocks'; import { getVis } from './_vis_fixture'; import { pieChartMockData } from './pie_chart_mock_data'; diff --git a/src/plugins/vis_types/vislib/public/vislib/visualizations/point_series/heatmap_chart.test.js b/src/plugins/vis_types/vislib/public/vislib/visualizations/point_series/heatmap_chart.test.js index d9bac77acf5ad4..c7dbaacfdae9e8 100644 --- a/src/plugins/vis_types/vislib/public/vislib/visualizations/point_series/heatmap_chart.test.js +++ b/src/plugins/vis_types/vislib/public/vislib/visualizations/point_series/heatmap_chart.test.js @@ -13,7 +13,7 @@ import { setHTMLElementClientSizes, setSVGElementGetBBox, setSVGElementGetComputedTextLength, -} from '@kbn/test/jest'; +} from '@kbn/test-jest-helpers'; // Data import series from '../../../fixtures/mock_data/date_histogram/_series'; diff --git a/src/plugins/vis_types/xy/public/editor/components/common/truncate_labels.test.tsx b/src/plugins/vis_types/xy/public/editor/components/common/truncate_labels.test.tsx index 902167cb246429..a688ddb7226202 100644 --- a/src/plugins/vis_types/xy/public/editor/components/common/truncate_labels.test.tsx +++ b/src/plugins/vis_types/xy/public/editor/components/common/truncate_labels.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ReactWrapper } from 'enzyme'; import { TruncateLabelsOption, TruncateLabelsOptionProps } from './truncate_labels'; import { findTestSubject } from '@elastic/eui/lib/test'; diff --git a/src/plugins/vis_types/xy/public/editor/components/options/metrics_axes/value_axes_panel.test.tsx b/src/plugins/vis_types/xy/public/editor/components/options/metrics_axes/value_axes_panel.test.tsx index 3e1a44993235b9..53acb302e98892 100644 --- a/src/plugins/vis_types/xy/public/editor/components/options/metrics_axes/value_axes_panel.test.tsx +++ b/src/plugins/vis_types/xy/public/editor/components/options/metrics_axes/value_axes_panel.test.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { shallow } from 'enzyme'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { Position } from '@elastic/charts'; import { ValueAxis, SeriesParam } from '../../../../types'; diff --git a/src/plugins/vis_types/xy/public/editor/components/options/point_series/point_series.test.tsx b/src/plugins/vis_types/xy/public/editor/components/options/point_series/point_series.test.tsx index 5bf9486bbc4ee1..dbd1bed390574d 100644 --- a/src/plugins/vis_types/xy/public/editor/components/options/point_series/point_series.test.tsx +++ b/src/plugins/vis_types/xy/public/editor/components/options/point_series/point_series.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ReactWrapper } from 'enzyme'; import { PointSeriesOptions } from './point_series'; import { findTestSubject } from '@elastic/eui/lib/test'; diff --git a/src/plugins/vis_types/xy/public/to_ast.ts b/src/plugins/vis_types/xy/public/to_ast.ts index 9e2c7554aaf7c2..9dec2f9af5ba4a 100644 --- a/src/plugins/vis_types/xy/public/to_ast.ts +++ b/src/plugins/vis_types/xy/public/to_ast.ts @@ -34,6 +34,7 @@ import { XyVisType } from '../common'; import { getEsaggsFn } from './to_ast_esaggs'; import { TimeRangeBounds } from '../../../data/common'; import { getSeriesParams } from './utils/get_series_params'; +import { getSafeId } from './utils/accessors'; const prepareLabel = (data: Labels) => { const label = buildExpressionFunction('label', { @@ -189,8 +190,9 @@ export const toExpressionAst: VisToExpressionAst = async (vis, params (dimensions.y || []).forEach((yDimension) => { const yAgg = responseAggs[yDimension.accessor]; + const aggId = getSafeId(yAgg.id); const seriesParam = (vis.params.seriesParams || []).find( - (param: any) => param.data.id === yAgg.id + (param: any) => param.data.id === aggId ); if (seriesParam) { const usedValueAxis = (vis.params.valueAxes || []).find( diff --git a/src/plugins/vis_types/xy/public/utils/get_color_picker.test.tsx b/src/plugins/vis_types/xy/public/utils/get_color_picker.test.tsx index 352cff0d4c4a9a..89cb8d50d4b8e4 100644 --- a/src/plugins/vis_types/xy/public/utils/get_color_picker.test.tsx +++ b/src/plugins/vis_types/xy/public/utils/get_color_picker.test.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { LegendColorPickerProps, XYChartSeriesIdentifier } from '@elastic/charts'; import { EuiPopover } from '@elastic/eui'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ComponentType, ReactWrapper } from 'enzyme'; import { getColorPicker } from './get_color_picker'; import { ColorPicker } from '../../../../charts/public'; diff --git a/src/plugins/visualizations/public/embeddable/visualize_embeddable_factory.tsx b/src/plugins/visualizations/public/embeddable/visualize_embeddable_factory.tsx index 22c39ad1d596ad..2868950867ad59 100644 --- a/src/plugins/visualizations/public/embeddable/visualize_embeddable_factory.tsx +++ b/src/plugins/visualizations/public/embeddable/visualize_embeddable_factory.tsx @@ -103,15 +103,19 @@ export class VisualizeEmbeddableFactory })`; }, showSavedObject: (savedObject) => { - const typeName: string = JSON.parse(savedObject.attributes.visState).type; - const visType = getTypes().get(typeName); - if (!visType) { + try { + const typeName: string = JSON.parse(savedObject.attributes.visState).type; + const visType = getTypes().get(typeName); + if (!visType) { + return false; + } + if (getUISettings().get(VISUALIZE_ENABLE_LABS_SETTING)) { + return true; + } + return visType.stage !== 'experimental'; + } catch { return false; } - if (getUISettings().get(VISUALIZE_ENABLE_LABS_SETTING)) { - return true; - } - return visType.stage !== 'experimental'; }, getSavedObjectSubType: (savedObject) => { return JSON.parse(savedObject.attributes.visState).type; diff --git a/src/plugins/visualizations/public/visualize_app/components/visualize_editor_common.test.tsx b/src/plugins/visualizations/public/visualize_app/components/visualize_editor_common.test.tsx index d0c7b56638bc29..81f0bd8d999093 100644 --- a/src/plugins/visualizations/public/visualize_app/components/visualize_editor_common.test.tsx +++ b/src/plugins/visualizations/public/visualize_app/components/visualize_editor_common.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test-jest-helpers'; import { VisualizeEditorCommon } from './visualize_editor_common'; import { VisualizeEditorVisInstance } from '../types'; import { SplitChartWarning } from './split_chart_warning'; 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 e3707a7aace798..b776068ab9c493 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { TypesStart, BaseVisType, 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 04824ae25704d9..ae9d13b879cf7d 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 @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { TypesStart, BaseVisType, 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 7514f467840e50..ae65251409c204 100644 --- a/src/plugins/visualizations/public/wizard/new_vis_modal.test.tsx +++ b/src/plugins/visualizations/public/wizard/new_vis_modal.test.tsx @@ -7,7 +7,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { TypesStart, VisGroups, BaseVisType } from '../vis_types'; import NewVisModal from './new_vis_modal'; import { ApplicationStart, SavedObjectsStart, DocLinksStart } from '../../../../core/public'; diff --git a/test/common/services/index_patterns.ts b/test/common/services/index_patterns.ts index 5b6d20990b6d1c..549137c79e9a27 100644 --- a/test/common/services/index_patterns.ts +++ b/test/common/services/index_patterns.ts @@ -7,7 +7,7 @@ */ import { FtrService } from '../ftr_provider_context'; -import { IndexPatternSpec } from '../../../src/plugins/data/common'; +import { DataViewSpec } from '../../../src/plugins/data/common'; export class IndexPatternsService extends FtrService { private readonly kibanaServer = this.ctx.getService('kibanaServer'); @@ -18,9 +18,9 @@ export class IndexPatternsService extends FtrService { async create( indexPattern: { title: string }, { override = false }: { override: boolean } = { override: false } - ): Promise { + ): Promise { const response = await this.kibanaServer.request<{ - index_pattern: IndexPatternSpec; + index_pattern: DataViewSpec; }>({ path: '/api/index_patterns/index_pattern', method: 'POST', diff --git a/test/functional/services/common/screenshots.ts b/test/functional/services/common/screenshots.ts index 0f2ab8e6edfbee..d5f901300941f7 100644 --- a/test/functional/services/common/screenshots.ts +++ b/test/functional/services/common/screenshots.ts @@ -22,7 +22,7 @@ const writeFileAsync = promisify(writeFile); export class ScreenshotsService extends FtrService { private readonly log = this.ctx.getService('log'); private readonly config = this.ctx.getService('config'); - private readonly failureMetadata = this.ctx.getService('failureMetadata'); + private readonly testMetadata = this.ctx.getService('testMetadata'); private readonly browser = this.ctx.getService('browser'); private readonly SESSION_DIRECTORY = resolve(this.config.get('screenshots.directory'), 'session'); @@ -51,11 +51,17 @@ export class ScreenshotsService extends FtrService { async compareAgainstBaseline(name: string, updateBaselines: boolean, el?: WebElementWrapper) { this.log.debug('compareAgainstBaseline'); const sessionPath = resolve(this.SESSION_DIRECTORY, `${name}.png`); - await this.capture(sessionPath, el); - const baselinePath = resolve(this.BASELINE_DIRECTORY, `${name}.png`); const failurePath = resolve(this.FAILURE_DIRECTORY, `${name}.png`); + await this.capture({ + path: sessionPath, + name, + el, + baselinePath, + failurePath, + }); + if (updateBaselines) { this.log.debug('Updating baseline snapshot'); // Make the directory if it doesn't exist @@ -76,22 +82,42 @@ export class ScreenshotsService extends FtrService { async take(name: string, el?: WebElementWrapper, subDirectories: string[] = []) { const path = resolve(this.SESSION_DIRECTORY, ...subDirectories, `${name}.png`); - await this.capture(path, el); - this.failureMetadata.addScreenshot(name, path); + await this.capture({ path, name, el }); } async takeForFailure(name: string, el?: WebElementWrapper) { const path = resolve(this.FAILURE_DIRECTORY, `${name}.png`); - await this.capture(path, el); - this.failureMetadata.addScreenshot(`failure[${name}]`, path); + await this.capture({ + path, + name: `failure[${name}]`, + el, + }); } - private async capture(path: string, el?: WebElementWrapper) { + private async capture({ + path, + el, + name, + baselinePath, + failurePath, + }: { + path: string; + name: string; + el?: WebElementWrapper; + baselinePath?: string; + failurePath?: string; + }) { try { this.log.info(`Taking screenshot "${path}"`); const screenshot = await (el ? el.takeScreenshot() : this.browser.takeScreenshot()); await mkdirAsync(dirname(path), { recursive: true }); await writeFileAsync(path, screenshot, 'base64'); + this.testMetadata.addScreenshot({ + name, + base64Png: Buffer.isBuffer(screenshot) ? screenshot.toString('base64') : screenshot, + baselinePath, + failurePath, + }); } catch (err) { this.log.error('SCREENSHOT FAILED'); this.log.error(err); diff --git a/x-pack/package.json b/x-pack/package.json index 8fb7a3483e5ef0..ccfad71a4f7b3d 100644 --- a/x-pack/package.json +++ b/x-pack/package.json @@ -1,6 +1,6 @@ { "name": "x-pack", - "version": "8.1.0", + "version": "8.2.0", "author": "Elastic", "private": true, "license": "Elastic-License", diff --git a/x-pack/plugins/apm/common/tutorial/instructions/apm_agent_instructions.ts b/x-pack/plugins/apm/common/tutorial/instructions/apm_agent_instructions.ts index daac81298008ec..695cf38bf2da2b 100644 --- a/x-pack/plugins/apm/common/tutorial/instructions/apm_agent_instructions.ts +++ b/x-pack/plugins/apm/common/tutorial/instructions/apm_agent_instructions.ts @@ -257,10 +257,10 @@ export const createJsAgentInstructions = (apmServerUrl = '') => [ { defaultMessage: 'APM Server disables RUM support by default. See the [documentation]({documentationLink}) \ -for details on how to enable RUM support.', +for details on how to enable RUM support. When using the APM integration with Fleet, RUM support is automatically enabled.', values: { documentationLink: - '{config.docs.base_url}guide/en/apm/server/{config.docs.version}/configuration-rum.html', + '{config.docs.base_url}guide/en/apm/guide/{config.docs.version}/configuration-rum.html', }, } ), diff --git a/x-pack/plugins/apm/public/components/app/rum_dashboard/action_menu/index.tsx b/x-pack/plugins/apm/public/components/app/rum_dashboard/action_menu/index.tsx index ae29016956feca..1215048bc55a07 100644 --- a/x-pack/plugins/apm/public/components/app/rum_dashboard/action_menu/index.tsx +++ b/x-pack/plugins/apm/public/components/app/rum_dashboard/action_menu/index.tsx @@ -9,6 +9,7 @@ import React from 'react'; import { EuiHeaderLinks, EuiHeaderLink, EuiToolTip } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { + RECORDS_FIELD, createExploratoryViewUrl, HeaderMenuPortal, } from '../../../../../../observability/public'; @@ -52,7 +53,7 @@ export function UXActionMenu({ reportDefinitions: { [SERVICE_NAME]: serviceName ? [serviceName] : [], }, - selectedMetricField: 'Records', + selectedMetricField: RECORDS_FIELD, }, ], }, diff --git a/x-pack/plugins/apm/public/components/fleet_integration/apm_policy_form/settings_definition/apm_settings.ts b/x-pack/plugins/apm/public/components/fleet_integration/apm_policy_form/settings_definition/apm_settings.ts index ec9f7409323760..8adda7b5983f12 100644 --- a/x-pack/plugins/apm/public/components/fleet_integration/apm_policy_form/settings_definition/apm_settings.ts +++ b/x-pack/plugins/apm/public/components/fleet_integration/apm_policy_form/settings_definition/apm_settings.ts @@ -78,7 +78,7 @@ export function getApmSettings({ }, { key: 'idle_timeout', - type: 'text', + type: 'duration', labelAppend: OPTIONAL_LABEL, label: i18n.translate( 'xpack.apm.fleet_integration.settings.apm.idleTimeoutLabel', @@ -91,7 +91,7 @@ export function getApmSettings({ }, { key: 'read_timeout', - type: 'text', + type: 'duration', labelAppend: OPTIONAL_LABEL, label: i18n.translate( 'xpack.apm.fleet_integration.settings.apm.readTimeoutLabel', @@ -101,7 +101,7 @@ export function getApmSettings({ }, { key: 'shutdown_timeout', - type: 'text', + type: 'duration', labelAppend: OPTIONAL_LABEL, label: i18n.translate( 'xpack.apm.fleet_integration.settings.apm.shutdownTimeoutLabel', @@ -114,7 +114,7 @@ export function getApmSettings({ }, { key: 'write_timeout', - type: 'text', + type: 'duration', labelAppend: OPTIONAL_LABEL, label: i18n.translate( 'xpack.apm.fleet_integration.settings.apm.writeTimeoutLabel', diff --git a/x-pack/plugins/cases/public/components/empty_value/empty_value.test.tsx b/x-pack/plugins/cases/public/components/empty_value/empty_value.test.tsx index e1dfc71867f6ef..47e6ec259640c4 100644 --- a/x-pack/plugins/cases/public/components/empty_value/empty_value.test.tsx +++ b/x-pack/plugins/cases/public/components/empty_value/empty_value.test.tsx @@ -8,7 +8,7 @@ import { mount, shallow } from 'enzyme'; import React from 'react'; import { ThemeProvider } from 'styled-components'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { defaultToEmptyTag, diff --git a/x-pack/plugins/cases/server/services/alerts/index.ts b/x-pack/plugins/cases/server/services/alerts/index.ts index 7444159a00bb07..7f966a471c725e 100644 --- a/x-pack/plugins/cases/server/services/alerts/index.ts +++ b/x-pack/plugins/cases/server/services/alerts/index.ts @@ -42,6 +42,7 @@ export class AlertService { const res = await this.scopedClusterClient.search({ index: indices, + ignore_unavailable: true, query: { ids: { values: ids } }, size: 0, aggregations: builtAggs, diff --git a/x-pack/plugins/cloud/public/plugin.test.ts b/x-pack/plugins/cloud/public/plugin.test.ts index 7198fb6f8a7743..1eef581610f004 100644 --- a/x-pack/plugins/cloud/public/plugin.test.ts +++ b/x-pack/plugins/cloud/public/plugin.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import { homePluginMock } from 'src/plugins/home/public/mocks'; import { securityMock } from '../../security/public/mocks'; diff --git a/x-pack/plugins/cloud/server/routes/chat.test.ts b/x-pack/plugins/cloud/server/routes/chat.test.ts index 9ed76eff6d0817..e12278e264e5e8 100644 --- a/x-pack/plugins/cloud/server/routes/chat.test.ts +++ b/x-pack/plugins/cloud/server/routes/chat.test.ts @@ -44,14 +44,16 @@ describe('chat route', () => { `); }); - test('returns user information and a token', async () => { + test('returns user information taken from saml metadata and a token', async () => { const security = securityMock.createSetup(); const username = 'user.name'; const email = 'user@elastic.co'; security.authc.getCurrentUser.mockReturnValueOnce({ username, - email, + metadata: { + saml_email: [email], + }, }); const router = httpServiceMock.createRouter(); diff --git a/x-pack/plugins/cloud/server/routes/chat.ts b/x-pack/plugins/cloud/server/routes/chat.ts index 62c4475c92ae57..1bc3505c087ae9 100644 --- a/x-pack/plugins/cloud/server/routes/chat.ts +++ b/x-pack/plugins/cloud/server/routes/chat.ts @@ -6,11 +6,18 @@ */ import { IRouter } from '../../../../../src/core/server'; -import type { SecurityPluginSetup } from '../../../security/server'; +import type { SecurityPluginSetup, AuthenticatedUser } from '../../../security/server'; import { GET_CHAT_USER_DATA_ROUTE_PATH } from '../../common/constants'; import type { GetChatUserDataResponseBody } from '../../common/types'; import { generateSignedJwt } from '../util/generate_jwt'; +type MetaWithSaml = AuthenticatedUser['metadata'] & { + saml_name: [string]; + saml_email: [string]; + saml_roles: [string]; + saml_principal: [string]; +}; + export const registerChatRoute = ({ router, chatIdentitySecret, @@ -33,7 +40,9 @@ export const registerChatRoute = ({ }, async (_context, request, response) => { const user = security.authc.getCurrentUser(request); - let { email: userEmail, username: userId } = user || {}; + const { metadata, username } = user || {}; + let userId = username; + let [userEmail] = (metadata as MetaWithSaml)?.saml_email || []; // In local development, these values are not populated. This is a workaround // to allow for local testing. 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 fe43f517f7f3fa..ad7d95fc64c2ec 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { getRandomString } from '@kbn/test/jest'; +import { getRandomString } from '@kbn/test-jest-helpers'; 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 e2f48e688610e6..c3a52400dea00d 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 @@ -6,7 +6,7 @@ */ import Chance from 'chance'; -import { getRandomString } from '@kbn/test/jest'; +import { getRandomString } from '@kbn/test-jest-helpers'; import { FollowerIndex } from '../../../../common/types'; const chance = new Chance(); 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 9f2cb6452c6f29..b3e47b2ad7dca7 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 @@ -11,7 +11,7 @@ Could not load worker ReferenceError: Worker is not defined at createWorker (//node_modules/brace/index.js:17992:5) */ -import { stubWebWorker } from '@kbn/test/jest'; // eslint-disable-line no-unused-vars +import { stubWebWorker } from '@kbn/test-jest-helpers'; // eslint-disable-line no-unused-vars import { act } from 'react-dom/test-utils'; import { getFollowerIndexMock } from './fixtures/follower_index'; 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 c1902e22265b8a..138ea72bfe7ffb 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; 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 43d677596690f8..0b6e6216209d85 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; 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 329d83d6fe3c71..0c7f483685075d 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed, findTestSubject } from '@kbn/test/jest'; +import { registerTestBed, findTestSubject } from '@kbn/test-jest-helpers'; 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 a873af2de8b066..ab107348bd5b72 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; 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 f8a68e54ea52ea..5f83aa841b11d8 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; 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 5e6a48413b18b9..961ce940084e70 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 @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { registerTestBed, findTestSubject } from '@kbn/test/jest'; +import { registerTestBed, findTestSubject } from '@kbn/test-jest-helpers'; 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 1f03a56fbbcdba..8263b14e9eaab9 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; 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 5f910565edb3a5..0fedc1ab6b9039 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 @@ -13,7 +13,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, delay } from '@kbn/test/jest'; +export { nextTick, getRandomString, findTestSubject, delay } from '@kbn/test-jest-helpers'; export { setupEnvironment } from './setup_environment'; diff --git a/x-pack/plugins/data_enhanced/public/search/ui/connected_search_session_indicator/connected_search_session_indicator.test.tsx b/x-pack/plugins/data_enhanced/public/search/ui/connected_search_session_indicator/connected_search_session_indicator.test.tsx index 6e9b06ad36df79..5f5753b8858e02 100644 --- a/x-pack/plugins/data_enhanced/public/search/ui/connected_search_session_indicator/connected_search_session_indicator.test.tsx +++ b/x-pack/plugins/data_enhanced/public/search/ui/connected_search_session_indicator/connected_search_session_indicator.test.tsx @@ -6,7 +6,7 @@ */ import React, { ReactNode } from 'react'; -import { StubBrowserStorage } from '@kbn/test/jest'; +import { StubBrowserStorage } from '@kbn/test-jest-helpers'; import { render, waitFor, screen, act } from '@testing-library/react'; import { Storage } from '../../../../../../../src/plugins/kibana_utils/public/'; import { dataPluginMock } from '../../../../../../../src/plugins/data/public/mocks'; diff --git a/x-pack/plugins/data_visualizer/kibana.json b/x-pack/plugins/data_visualizer/kibana.json index 03f21bcde469da..aee54c216150c5 100644 --- a/x-pack/plugins/data_visualizer/kibana.json +++ b/x-pack/plugins/data_visualizer/kibana.json @@ -30,6 +30,7 @@ "esUiShared", "fieldFormats", "uiActions", + "lens", "cloud" ], "owner": { diff --git a/x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/action_menu/lens_utils.ts b/x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/action_menu/lens_utils.ts index 3db1795456127b..10ee347750e10c 100644 --- a/x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/action_menu/lens_utils.ts +++ b/x-pack/plugins/data_visualizer/public/application/common/components/field_data_row/action_menu/lens_utils.ts @@ -17,6 +17,7 @@ import type { TypedLensByValueInput, XYLayerConfig, } from '../../../../../../../lens/public'; +import { DOCUMENT_FIELD_NAME as RECORDS_FIELD } from '../../../../../../../lens/common/constants'; import { FieldVisConfig } from '../../stats_table/types'; import { JOB_FIELD_TYPES } from '../../../../../../common/constants'; @@ -52,7 +53,7 @@ export function getNumberSettings(item: FieldVisConfig, defaultIndexPattern: Ind label: COUNT, dataType: 'number', isBucketed: false, - sourceField: 'Records', + sourceField: RECORDS_FIELD, operationType: 'count', }, }; @@ -107,7 +108,7 @@ export function getDateSettings(item: FieldVisConfig) { label: COUNT, operationType: 'count', scale: 'ratio', - sourceField: 'Records', + sourceField: RECORDS_FIELD, }, col1: { dataType: 'date', @@ -148,7 +149,7 @@ export function getKeywordSettings(item: FieldVisConfig) { label: COUNT, dataType: 'number', isBucketed: false, - sourceField: 'Records', + sourceField: RECORDS_FIELD, operationType: 'count', }, }; @@ -181,7 +182,7 @@ export function getBooleanSettings(item: FieldVisConfig) { label: COUNT, dataType: 'number', isBucketed: false, - sourceField: 'Records', + sourceField: RECORDS_FIELD, operationType: 'count', }, }; diff --git a/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/overrides.test.js b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/overrides.test.js index 8a4695f8231288..a81b3b5865008e 100644 --- a/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/overrides.test.js +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/edit_flyout/overrides.test.js @@ -5,7 +5,7 @@ * 2.0. */ -import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; import { FILE_FORMATS } from '../../../../../common/constants'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_logic.test.ts index 62ba44128663a9..a87555c58014a4 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/analytics_logic.test.ts @@ -11,7 +11,7 @@ jest.mock('../engine', () => ({ EngineLogic: { values: { engineName: 'test-engine' } }, })); -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { itShowsServerErrorAsFlashMessage } from '../../../test_helpers'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_tables/test_helpers/shared_columns_tests.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_tables/test_helpers/shared_columns_tests.tsx index ea5a28c02c989e..d9ffb83a561c4c 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_tables/test_helpers/shared_columns_tests.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/analytics/components/analytics_tables/test_helpers/shared_columns_tests.tsx @@ -14,7 +14,7 @@ import '../../../../../__mocks__/engine_logic.mock'; import { ReactWrapper } from 'enzyme'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; export const runActionColumnTests = (wrapper: ReactWrapper) => { const { http } = mockHttpValues; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/api_logs_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/api_logs_logic.test.ts index 51d51b5aee88c0..35fa74374acb24 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/api_logs_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/api_logs/api_logs_logic.test.ts @@ -13,7 +13,7 @@ import { import { mockApiLog } from './__mocks__/api_log.mock'; import '../../__mocks__/engine_logic.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { DEFAULT_META } from '../../../shared/constants'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/add_domain/add_domain_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/add_domain/add_domain_logic.test.ts index 466ccc61838f0c..08bd78b5298d44 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/add_domain/add_domain_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/add_domain/add_domain_logic.test.ts @@ -26,7 +26,7 @@ jest.mock('./utils', () => ({ getDomainWithProtocol: jest.fn().mockImplementation((domain) => domain), })); -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { CrawlerLogic } from '../../crawler_logic'; import { CrawlerDomain } from '../../types'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/manage_crawls_popover/automatic_crawl_scheduler_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/manage_crawls_popover/automatic_crawl_scheduler_logic.test.ts index 3c95243459a1cf..5c9e95e097dd40 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/manage_crawls_popover/automatic_crawl_scheduler_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/manage_crawls_popover/automatic_crawl_scheduler_logic.test.ts @@ -20,7 +20,7 @@ jest.mock('./manage_crawls_popover_logic', () => ({ }, })); -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { CrawlUnits } from '../../types'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/manage_crawls_popover/manage_crawls_popover_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/manage_crawls_popover/manage_crawls_popover_logic.test.ts index f80465fa2c407c..da879192efdfa4 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/manage_crawls_popover/manage_crawls_popover_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/manage_crawls_popover/manage_crawls_popover_logic.test.ts @@ -12,7 +12,7 @@ import { } from '../../../../../__mocks__/kea_logic'; import '../../../../__mocks__/engine_logic.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { CrawlerDomain } from '../../types'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawl_detail_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawl_detail_logic.test.ts index 152fe0f64de4d5..f24fe4576e4493 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawl_detail_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawl_detail_logic.test.ts @@ -8,7 +8,7 @@ import { LogicMounter, mockHttpValues } from '../../../__mocks__/kea_logic'; import '../../__mocks__/engine_logic.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { itShowsServerErrorAsFlashMessage } from '../../../test_helpers'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_domains_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_domains_logic.test.ts index fda96ca5f8381d..a4963d7f21b514 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_domains_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_domains_logic.test.ts @@ -12,7 +12,7 @@ import { } from '../../../__mocks__/kea_logic'; import '../../__mocks__/engine_logic.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { Meta } from '../../../../../common/types'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_logic.test.ts index 0735b5262a20ad..e622798e688ab8 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_logic.test.ts @@ -12,7 +12,7 @@ import { } from '../../../__mocks__/kea_logic'; import '../../__mocks__/engine_logic.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { itShowsServerErrorAsFlashMessage } from '../../../test_helpers'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_single_domain_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_single_domain_logic.test.ts index 547218ad6a2c1c..53b63831f14b7a 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_single_domain_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/crawler_single_domain_logic.test.ts @@ -21,7 +21,7 @@ jest.mock('./crawler_logic', () => ({ }, })); -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { itShowsServerErrorAsFlashMessage } from '../../../test_helpers'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_logic.test.ts index decb98d227975f..4ccd91959831a6 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_logic.test.ts @@ -11,7 +11,7 @@ import { mockHttpValues, } from '../../../__mocks__/kea_logic'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { DEFAULT_META } from '../../../shared/constants'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/components/suggestions_logic.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/components/suggestions_logic.test.tsx index a3ca646bd9f54e..db9ee7a4bd12bd 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/components/suggestions_logic.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/components/suggestions_logic.test.tsx @@ -8,7 +8,7 @@ import { LogicMounter, mockHttpValues } from '../../../../__mocks__/kea_logic'; import '../../../__mocks__/engine_logic.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { DEFAULT_META } from '../../../../shared/constants'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/curation_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/curation_logic.test.ts index 644139250c07c5..193d397b1fb509 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/curation_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/curation_logic.test.ts @@ -13,7 +13,7 @@ import { } from '../../../../__mocks__/kea_logic'; import '../../../__mocks__/engine_logic.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { itShowsServerErrorAsFlashMessage } from '../../../../test_helpers'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curations_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curations_logic.test.ts index 71d8b65f1a6390..d8fcc01c29a963 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curations_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curations_logic.test.ts @@ -13,7 +13,7 @@ import { } from '../../../__mocks__/kea_logic'; import '../../__mocks__/engine_logic.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { DEFAULT_META } from '../../../shared/constants'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curation_suggestion/curation_suggestion_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curation_suggestion/curation_suggestion_logic.test.ts index e7ac2b3610998f..8b20c6a64e073d 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curation_suggestion/curation_suggestion_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curation_suggestion/curation_suggestion_logic.test.ts @@ -14,7 +14,7 @@ import { import '../../../../__mocks__/engine_logic.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { itShowsServerErrorAsFlashMessage } from '../../../../../test_helpers'; import { HydratedCurationSuggestion } from '../../types'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations_history/components/ignored_queries_panel/ignored_queries_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations_history/components/ignored_queries_panel/ignored_queries_logic.test.ts index af9f8768207905..fd6589330e43f8 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations_history/components/ignored_queries_panel/ignored_queries_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations_history/components/ignored_queries_panel/ignored_queries_logic.test.ts @@ -16,7 +16,7 @@ import { itShowsServerErrorAsFlashMessage } from '../../../../../../../test_help // I don't know why eslint is saying this line is out of order // eslint-disable-next-line import/order -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { IgnoredQueriesLogic } from './ignored_queries_logic'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations_settings/curations_settings.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations_settings/curations_settings.test.tsx index b95ae0bca5bf6e..73559b2c4b7577 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations_settings/curations_settings.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations_settings/curations_settings.test.tsx @@ -17,7 +17,7 @@ import { shallow, ShallowWrapper } from 'enzyme'; import { EuiButtonEmpty, EuiCallOut, EuiSwitch } from '@elastic/eui'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { docLinks } from '../../../../../shared/doc_links'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations_settings/curations_settings_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations_settings/curations_settings_logic.test.ts index e9643f92f2f715..e3f8a47b401b4d 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations_settings/curations_settings_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations_settings/curations_settings_logic.test.ts @@ -17,7 +17,7 @@ jest.mock('../../curations_logic', () => ({ }, })); -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { CurationsLogic } from '../..'; import { itShowsServerErrorAsFlashMessage } from '../../../../../test_helpers'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/document_creation_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/document_creation_logic.test.ts index 753871765896a1..edd5c5566a45d1 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/document_creation_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/document_creation/document_creation_logic.test.ts @@ -9,7 +9,7 @@ import { LogicMounter, mockHttpValues } from '../../../__mocks__/kea_logic'; import dedent from 'dedent'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; jest.mock('../engine', () => ({ EngineLogic: { values: { engineName: 'test-engine' } }, diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/document_detail_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/document_detail_logic.test.ts index 848a85f23c2cb2..3cdad784a7d273 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/document_detail_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/documents/document_detail_logic.test.ts @@ -13,7 +13,7 @@ import { } from '../../../__mocks__/kea_logic'; import { mockEngineValues } from '../../__mocks__'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { InternalSchemaType } from '../../../shared/schema/types'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_logic.test.ts index adcc6bc546629d..2b0a4627a64b34 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_logic.test.ts @@ -11,7 +11,7 @@ import { mockFlashMessageHelpers, } from '../../../__mocks__/kea_logic'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { SchemaType } from '../../../shared/schema/types'; import { ApiTokenTypes } from '../credentials/constants'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_creation/engine_creation_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_creation/engine_creation_logic.test.ts index 70ff3b5adc078a..3379b5d7850c81 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_creation/engine_creation_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_creation/engine_creation_logic.test.ts @@ -12,7 +12,7 @@ import { mockFlashMessageHelpers, } from '../../../__mocks__/kea_logic'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { EngineCreationLogic } from './engine_creation_logic'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/engine_overview_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/engine_overview_logic.test.ts index 142aab98a643b4..6f0454ca73754d 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/engine_overview_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/engine_overview_logic.test.ts @@ -11,7 +11,7 @@ jest.mock('../engine', () => ({ EngineLogic: { values: { engineName: 'some-engine' } }, })); -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { itShowsServerErrorAsFlashMessage } from '../../../test_helpers'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/engines_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/engines_logic.test.ts index d0a227c8c6fbe2..9659745aeb61dd 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/engines_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/engines_logic.test.ts @@ -11,7 +11,7 @@ import { mockFlashMessageHelpers, } from '../../../__mocks__/kea_logic'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { DEFAULT_META } from '../../../shared/constants'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/log_retention_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/log_retention_logic.test.ts index 20c5860160b787..c254a978f87893 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/log_retention_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/log_retention/log_retention_logic.test.ts @@ -11,7 +11,7 @@ import { mockFlashMessageHelpers, } from '../../../__mocks__/kea_logic'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { LogRetentionOptions } from './types'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/meta_engine_creation/meta_engine_creation_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/meta_engine_creation/meta_engine_creation_logic.test.ts index a785f70a4edb76..9f030444762633 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/meta_engine_creation/meta_engine_creation_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/meta_engine_creation/meta_engine_creation_logic.test.ts @@ -12,7 +12,7 @@ import { mockKibanaValues, } from '../../../__mocks__/kea_logic'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { MetaEngineCreationLogic } from './meta_engine_creation_logic'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_logic.test.ts index 6ac1c27a27959a..605c5ee9d7e805 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_logic.test.ts @@ -12,7 +12,7 @@ import { } from '../../../__mocks__/kea_logic'; import { mockEngineValues, mockEngineActions } from '../../__mocks__'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { itShowsServerErrorAsFlashMessage } from '../../../test_helpers'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_logic.test.ts index 92cb2346e0a26d..f498d53c509d13 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/result_settings_logic.test.ts @@ -10,7 +10,7 @@ import { mockEngineValues } from '../../__mocks__'; import { omit } from 'lodash'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { Schema, SchemaConflicts, SchemaType } from '../../../shared/schema/types'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/sample_response/sample_response_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/sample_response/sample_response_logic.test.ts index 426934b95388e1..ee20fab3da66c7 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/sample_response/sample_response_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/result_settings/sample_response/sample_response_logic.test.ts @@ -8,7 +8,7 @@ import { LogicMounter, mockHttpValues } from '../../../../__mocks__/kea_logic'; import '../../../__mocks__/engine_logic.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { flashAPIErrors } from '../../../../shared/flash_messages'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mappings_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mappings_logic.test.ts index a7422b34d28435..d6802c303807b6 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mappings_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/role_mappings/role_mappings_logic.test.ts @@ -13,7 +13,7 @@ import { import { engines } from '../../__mocks__/engines.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { elasticsearchUsers } from '../../../shared/role_mapping/__mocks__/elasticsearch_users'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/sample_engine_creation_cta/sample_engine_creation_cta_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/sample_engine_creation_cta/sample_engine_creation_cta_logic.test.ts index 0b8e5e97cf5ed4..dd469a486ca457 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/sample_engine_creation_cta/sample_engine_creation_cta_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/sample_engine_creation_cta/sample_engine_creation_cta_logic.test.ts @@ -12,7 +12,7 @@ import { mockFlashMessageHelpers, } from '../../../__mocks__/kea_logic'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { SampleEngineCreationCtaLogic } from './sample_engine_creation_cta_logic'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/reindex_job/reindex_job_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/reindex_job/reindex_job_logic.test.ts index bb8156a8b55fab..67c88d211f118e 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/reindex_job/reindex_job_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/reindex_job/reindex_job_logic.test.ts @@ -12,7 +12,7 @@ import { } from '../../../../__mocks__/kea_logic'; import '../../../__mocks__/engine_logic.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { ReindexJobLogic } from './reindex_job_logic'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_base_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_base_logic.test.ts index 5b40b362bc6655..e12ad7405742af 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_base_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_base_logic.test.ts @@ -8,7 +8,7 @@ import { LogicMounter, mockHttpValues } from '../../../__mocks__/kea_logic'; import '../../__mocks__/engine_logic.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { SchemaType } from '../../../shared/schema/types'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_logic.test.ts index 484996b7105249..8f74a44f8a9303 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/schema/schema_logic.test.ts @@ -12,7 +12,7 @@ import { } from '../../../__mocks__/kea_logic'; import { mockEngineActions } from '../../__mocks__/engine_logic.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { SchemaType, Schema } from '../../../shared/schema/types'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/search/search_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/search/search_logic.test.ts index d4f5ee29f74677..a56d2f7d5c949f 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/search/search_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/search/search_logic.test.ts @@ -12,7 +12,7 @@ import { mockFlashMessageHelpers, } from '../../../__mocks__/kea_logic'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { SearchLogic } from './search_logic'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/search_ui/search_ui_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/search_ui/search_ui_logic.test.ts index 49444fbd0c5c57..58f6f3d98eb280 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/search_ui/search_ui_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/search_ui/search_ui_logic.test.ts @@ -12,7 +12,7 @@ import { } from '../../../__mocks__/kea_logic'; import { mockEngineValues } from '../../__mocks__'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { itShowsServerErrorAsFlashMessage } from '../../../test_helpers'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/source_engines_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/source_engines_logic.test.ts index 75d3c46ef72eed..eaaf43259185e4 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/source_engines_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/source_engines/source_engines_logic.test.ts @@ -13,7 +13,7 @@ import { import { mockRecursivelyFetchEngines } from '../../__mocks__'; import '../../__mocks__/engine_logic.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { EngineLogic } from '../engine'; import { EngineDetails } from '../engine/types'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/synonyms/synonyms_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/components/synonyms/synonyms_logic.test.ts index 7376bc11df79e8..b00619359f6c8b 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/synonyms/synonyms_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/synonyms/synonyms_logic.test.ts @@ -12,7 +12,7 @@ import { } from '../../../__mocks__/kea_logic'; import '../../__mocks__/engine_logic.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { itShowsServerErrorAsFlashMessage } from '../../../test_helpers'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/utils/recursively_fetch_engines/index.test.ts b/x-pack/plugins/enterprise_search/public/applications/app_search/utils/recursively_fetch_engines/index.test.ts index c03ca8267993a6..2eb7f5cb3cdfb3 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/utils/recursively_fetch_engines/index.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/utils/recursively_fetch_engines/index.test.ts @@ -7,7 +7,7 @@ import { mockHttpValues } from '../../../__mocks__/kea_logic'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { itShowsServerErrorAsFlashMessage } from '../../../test_helpers'; diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/tables/generic_endpoint_inline_editable_table/generic_endpoint_inline_editable_table_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/shared/tables/generic_endpoint_inline_editable_table/generic_endpoint_inline_editable_table_logic.test.ts index 481013d91bf6fe..a87aadcc04995d 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/tables/generic_endpoint_inline_editable_table/generic_endpoint_inline_editable_table_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/shared/tables/generic_endpoint_inline_editable_table/generic_endpoint_inline_editable_table_logic.test.ts @@ -21,7 +21,7 @@ import { mockHttpValues, } from '../../../__mocks__/kea_logic'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { GenericEndpointInlineEditableTableLogic } from './generic_endpoint_inline_editable_table_logic'; diff --git a/x-pack/plugins/enterprise_search/public/applications/test_helpers/error_handling.ts b/x-pack/plugins/enterprise_search/public/applications/test_helpers/error_handling.ts index 4f1f4a40aa5039..8f17edf6628fa2 100644 --- a/x-pack/plugins/enterprise_search/public/applications/test_helpers/error_handling.ts +++ b/x-pack/plugins/enterprise_search/public/applications/test_helpers/error_handling.ts @@ -7,7 +7,7 @@ import { mockFlashMessageHelpers } from '../__mocks__/kea_logic'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { HttpHandler } from 'src/core/public'; export const itShowsServerErrorAsFlashMessage = (httpMethod: HttpHandler, callback: () => void) => { diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/api_keys_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/api_keys_logic.test.ts index a02b1578bd38a6..2013539b45b27e 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/api_keys_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/api_keys/api_keys_logic.test.ts @@ -11,7 +11,7 @@ import { mockHttpValues, } from '../../../__mocks__/kea_logic'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { DEFAULT_META } from '../../../shared/constants'; import { itShowsServerErrorAsFlashMessage } from '../../../test_helpers'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/add_source_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/add_source_logic.test.ts index da4e9cad9e276d..371f01cdad2123 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/add_source_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/add_source_logic.test.ts @@ -13,7 +13,7 @@ import { } from '../../../../../__mocks__/kea_logic'; import { sourceConfigData } from '../../../../__mocks__/content_sources.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { itShowsServerErrorAsFlashMessage } from '../../../../../test_helpers'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/display_settings_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/display_settings_logic.test.ts index 81a97c2d19e165..336f892bad51bd 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/display_settings_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/display_settings/display_settings_logic.test.ts @@ -13,7 +13,7 @@ import { } from '../../../../../__mocks__/kea_logic'; import { exampleResult } from '../../../../__mocks__/content_sources.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { itShowsServerErrorAsFlashMessage } from '../../../../../test_helpers'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_logic.test.ts index 748e5068833cf0..e266fb310faa77 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/schema/schema_logic.test.ts @@ -12,7 +12,7 @@ import { } from '../../../../../__mocks__/kea_logic'; import { mostRecentIndexJob } from '../../../../__mocks__/content_sources.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; const contentSource = { id: 'source123' }; jest.mock('../../source_logic', () => ({ diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/synchronization/synchronization_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/synchronization/synchronization_logic.test.ts index 0ccfd6aa63ae47..20a6ba238a2f43 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/synchronization/synchronization_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/synchronization/synchronization_logic.test.ts @@ -13,7 +13,7 @@ import { } from '../../../../../__mocks__/kea_logic'; import { fullContentSources } from '../../../../__mocks__/content_sources.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { itShowsServerErrorAsFlashMessage } from '../../../../../test_helpers'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/group_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/group_logic.test.ts index df61e23fa3cdcc..85b324f0a31bcd 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/group_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/group_logic.test.ts @@ -14,7 +14,7 @@ import { import { groups } from '../../__mocks__/groups.mock'; import { mockGroupValues } from './__mocks__/group_logic.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { itShowsServerErrorAsFlashMessage } from '../../../test_helpers'; import { GROUPS_PATH } from '../../routes'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups_logic.test.ts index 15951a9f8b9caf..14300f98ddf29f 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/groups/groups_logic.test.ts @@ -15,7 +15,7 @@ import { groups } from '../../__mocks__/groups.mock'; import { users } from '../../__mocks__/users.mock'; import { mockGroupsValues } from './__mocks__/groups_logic.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { JSON_HEADER as headers } from '../../../../../common/constants'; import { DEFAULT_META } from '../../../shared/constants'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/oauth_authorize/oauth_authorize_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/oauth_authorize/oauth_authorize_logic.test.ts index 747feb9bc58800..6e90d5de3db8a5 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/oauth_authorize/oauth_authorize_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/oauth_authorize/oauth_authorize_logic.test.ts @@ -11,7 +11,7 @@ import { mockHttpValues, } from '../../../__mocks__/kea_logic'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { OAuthAuthorizeLogic, transformServerPreAuth } from './oauth_authorize_logic'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mappings_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mappings_logic.test.ts index 9379c81afe1995..b3246171ee5a77 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mappings_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/role_mappings/role_mappings_logic.test.ts @@ -13,7 +13,7 @@ import { import { groups } from '../../__mocks__/groups.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { elasticsearchUsers } from '../../../shared/role_mapping/__mocks__/elasticsearch_users'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/search_authorize/search_authorize_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/search_authorize/search_authorize_logic.test.ts index bc8e1942e7a1fa..1aaa9ec622078e 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/search_authorize/search_authorize_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/search_authorize/search_authorize_logic.test.ts @@ -11,7 +11,7 @@ import { mockHttpValues, } from '../../../__mocks__/kea_logic'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { SearchAuthorizeLogic } from './search_authorize_logic'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/security_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/security_logic.test.ts index df9035d57e56ba..5469376f1ca337 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/security_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/security_logic.test.ts @@ -7,7 +7,7 @@ import { LogicMounter, mockHttpValues } from '../../../__mocks__/kea_logic'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { itShowsServerErrorAsFlashMessage } from '../../../test_helpers'; diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/components/branding_section.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/components/branding_section.test.tsx index 876891161b28bd..b8f4c55bc7babb 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/components/branding_section.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/components/branding_section.test.tsx @@ -10,7 +10,7 @@ import React from 'react'; import { shallow, mount } from 'enzyme'; import { EuiFilePicker, EuiConfirmModal } from '@elastic/eui'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; jest.mock('../../../utils', () => ({ readUploadedFileAsBase64: jest.fn(({ img }) => img), diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/settings_logic.test.ts b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/settings_logic.test.ts index d98c9efe04d8c5..f226434b8b8c0c 100644 --- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/settings_logic.test.ts +++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/settings/settings_logic.test.ts @@ -13,7 +13,7 @@ import { } from '../../../__mocks__/kea_logic'; import { configuredSources, oauthApplication } from '../../__mocks__/content_sources.mock'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { itShowsServerErrorAsFlashMessage } from '../../../test_helpers'; import { ORG_UPDATED_MESSAGE, OAUTH_APP_UPDATED_MESSAGE } from '../../constants'; diff --git a/x-pack/plugins/file_upload/kibana.json b/x-pack/plugins/file_upload/kibana.json index f70bc6377972a1..b4ee114645e1cf 100644 --- a/x-pack/plugins/file_upload/kibana.json +++ b/x-pack/plugins/file_upload/kibana.json @@ -1,6 +1,6 @@ { "id": "fileUpload", - "version": "8.1.0", + "version": "8.2.0", "kibanaVersion": "kibana", "server": true, "ui": true, diff --git a/x-pack/plugins/fleet/README.md b/x-pack/plugins/fleet/README.md index 6c26cb29fc541d..f67314ba49fa48 100644 --- a/x-pack/plugins/fleet/README.md +++ b/x-pack/plugins/fleet/README.md @@ -36,7 +36,7 @@ One common development workflow is: ``` - Start Elasticsearch in one shell ``` - yarn es snapshot -E xpack.security.authc.api_key.enabled=true + yarn es snapshot -E xpack.security.authc.api_key.enabled=true -E xpack.security.authc.token.enabled=true ``` - Start Kibana in another shell ``` @@ -58,6 +58,19 @@ _The following is adapted from the Fleet Server [README](https://github.com/elas ```yml server.host: 0.0.0.0 +xpack.fleet.agents.enabled: true +xpack.fleet.packages: + - name: fleet_server + version: latest +xpack.fleet.agentPolicies: + - name: Fleet Server policy + id: fleet-server-policy + description: Fleet server policy + namespace: default + package_policies: + - name: Fleet Server + package: + name: fleet_server ``` 2. Append the following option to the command you use to start Elasticsearch @@ -69,7 +82,7 @@ server.host: 0.0.0.0 This command should look something like this: ``` -yarn es snapshot --license trial -E xpack.security.authc.api_key.enabled=true -E path.data=/tmp/es-data -E http.host=0.0.0.0 +yarn es snapshot --license trial -E xpack.security.authc.api_key.enabled=true -E xpack.security.authc.token.enabled=true -E path.data=/tmp/es-data -E http.host=0.0.0.0 ``` 3. Run the Fleet Server Docker container. Make sure you include a `BASE-PATH` value if your local Kibana instance is using one. `YOUR-IP` should correspond to the IP address used by your Docker network to represent the host. For Windows and Mac machines, this should be `192.168.65.2`. If you're not sure what this IP should be, run the following to look it up: @@ -81,7 +94,7 @@ docker run -it --rm alpine nslookup host.docker.internal To run the Fleet Server Docker container: ``` -docker run -e KIBANA_HOST=http://{YOUR-IP}:5601/{BASE-PATH} -e KIBANA_USERNAME=elastic -e KIBANA_PASSWORD=changeme -e ELASTICSEARCH_HOST=http://{YOUR-IP}:9200 -e ELASTICSEARCH_USERNAME=elastic -e ELASTICSEARCH_PASSWORD=changeme -e KIBANA_FLEET_SETUP=1 -e FLEET_SERVER_ENABLE=1 -e FLEET_SERVER_INSECURE_HTTP=1 -p 8220:8220 docker.elastic.co/beats/elastic-agent:{VERSION} +docker run -e KIBANA_HOST=http://{YOUR-IP}:5601/{BASE-PATH} -e KIBANA_USERNAME=elastic -e KIBANA_PASSWORD=changeme -e ELASTICSEARCH_HOST=http://{YOUR-IP}:9200 -e KIBANA_FLEET_SETUP=1 -e FLEET_SERVER_ENABLE=1 -e FLEET_SERVER_INSECURE_HTTP=1 -e FLEET_SERVER_POLICY_ID=fleet-server-policy -p 8220:8220 docker.elastic.co/beats/elastic-agent:{VERSION} ``` Ensure you provide the `-p 8220:8220` port mapping to map the Fleet Server container's port `8220` to your local machine's port `8220` in order for Fleet to communicate with Fleet Server. diff --git a/x-pack/plugins/fleet/common/services/validate_package_policy.test.ts b/x-pack/plugins/fleet/common/services/validate_package_policy.test.ts index 98056d6906c592..afb6a2f806f9ad 100644 --- a/x-pack/plugins/fleet/common/services/validate_package_policy.test.ts +++ b/x-pack/plugins/fleet/common/services/validate_package_policy.test.ts @@ -606,6 +606,132 @@ describe('Fleet - validatePackagePolicy()', () => { }, }); }); + + it('returns package policy validation error if input var does not exist', () => { + expect( + validatePackagePolicy( + { + description: 'Linux Metrics', + enabled: true, + inputs: [ + { + enabled: true, + streams: [ + { + data_stream: { + dataset: 'linux.memory', + type: 'metrics', + }, + enabled: true, + }, + ], + type: 'linux/metrics', + vars: { + period: { + type: 'string', + value: '1s', + }, + }, + }, + ], + name: 'linux-3d13ada6-a9ae-46df-8e57-ff5050f4b671', + namespace: 'default', + output_id: '', + package: { + name: 'linux', + title: 'Linux Metrics', + version: '0.6.2', + }, + policy_id: 'b25cb6e0-8347-11ec-96f9-6590c25bacf9', + }, + { + ...mockPackage, + name: 'linux', + policy_templates: [ + { + name: 'system', + title: 'Linux kernel metrics', + description: 'Collect system metrics from Linux operating systems', + inputs: [ + { + title: 'Collect system metrics from Linux instances', + vars: [ + { + name: 'system.hostfs', + type: 'text', + title: 'Proc Filesystem Directory', + multi: false, + required: false, + show_user: true, + description: 'The proc filesystem base directory.', + }, + ], + type: 'system/metrics', + description: + 'Collecting Linux entropy, Network Summary, RAID, service, socket, and users metrics', + }, + { + title: 'Collect low-level system metrics from Linux instances', + vars: [], + type: 'linux/metrics', + description: 'Collecting Linux conntrack, ksm, pageinfo metrics.', + }, + ], + multiple: true, + }, + ], + data_streams: [ + { + dataset: 'linux.memory', + package: 'linux', + path: 'memory', + streams: [ + { + input: 'linux/metrics', + title: 'Linux memory metrics', + vars: [ + { + name: 'period', + type: 'text', + title: 'Period', + multi: false, + required: true, + show_user: true, + default: '10s', + }, + ], + template_path: 'stream.yml.hbs', + description: 'Linux paging and memory management metrics', + }, + ], + title: 'Linux-only memory metrics', + release: 'experimental', + type: 'metrics', + }, + ], + }, + safeLoad + ) + ).toEqual({ + description: null, + inputs: { + 'linux/metrics': { + streams: { + 'linux.memory': { + vars: { + period: ['Period is required'], + }, + }, + }, + vars: { + period: ['period var definition does not exist'], + }, + }, + }, + name: null, + namespace: null, + }); + }); }); describe('works for packages with multiple policy templates (aka integrations)', () => { diff --git a/x-pack/plugins/fleet/common/services/validate_package_policy.ts b/x-pack/plugins/fleet/common/services/validate_package_policy.ts index b6befdf8c790e9..f1e28bfbe4e555 100644 --- a/x-pack/plugins/fleet/common/services/validate_package_policy.ts +++ b/x-pack/plugins/fleet/common/services/validate_package_policy.ts @@ -143,7 +143,7 @@ export const validatePackagePolicy = ( results[name] = input.enabled ? validatePackagePolicyConfig( configEntry, - inputVarDefsByPolicyTemplateAndType[inputKey][name], + (inputVarDefsByPolicyTemplateAndType[inputKey] ?? {})[name], name, safeLoadYaml ) @@ -210,10 +210,15 @@ export const validatePackagePolicyConfig = ( } if (varDef === undefined) { - // eslint-disable-next-line no-console - console.debug(`No variable definition for ${varName} found`); - - return null; + errors.push( + i18n.translate('xpack.fleet.packagePolicyValidation.nonExistentVarMessage', { + defaultMessage: '{varName} var definition does not exist', + values: { + varName, + }, + }) + ); + return errors; } if (varDef.required) { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.tsx index 4bce393aebb146..8151215c3cced6 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.tsx @@ -64,10 +64,9 @@ import type { } from '../../../../../../common/types/rest_spec'; import type { PackagePolicyEditExtensionComponentProps } from '../../../types'; import { pkgKeyFromPackageInfo, storedPackagePoliciesToAgentInputs } from '../../../services'; - import { EuiButtonWithTooltip } from '../../../../integrations/sections/epm/screens/detail'; -import { hasUpgradeAvailable } from './utils'; +import { fixApmDurationVars, hasUpgradeAvailable } from './utils'; export const EditPackagePolicyPage = memo(() => { const { @@ -232,6 +231,10 @@ export const EditPackagePolicyForm = memo<{ ...basePolicyInputVars, }; } + // Fix duration vars, if it's a migrated setting, and it's a plain old number with no suffix + if (basePackage.name === 'apm') { + newVars = fixApmDurationVars(newVars); + } return { ...restOfInput, streams: streams.map((stream: any) => { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/utils/fix_apm_duration_vars.test.ts b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/utils/fix_apm_duration_vars.test.ts new file mode 100644 index 00000000000000..ab2a8238e7b377 --- /dev/null +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/utils/fix_apm_duration_vars.test.ts @@ -0,0 +1,50 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { fixApmDurationVars } from './fix_apm_duration_vars'; + +describe('Edit Package Policy - fixApmDurationVars()', () => { + const mockApmVars = { + idle_timeout: { + type: 'text', + value: '45', + }, + read_timeout: { + type: 'text', + value: '3600', + }, + shutdown_timeout: { + type: 'text', + value: '30s', + }, + max_header_bytes: { + type: 'integer', + value: 3, + }, + url: { + type: 'text', + value: 'http://localhost:8200', + }, + }; + describe('when the APM var is a duration var', () => { + it('adds duration unit suffix to APM duration vars ', () => { + const newVars = fixApmDurationVars(mockApmVars); + expect(newVars.idle_timeout.value).toEqual('45s'); + }); + it('doesnt add the suffix if doesnt end with number', () => { + const newVars = fixApmDurationVars(mockApmVars); + expect(newVars.shutdown_timeout.value).toEqual(mockApmVars.shutdown_timeout.value); + }); + }); + describe('when the APM is not a duration var', () => { + it('keeps the same value', () => { + const newVars = fixApmDurationVars(mockApmVars); + expect(newVars.url.value).toEqual(mockApmVars.url.value); + expect(newVars.max_header_bytes.value).toEqual(mockApmVars.max_header_bytes.value); + }); + }); +}); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/utils/fix_apm_duration_vars.ts b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/utils/fix_apm_duration_vars.ts new file mode 100644 index 00000000000000..bea92f35f52ccc --- /dev/null +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/utils/fix_apm_duration_vars.ts @@ -0,0 +1,35 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { PackagePolicyConfigRecord } from '../../../../../integrations/types'; +import { DURATION_APM_SETTINGS_VARS } from '../../../../constants'; + +// Fix duration vars, if it's a migrated setting, and it's a plain old number with no suffix, we should assume seconds +export function fixApmDurationVars(vars: PackagePolicyConfigRecord) { + const { IDLE_TIMEOUT, READ_TIMEOUT, SHUTDOWN_TIMEOUT, TAIL_SAMPLING_INTERVAL, WRITE_TIMEOUT } = + DURATION_APM_SETTINGS_VARS; + // convert vars to array, map each key/value pair into another pair + // and then fromEntries gives back the object + return Object.fromEntries( + Object.entries(vars).map((entry: any) => { + if ( + entry[0] === IDLE_TIMEOUT || + entry[0] === READ_TIMEOUT || + entry[0] === SHUTDOWN_TIMEOUT || + entry[0] === TAIL_SAMPLING_INTERVAL || + entry[0] === WRITE_TIMEOUT + ) { + // we add the unit seconds sufix as default + if (/[0-9]+$/.test(entry[1].value)) { + entry[1] = { ...entry[1], value: entry[1].value + 's' }; + return [entry[0], entry[1]]; + } + } + return entry; + }) + ); +} diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/utils/index.ts b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/utils/index.ts index e8206e9dbbf97d..be01b9834a7dc0 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/utils/index.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/utils/index.ts @@ -6,3 +6,4 @@ */ export * from './has_upgrade_available'; +export { fixApmDurationVars } from './fix_apm_duration_vars'; diff --git a/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/agent_enrollment_flyout.test.tsx b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/agent_enrollment_flyout.test.tsx index 0e6138aea7cb43..617bd95e18a6dc 100644 --- a/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/agent_enrollment_flyout.test.tsx +++ b/x-pack/plugins/fleet/public/components/agent_enrollment_flyout/agent_enrollment_flyout.test.tsx @@ -8,7 +8,7 @@ import './agent_enrollment_flyout.test.mocks'; import React from 'react'; -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; import { act } from '@testing-library/react'; import { coreMock } from 'src/core/public/mocks'; diff --git a/x-pack/plugins/fleet/public/constants/index.ts b/x-pack/plugins/fleet/public/constants/index.ts index dddd7552f01512..6fa1a4161a0663 100644 --- a/x-pack/plugins/fleet/public/constants/index.ts +++ b/x-pack/plugins/fleet/public/constants/index.ts @@ -29,3 +29,11 @@ export * from './page_paths'; export const INDEX_NAME = '.kibana'; export const CUSTOM_LOGS_INTEGRATION_NAME = 'log'; + +export const DURATION_APM_SETTINGS_VARS = { + IDLE_TIMEOUT: 'idle_timeout', + READ_TIMEOUT: 'read_timeout', + SHUTDOWN_TIMEOUT: 'shutdown_timeout', + TAIL_SAMPLING_INTERVAL: 'tail_sampling_interval', + WRITE_TIMEOUT: 'write_timeout', +}; diff --git a/x-pack/plugins/fleet/server/integration_tests/docker_registry_helper.ts b/x-pack/plugins/fleet/server/integration_tests/docker_registry_helper.ts new file mode 100644 index 00000000000000..bb34dc3258d05d --- /dev/null +++ b/x-pack/plugins/fleet/server/integration_tests/docker_registry_helper.ts @@ -0,0 +1,69 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { spawn } from 'child_process'; +import type { ChildProcess } from 'child_process'; + +import fetch from 'node-fetch'; + +const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); + +export function useDockerRegistry() { + const packageRegistryPort = process.env.FLEET_PACKAGE_REGISTRY_PORT || '8081'; + + if (!packageRegistryPort.match(/^[0-9]{4}/)) { + throw new Error('Invalid FLEET_PACKAGE_REGISTRY_PORT'); + } + + let dockerProcess: ChildProcess | undefined; + async function startDockerRegistryServer() { + const dockerImage = `docker.elastic.co/package-registry/distribution@sha256:de952debe048d903fc73e8a4472bb48bb95028d440cba852f21b863d47020c61`; + + const args = ['run', '--rm', '-p', `${packageRegistryPort}:8080`, dockerImage]; + + dockerProcess = spawn('docker', args, { stdio: 'inherit' }); + + let isExited = dockerProcess.exitCode !== null; + dockerProcess.once('exit', () => { + isExited = true; + }); + + let retries = 0; + while (!isExited && retries++ <= 20) { + try { + const res = await fetch(`http://localhost:${packageRegistryPort}/`); + if (res.status === 200) { + return; + } + } catch (err) { + // swallow errors + } + + await delay(3000); + } + + dockerProcess.kill(); + throw new Error('Unable to setup docker registry'); + } + + async function cleanupDockerRegistryServer() { + if (dockerProcess && !dockerProcess.killed) { + dockerProcess.kill(); + } + } + + beforeAll(async () => { + jest.setTimeout(5 * 60 * 1000); // 5 minutes timeout + await startDockerRegistryServer(); + }); + + afterAll(async () => { + await cleanupDockerRegistryServer(); + }); + + return `http://localhost:${packageRegistryPort}`; +} diff --git a/x-pack/plugins/fleet/server/integration_tests/reset_preconfiguration.test.ts b/x-pack/plugins/fleet/server/integration_tests/reset_preconfiguration.test.ts index 9efbacfae17bf6..4a2b4f2495e965 100644 --- a/x-pack/plugins/fleet/server/integration_tests/reset_preconfiguration.test.ts +++ b/x-pack/plugins/fleet/server/integration_tests/reset_preconfiguration.test.ts @@ -14,6 +14,8 @@ import type { HttpMethod } from 'src/core/test_helpers/kbn_server'; import type { AgentPolicySOAttributes } from '../types'; +import { useDockerRegistry } from './docker_registry_helper'; + const logFilePath = Path.join(__dirname, 'logs.log'); type Root = ReturnType; @@ -46,6 +48,8 @@ describe('Fleet preconfiguration reset', () => { let esServer: kbnTestServer.TestElasticsearchUtils; let kbnServer: kbnTestServer.TestKibanaUtils; + const registryUrl = useDockerRegistry(); + const startServers = async () => { const { startES } = kbnTestServer.createTestServers({ adjustTimeout: (t) => jest.setTimeout(t), @@ -63,6 +67,7 @@ describe('Fleet preconfiguration reset', () => { { xpack: { fleet: { + registryUrl, packages: [ { name: 'fleet_server', @@ -195,8 +200,7 @@ describe('Fleet preconfiguration reset', () => { await stopServers(); }); - // FLAKY: https://github.com/elastic/kibana/issues/123103 - describe.skip('Reset all policy', () => { + describe('Reset all policy', () => { it('Works and reset all preconfigured policies', async () => { const resetAPI = getSupertestWithAdminUser( kbnServer.root, @@ -225,9 +229,7 @@ describe('Fleet preconfiguration reset', () => { }); }); - // FLAKY: https://github.com/elastic/kibana/issues/123104 - // FLAKY: https://github.com/elastic/kibana/issues/123105 - describe.skip('Reset one preconfigured policy', () => { + describe('Reset one preconfigured policy', () => { const POLICY_ID = 'test-12345'; it('Works and reset one preconfigured policies if the policy is already deleted (with a ghost package policy)', async () => { diff --git a/x-pack/plugins/fleet/server/services/preconfiguration.ts b/x-pack/plugins/fleet/server/services/preconfiguration.ts index d8c2032596e34e..06d700c3577b54 100644 --- a/x-pack/plugins/fleet/server/services/preconfiguration.ts +++ b/x-pack/plugins/fleet/server/services/preconfiguration.ts @@ -348,7 +348,7 @@ export async function ensurePreconfiguredPackagesAndPolicies( policy!, packagePoliciesToAdd!, defaultOutput, - !created + true ); // Add the is_managed flag after configuring package policies to avoid errors 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 8f22ee8082e81e..99d55bf608ebfb 100644 --- a/x-pack/plugins/global_search/public/services/utils.test.ts +++ b/x-pack/plugins/global_search/public/services/utils.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { StubBrowserStorage } from '@kbn/test/jest'; +import { StubBrowserStorage } from '@kbn/test-jest-helpers'; import { getDefaultPreference } from './utils'; describe('getDefaultPreference', () => { diff --git a/x-pack/plugins/global_search_bar/kibana.json b/x-pack/plugins/global_search_bar/kibana.json index 94b8aba2dd7f9f..538b003a29ef00 100644 --- a/x-pack/plugins/global_search_bar/kibana.json +++ b/x-pack/plugins/global_search_bar/kibana.json @@ -4,7 +4,7 @@ "name": "Kibana Core", "githubTeam": "kibana-core" }, - "version": "8.1.0", + "version": "8.2.0", "kibanaVersion": "kibana", "server": false, "ui": true, diff --git a/x-pack/plugins/graph/kibana.json b/x-pack/plugins/graph/kibana.json index e8b651a9eb0ea8..b4b1e9c21a235a 100644 --- a/x-pack/plugins/graph/kibana.json +++ b/x-pack/plugins/graph/kibana.json @@ -1,6 +1,6 @@ { "id": "graph", - "version": "8.1.0", + "version": "8.2.0", "kibanaVersion": "kibana", "server": true, "ui": true, 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 7d39e8027e92b9..58a2996fd1e674 100644 --- a/x-pack/plugins/graph/public/components/search_bar.test.tsx +++ b/x-pack/plugins/graph/public/components/search_bar.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { SearchBar, SearchBarProps } from './search_bar'; import React, { Component, 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 1c3fbb9f54f671..96d5a2a5b2bac4 100644 --- a/x-pack/plugins/graph/public/components/settings/settings.test.tsx +++ b/x-pack/plugins/graph/public/components/settings/settings.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { EuiTab, EuiListGroupItem, EuiButton, EuiAccordion, EuiFieldText } from '@elastic/eui'; import * as Rx from 'rxjs'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { Settings, SettingsWorkspaceProps } from './settings'; import { act } from '@testing-library/react'; import { ReactWrapper } from 'enzyme'; diff --git a/x-pack/plugins/grokdebugger/kibana.json b/x-pack/plugins/grokdebugger/kibana.json index f8cb75f7d10b66..bbba9651882fdf 100644 --- a/x-pack/plugins/grokdebugger/kibana.json +++ b/x-pack/plugins/grokdebugger/kibana.json @@ -1,6 +1,6 @@ { "id": "grokdebugger", - "version": "8.1.0", + "version": "8.2.0", "kibanaVersion": "kibana", "owner": { "name": "Stack Management", 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 8d55a3e093a311..153f1c09c53a9d 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 @@ -7,7 +7,7 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; -import { registerTestBed, TestBed, TestBedConfig } from '@kbn/test/jest'; +import { registerTestBed, TestBed, TestBedConfig } from '@kbn/test-jest-helpers'; import { docLinksServiceMock } from 'src/core/public/mocks'; import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; import { createBreadcrumbsMock } from '../../../public/application/services/breadcrumbs.mock'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/edit_warning.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/edit_warning.test.ts index 521d5d4da8cefe..83b3a9fc533983 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/edit_warning.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/edit_warning.test.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; import { setupEnvironment } from '../../helpers'; import { initTestBed } from '../init_test_bed'; import { getDefaultHotPhasePolicy, POLICY_NAME } from '../constants'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/frozen_phase.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/frozen_phase.test.ts index aaa2b3dafddde7..57a70237be6e14 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/frozen_phase.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/frozen_phase.test.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; import { licensingMock } from '../../../../../licensing/public/mocks'; import { setupEnvironment } from '../../helpers'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/cloud_aware_behavior.helpers.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/cloud_aware_behavior.helpers.ts index 9741ee87bda109..a0a1c80c90bbe4 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/cloud_aware_behavior.helpers.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/features/node_allocation/cloud_aware_behavior.helpers.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { TestBedConfig } from '@kbn/test/jest'; +import { TestBedConfig } from '@kbn/test-jest-helpers'; import { AppServicesContext } from '../../../../../public/types'; import { createTogglePhaseAction, createNodeAllocationActions } from '../../../helpers'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/validation.helpers.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/validation.helpers.ts index 84ee96cd469871..5b5d3819c34639 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/validation.helpers.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/form_validation/validation.helpers.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { TestBedConfig } from '@kbn/test/jest'; +import { TestBedConfig } from '@kbn/test-jest-helpers'; import { createColdPhaseActions, createDeletePhaseActions, diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/init_test_bed.tsx b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/init_test_bed.tsx index 251ff234c230e8..64d5cd65cda687 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/init_test_bed.tsx +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/init_test_bed.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { registerTestBed, TestBedConfig } from '@kbn/test/jest'; +import { registerTestBed, TestBedConfig } from '@kbn/test-jest-helpers'; import { docLinksServiceMock } from 'src/core/public/mocks'; import '../helpers/global_mocks'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/errors_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/errors_actions.ts index 34d07d4a36ff93..4b863071e191c0 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/errors_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/errors_actions.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; import { Phase } from '../../../../common/types'; const createWaitForValidationAction = (testBed: TestBed) => () => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/forcemerge_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/forcemerge_actions.ts index f2a27aba9ec56f..b6ed40de36ca97 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/forcemerge_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/forcemerge_actions.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; import { Phase } from '../../../../common/types'; import { createFormToggleAction } from './form_toggle_action'; import { createFormSetValueAction } from './form_set_value_action'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/form_set_value_action.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/form_set_value_action.ts index 95e90ac04192bd..57a41831406f96 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/form_set_value_action.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/form_set_value_action.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; export function createFormSetValueAction( testBed: TestBed, diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/form_toggle_action.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/form_toggle_action.ts index 6bf47f5d513f68..b2408583cc3aae 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/form_toggle_action.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/form_toggle_action.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; export const createFormToggleAction = (testBed: TestBed, dataTestSubject: string) => async () => { const { form, component } = testBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/form_toggle_and_set_value_action.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/form_toggle_and_set_value_action.ts index b3510466b4b901..a5c436b13ee0fd 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/form_toggle_and_set_value_action.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/form_toggle_and_set_value_action.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; import { createFormToggleAction } from './form_toggle_action'; import { createFormSetValueAction } from './form_set_value_action'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/index_priority_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/index_priority_actions.ts index eeab42c408244d..79fb77e53cc593 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/index_priority_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/index_priority_actions.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; import { Phase } from '../../../../common/types'; import { createFormToggleAction } from './form_toggle_action'; import { createFormToggleAndSetValueAction } from './form_toggle_and_set_value_action'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/min_age_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/min_age_actions.ts index 551474c8b16e6c..ef00fdc8d7757c 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/min_age_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/min_age_actions.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; import { Phase } from '../../../../common/types'; import { createFormSetValueAction } from './form_set_value_action'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/node_allocation_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/node_allocation_actions.ts index 7c0f8fea7299d2..2a680590654a84 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/node_allocation_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/node_allocation_actions.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; import { DataTierAllocationType } from '../../../../public/application/sections/edit_policy/types'; import { Phase } from '../../../../common/types'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/phases.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/phases.ts index 7f07480cc248db..4bc223943c6c7d 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/phases.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/phases.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; import { createForceMergeActions, createShrinkActions, diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/readonly_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/readonly_actions.ts index b76143eccf1f25..1a7ec56815b009 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/readonly_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/readonly_actions.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; import { Phase } from '../../../../common/types'; import { createFormToggleAction } from './form_toggle_action'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/replicas_action.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/replicas_action.ts index f987ce6d0ca2f2..43eca26a4e1ceb 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/replicas_action.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/replicas_action.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; import { Phase } from '../../../../common/types'; import { createFormToggleAndSetValueAction } from './form_toggle_and_set_value_action'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/request_flyout_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/request_flyout_actions.ts index 87e66ea71e0e46..ca79d52741595e 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/request_flyout_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/request_flyout_actions.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; const jsonSelector = 'policyRequestJson'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/rollover_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/rollover_actions.ts index 93a1b959ec9691..683ba31843829b 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/rollover_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/rollover_actions.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; import { createFormToggleAction } from './form_toggle_action'; import { createFormSetValueAction } from './form_set_value_action'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/save_policy_action.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/save_policy_action.ts index 3fcd1205b6e1a6..9c27e38d75e0de 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/save_policy_action.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/save_policy_action.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; export const createSavePolicyAction = (testBed: TestBed) => async () => { const { find, component } = testBed; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/searchable_snapshot_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/searchable_snapshot_actions.ts index f1a64c3943511b..3efffcddbece6b 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/searchable_snapshot_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/searchable_snapshot_actions.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; import { Phase } from '../../../../common/types'; import { createFormToggleAction } from './form_toggle_action'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/shrink_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/shrink_actions.ts index 394a64696d5eba..def20f73b82fec 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/shrink_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/shrink_actions.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; import { act } from 'react-dom/test-utils'; import { Phase } from '../../../../common/types'; import { createFormSetValueAction } from './form_set_value_action'; diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/snapshot_policy_actions.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/snapshot_policy_actions.ts index 37e0ef17d22544..8aaf968560a1d5 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/snapshot_policy_actions.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/snapshot_policy_actions.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { TestBed } from '@kbn/test/target_types/jest'; +import type { TestBed } from '@kbn/test-jest-helpers'; import { act } from 'react-dom/test-utils'; const createSetWaitForSnapshotAction = (testBed: TestBed) => async (snapshotPolicyName: string) => { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/toggle_phase_action.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/toggle_phase_action.ts index ce5b8b234e0882..c22efae87d5ac3 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/toggle_phase_action.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/helpers/actions/toggle_phase_action.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; import { act } from 'react-dom/test-utils'; import { Phase } from '../../../../common/types'; 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 a38c6e1af5c2a4..240cc18fdc02d7 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 @@ -9,7 +9,7 @@ import moment from 'moment-timezone'; import axios from 'axios'; import axiosXhrAdapter from 'axios/lib/adapters/xhr'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { usageCollectionPluginMock } from '../../../../src/plugins/usage_collection/public/mocks'; import { Index } from '../common/types'; import { diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/policy_table.test.tsx b/x-pack/plugins/index_lifecycle_management/__jest__/policy_table.test.tsx index 1a45b2c6d93dca..3a1c2dd36812f6 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/policy_table.test.tsx +++ b/x-pack/plugins/index_lifecycle_management/__jest__/policy_table.test.tsx @@ -8,7 +8,7 @@ import moment from 'moment-timezone'; import React, { ReactElement } from 'react'; import { ReactWrapper } from 'enzyme'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { findTestSubject, takeMountedSnapshot } from '@elastic/eui/lib/test'; 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 79df6e8e9f20c1..ba2dea966d8cb1 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 @@ -7,8 +7,8 @@ import './mocks'; -export type { TestBed } from '@kbn/test/jest'; -export { nextTick, getRandomString, findTestSubject } from '@kbn/test/jest'; +export type { TestBed } from '@kbn/test-jest-helpers'; +export { nextTick, getRandomString, findTestSubject } from '@kbn/test-jest-helpers'; export { setupEnvironment, 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 e3184cadbdc499..e3295a8f4fb18a 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 @@ -9,7 +9,12 @@ import { act } from 'react-dom/test-utils'; import { ReactWrapper } from 'enzyme'; import { EuiDescriptionListDescription } from '@elastic/eui'; -import { registerTestBed, TestBed, AsyncTestBedConfig, findTestSubject } from '@kbn/test/jest'; +import { + registerTestBed, + TestBed, + AsyncTestBedConfig, + findTestSubject, +} from '@kbn/test-jest-helpers'; 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 ad8aceb7d56b81..46287fcdcf074c 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test/jest'; +import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test-jest-helpers'; 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 426bb11f3c7333..60d4b7d3f23170 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 @@ -16,7 +16,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 '@kbn/test/jest'; +import { stubWebWorker } from '@kbn/test-jest-helpers'; 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 4ddd14562577ab..69dcabc287d6b4 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 @@ -7,7 +7,12 @@ import { act } from 'react-dom/test-utils'; -import { registerTestBed, TestBed, AsyncTestBedConfig, findTestSubject } from '@kbn/test/jest'; +import { + registerTestBed, + TestBed, + AsyncTestBedConfig, + findTestSubject, +} from '@kbn/test-jest-helpers'; 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 018025b25246b3..719758e18525a5 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 @@ -8,7 +8,12 @@ import { act } from 'react-dom/test-utils'; import { ReactWrapper } from 'enzyme'; -import { registerTestBed, TestBed, AsyncTestBedConfig, findTestSubject } from '@kbn/test/jest'; +import { + registerTestBed, + TestBed, + AsyncTestBedConfig, + findTestSubject, +} from '@kbn/test-jest-helpers'; 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 9e3f323ca45ea8..6387a0904a69cc 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 @@ -43,7 +43,7 @@ jest.mock('../../../public/application/lib/ace.js', () => { Could not load worker ReferenceError: Worker is not defined at createWorker (//node_modules/brace/index.js:17992:5) */ -import { stubWebWorker } from '@kbn/test/jest'; +import { stubWebWorker } from '@kbn/test-jest-helpers'; 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 dffa6fee19d061..9aec6cae7a17e3 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed, AsyncTestBedConfig } from '@kbn/test/jest'; +import { registerTestBed, AsyncTestBedConfig } from '@kbn/test-jest-helpers'; 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 450d2c524b4455..b039fa83000ed7 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed, AsyncTestBedConfig } from '@kbn/test/jest'; +import { registerTestBed, AsyncTestBedConfig } from '@kbn/test-jest-helpers'; 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 6c73da3b3379d4..a7f87d828eb23c 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed, AsyncTestBedConfig } from '@kbn/test/jest'; +import { registerTestBed, AsyncTestBedConfig } from '@kbn/test-jest-helpers'; 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 d14855354f0ade..57d0b282d351d4 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 @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; -import { TestBed, SetupFunc } from '@kbn/test/jest'; +import { TestBed, SetupFunc } from '@kbn/test-jest-helpers'; 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 5e5538fcca4e87..f98c891e5f4f55 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 @@ -19,7 +19,7 @@ import axiosXhrAdapter from 'axios/lib/adapters/xhr'; Could not load worker ReferenceError: Worker is not defined at createWorker (//node_modules/brace/index.js:17992:5) */ -import { mountWithIntl, stubWebWorker } from '@kbn/test/jest'; // eslint-disable-line no-unused-vars +import { mountWithIntl, stubWebWorker } from '@kbn/test-jest-helpers'; // eslint-disable-line no-unused-vars import { BASE_PATH, API_BASE_PATH } from '../../common/constants'; import { AppWithoutRouter } from '../../public/application/app'; diff --git a/x-pack/plugins/index_management/common/constants/plugin.ts b/x-pack/plugins/index_management/common/constants/plugin.ts index 060d42ca26b023..482661045b3fa0 100644 --- a/x-pack/plugins/index_management/common/constants/plugin.ts +++ b/x-pack/plugins/index_management/common/constants/plugin.ts @@ -22,4 +22,4 @@ export const PLUGIN = { // "PluginInitializerContext.env.packageInfo.version". In some cases it is not possible // to dynamically inject that version without a huge refactor on the code base. // We will then keep this single constant to declare on which major branch we are. -export const MAJOR_VERSION = '8.1.0'; +export const MAJOR_VERSION = '8.2.0'; 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 06f0036cc5c77b..18b5bbfd775bb9 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test/jest'; +import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test-jest-helpers'; 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 49bef82ce3d118..cdf376028ff1d7 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed, TestBed } from '@kbn/test/jest'; +import { registerTestBed, TestBed } from '@kbn/test-jest-helpers'; 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 e7b8df245aaa9f..6e0f9d55ef7f04 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test/jest'; +import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test-jest-helpers'; 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 578a1241251078..ce97ac9d4e222d 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 @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; 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 680550d16096b7..2a01518e25466c 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 @@ -13,7 +13,7 @@ import { AsyncTestBedConfig, findTestSubject, nextTick, -} from '@kbn/test/jest'; +} from '@kbn/test-jest-helpers'; import { BASE_PATH } from '../../../../../../../common'; 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 5185878ee98bc5..72c3b8af534a55 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 @@ -8,7 +8,7 @@ import { setup as componentTemplatesListSetup } from './component_template_list.helpers'; import { setup as componentTemplateDetailsSetup } from './component_template_details.helpers'; -export { nextTick, getRandomString, findTestSubject } from '@kbn/test/jest'; +export { nextTick, getRandomString, findTestSubject } from '@kbn/test-jest-helpers'; export { setupEnvironment, componentTemplatesDependencies } 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 d436492756659d..5244cdb65bb0f5 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 @@ -12,8 +12,8 @@ import { getMappingsEditorDataFactory, } from './mappings_editor.helpers'; -export type { TestBed } from '@kbn/test/jest'; -export { nextTick, getRandomString, findTestSubject } from '@kbn/test/jest'; +export type { TestBed } from '@kbn/test-jest-helpers'; +export { nextTick, getRandomString, findTestSubject } from '@kbn/test-jest-helpers'; export { kibanaVersion } from './setup_environment'; export const componentHelpers = { 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 074d96e9be4c17..1e3cfd99cedb4e 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,7 +7,7 @@ import { act } from 'react-dom/test-utils'; import { ReactWrapper } from 'enzyme'; -import { registerTestBed, TestBed, findTestSubject } from '@kbn/test/jest'; +import { registerTestBed, TestBed, findTestSubject } from '@kbn/test-jest-helpers'; // This import needs to come first as it sets the jest.mock calls import { WithAppDependencies } from './setup_environment'; 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 8259c78b8e1402..c2502f14facfb7 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 @@ -18,7 +18,7 @@ jest.mock('lodash', () => { }; }); -import { registerTestBed, TestBed } from '@kbn/test/jest'; +import { registerTestBed, TestBed } from '@kbn/test-jest-helpers'; import { LoadMappingsProvider } from './load_mappings_provider'; const ComponentToTest = ({ onJson }: { onJson: () => void }) => ( diff --git a/x-pack/plugins/index_management/server/lib/fetch_indices.ts b/x-pack/plugins/index_management/server/lib/fetch_indices.ts index 5050353f992b6a..7b25956703db29 100644 --- a/x-pack/plugins/index_management/server/lib/fetch_indices.ts +++ b/x-pack/plugins/index_management/server/lib/fetch_indices.ts @@ -30,6 +30,9 @@ async function fetchIndicesCall( '*.settings.index.hidden', '*.data_stream', ], + // for better performance only compute aliases and settings of indices but not mappings + // @ts-expect-error new param https://github.com/elastic/elasticsearch-specification/issues/1382 + features: ['aliases', 'settings'], }); if (!Object.keys(indices).length) { diff --git a/x-pack/plugins/index_management/test/fixtures/template.ts b/x-pack/plugins/index_management/test/fixtures/template.ts index dd279cf4bcaecf..ae9be960157350 100644 --- a/x-pack/plugins/index_management/test/fixtures/template.ts +++ b/x-pack/plugins/index_management/test/fixtures/template.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { getRandomString, getRandomNumber } from '@kbn/test/jest'; +import { getRandomString, getRandomNumber } from '@kbn/test-jest-helpers'; import { TemplateDeserialized, TemplateType, TemplateListItem } from '../../common'; const objHasProperties = (obj?: Record): boolean => { diff --git a/x-pack/plugins/infra/common/http_api/metadata_api.ts b/x-pack/plugins/infra/common/http_api/metadata_api.ts index a0524af805f00c..0f847f19f75d3a 100644 --- a/x-pack/plugins/infra/common/http_api/metadata_api.ts +++ b/x-pack/plugins/infra/common/http_api/metadata_api.ts @@ -37,8 +37,8 @@ export const InfraMetadataHostRT = rt.partial({ name: rt.string, hostname: rt.string, id: rt.string, - ip: rt.array(rt.string), - mac: rt.array(rt.string), + ip: rt.union([rt.array(rt.string), rt.string]), + mac: rt.union([rt.array(rt.string), rt.string]), os: InfraMetadataOSRT, architecture: rt.string, containerized: rt.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 c8cd2da45c5c32..d34f6b369b2df8 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { mountWithIntl, nextTick, shallowWithIntl } from '@kbn/test/jest'; +import { mountWithIntl, nextTick, shallowWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; import { act } from 'react-dom/test-utils'; // We are using this inside a `jest.mock` call. Jest requires dynamic dependencies to be prefixed with `mock` diff --git a/x-pack/plugins/infra/public/alerting/metric_anomaly/components/expression.test.tsx b/x-pack/plugins/infra/public/alerting/metric_anomaly/components/expression.test.tsx index 3bbc3cb2662cbc..e40c72171f72b7 100644 --- a/x-pack/plugins/infra/public/alerting/metric_anomaly/components/expression.test.tsx +++ b/x-pack/plugins/infra/public/alerting/metric_anomaly/components/expression.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; // We are using this inside a `jest.mock` call. Jest requires dynamic dependencies to be prefixed with `mock` import { coreMock as mockCoreMock } from 'src/core/public/mocks'; import React from 'react'; 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 94192f9f911c54..309808bf48352c 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import React from 'react'; import { act } from 'react-dom/test-utils'; // We are using this inside a `jest.mock` call. Jest requires dynamic dependencies to be prefixed with `mock` 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 f7e3201bbf2c92..e5c6e1a4d89846 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 @@ -6,7 +6,7 @@ */ import { DataViewBase } from '@kbn/es-query'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import React from 'react'; import { act } from 'react-dom/test-utils'; // We are using this inside a `jest.mock` call. Jest requires dynamic dependencies to be prefixed with `mock` 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 1d8c6f63398785..6a0de2481e64a8 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import React from 'react'; import { act } from 'react-dom/test-utils'; import { Comparator } from '../../../../common/alerting/metrics'; 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 f30878dd2ff3db..1fe14d9b2965b4 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { mountHook } from '@kbn/test/jest'; +import { mountHook } from '@kbn/test-jest-helpers'; 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 c16314a6c0e710..5260cd4d680f6e 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 @@ -8,7 +8,7 @@ import { createMemoryHistory } from 'history'; import React from 'react'; import { Router } from 'react-router-dom'; -import { mountHook } from '@kbn/test/jest'; +import { mountHook } from '@kbn/test-jest-helpers'; 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 ed88156b740bf7..5f4dc01fa924ad 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 @@ -11,7 +11,7 @@ import { setup as pipelinesCloneSetup } from './pipelines_clone.helpers'; import { setup as pipelinesEditSetup } from './pipelines_edit.helpers'; import { setup as pipelinesCreateFromCsvSetup } from './pipelines_create_from_csv.helpers'; -export { nextTick, getRandomString, findTestSubject } from '@kbn/test/jest'; +export { nextTick, getRandomString, findTestSubject } from '@kbn/test-jest-helpers'; 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 3f11f9538ffa9e..432b9046f10714 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 @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; 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 51f6d9bd96bd6a..5b5d6704e90016 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed, AsyncTestBedConfig, TestBed } from '@kbn/test/jest'; +import { registerTestBed, AsyncTestBedConfig, TestBed } from '@kbn/test-jest-helpers'; 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 faf1b42042ec1e..3dc97cf121b986 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed, AsyncTestBedConfig, TestBed } from '@kbn/test/jest'; +import { registerTestBed, AsyncTestBedConfig, TestBed } from '@kbn/test-jest-helpers'; 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_create_from_csv.helpers.ts b/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipelines_create_from_csv.helpers.ts index e7de57de0e9486..ea9d623e216b2e 100644 --- a/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipelines_create_from_csv.helpers.ts +++ b/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipelines_create_from_csv.helpers.ts @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; -import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test/jest'; +import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test-jest-helpers'; import { PipelinesCreateFromCsv } from '../../../public/application/sections/pipelines_create_from_csv'; import { WithAppDependencies } from './setup_environment'; import { getCreateFromCsvPath, ROUTES } from '../../../public/application/services/navigation'; 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 9a3c41196653f4..74d124de885ffb 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed, AsyncTestBedConfig, TestBed } from '@kbn/test/jest'; +import { registerTestBed, AsyncTestBedConfig, TestBed } from '@kbn/test-jest-helpers'; 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 e2d9f1f8bf5f94..6fa3a7a9473fea 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 @@ -7,7 +7,12 @@ import { act } from 'react-dom/test-utils'; -import { registerTestBed, TestBed, AsyncTestBedConfig, findTestSubject } from '@kbn/test/jest'; +import { + registerTestBed, + TestBed, + AsyncTestBedConfig, + findTestSubject, +} from '@kbn/test-jest-helpers'; 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/kibana.json b/x-pack/plugins/ingest_pipelines/kibana.json index 958aa729ccf0de..912584e8083317 100644 --- a/x-pack/plugins/ingest_pipelines/kibana.json +++ b/x-pack/plugins/ingest_pipelines/kibana.json @@ -1,6 +1,6 @@ { "id": "ingestPipelines", - "version": "8.1.0", + "version": "8.2.0", "server": true, "ui": true, "owner": { diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/__jest__/pipeline_processors_editor.helpers.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/__jest__/pipeline_processors_editor.helpers.tsx index 79ffd28c9e7884..dd269e34fa694d 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/__jest__/pipeline_processors_editor.helpers.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/__jest__/pipeline_processors_editor.helpers.tsx @@ -8,7 +8,7 @@ import { act } from 'react-dom/test-utils'; import React from 'react'; -import { registerTestBed, TestBed } from '@kbn/test/jest'; +import { registerTestBed, TestBed } from '@kbn/test-jest-helpers'; import { Props } from '../'; import { ProcessorsEditorWithDeps } from './processors_editor'; diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/__jest__/processors/processor.helpers.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/__jest__/processors/processor.helpers.tsx index 65d9b8f306058d..274d41651fe91a 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/__jest__/processors/processor.helpers.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/__jest__/processors/processor.helpers.tsx @@ -13,8 +13,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 '@kbn/test/jest'; -import { stubWebWorker } from '@kbn/test/jest'; +import { registerTestBed, TestBed } from '@kbn/test-jest-helpers'; +import { stubWebWorker } from '@kbn/test-jest-helpers'; 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_editor/__jest__/test_pipeline.helpers.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/__jest__/test_pipeline.helpers.tsx index 263a40a605d2d0..ff8802a91cc9b3 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/__jest__/test_pipeline.helpers.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/__jest__/test_pipeline.helpers.tsx @@ -13,8 +13,8 @@ import axiosXhrAdapter from 'axios/lib/adapters/xhr'; /* eslint-disable-next-line @kbn/eslint/no-restricted-paths */ import { usageCollectionPluginMock } from 'src/plugins/usage_collection/public/mocks'; -import { registerTestBed, TestBed } from '@kbn/test/jest'; -import { stubWebWorker } from '@kbn/test/jest'; +import { registerTestBed, TestBed } from '@kbn/test-jest-helpers'; +import { stubWebWorker } from '@kbn/test-jest-helpers'; /* eslint-disable-next-line @kbn/eslint/no-restricted-paths */ import '../../../../../../../../src/plugins/es_ui_shared/public/components/code_editor/jest_mock'; diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/load_from_json/modal_provider.test.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/load_from_json/modal_provider.test.tsx index 74b759fc803755..9392fe2398e2f4 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/load_from_json/modal_provider.test.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/load_from_json/modal_provider.test.tsx @@ -18,7 +18,7 @@ jest.mock('lodash', () => { }; }); -import { registerTestBed, TestBed } from '@kbn/test/jest'; +import { registerTestBed, TestBed } from '@kbn/test-jest-helpers'; const setup = ({ onDone }: { onDone: OnDoneLoadJsonHandler }) => { return registerTestBed( diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/cell_value.test.tsx b/x-pack/plugins/lens/public/datatable_visualization/components/cell_value.test.tsx index 21f6cb6bc2052d..7cd45dffd5def5 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/cell_value.test.tsx +++ b/x-pack/plugins/lens/public/datatable_visualization/components/cell_value.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; import { DataContext } from './table_basic'; import { createGridCell } from './cell_value'; diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/columns.tsx b/x-pack/plugins/lens/public/datatable_visualization/components/columns.tsx index a8ba6d553b7388..67d95f04869f87 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/columns.tsx +++ b/x-pack/plugins/lens/public/datatable_visualization/components/columns.tsx @@ -19,23 +19,27 @@ import type { ColumnConfig } from '../../../common/expressions'; export const createGridColumns = ( bucketColumns: string[], table: Datatable, - handleFilterClick: ( - field: string, - value: unknown, - colIndex: number, - rowIndex: number, - negate?: boolean - ) => void, - handleTransposedColumnClick: ( - bucketValues: Array<{ originalBucketColumn: DatatableColumn; value: unknown }>, - negate?: boolean - ) => void, + handleFilterClick: + | (( + field: string, + value: unknown, + colIndex: number, + rowIndex: number, + negate?: boolean + ) => void) + | undefined, + handleTransposedColumnClick: + | (( + bucketValues: Array<{ originalBucketColumn: DatatableColumn; value: unknown }>, + negate?: boolean + ) => void) + | undefined, isReadOnly: boolean, columnConfig: ColumnConfig, visibleColumns: string[], formatFactory: FormatFactory, onColumnResize: (eventData: { columnId: string; width: number | undefined }) => void, - onColumnHide: (eventData: { columnId: string }) => void, + onColumnHide: ((eventData: { columnId: string }) => void) | undefined, alignments: Record ) => { const columnsReverseLookup = table.columns.reduce< @@ -63,86 +67,87 @@ export const createGridColumns = ( const filterable = bucketLookup.has(field); const { name, index: colIndex } = columnsReverseLookup[field]; - const cellActions = filterable - ? [ - ({ rowIndex, columnId, Component, closePopover }: EuiDataGridColumnCellActionProps) => { - const { rowValue, contentsIsDefined, cellContent } = getContentData({ - rowIndex, - columnId, - }); - - const filterForText = i18n.translate( - 'xpack.lens.table.tableCellFilter.filterForValueText', - { - defaultMessage: 'Filter for value', - } - ); - const filterForAriaLabel = i18n.translate( - 'xpack.lens.table.tableCellFilter.filterForValueAriaLabel', - { - defaultMessage: 'Filter for value: {cellContent}', - values: { - cellContent, - }, - } - ); - - return ( - contentsIsDefined && ( - { - handleFilterClick(field, rowValue, colIndex, rowIndex); - closePopover(); - }} - iconType="plusInCircle" - > - {filterForText} - - ) - ); - }, - ({ rowIndex, columnId, Component, closePopover }: EuiDataGridColumnCellActionProps) => { - const { rowValue, contentsIsDefined, cellContent } = getContentData({ - rowIndex, - columnId, - }); - - const filterOutText = i18n.translate( - 'xpack.lens.table.tableCellFilter.filterOutValueText', - { - defaultMessage: 'Filter out value', - } - ); - const filterOutAriaLabel = i18n.translate( - 'xpack.lens.table.tableCellFilter.filterOutValueAriaLabel', - { - defaultMessage: 'Filter out value: {cellContent}', - values: { - cellContent, - }, - } - ); - - return ( - contentsIsDefined && ( - { - handleFilterClick(field, rowValue, colIndex, rowIndex, true); - closePopover(); - }} - iconType="minusInCircle" - > - {filterOutText} - - ) - ); - }, - ] - : undefined; + const cellActions = + filterable && handleFilterClick + ? [ + ({ rowIndex, columnId, Component, closePopover }: EuiDataGridColumnCellActionProps) => { + const { rowValue, contentsIsDefined, cellContent } = getContentData({ + rowIndex, + columnId, + }); + + const filterForText = i18n.translate( + 'xpack.lens.table.tableCellFilter.filterForValueText', + { + defaultMessage: 'Filter for value', + } + ); + const filterForAriaLabel = i18n.translate( + 'xpack.lens.table.tableCellFilter.filterForValueAriaLabel', + { + defaultMessage: 'Filter for value: {cellContent}', + values: { + cellContent, + }, + } + ); + + return ( + contentsIsDefined && ( + { + handleFilterClick(field, rowValue, colIndex, rowIndex); + closePopover(); + }} + iconType="plusInCircle" + > + {filterForText} + + ) + ); + }, + ({ rowIndex, columnId, Component, closePopover }: EuiDataGridColumnCellActionProps) => { + const { rowValue, contentsIsDefined, cellContent } = getContentData({ + rowIndex, + columnId, + }); + + const filterOutText = i18n.translate( + 'xpack.lens.table.tableCellFilter.filterOutValueText', + { + defaultMessage: 'Filter out value', + } + ); + const filterOutAriaLabel = i18n.translate( + 'xpack.lens.table.tableCellFilter.filterOutValueAriaLabel', + { + defaultMessage: 'Filter out value: {cellContent}', + values: { + cellContent, + }, + } + ); + + return ( + contentsIsDefined && ( + { + handleFilterClick(field, rowValue, colIndex, rowIndex, true); + closePopover(); + }} + iconType="minusInCircle" + > + {filterOutText} + + ) + ); + }, + ] + : undefined; const columnArgs = columnConfig.columns.find(({ columnId }) => columnId === field); const isTransposed = Boolean(columnArgs?.originalColumnId); @@ -163,7 +168,7 @@ export const createGridColumns = ( 'data-test-subj': 'lensDatatableResetWidth', isDisabled: initialWidth == null, }); - if (!isTransposed) { + if (!isTransposed && onColumnHide) { additionalActions.push({ color: 'text', size: 'xs', @@ -178,7 +183,7 @@ export const createGridColumns = ( } if (!isReadOnly) { - if (isTransposed && columnArgs?.bucketValues) { + if (isTransposed && columnArgs?.bucketValues && handleTransposedColumnClick) { const bucketValues = columnArgs?.bucketValues; additionalActions.push({ color: 'text', diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor.test.tsx b/x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor.test.tsx index 22f5227baa5565..d8dabd81441da6 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor.test.tsx +++ b/x-pack/plugins/lens/public/datatable_visualization/components/dimension_editor.test.tsx @@ -10,7 +10,7 @@ import { EuiButtonGroup, EuiComboBox, EuiFieldText } from '@elastic/eui'; import { FramePublicAPI, Operation, VisualizationDimensionEditorProps } from '../../types'; import { DatatableVisualizationState } from '../visualization'; import { createMockDatasource, createMockFramePublicAPI } from '../../mocks'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { TableDimensionEditor } from './dimension_editor'; import { chartPluginMock } from 'src/plugins/charts/public/mocks'; import { PaletteRegistry } from 'src/plugins/charts/public'; diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/table_basic.test.tsx b/x-pack/plugins/lens/public/datatable_visualization/components/table_basic.test.tsx index 46ca179e7cdb4c..8c75ee9efcc6bb 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/table_basic.test.tsx +++ b/x-pack/plugins/lens/public/datatable_visualization/components/table_basic.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { ReactWrapper, shallow, mount } from 'enzyme'; import { act } from 'react-dom/test-utils'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { EuiDataGrid } from '@elastic/eui'; import { IAggType } from 'src/plugins/data/public'; import { @@ -121,6 +121,7 @@ describe('DatatableComponent', () => { paletteService={chartPluginMock.createPaletteRegistry()} uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} renderMode="edit" + interactive /> ) ).toMatchSnapshot(); @@ -141,6 +142,7 @@ describe('DatatableComponent', () => { renderMode="edit" paletteService={chartPluginMock.createPaletteRegistry()} uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + interactive /> ) ).toMatchSnapshot(); @@ -161,6 +163,7 @@ describe('DatatableComponent', () => { renderMode="view" paletteService={chartPluginMock.createPaletteRegistry()} uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + interactive /> ) ).toMatchSnapshot(); @@ -185,6 +188,7 @@ describe('DatatableComponent', () => { renderMode="edit" paletteService={chartPluginMock.createPaletteRegistry()} uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + interactive /> ); @@ -230,6 +234,7 @@ describe('DatatableComponent', () => { renderMode="edit" paletteService={chartPluginMock.createPaletteRegistry()} uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + interactive /> ); @@ -314,6 +319,7 @@ describe('DatatableComponent', () => { renderMode="edit" paletteService={chartPluginMock.createPaletteRegistry()} uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + interactive /> ); @@ -340,6 +346,36 @@ describe('DatatableComponent', () => { }); }); + test('it should not invoke executeTriggerActions if interactivity is set to false', async () => { + const { args, data } = sampleArgs(); + + const wrapper = mountWithIntl( + ({ convert: (x) => x } as IFieldFormat)} + dispatchEvent={onDispatchEvent} + getType={jest.fn(() => ({ type: 'buckets' } as IAggType))} + renderMode="edit" + paletteService={chartPluginMock.createPaletteRegistry()} + uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + interactive={false} + /> + ); + + wrapper.find('[data-test-subj="dataGridRowCell"]').first().simulate('focus'); + + await waitForWrapperUpdate(wrapper); + + expect(wrapper.find('[data-test-subj="lensDatatableFilterOut"]').exists()).toBe(false); + }); + test('it shows emptyPlaceholder for undefined bucketed data', () => { const { args, data } = sampleArgs(); const emptyData: LensMultiTable = { @@ -364,6 +400,7 @@ describe('DatatableComponent', () => { renderMode="edit" paletteService={chartPluginMock.createPaletteRegistry()} uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + interactive /> ); expect(component.find(VisualizationContainer)).toHaveLength(1); @@ -387,6 +424,7 @@ describe('DatatableComponent', () => { renderMode="edit" paletteService={chartPluginMock.createPaletteRegistry()} uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + interactive /> ); @@ -437,6 +475,7 @@ describe('DatatableComponent', () => { renderMode="view" paletteService={chartPluginMock.createPaletteRegistry()} uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + interactive /> ); @@ -467,6 +506,7 @@ describe('DatatableComponent', () => { renderMode="view" paletteService={chartPluginMock.createPaletteRegistry()} uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + interactive /> ); @@ -495,6 +535,7 @@ describe('DatatableComponent', () => { renderMode="view" paletteService={chartPluginMock.createPaletteRegistry()} uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + interactive /> ); @@ -541,6 +582,7 @@ describe('DatatableComponent', () => { renderMode="view" paletteService={chartPluginMock.createPaletteRegistry()} uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + interactive /> ); @@ -567,6 +609,7 @@ describe('DatatableComponent', () => { renderMode="edit" paletteService={chartPluginMock.createPaletteRegistry()} uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + interactive /> ); // mnake a copy of the data, changing only the name of the first column @@ -602,6 +645,7 @@ describe('DatatableComponent', () => { renderMode="view" paletteService={chartPluginMock.createPaletteRegistry()} uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + interactive /> ); @@ -637,6 +681,7 @@ describe('DatatableComponent', () => { renderMode="view" paletteService={chartPluginMock.createPaletteRegistry()} uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + interactive /> ); expect(wrapper.find('[data-test-subj="lnsDataTable-footer-a"]').exists()).toEqual(false); @@ -672,6 +717,7 @@ describe('DatatableComponent', () => { renderMode="view" paletteService={chartPluginMock.createPaletteRegistry()} uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + interactive /> ); @@ -706,6 +752,7 @@ describe('DatatableComponent', () => { renderMode="view" paletteService={chartPluginMock.createPaletteRegistry()} uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} + interactive /> ); @@ -728,6 +775,7 @@ describe('DatatableComponent', () => { paletteService={chartPluginMock.createPaletteRegistry()} uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} renderMode="edit" + interactive /> ); @@ -762,6 +810,7 @@ describe('DatatableComponent', () => { paletteService={chartPluginMock.createPaletteRegistry()} uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} renderMode="edit" + interactive /> ); @@ -786,6 +835,7 @@ describe('DatatableComponent', () => { paletteService: chartPluginMock.createPaletteRegistry(), uiSettings: { get: jest.fn() } as unknown as IUiSettingsClient, renderMode: 'edit' as RenderMode, + interactive: true, }; const wrapper = mount( @@ -821,6 +871,7 @@ describe('DatatableComponent', () => { paletteService={chartPluginMock.createPaletteRegistry()} uiSettings={{ get: jest.fn() } as unknown as IUiSettingsClient} renderMode="edit" + interactive /> ); diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/table_basic.tsx b/x-pack/plugins/lens/public/datatable_visualization/components/table_basic.tsx index 116331771a9dd6..403858f4ba48cf 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/table_basic.tsx +++ b/x-pack/plugins/lens/public/datatable_visualization/components/table_basic.tsx @@ -58,6 +58,8 @@ const PAGE_SIZE_OPTIONS = [DEFAULT_PAGE_SIZE, 20, 30, 50, 100]; export const DatatableComponent = (props: DatatableRenderProps) => { const [firstTable] = Object.values(props.data.tables); + const isInteractive = props.interactive; + const [columnConfig, setColumnConfig] = useState({ columns: props.args.columns, sortingColumnId: props.args.sortingColumnId, @@ -160,13 +162,16 @@ export const DatatableComponent = (props: DatatableRenderProps) => { ); const handleFilterClick = useMemo( - () => createGridFilterHandler(firstTableRef, onClickValue), - [firstTableRef, onClickValue] + () => (isInteractive ? createGridFilterHandler(firstTableRef, onClickValue) : undefined), + [firstTableRef, onClickValue, isInteractive] ); const handleTransposedColumnClick = useMemo( - () => createTransposeColumnFilterHandler(onClickValue, untransposedDataRef), - [onClickValue, untransposedDataRef] + () => + isInteractive + ? createTransposeColumnFilterHandler(onClickValue, untransposedDataRef) + : undefined, + [onClickValue, untransposedDataRef, isInteractive] ); const bucketColumns = useMemo( @@ -206,8 +211,11 @@ export const DatatableComponent = (props: DatatableRenderProps) => { ); const onColumnHide = useMemo( - () => createGridHideHandler(columnConfig, setColumnConfig, onEditAction), - [onEditAction, setColumnConfig, columnConfig] + () => + isInteractive + ? createGridHideHandler(columnConfig, setColumnConfig, onEditAction) + : undefined, + [onEditAction, setColumnConfig, columnConfig, isInteractive] ); const isNumericMap: Record = useMemo(() => { @@ -278,7 +286,7 @@ export const DatatableComponent = (props: DatatableRenderProps) => { ); const trailingControlColumns: EuiDataGridControlColumn[] = useMemo(() => { - if (!hasAtLeastOneRowClickAction || !onRowContextMenuClick) { + if (!hasAtLeastOneRowClickAction || !onRowContextMenuClick || !isInteractive) { return []; } return [ @@ -311,7 +319,13 @@ export const DatatableComponent = (props: DatatableRenderProps) => { }, }, ]; - }, [firstTableRef, onRowContextMenuClick, columnConfig, hasAtLeastOneRowClickAction]); + }, [ + firstTableRef, + onRowContextMenuClick, + columnConfig, + hasAtLeastOneRowClickAction, + isInteractive, + ]); const renderCellValue = useMemo( () => @@ -333,7 +347,7 @@ export const DatatableComponent = (props: DatatableRenderProps) => { [visibleColumns] ); - const sorting = useMemo( + const sorting = useMemo( () => createGridSortingConfig(sortBy, sortDirection as LensGridDirection, onEditAction), [onEditAction, sortBy, sortDirection] ); diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/toolbar.test.tsx b/x-pack/plugins/lens/public/datatable_visualization/components/toolbar.test.tsx index 35e5c81cb72c4d..6bc27808c7c0c3 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/toolbar.test.tsx +++ b/x-pack/plugins/lens/public/datatable_visualization/components/toolbar.test.tsx @@ -6,7 +6,7 @@ */ import React, { FormEvent } from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { DataTableToolbar } from './toolbar'; import { DatatableVisualizationState } from '../visualization'; import { FramePublicAPI, VisualizationToolbarProps } from '../../types'; diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/types.ts b/x-pack/plugins/lens/public/datatable_visualization/components/types.ts index e7be5b78545e80..c5d94549b687ee 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/types.ts +++ b/x-pack/plugins/lens/public/datatable_visualization/components/types.ts @@ -49,6 +49,7 @@ export type DatatableRenderProps = DatatableProps & { renderMode: RenderMode; paletteService: PaletteRegistry; uiSettings: IUiSettingsClient; + interactive: boolean; /** * A boolean for each table row, which is true if the row active diff --git a/x-pack/plugins/lens/public/datatable_visualization/expression.tsx b/x-pack/plugins/lens/public/datatable_visualization/expression.tsx index 2417e395792e0a..51b6f7b8332f5d 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/expression.tsx +++ b/x-pack/plugins/lens/public/datatable_visualization/expression.tsx @@ -41,7 +41,7 @@ export const getDatatableRenderer = (dependencies: { handlers: ILensInterpreterRenderHandlers ) => { const resolvedGetType = await dependencies.getType; - const { hasCompatibleActions } = handlers; + const { hasCompatibleActions, isInteractive } = handlers; // An entry for each table row, whether it has any actions attached to // ROW_CLICK_TRIGGER trigger. @@ -81,6 +81,7 @@ export const getDatatableRenderer = (dependencies: { paletteService={dependencies.paletteService} getType={resolvedGetType} rowHasRowClickTriggerActions={rowHasRowClickTriggerActions} + interactive={isInteractive()} uiSettings={dependencies.uiSettings} /> 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 6beb565be098c1..d52eb3c5780591 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl as mount } from '@kbn/test/jest'; +import { mountWithIntl as mount } from '@kbn/test-jest-helpers'; import { debouncedComponent } from './debounced_component'; import { act } from 'react-dom/test-utils'; diff --git a/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx b/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx index 17e18392e83e9f..5ae3cb571bdbb0 100644 --- a/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx +++ b/x-pack/plugins/lens/public/embeddable/embeddable.test.tsx @@ -318,6 +318,52 @@ describe('embeddable', () => { expect(spacesPluginStart.ui.components.getEmbeddableLegacyUrlConflict).toHaveBeenCalled(); }); + it('should not render if timeRange prop is not passed when a referenced data view is time based', async () => { + attributeService = attributeServiceMockFromSavedVis({ + ...savedVis, + references: [ + { type: 'index-pattern', id: '123', name: 'abc' }, + { type: 'index-pattern', id: '123', name: 'def' }, + { type: 'index-pattern', id: '456', name: 'ghi' }, + ], + }); + const embeddable = new Embeddable( + { + timefilter: dataPluginMock.createSetupContract().query.timefilter.timefilter, + attributeService, + expressionRenderer, + basePath, + inspector: inspectorPluginMock.createStartContract(), + indexPatternService: { + get: (id: string) => Promise.resolve({ id, isTimeBased: jest.fn(() => true) }), + } as unknown as IndexPatternsContract, + capabilities: { + canSaveDashboards: true, + canSaveVisualizations: true, + }, + getTrigger, + visualizationMap: {}, + injectFilterReferences: jest.fn(mockInjectFilterReferences), + theme: themeServiceMock.createStartContract(), + documentToExpression: () => + Promise.resolve({ + ast: { + type: 'expression', + chain: [ + { type: 'function', function: 'my', arguments: {} }, + { type: 'function', function: 'expression', arguments: {} }, + ], + }, + errors: undefined, + }), + }, + {} as LensEmbeddableInput + ); + await embeddable.initializeSavedVis({} as LensEmbeddableInput); + embeddable.render(mountpoint); + expect(expressionRenderer).toHaveBeenCalledTimes(0); + }); + it('should initialize output with deduped list of index patterns', async () => { attributeService = attributeServiceMockFromSavedVis({ ...savedVis, @@ -335,7 +381,7 @@ describe('embeddable', () => { basePath, inspector: inspectorPluginMock.createStartContract(), indexPatternService: { - get: (id: string) => Promise.resolve({ id }), + get: (id: string) => Promise.resolve({ id, isTimeBased: () => false }), } as unknown as IndexPatternsContract, capabilities: { canSaveDashboards: true, diff --git a/x-pack/plugins/lens/public/embeddable/embeddable.tsx b/x-pack/plugins/lens/public/embeddable/embeddable.tsx index c72b137d4ea53f..1400f9f9bae372 100644 --- a/x-pack/plugins/lens/public/embeddable/embeddable.tsx +++ b/x-pack/plugins/lens/public/embeddable/embeddable.tsx @@ -272,11 +272,13 @@ export class Embeddable } switch (this.savedVis.visualizationType) { case 'lnsXY': + case 'lnsHeatmap': return [VIS_EVENT_TO_TRIGGER.filter, VIS_EVENT_TO_TRIGGER.brush]; case 'lnsDatatable': return [VIS_EVENT_TO_TRIGGER.filter, VIS_EVENT_TO_TRIGGER.tableRowContextMenuClick]; case 'lnsPie': return [VIS_EVENT_TO_TRIGGER.filter]; + case 'lnsGauge': case 'lnsMetric': default: return []; @@ -310,6 +312,31 @@ export class Embeddable return ret?.length ? ret : undefined; } + private maybeAddTimeRangeError( + errors: ErrorMessage[] | undefined, + input: LensEmbeddableInput, + indexPatterns: IndexPattern[] + ) { + // if at least one indexPattern is time based, then the Lens embeddable requires the timeRange prop + if ( + input.timeRange == null && + indexPatterns.some((indexPattern) => indexPattern.isTimeBased()) + ) { + return [ + ...(errors || []), + { + shortMessage: i18n.translate('xpack.lens.embeddable.missingTimeRangeParam.shortMessage', { + defaultMessage: `Missing timeRange property`, + }), + longMessage: i18n.translate('xpack.lens.embeddable.missingTimeRangeParam.longMessage', { + defaultMessage: `The timeRange property is required for the given configuration`, + }), + }, + ]; + } + return errors; + } + async initializeSavedVis(input: LensEmbeddableInput) { const unwrapResult: LensUnwrapResult | false = await this.deps.attributeService .unwrapAttributes(input) @@ -336,15 +363,12 @@ export class Embeddable this.expression = expression; this.errors = this.maybeAddConflictError(errors, metaInfo?.sharingSavedObjectProps); - if (this.errors) { - this.logError('validation'); - } await this.initializeOutput(); this.isInitialized = true; } onContainerStateChanged(containerState: LensEmbeddableInput) { - if (this.handleContainerStateChanged(containerState)) this.reload(); + if (this.handleContainerStateChanged(containerState) || this.errors?.length) this.reload(); } handleContainerStateChanged(containerState: LensEmbeddableInput): boolean { @@ -590,6 +614,13 @@ export class Embeddable // the container to pick them up and use them to configure filter bar and // config dropdown correctly. const input = this.getInput(); + + this.errors = this.maybeAddTimeRangeError(this.errors, input, indexPatterns); + + if (this.errors) { + this.logError('validation'); + } + const title = input.hidePanelTitles ? '' : input.title || this.savedVis.title; const savedObjectId = (input as LensByReferenceInput).savedObjectId; this.updateOutput({ diff --git a/x-pack/plugins/lens/public/embeddable/embeddable_component.tsx b/x-pack/plugins/lens/public/embeddable/embeddable_component.tsx index 94473f2be36136..c4bbe3800ab71c 100644 --- a/x-pack/plugins/lens/public/embeddable/embeddable_component.tsx +++ b/x-pack/plugins/lens/public/embeddable/embeddable_component.tsx @@ -25,6 +25,8 @@ import type { IndexPatternPersistedState } from '../indexpattern_datasource/type import type { XYState } from '../xy_visualization/types'; import type { PieVisualizationState, MetricState } from '../../common/expressions'; import type { DatatableVisualizationState } from '../datatable_visualization/visualization'; +import type { HeatmapVisualizationState } from '../heatmap_visualization/types'; +import type { GaugeVisualizationState } from '../visualizations/gauge/constants'; type LensAttributes = Omit< Document, @@ -48,7 +50,9 @@ export type TypedLensByValueInput = Omit & { | LensAttributes<'lnsXY', XYState> | LensAttributes<'lnsPie', PieVisualizationState> | LensAttributes<'lnsDatatable', DatatableVisualizationState> - | LensAttributes<'lnsMetric', MetricState>; + | LensAttributes<'lnsMetric', MetricState> + | LensAttributes<'lnsHeatmap', HeatmapVisualizationState> + | LensAttributes<'lnsGauge', GaugeVisualizationState>; }; export type EmbeddableComponentProps = (TypedLensByValueInput | LensByReferenceInput) & { diff --git a/x-pack/plugins/lens/public/index.ts b/x-pack/plugins/lens/public/index.ts index 3e622d8ac93124..463687edd3c6cf 100644 --- a/x-pack/plugins/lens/public/index.ts +++ b/x-pack/plugins/lens/public/index.ts @@ -28,6 +28,8 @@ export type { } from '../common/expressions'; export type { ValueLabelConfig } from '../common/types'; export type { DatatableVisualizationState } from './datatable_visualization/visualization'; +export type { HeatmapVisualizationState } from './heatmap_visualization/types'; +export type { GaugeVisualizationState } from './visualizations/gauge/constants'; export type { IndexPatternPersistedState, PersistedIndexPatternLayer, @@ -56,6 +58,7 @@ export type { MathIndexPatternColumn, OverallSumIndexPatternColumn, FormulaPublicApi, + StaticValueIndexPatternColumn, } from './indexpattern_datasource/types'; export type { LensEmbeddableInput } from './embeddable'; 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 7fe115847b2b55..03dc83d0308381 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/datapanel.test.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/datapanel.test.tsx @@ -17,7 +17,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 '@kbn/test/jest'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; 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_editor.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_editor.tsx index 079580ce69896f..45bdfd2091a3b4 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_editor.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_editor.tsx @@ -638,7 +638,6 @@ export function DimensionEditor(props: DimensionEditorProps) { () => String( selectedColumn && - !selectedColumn.customLabel && operationDefinitionMap[selectedColumn.operationType].getDefaultLabel( selectedColumn, state.indexPatterns[state.layers[layerId].indexPatternId], @@ -767,6 +766,7 @@ export function DimensionEditor(props: DimensionEditorProps) { // re-render the input from scratch to obtain new "initial value" if the underlying default label changes key={defaultLabel} value={selectedColumn.label} + defaultValue={defaultLabel} onChange={(value) => { updateLayer({ columns: { 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 975e08e5ca1a94..d8121e4b726bea 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 @@ -21,7 +21,7 @@ import { IndexPatternDimensionEditorComponent, IndexPatternDimensionEditorProps, } from './dimension_panel'; -import { mountWithIntl as mount, shallowWithIntl as shallow } from '@kbn/test/jest'; +import { mountWithIntl as mount, shallowWithIntl as shallow } from '@kbn/test-jest-helpers'; import { IUiSettingsClient, SavedObjectsClientContract, HttpSetup, CoreSetup } from 'kibana/public'; import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { generateId } from '../../id_generator'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimensions_editor_helpers.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimensions_editor_helpers.tsx index 033ac9c7071517..cbe158372e5a2a 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimensions_editor_helpers.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimensions_editor_helpers.tsx @@ -33,11 +33,17 @@ export function isQuickFunction(operationType: string) { export const LabelInput = ({ value, onChange, + defaultValue, }: { value: string; onChange: (value: string) => void; + defaultValue?: string; }) => { - const { inputValue, handleInputChange, initialValue } = useDebouncedValue({ onChange, value }); + const { inputValue, handleInputChange, initialValue } = useDebouncedValue({ + onChange, + value, + defaultValue, + }); return ( diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.test.tsx index a0e5fca114c378..0fb7f35beb02b2 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.test.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.test.tsx @@ -840,7 +840,7 @@ describe('formula', () => { ...columnParams, } as FormulaIndexPatternColumn, }, - columnOrder: [], + columnOrder: ['col1'], indexPatternId: '', }; } @@ -1388,6 +1388,45 @@ invalid: " } }); + it('returns an error if the formula is fully static and there is at least one bucket dimension', () => { + const formulaLayer = getNewLayerWithFormula('5 + 3 * 7'); + expect( + formulaOperation.getErrorMessage!( + { + ...formulaLayer, + columns: { + ...formulaLayer.columns, + col0: { + dataType: 'date', + isBucketed: true, + label: '', + operationType: 'date_histogram', + references: [], + sourceField: 'ts', + }, + }, + columnOrder: ['col0', 'col1'], + }, + 'col1', + indexPattern, + operationDefinitionMap + ) + ).toEqual([ + 'A layer with only static values will not show results, use at least one dynamic metric', + ]); + }); + + it('returns no error if the formula is fully static and there is no bucket dimension', () => { + expect( + formulaOperation.getErrorMessage!( + getNewLayerWithFormula('5 + 3 * 7'), + 'col1', + indexPattern, + operationDefinitionMap + ) + ).toEqual(undefined); + }); + it('returns no error if a math operation is passed to fullReference operations', () => { const formulas = [ 'derivative(7+1)', diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.tsx index ce0d03a232e28b..9bbd1588d29b6a 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/formula.tsx @@ -86,6 +86,25 @@ export const formulaOperation: OperationDefinition marker); + const hasBuckets = layer.columnOrder.some((colId) => layer.columns[colId].isBucketed); + const hasOtherMetrics = layer.columnOrder.some((colId) => { + const col = layer.columns[colId]; + return ( + !col.isBucketed && + !col.isStaticValue && + col.operationType !== 'math' && + col.operationType !== 'formula' + ); + }); + + if (hasBuckets && !hasOtherMetrics) { + innerErrors.push({ + message: i18n.translate('xpack.lens.indexPattern.noRealMetricError', { + defaultMessage: + 'A layer with only static values will not show results, use at least one dynamic metric', + }), + }); + } return innerErrors.length ? innerErrors.map(({ message }) => message) : undefined; }, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/advanced_editor.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/advanced_editor.tsx index 84bcb48f95234d..8a35a093f4ac04 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/advanced_editor.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/advanced_editor.tsx @@ -134,6 +134,7 @@ export const RangePopover = ({ compressed placeholder={FROM_PLACEHOLDER} isInvalid={!isValidRange(tempRange)} + step={1} /> @@ -164,6 +165,7 @@ export const RangePopover = ({ onSubmit(); } }} + step={1} /> diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/static_value.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/static_value.tsx index 0adaf8ea006402..d41ddaf26fb3f0 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/static_value.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/static_value.tsx @@ -215,6 +215,7 @@ export const staticValueOperation: OperationDefinition< compressed value={inputValue ?? ''} onChange={onChangeHandler} + step="any" /> ); diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/index.ts b/x-pack/plugins/lens/public/indexpattern_datasource/operations/index.ts index 4474effc8c8c86..05454c4e0751c4 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/index.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/index.ts @@ -40,4 +40,5 @@ export type { OverallAverageIndexPatternColumn, FormulaIndexPatternColumn, MathIndexPatternColumn, + StaticValueIndexPatternColumn, } from './definitions'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/to_expression.ts b/x-pack/plugins/lens/public/indexpattern_datasource/to_expression.ts index 432c932b85da82..0d8b57a5502ad5 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/to_expression.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/to_expression.ts @@ -29,6 +29,15 @@ import { isColumnFormatted, isColumnOfType } from './operations/definitions/help type OriginalColumn = { id: string } & GenericIndexPatternColumn; +declare global { + interface Window { + /** + * Debug setting to make requests complete slower than normal. data.search.aggs.shardDelay.enabled has to be set via settings for this to work + */ + ELASTIC_LENS_DELAY_SECONDS?: number; + } +} + function getExpressionForLayer( layer: IndexPatternLayer, indexPattern: IndexPattern, @@ -139,8 +148,27 @@ function getExpressionForLayer( } }); + if (window.ELASTIC_LENS_DELAY_SECONDS) { + aggs.push( + buildExpression({ + type: 'expression', + chain: [ + buildExpressionFunction('aggShardDelay', { + id: 'the-delay', + enabled: true, + schema: 'metric', + delay: `${window.ELASTIC_LENS_DELAY_SECONDS}s`, + }).toAst(), + ], + }) + ); + } + const idMap = esAggEntries.reduce((currentIdMap, [colId, column], index) => { - const esAggsId = `col-${index}-${index}`; + const esAggsId = window.ELASTIC_LENS_DELAY_SECONDS + ? `col-${index + (column.isBucketed ? 0 : 1)}-${index}` + : `col-${index}-${index}`; + return { ...currentIdMap, [esAggsId]: { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/types.ts b/x-pack/plugins/lens/public/indexpattern_datasource/types.ts index 08786b181f3e79..5bb4d58ed20fa0 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/types.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/types.ts @@ -36,6 +36,7 @@ export type { FormulaIndexPatternColumn, MathIndexPatternColumn, OverallSumIndexPatternColumn, + StaticValueIndexPatternColumn, } from './operations'; export type { FormulaPublicApi } from './operations/definitions/formula/formula_public_api'; diff --git a/x-pack/plugins/lens/public/metric_visualization/dimension_editor.test.tsx b/x-pack/plugins/lens/public/metric_visualization/dimension_editor.test.tsx index ef0687a2cd519f..b296313086d7fd 100644 --- a/x-pack/plugins/lens/public/metric_visualization/dimension_editor.test.tsx +++ b/x-pack/plugins/lens/public/metric_visualization/dimension_editor.test.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { EuiButtonGroup } from '@elastic/eui'; import { FramePublicAPI, VisualizationDimensionEditorProps } from '../types'; import { createMockDatasource, createMockFramePublicAPI } from '../mocks'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { MetricDimensionEditor } from './dimension_editor'; import { chartPluginMock } from 'src/plugins/charts/public/mocks'; import { ColorMode, PaletteOutput, PaletteRegistry } from 'src/plugins/charts/public'; diff --git a/x-pack/plugins/lens/public/mocks/store_mocks.tsx b/x-pack/plugins/lens/public/mocks/store_mocks.tsx index 1b1d83ef2892da..3365657fea34e8 100644 --- a/x-pack/plugins/lens/public/mocks/store_mocks.tsx +++ b/x-pack/plugins/lens/public/mocks/store_mocks.tsx @@ -9,7 +9,7 @@ import React from 'react'; // eslint-disable-next-line import/no-extraneous-dependencies import { ReactWrapper } from 'enzyme'; // eslint-disable-next-line import/no-extraneous-dependencies -import { mountWithIntl as mount } from '@kbn/test/jest'; +import { mountWithIntl as mount } from '@kbn/test-jest-helpers'; import { Provider } from 'react-redux'; import { act } from 'react-dom/test-utils'; import { PreloadedState } from '@reduxjs/toolkit'; diff --git a/x-pack/plugins/lens/public/pie_visualization/get_legend_action.test.tsx b/x-pack/plugins/lens/public/pie_visualization/get_legend_action.test.tsx index 91886c6cf19d60..df0648aa40d741 100644 --- a/x-pack/plugins/lens/public/pie_visualization/get_legend_action.test.tsx +++ b/x-pack/plugins/lens/public/pie_visualization/get_legend_action.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { LegendActionProps, SeriesIdentifier } from '@elastic/charts'; import { EuiPopover } from '@elastic/eui'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ComponentType, ReactWrapper } from 'enzyme'; import type { Datatable } from 'src/plugins/expressions/public'; import { getLegendAction } from './get_legend_action'; diff --git a/x-pack/plugins/lens/public/shared_components/axis_title_settings.test.tsx b/x-pack/plugins/lens/public/shared_components/axis_title_settings.test.tsx index 4cb7f6d1314b6a..433a0f821f2731 100644 --- a/x-pack/plugins/lens/public/shared_components/axis_title_settings.test.tsx +++ b/x-pack/plugins/lens/public/shared_components/axis_title_settings.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { shallowWithIntl as shallow } from '@kbn/test/jest'; +import { shallowWithIntl as shallow } from '@kbn/test-jest-helpers'; import { AxisTitleSettings, AxisTitleSettingsProps } from './axis_title_settings'; describe('Axes Title settings', () => { diff --git a/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges.test.tsx b/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges.test.tsx index 872bff882fbff1..aafcc3fce8dde5 100644 --- a/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges.test.tsx +++ b/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; import { act } from 'react-dom/test-utils'; import { ColorRanges, ColorRangesProps } from './color_ranges'; @@ -14,18 +14,18 @@ import { PaletteRegistry } from 'src/plugins/charts/public'; import { ColorRangesContext } from './color_ranges_context'; const extraActionSelectors = { - addColorRange: '[data-test-subj^="lnsPalettePanel_dynamicColoring_addColorRange"]', + addColor: '[data-test-subj^="lnsPalettePanel_dynamicColoring_addColor"]', reverseColors: '[data-test-subj^="lnsPalettePanel_dynamicColoring_reverseColors"]', - distributeEqually: '[data-test-subj="lnsPalettePanel_dynamicColoring_distributeEqually"]', + distributeValues: '[data-test-subj="lnsPalettePanel_dynamicColoring_distributeValues"]', }; const pageObjects = { getAddColorRangeButton: (component: ReactWrapper) => - component.find(extraActionSelectors.addColorRange).first(), + component.find(extraActionSelectors.addColor).first(), reverseColors: (component: ReactWrapper) => component.find(extraActionSelectors.reverseColors).first(), - distributeEqually: (component: ReactWrapper) => - component.find(extraActionSelectors.distributeEqually).first(), + distributeValues: (component: ReactWrapper) => + component.find(extraActionSelectors.distributeValues).first(), }; function renderColorRanges(props: ColorRangesProps) { @@ -142,7 +142,7 @@ describe('Color Ranges', () => { }); }); - it('should distribute equally ranges when use click on "Distribute equally" button', () => { + it('should distribute equally ranges when use click on "Distribute values" button', () => { props.colorRanges = [ { color: '#aaa', start: 0, end: 2 }, { color: '#bbb', start: 3, end: 4 }, @@ -153,7 +153,7 @@ describe('Color Ranges', () => { const component = renderColorRanges(props); act(() => { - pageObjects.distributeEqually(component).simulate('click'); + pageObjects.distributeValues(component).simulate('click'); }); component.update(); diff --git a/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges.tsx b/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges.tsx index 76cab5ba743d3f..c22ac8f1d860bd 100644 --- a/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges.tsx +++ b/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges.tsx @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import React, { useState, useEffect, Dispatch, useContext } from 'react'; +import React, { useState, useEffect, Dispatch } from 'react'; import { EuiFlexGroup, EuiTextColor, EuiFlexItem } from '@elastic/eui'; @@ -22,8 +22,6 @@ import type { PaletteConfigurationActions } from '../types'; import { defaultPaletteParams } from '../constants'; -import { ColorRangesContext } from './color_ranges_context'; - export interface ColorRangesProps { colorRanges: ColorRange[]; paletteConfiguration: CustomPaletteParamsConfig | undefined; @@ -37,7 +35,6 @@ export function ColorRanges({ showExtraActions = true, dispatch, }: ColorRangesProps) { - const { dataBounds } = useContext(ColorRangesContext); const [colorRangesValidity, setColorRangesValidity] = useState< Record >({}); @@ -48,8 +45,8 @@ export function ColorRanges({ const rangeType = paletteConfiguration?.rangeType ?? defaultPaletteParams.rangeType; useEffect(() => { - setColorRangesValidity(validateColorRanges(colorRanges, dataBounds, rangeType)); - }, [colorRanges, rangeType, dataBounds]); + setColorRangesValidity(validateColorRanges(colorRanges)); + }, [colorRanges]); return ( { + const onDistributeValues = useCallback(() => { dispatch({ type: 'distributeEqually', payload: { dataBounds, palettes } }); }, [dataBounds, dispatch, palettes]); + const oneColorRangeWarn = i18n.translate( + 'xpack.lens.dynamicColoring.customPalette.oneColorRange', + { + defaultMessage: `Requires more than one color`, + } + ); + return ( @@ -59,13 +66,13 @@ export function ColorRangesExtraActions({ delay="regular" > - - - + + + + - - - + + + + ); diff --git a/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges_item.tsx b/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges_item.tsx index a6d66a9177ad53..604ecdb363522f 100644 --- a/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges_item.tsx +++ b/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges_item.tsx @@ -17,7 +17,6 @@ import { EuiIcon, EuiColorPickerSwatch, EuiButtonIcon, - EuiToolTip, EuiFieldNumberProps, } from '@elastic/eui'; @@ -39,7 +38,6 @@ import { checkIsMaxContinuity, checkIsMinContinuity, } from '../../../../../../../src/plugins/charts/common'; -import { getOutsideDataBoundsWarningMessage } from './color_ranges_validation'; export interface ColorRangesItemProps { colorRange: ColorRange; @@ -81,25 +79,13 @@ const getActionButton = (mode: ColorRangeItemMode) => { return mode === 'edit' ? ColorRangeAutoDetectButton : ColorRangeEditButton; }; -const getAppend = ( - rangeType: CustomPaletteParams['rangeType'], - mode: ColorRangeItemMode, - validation?: ColorRangeValidation -) => { +const getAppend = (rangeType: CustomPaletteParams['rangeType'], mode: ColorRangeItemMode) => { const items: EuiFieldNumberProps['append'] = []; - if (rangeType === 'percent') { + if (rangeType === 'percent' && mode !== 'auto') { items.push('%'); } - if (mode !== 'auto' && validation?.warnings.length) { - items.push( - - - - ); - } - return items; }; @@ -127,8 +113,12 @@ export function ColorRangeItem({ (e: FocusEvent) => { const prevStartValue = colorRanges[index - 1]?.start ?? Number.NEGATIVE_INFINITY; const nextStartValue = colorRanges[index + 1]?.start ?? Number.POSITIVE_INFINITY; + const lastEndValue = colorRanges[colorRanges.length - 1]?.end ?? Number.POSITIVE_INFINITY; - const shouldSort = colorRange.start > nextStartValue || prevStartValue > colorRange.start; + const shouldSort = + colorRange.start > nextStartValue || + prevStartValue > colorRange.start || + (!isLast && colorRange.start > lastEndValue); const isFocusStillInContent = (e.currentTarget as Node)?.contains(e.relatedTarget as Node) || popoverInFocus; @@ -136,7 +126,7 @@ export function ColorRangeItem({ dispatch({ type: 'sortColorRanges', payload: { dataBounds, palettes } }); } }, - [colorRange.start, colorRanges, dispatch, index, popoverInFocus, dataBounds, palettes] + [colorRange.start, colorRanges, dispatch, index, popoverInFocus, dataBounds, palettes, isLast] ); const onValueChange = useCallback( @@ -190,6 +180,7 @@ export function ColorRangeItem({ } secondaryInputDisplay="top" color={colorRange.color} + showAlpha={true} onFocus={() => setPopoverInFocus(true)} onBlur={() => { setPopoverInFocus(false); @@ -205,11 +196,13 @@ export function ColorRangeItem({ compressed fullWidth={true} isInvalid={!isValid} - value={mode !== 'auto' ? localValue : ''} + value={ + mode !== 'auto' && localValue !== undefined && isFinite(localValue) ? localValue : '' + } disabled={isDisabled} onChange={onValueChange} placeholder={mode === 'auto' ? getPlaceholderForAutoMode(isLast) : ''} - append={getAppend(rangeType, mode, validation)} + append={getAppend(rangeType, mode)} onBlur={onLeaveFocus} data-test-subj={`lnsPalettePanel_dynamicColoring_range_value_${index}`} prepend={{isLast ? '\u2264' : '\u2265'}} @@ -219,6 +212,7 @@ export function ColorRangeItem({ index: index + 1, }, })} + step="any" /> {ActionButton ? ( diff --git a/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges_item_buttons.tsx b/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges_item_buttons.tsx index 3f289395f7b7d7..8e29a4fa2c6bfb 100644 --- a/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges_item_buttons.tsx +++ b/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges_item_buttons.tsx @@ -82,26 +82,28 @@ export function ColorRangeEditButton({ }); }, [isLast, dispatch, continuity, dataBounds, palettes]); - const title = i18n.translate('xpack.lens.dynamicColoring.customPalette.editButtonAriaLabel', { - defaultMessage: 'Edit', - }); + let tooltipContent = isLast + ? i18n.translate('xpack.lens.dynamicColoring.customPalette.setCustomMinValue', { + defaultMessage: `Set custom maximum value`, + }) + : i18n.translate('xpack.lens.dynamicColoring.customPalette.setCustomMaxValue', { + defaultMessage: `Set custom minimum value`, + }); + + if (disableSwitchingContinuity) { + tooltipContent = i18n.translate( + 'xpack.lens.dynamicColoring.customPalette.disallowedEditMinMaxValues', + { + defaultMessage: `You cannot set custom value for current configuration`, + } + ); + } return ( - + + + + ); } diff --git a/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges_validation.test.ts b/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges_validation.test.ts index a645d637bc6a58..d32936f89ebfa5 100644 --- a/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges_validation.test.ts +++ b/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges_validation.test.ts @@ -27,99 +27,20 @@ describe('Color ranges validation', () => { color: '#aaa', }, ]; - const validation = validateColorRanges(colorRanges, { min: 0, max: 100 }, 'number'); + const validation = validateColorRanges(colorRanges); expect(validation['0']).toEqual({ errors: [], - warnings: [], isValid: true, }); expect(validation['1']).toEqual({ errors: ['invalidColor'], - warnings: [], isValid: false, }); expect(validation.last).toEqual({ errors: ['greaterThanMaxValue'], - warnings: [], isValid: false, }); }); - - it('should return correct warnings for color ranges', () => { - const colorRanges = [ - { - start: 0, - end: 10, - color: '#aaa', - }, - { - start: 10, - end: 20, - color: '#bbb', - }, - { - start: 20, - end: 35, - color: '#ccc', - }, - ]; - const validation = validateColorRanges(colorRanges, { min: 5, max: 30 }, 'number'); - expect(validation['0']).toEqual({ - errors: [], - warnings: ['lowerThanDataBounds'], - isValid: true, - }); - expect(validation['1']).toEqual({ - errors: [], - warnings: [], - isValid: true, - }); - expect(validation.last).toEqual({ - errors: [], - warnings: ['greaterThanDataBounds'], - isValid: true, - }); - }); - - it('should not return warnings for color ranges in number mode if we get fallback as data bounds', () => { - const colorRanges = [ - { - start: 0, - end: 10, - color: '#aaa', - }, - { - start: 10, - end: 20, - color: '#bbb', - }, - { - start: 20, - end: 35, - color: '#ccc', - }, - ]; - const validation = validateColorRanges( - colorRanges, - { min: 5, max: 30, fallback: true }, - 'number' - ); - expect(validation['0']).toEqual({ - errors: [], - warnings: [], - isValid: true, - }); - expect(validation['1']).toEqual({ - errors: [], - warnings: [], - isValid: true, - }); - expect(validation.last).toEqual({ - errors: [], - warnings: [], - isValid: true, - }); - }); }); describe('isAllColorRangesValid', () => { @@ -141,10 +62,10 @@ describe('Color ranges validation', () => { color: '#ccc', }, ]; - let isValid = isAllColorRangesValid(colorRanges, { min: 5, max: 40 }, 'number'); + let isValid = isAllColorRangesValid(colorRanges); expect(isValid).toBeFalsy(); colorRanges[colorRanges.length - 1].end = 30; - isValid = isAllColorRangesValid(colorRanges, { min: 5, max: 40 }, 'number'); + isValid = isAllColorRangesValid(colorRanges); expect(isValid).toBeTruthy(); }); }); diff --git a/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges_validation.tsx b/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges_validation.tsx index 30cfe380663780..d8e5083f5e9719 100644 --- a/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges_validation.tsx +++ b/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/color_ranges_validation.tsx @@ -5,23 +5,16 @@ * 2.0. */ import { i18n } from '@kbn/i18n'; -import { getDataMinMax, isValidColor } from '../utils'; +import { isValidColor } from '../utils'; import type { ColorRange, ColorRangeAccessor } from './types'; -import type { DataBounds } from '../types'; - -import { CustomPaletteParams } from '../../../../common'; /** @internal **/ type ColorRangeValidationErrors = 'invalidColor' | 'invalidValue' | 'greaterThanMaxValue'; -/** @internal **/ -type ColorRangeValidationWarnings = 'lowerThanDataBounds' | 'greaterThanDataBounds'; - /** @internal **/ export interface ColorRangeValidation { errors: ColorRangeValidationErrors[]; - warnings: ColorRangeValidationWarnings[]; isValid: boolean; } @@ -44,7 +37,7 @@ export const getErrorMessages = (colorRangesValidity: Record { - for (const warning of warnings) { - switch (warning) { - case 'lowerThanDataBounds': - return i18n.translate('xpack.lens.dynamicColoring.customPalette.lowerThanDataBounds', { - defaultMessage: 'This value is outside the minimum data bound', - }); - case 'greaterThanDataBounds': - return i18n.translate('xpack.lens.dynamicColoring.customPalette.greaterThanDataBounds', { - defaultMessage: 'This value is outside the maximum data bound', - }); - } - } -}; - -const checkForComplianceWithDataBounds = (value: number, minMax?: [number, number]) => { - const warnings: ColorRangeValidationWarnings[] = []; - if (minMax) { - const [min, max] = minMax; - - if (value < min) { - warnings.push('lowerThanDataBounds'); - } - if (value > max) { - warnings.push('greaterThanDataBounds'); - } - } - - return warnings; -}; - /** @internal **/ -export const validateColorRange = ( - colorRange: ColorRange, - accessor: ColorRangeAccessor, - minMax?: [number, number] -) => { +export const validateColorRange = (colorRange: ColorRange, accessor: ColorRangeAccessor) => { const errors: ColorRangeValidationErrors[] = []; - let warnings: ColorRangeValidationWarnings[] = []; if (Number.isNaN(colorRange[accessor])) { errors.push('invalidValue'); @@ -102,53 +59,33 @@ export const validateColorRange = ( if (colorRange.start > colorRange.end) { errors.push('greaterThanMaxValue'); } - warnings = [...warnings, ...checkForComplianceWithDataBounds(colorRange.end, minMax)]; - } else { - if (!isValidColor(colorRange.color)) { - errors.push('invalidColor'); - } - warnings = [...warnings, ...checkForComplianceWithDataBounds(colorRange.start, minMax)]; + } else if (!isValidColor(colorRange.color)) { + errors.push('invalidColor'); } return { isValid: !errors.length, errors, - warnings, } as ColorRangeValidation; }; export const validateColorRanges = ( - colorRanges: ColorRange[], - dataBounds: DataBounds, - rangeType: CustomPaletteParams['rangeType'] + colorRanges: ColorRange[] ): Record => { - let minMax: [number, number] | undefined; - - if ((dataBounds.fallback && rangeType === 'percent') || !dataBounds.fallback) { - const { min, max } = getDataMinMax(rangeType, dataBounds); - minMax = [min, max]; - } - const validations = colorRanges.reduce>( (acc, item, index) => ({ ...acc, - [index]: validateColorRange(item, 'start', minMax), + [index]: validateColorRange(item, 'start'), }), {} ); return { ...validations, - last: validateColorRange(colorRanges[colorRanges.length - 1], 'end', minMax), + last: validateColorRange(colorRanges[colorRanges.length - 1], 'end'), }; }; -export const isAllColorRangesValid = ( - colorRanges: ColorRange[], - dataBounds: DataBounds, - rangeType: CustomPaletteParams['rangeType'] -) => { - return Object.values(validateColorRanges(colorRanges, dataBounds, rangeType)).every( - (colorRange) => colorRange.isValid - ); +export const isAllColorRangesValid = (colorRanges: ColorRange[]) => { + return Object.values(validateColorRanges(colorRanges)).every((colorRange) => colorRange.isValid); }; diff --git a/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/utils/color_ranges_crud.test.ts b/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/utils/color_ranges_crud.test.ts index 837c66eeb1e5e6..abfd64c6a84a9d 100644 --- a/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/utils/color_ranges_crud.test.ts +++ b/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/utils/color_ranges_crud.test.ts @@ -23,16 +23,7 @@ describe('addColorRange', () => { ]; }); - it('should add new color range with the corresponding interval', () => { - expect(addColorRange(colorRanges, 'number', { min: 0, max: 81 })).toEqual([ - { color: '#aaa', start: 20, end: 40 }, - { color: '#bbb', start: 40, end: 60 }, - { color: '#ccc', start: 60, end: 80 }, - { color: '#ccc', start: 80, end: 81 }, - ]); - }); - - it('should add new color range with the interval equal 1 if new range out of max bound', () => { + it('should add new color range with the corresponding interva', () => { colorRanges[colorRanges.length - 1].end = 80; expect(addColorRange(colorRanges, 'number', { min: 0, max: 80 })).toEqual([ { color: '#aaa', start: 20, end: 40 }, diff --git a/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/utils/color_ranges_crud.ts b/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/utils/color_ranges_crud.ts index 6a2e92d284f01a..b391c2bfac28e0 100644 --- a/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/utils/color_ranges_crud.ts +++ b/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/utils/color_ranges_crud.ts @@ -5,7 +5,6 @@ * 2.0. */ import { getDataMinMax, roundValue } from '../../utils'; -import { calculateMaxStep } from './utils'; import type { ColorRange, ColorRangeAccessor } from '../types'; import type { DataBounds } from '../../types'; @@ -43,12 +42,7 @@ export const addColorRange = ( const { max: dataMax } = getDataMinMax(rangeType, dataBounds); const max = Math.max(dataMax, lastEnd); - const step = calculateMaxStep( - newColorRanges.map((item) => item.start), - max - ); - - let insertEnd = roundValue(Math.min(lastStart + step, max)); + let insertEnd = roundValue(Math.min(lastStart + 1, max)); if (insertEnd === Number.NEGATIVE_INFINITY) { insertEnd = 1; diff --git a/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/utils/utils.test.ts b/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/utils/utils.test.ts index daebb02e44e462..d0b650eba01400 100644 --- a/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/utils/utils.test.ts +++ b/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/utils/utils.test.ts @@ -9,7 +9,7 @@ import { sortColorRanges, calculateMaxStep, toColorStops, getValueForContinuity describe('utils', () => { it('sortColorRanges', () => { - const colorRanges = [ + let colorRanges = [ { color: '#aaa', start: 55, end: 40 }, { color: '#bbb', start: 40, end: 60 }, { color: '#ccc', start: 60, end: 80 }, @@ -19,6 +19,31 @@ describe('utils', () => { { color: '#aaa', start: 55, end: 60 }, { color: '#ccc', start: 60, end: 80 }, ]); + + colorRanges = [ + { color: '#aaa', start: 55, end: 90 }, + { color: '#bbb', start: 90, end: 60 }, + { color: '#ccc', start: 60, end: 80 }, + ]; + expect(sortColorRanges(colorRanges)).toEqual([ + { color: '#aaa', start: 55, end: 60 }, + { color: '#ccc', start: 60, end: 80 }, + { color: '#bbb', start: 80, end: 90 }, + ]); + + colorRanges = [ + { color: '#aaa', start: 55, end: 90 }, + { color: '#bbb', start: 90, end: 60 }, + { color: '#ccc', start: 60, end: Infinity }, + ]; + expect(sortColorRanges(colorRanges)).toEqual([ + { color: '#aaa', start: 55, end: 60 }, + { color: '#ccc', start: 60, end: 90 }, + { color: '#bbb', start: 90, end: Infinity }, + ]); + + colorRanges = [{ color: '#aaa', start: 90, end: 55 }]; + expect(sortColorRanges(colorRanges)).toEqual([{ color: '#aaa', start: 55, end: 90 }]); }); it('calculateMaxStep', () => { diff --git a/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/utils/utils.ts b/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/utils/utils.ts index 300df9b3b317b2..4c8dd17c77c618 100644 --- a/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/utils/utils.ts +++ b/x-pack/plugins/lens/public/shared_components/coloring/color_ranges/utils/utils.ts @@ -25,15 +25,28 @@ export const isLastItem = (accessor: ColorRangeAccessor) => accessor === 'end'; * @internal */ export const sortColorRanges = (colorRanges: ColorRange[]) => { - const maxValue = colorRanges[colorRanges.length - 1].end; + const lastRange = colorRanges[colorRanges.length - 1]; - return [...colorRanges] + // we should add last end as new start because we should include it on sorting + return [...colorRanges, { start: lastRange.end, color: lastRange.color, end: undefined }] .sort(({ start: startA }, { start: startB }) => Number(startA) - Number(startB)) - .map((newColorRange, i, array) => ({ - color: newColorRange.color, - start: newColorRange.start, - end: i !== array.length - 1 ? array[i + 1].start : maxValue, - })); + .reduce((sortedColorRange, newColorRange, i, array) => { + // we should pick correct color for the last range. + // If after sorting we don't change last value we should just take color in array order + // In another case we should get the next one. + let color = newColorRange.color; + if (i === array.length - 2 && array[i + 1].start !== lastRange.end) { + color = array[i + 1].color; + } + if (i !== array.length - 1) { + sortedColorRange.push({ + color, + start: newColorRange.start, + end: array[i + 1].start, + }); + } + return sortedColorRange; + }, [] as ColorRange[]); }; /** @@ -91,16 +104,17 @@ export const getValueForContinuity = ( if (checkIsMaxContinuity(continuity)) { value = Number.POSITIVE_INFINITY; } else { - value = + value = roundValue( colorRanges[colorRanges.length - 1].start > max ? colorRanges[colorRanges.length - 1].start + 1 - : max; + : max + ); } } else { if (checkIsMinContinuity(continuity)) { value = Number.NEGATIVE_INFINITY; } else { - value = colorRanges[0].end < min ? colorRanges[0].end - 1 : min; + value = roundValue(colorRanges[0].end < min ? colorRanges[0].end - 1 : min); } } diff --git a/x-pack/plugins/lens/public/shared_components/coloring/palette_configuration.test.tsx b/x-pack/plugins/lens/public/shared_components/coloring/palette_configuration.test.tsx index a97f3d3f041122..cb7ce91b84aeb5 100644 --- a/x-pack/plugins/lens/public/shared_components/coloring/palette_configuration.test.tsx +++ b/x-pack/plugins/lens/public/shared_components/coloring/palette_configuration.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { EuiButtonGroup, EuiColorPalettePickerPaletteProps } from '@elastic/eui'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { chartPluginMock } from 'src/plugins/charts/public/mocks'; import type { PaletteOutput, PaletteRegistry } from 'src/plugins/charts/public'; import { ReactWrapper } from 'enzyme'; diff --git a/x-pack/plugins/lens/public/shared_components/coloring/palette_configuration.tsx b/x-pack/plugins/lens/public/shared_components/coloring/palette_configuration.tsx index 104b8e4319e40a..46aede7432b04b 100644 --- a/x-pack/plugins/lens/public/shared_components/coloring/palette_configuration.tsx +++ b/x-pack/plugins/lens/public/shared_components/coloring/palette_configuration.tsx @@ -17,7 +17,6 @@ import './palette_configuration.scss'; import type { CustomPaletteParams, RequiredPaletteParamTypes } from '../../../common'; import { toColorRanges, getFallbackDataBounds } from './utils'; -import { defaultPaletteParams } from './constants'; import { ColorRanges, ColorRangesContext } from './color_ranges'; import { isAllColorRangesValid } from './color_ranges/color_ranges_validation'; import { paletteConfigurationReducer } from './palette_configuration_reducer'; @@ -52,12 +51,10 @@ export function CustomizablePalette({ useDebounce( () => { - const rangeType = - localState.activePalette?.params?.rangeType ?? defaultPaletteParams.rangeType; if ( (localState.activePalette !== activePalette || colorRangesToShow !== localState.colorRanges) && - isAllColorRangesValid(localState.colorRanges, dataBounds, rangeType) + isAllColorRangesValid(localState.colorRanges) ) { setPalette(localState.activePalette); } diff --git a/x-pack/plugins/lens/public/shared_components/coloring/utils.ts b/x-pack/plugins/lens/public/shared_components/coloring/utils.ts index 16cb843f3dfb4a..6a90119e4ca71f 100644 --- a/x-pack/plugins/lens/public/shared_components/coloring/utils.ts +++ b/x-pack/plugins/lens/public/shared_components/coloring/utils.ts @@ -248,6 +248,9 @@ export function calculateStop( oldInterval: number, newInterval: number ) { + if (oldInterval === 0) { + return newInterval + newMin; + } return roundValue(newMin + ((stopValue - oldMin) * newInterval) / oldInterval); } @@ -411,7 +414,8 @@ export function roundValue(value: number, fractionDigits: number = 2) { export function getStepValue(colorStops: ColorStop[], newColorStops: ColorStop[], max: number) { const length = newColorStops.length; // workout the steps from the last 2 items - const dataStep = newColorStops[length - 1].stop - newColorStops[length - 2].stop || 1; + const dataStep = + length > 1 ? newColorStops[length - 1].stop - newColorStops[length - 2].stop || 1 : 1; let step = Number(dataStep.toFixed(2)); if (max < colorStops[length - 1].stop + step) { const diffToMax = max - colorStops[length - 1].stop; diff --git a/x-pack/plugins/lens/public/shared_components/debounced_value.ts b/x-pack/plugins/lens/public/shared_components/debounced_value.ts index 412199a371f1f7..77848e678b1352 100644 --- a/x-pack/plugins/lens/public/shared_components/debounced_value.ts +++ b/x-pack/plugins/lens/public/shared_components/debounced_value.ts @@ -21,9 +21,11 @@ export const useDebouncedValue = ( { onChange, value, + defaultValue, }: { onChange: (val: T) => void; value: T; + defaultValue?: T; }, { allowFalsyValue }: { allowFalsyValue?: boolean } = {} ) => { @@ -32,7 +34,7 @@ export const useDebouncedValue = ( const shouldUpdateWithFalsyValue = Boolean(allowFalsyValue); // Save the initial value - const initialValue = useRef(value); + const initialValue = useRef(defaultValue ?? value); const flushChangesTimeout = useRef(); diff --git a/x-pack/plugins/lens/public/shared_components/legend_location_settings.test.tsx b/x-pack/plugins/lens/public/shared_components/legend_location_settings.test.tsx index 0c494f4d0090d0..49a53c1abf66f8 100644 --- a/x-pack/plugins/lens/public/shared_components/legend_location_settings.test.tsx +++ b/x-pack/plugins/lens/public/shared_components/legend_location_settings.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { Position } from '@elastic/charts'; -import { shallowWithIntl as shallow, mountWithIntl as mount } from '@kbn/test/jest'; +import { shallowWithIntl as shallow, mountWithIntl as mount } from '@kbn/test-jest-helpers'; import { LegendLocationSettings, LegendLocationSettingsProps } from './legend_location_settings'; describe('Legend Location Settings', () => { diff --git a/x-pack/plugins/lens/public/shared_components/legend_location_settings.tsx b/x-pack/plugins/lens/public/shared_components/legend_location_settings.tsx index 4265dee2251b5e..6791d5586d327d 100644 --- a/x-pack/plugins/lens/public/shared_components/legend_location_settings.tsx +++ b/x-pack/plugins/lens/public/shared_components/legend_location_settings.tsx @@ -170,6 +170,7 @@ const FloatingColumnsInput = ({ onChange={(e) => { handleInputChange(Number(e.target.value)); }} + step={1} /> ); }; 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 95739c294b3206..0072a6cd2dcce4 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 { shallowWithIntl as shallow } from '@kbn/test/jest'; +import { shallowWithIntl as shallow } from '@kbn/test-jest-helpers'; import { LegendSettingsPopover, LegendSettingsPopoverProps, diff --git a/x-pack/plugins/lens/public/shared_components/legend_settings_popover.tsx b/x-pack/plugins/lens/public/shared_components/legend_settings_popover.tsx index ba5e93c3f89522..875fd2ab263136 100644 --- a/x-pack/plugins/lens/public/shared_components/legend_settings_popover.tsx +++ b/x-pack/plugins/lens/public/shared_components/legend_settings_popover.tsx @@ -140,6 +140,7 @@ export const MaxLinesInput = ({ value={inputValue} min={MIN_TRUNCATE_LINES} max={MAX_TRUNCATE_LINES} + step={1} compressed disabled={isDisabled} onChange={(e) => { diff --git a/x-pack/plugins/lens/public/shared_components/value_labels_settings.test.tsx b/x-pack/plugins/lens/public/shared_components/value_labels_settings.test.tsx index ae68a40d8cea61..7f5ebcf7aa2817 100644 --- a/x-pack/plugins/lens/public/shared_components/value_labels_settings.test.tsx +++ b/x-pack/plugins/lens/public/shared_components/value_labels_settings.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { shallowWithIntl as shallow } from '@kbn/test/jest'; +import { shallowWithIntl as shallow } from '@kbn/test-jest-helpers'; import { ValueLabelsSettings, VisualOptionsProps } from './value_labels_settings'; describe('Value labels Settings', () => { diff --git a/x-pack/plugins/lens/public/state_management/context_middleware/index.test.ts b/x-pack/plugins/lens/public/state_management/context_middleware/index.test.ts index 0c3f53cec3a703..f115cb59e6121d 100644 --- a/x-pack/plugins/lens/public/state_management/context_middleware/index.test.ts +++ b/x-pack/plugins/lens/public/state_management/context_middleware/index.test.ts @@ -122,5 +122,26 @@ describe('contextMiddleware', () => { expect(store.dispatch).not.toHaveBeenCalled(); expect(next).toHaveBeenCalledWith(action); }); + + it('does not trigger another update on active data update', () => { + const data = mockDataPlugin(); + (data.nowProvider.get as jest.Mock).mockReturnValue(new Date(Date.now() - 30000)); + (data.query.timefilter.timefilter.getTime as jest.Mock).mockReturnValue({ + from: 'now-2m', + to: 'now', + }); + (data.query.timefilter.timefilter.getBounds as jest.Mock).mockReturnValue({ + min: moment(Date.now() - 100000), + max: moment(Date.now() - 30000), + }); + const { next, invoke, store } = createMiddleware(data); + const action = { + type: 'lens/onActiveDataChange', + payload: {}, + }; + invoke(action); + expect(store.dispatch).not.toHaveBeenCalled(); + expect(next).toHaveBeenCalledWith(action); + }); }); }); diff --git a/x-pack/plugins/lens/public/state_management/context_middleware/index.ts b/x-pack/plugins/lens/public/state_management/context_middleware/index.ts index 55d066f6db55b5..25dea5527d0612 100644 --- a/x-pack/plugins/lens/public/state_management/context_middleware/index.ts +++ b/x-pack/plugins/lens/public/state_management/context_middleware/index.ts @@ -12,6 +12,7 @@ import { setState, LensDispatch, LensStoreDeps, navigateAway } from '..'; import { LensAppState } from '../types'; import { getResolvedDateRange, containsDynamicMath } from '../../utils'; import { subscribeToExternalContext } from './subscribe_to_external_context'; +import { onActiveDataChange } from '../lens_slice'; export const contextMiddleware = (storeDeps: LensStoreDeps) => (store: MiddlewareAPI) => { const unsubscribeFromExternalContext = subscribeToExternalContext( @@ -20,7 +21,7 @@ export const contextMiddleware = (storeDeps: LensStoreDeps) => (store: Middlewar store.dispatch ); return (next: Dispatch) => (action: PayloadAction>) => { - if (!action.payload?.searchSessionId) { + if (!action.payload?.searchSessionId && !onActiveDataChange.match(action)) { updateTimeRange(storeDeps.lensServices.data, store.dispatch); } if (navigateAway.match(action)) { diff --git a/x-pack/plugins/lens/public/visualizations/gauge/dimension_editor.tsx b/x-pack/plugins/lens/public/visualizations/gauge/dimension_editor.tsx index 18084a8c3db518..a6da226e654de2 100644 --- a/x-pack/plugins/lens/public/visualizations/gauge/dimension_editor.tsx +++ b/x-pack/plugins/lens/public/visualizations/gauge/dimension_editor.tsx @@ -167,7 +167,6 @@ export function GaugeDimensionEditor( palettes={props.paletteService} activePalette={activePalette} dataBounds={currentMinMax} - disableSwitchingContinuity={true} setPalette={(newPalette) => { // if the new palette is not custom, replace the rangeMin with the artificial one if ( diff --git a/x-pack/plugins/lens/public/visualizations/gauge/toolbar_component/gauge_toolbar.test.tsx b/x-pack/plugins/lens/public/visualizations/gauge/toolbar_component/gauge_toolbar.test.tsx index 93d9eb04775ea0..1c3a5fdea55933 100644 --- a/x-pack/plugins/lens/public/visualizations/gauge/toolbar_component/gauge_toolbar.test.tsx +++ b/x-pack/plugins/lens/public/visualizations/gauge/toolbar_component/gauge_toolbar.test.tsx @@ -6,7 +6,7 @@ */ import React, { FormEvent } from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ToolbarButton } from 'src/plugins/kibana_react/public'; import { ReactWrapper } from 'enzyme'; import { act } from 'react-dom/test-utils'; 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 027165a2eb5d04..bc57547bc0ee66 100644 --- a/x-pack/plugins/lens/public/xy_visualization/expression.test.tsx +++ b/x-pack/plugins/lens/public/xy_visualization/expression.test.tsx @@ -43,7 +43,7 @@ import { Datatable, DatatableRow } from '../../../../../src/plugins/expressions/ import React from 'react'; import { shallow } from 'enzyme'; import { createMockExecutionContext } from '../../../../../src/plugins/expressions/common/mocks'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { chartPluginMock } from '../../../../../src/plugins/charts/public/mocks'; import { EmptyPlaceholder } from '../../../../../src/plugins/charts/public'; import { XyEndzones } from './x_domain'; diff --git a/x-pack/plugins/lens/public/xy_visualization/get_legend_action.test.tsx b/x-pack/plugins/lens/public/xy_visualization/get_legend_action.test.tsx index 5d1b45e4814996..c15c0916bee0bd 100644 --- a/x-pack/plugins/lens/public/xy_visualization/get_legend_action.test.tsx +++ b/x-pack/plugins/lens/public/xy_visualization/get_legend_action.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { LegendActionProps, SeriesIdentifier } from '@elastic/charts'; import { EuiPopover } from '@elastic/eui'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ComponentType, ReactWrapper } from 'enzyme'; import type { LensMultiTable } from '../../common'; import { layerTypes } from '../../common'; diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/axis_settings_popover.test.tsx b/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/axis_settings_popover.test.tsx index 81e82bd1fb904b..a57298787b2e35 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/axis_settings_popover.test.tsx +++ b/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/axis_settings_popover.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { shallowWithIntl as shallow } from '@kbn/test/jest'; +import { shallowWithIntl as shallow } from '@kbn/test-jest-helpers'; import { AxisSettingsPopover, AxisSettingsPopoverProps } from './axis_settings_popover'; import { ToolbarPopover } from '../../shared_components'; import { layerTypes } from '../../../common'; diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/axis_settings_popover.tsx b/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/axis_settings_popover.tsx index 6f0adf3d338107..20d2bd31c7c648 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/axis_settings_popover.tsx +++ b/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/axis_settings_popover.tsx @@ -459,6 +459,7 @@ export const AxisSettingsPopover: React.FunctionComponent @@ -504,6 +505,7 @@ export const AxisSettingsPopover: React.FunctionComponent diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/fill_opacity_option.test.tsx b/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/fill_opacity_option.test.tsx index 3ba29e4f72c837..f9920647478be6 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/fill_opacity_option.test.tsx +++ b/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/fill_opacity_option.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl as mount, shallowWithIntl as shallow } from '@kbn/test/jest'; +import { mountWithIntl as mount, shallowWithIntl as shallow } from '@kbn/test-jest-helpers'; import { EuiRange } from '@elastic/eui'; import { FillOpacityOption } from './fill_opacity_option'; diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/line_curve_option.test.tsx b/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/line_curve_option.test.tsx index c37a36a42fa47a..272adc3b17f052 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/line_curve_option.test.tsx +++ b/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/line_curve_option.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl as mount, shallowWithIntl as shallow } from '@kbn/test/jest'; +import { mountWithIntl as mount, shallowWithIntl as shallow } from '@kbn/test-jest-helpers'; import { EuiSwitch } from '@elastic/eui'; import { LineCurveOption } from './line_curve_option'; diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/missing_value_option.test.tsx b/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/missing_value_option.test.tsx index ce4e05223b5a34..d3960acd563771 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/missing_value_option.test.tsx +++ b/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/missing_value_option.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { shallowWithIntl as shallow, mountWithIntl as mount } from '@kbn/test/jest'; +import { shallowWithIntl as shallow, mountWithIntl as mount } from '@kbn/test-jest-helpers'; import { EuiSuperSelect } from '@elastic/eui'; import { MissingValuesOptions } from './missing_values_option'; diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/visual_options_popover.test.tsx b/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/visual_options_popover.test.tsx index 6b48738e22a609..fe8a71ad9f326e 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/visual_options_popover.test.tsx +++ b/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/visual_options_popover/visual_options_popover.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { shallowWithIntl as shallow } from '@kbn/test/jest'; +import { shallowWithIntl as shallow } from '@kbn/test-jest-helpers'; import { Position } from '@elastic/charts'; import type { FramePublicAPI } from '../../../types'; import { createMockDatasource, createMockFramePublicAPI } from '../../../mocks'; diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/xy_config_panel.test.tsx b/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/xy_config_panel.test.tsx index e5b1870c73404a..0ffa2d394bcafa 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/xy_config_panel.test.tsx +++ b/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/xy_config_panel.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl as mount, shallowWithIntl as shallow } from '@kbn/test/jest'; +import { mountWithIntl as mount, shallowWithIntl as shallow } from '@kbn/test-jest-helpers'; import { EuiButtonGroupProps, EuiButtonGroup } from '@elastic/eui'; import { LayerContextMenu, XyToolbar, DimensionEditor } from '.'; import { AxisSettingsPopover } from './axis_settings_popover'; diff --git a/x-pack/plugins/lens/readme.md b/x-pack/plugins/lens/readme.md index 927c4bbef290c0..c85005c09754ef 100644 --- a/x-pack/plugins/lens/readme.md +++ b/x-pack/plugins/lens/readme.md @@ -24,6 +24,8 @@ Run all tests from the `x-pack` root directory Lens state is kept in the Redux Store. To enable redux logger, open Chrome Developer Tools and type in the console: `window.ELASTIC_LENS_LOGGER=true`. +To simulate long running searches, set `data.search.aggs.shardDelay.enabled` in your `kibana.dev.yml` to true and set the dealy via console in the browser (e.g. for a 20 seconds delay): `window.ELASTIC_LENS_DELAY_SECONDS=20`. + ## UI Terminology Lens has a lot of UI elements – to make it easier to refer to them in issues or bugs, this is a hopefully complete list: 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 a5f6a866bc9deb..62b7dbf6c1a786 100644 --- a/x-pack/plugins/license_management/__jest__/upload_license.test.tsx +++ b/x-pack/plugins/license_management/__jest__/upload_license.test.tsx @@ -9,7 +9,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 '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; // @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 eacd397d600167..25ef77612ca2c7 100644 --- a/x-pack/plugins/license_management/__jest__/util/util.js +++ b/x-pack/plugins/license_management/__jest__/util/util.js @@ -10,7 +10,7 @@ import React from 'react'; import { Provider } from 'react-redux'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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 b9f4c6d707a3b6..32103896134ad6 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 398310e72be025..a99f8ce5519f5b 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 a8ee367e8d36f5..7889a91f925f9f 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 3d7babb95eeb95..9186d8138c0944 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test-jest-helpers'; 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 13db9e6e73e600..2f0a707d880c26 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 fb8a5e2a627c74..620e8081c67440 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 38213733d5e728..79c49319bfb45c 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test-jest-helpers'; import { PipelinesTable } from './pipelines_table'; describe('PipelinesTable component', () => { diff --git a/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_size_property.test.tsx b/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_size_property.test.tsx index 4e6b8ea73beae9..0681d12007c4ab 100644 --- a/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_size_property.test.tsx +++ b/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_size_property.test.tsx @@ -50,6 +50,9 @@ describe('renderLegendDetailRow', () => { supportsFieldMetaFromEs: () => { return true; }, + supportsFieldMetaFromLocalData: () => { + return true; + }, } as unknown as IField; const sizeProp = new DynamicSizeProperty( { minSize: 0, maxSize: 10, fieldMetaOptions: { isEnabled: true } }, diff --git a/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_style_property.tsx b/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_style_property.tsx index 543429ce77a264..517bb68a0025dd 100644 --- a/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_style_property.tsx +++ b/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_style_property.tsx @@ -295,7 +295,20 @@ export class DynamicStyleProperty } getFieldMetaOptions() { - return _.get(this.getOptions(), 'fieldMetaOptions', { isEnabled: true }); + const fieldMetaOptions = _.get(this.getOptions(), 'fieldMetaOptions', { isEnabled: true }); + + // In 8.0, UI changed to not allow setting isEnabled to false when fieldMeta from local not supported + // Saved objects created prior to 8.0 may have a configuration where + // fieldMetaOptions.isEnabled is false and the field does not support fieldMeta from local. + // In these cases, force isEnabled to true + // The exact case that spawned this fix is with ES_SEARCH sources and 8.0 where vector tiles switched + // from vector tiles generated via Kibana server to vector tiles generated via Elasticsearch. + // Kibana vector tiles supported fieldMeta from local while Elasticsearch vector tiles do not support fieldMeta from local. + if (this._field && !this._field.supportsFieldMetaFromLocalData()) { + fieldMetaOptions.isEnabled = true; + } + + return fieldMetaOptions; } getDataMappingFunction() { diff --git a/x-pack/plugins/maps/public/index.ts b/x-pack/plugins/maps/public/index.ts index 5778c8d3b654f7..071300b7784fb0 100644 --- a/x-pack/plugins/maps/public/index.ts +++ b/x-pack/plugins/maps/public/index.ts @@ -20,6 +20,8 @@ export const plugin: PluginInitializer = ( export { MAP_SAVED_OBJECT_TYPE } from '../common/constants'; export type { PreIndexedShape } from '../common/elasticsearch_util'; +export { GEOJSON_FEATURE_ID_PROPERTY_NAME } from './classes/layers/vector_layer/geojson_vector_layer/assign_feature_ids'; + export type { ITooltipProperty, RenderTooltipContentParams, 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 430b56b4b52b92..bb9fa3a8ec4d65 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 @@ -9,7 +9,7 @@ import mockAnnotations from '../annotations_table/__mocks__/mock_annotations.jso import moment from 'moment-timezone'; import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { AnnotationDescriptionList } from './index'; 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 0caf92baca88d3..1681d151cd31f6 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 @@ -8,7 +8,7 @@ import jobConfig from '../../../../../common/types/__mocks__/job_config_farequote'; import mockAnnotations from './__mocks__/mock_annotations.json'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 668d392bffbbe9..67f6a9b12dfa15 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test-jest-helpers'; import { AnomalyDetails } from './anomaly_details'; const props = { diff --git a/x-pack/plugins/ml/public/application/components/entity_cell/entity_cell.test.tsx b/x-pack/plugins/ml/public/application/components/entity_cell/entity_cell.test.tsx index efe405044f45e4..d726356624b357 100644 --- a/x-pack/plugins/ml/public/application/components/entity_cell/entity_cell.test.tsx +++ b/x-pack/plugins/ml/public/application/components/entity_cell/entity_cell.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { EntityCell } from './entity_cell'; const defaultProps = { 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 3f64ff794d9abb..ea444193db0b11 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { FullTimeRangeSelector } from './index'; import type { Query } from 'src/plugins/data/public'; import type { DataView } from '../../../../../../../src/plugins/data_views/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 149cdf9bb9aa0c..37315b61c2d027 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 f4752f54073708..1c979525ca9eb6 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 f13b2d010a370b..2fbf69c67f26a6 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 @@ -8,7 +8,7 @@ // Mock the mlJobService that is imported for saving rules. jest.mock('../../services/job_service.js', () => 'mlJobService'); -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 eaa352b33253d1..69a71dda38cb4d 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 @@ -8,7 +8,7 @@ // Mock the mlJobService that is imported for saving rules. jest.mock('../../services/job_service.js', () => 'mlJobService'); -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 20a66bcf5b140e..2553baa11da339 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 @@ -56,7 +56,7 @@ jest.mock('../../../../../../../src/plugins/kibana_react/public', () => ({ }, })); -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 59e5000dee7fd0..c030dcfa1f0a47 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 @@ -8,7 +8,7 @@ // Mock the mlJobService that is imported for saving rules. jest.mock('../../services/job_service.js', () => 'mlJobService'); -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 5a9c6bb3af4cde..86a777f65a3389 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 @@ -16,7 +16,7 @@ jest.mock('../../capabilities/check_capabilities', () => ({ checkPermission: (privilege) => mockCheckPermission(privilege), })); -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 802cd51575c78d..2c255728f2eb3b 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 cf06149b728b0e..457a552bad6c9c 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 80b77e41a69642..9ae947c404c2e7 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 @@ -7,7 +7,7 @@ jest.mock('../../../services/job_service.js', () => 'mlJobService'); -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 d4d93506a4d9dc..7df277ae0b6ab5 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 @@ -29,7 +29,7 @@ jest.mock('../../../services/ml_api_service', () => ({ }, })); -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 8ec83d8679e878..b1755660960ad4 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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/components/analytics_list/__mocks__/analytics_list_item.json b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/__mocks__/analytics_list_item.json index 1b7d353d9f3038..cf56dedf664eef 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/__mocks__/analytics_list_item.json +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/__mocks__/analytics_list_item.json @@ -22,7 +22,7 @@ }, "model_memory_limit": "50mb", "create_time": 1568974998023, - "version": "8.1.0" + "version": "8.2.0" }, "id": "fq_outlier_1222", "checkpointing": {}, 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 f848aaf7166413..36cc01d4462b9a 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountHook } from '@kbn/test/jest'; +import { mountHook } from '@kbn/test-jest-helpers'; import { MlContext } from '../../../../../contexts/ml'; import { kibanaContextValueMock } from '../../../../../contexts/ml/__mocks__/kibana_context_value'; 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 8f089ab8c07ce0..8e39120e36411f 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 @@ -13,7 +13,7 @@ jest.mock('../../services/field_format_service', () => ({ }, })); -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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 ef0482806f4238..c2149097c8733b 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 133ca3e8eb628b..2582dcfb05c165 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 @@ -13,7 +13,7 @@ jest.mock('../../services/field_format_service', () => ({ }, })); -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; import { ExplorerChartSingleMetric } from './explorer_chart_single_metric'; diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/jobs_list_view/jobs_list_view.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/jobs_list_view/jobs_list_view.js index 86b38f88c7199a..e77f2d6c2aab90 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/jobs_list_view/jobs_list_view.js +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/jobs_list_view/jobs_list_view.js @@ -7,7 +7,6 @@ import React, { Component } from 'react'; import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; -import { debounce } from 'lodash'; import { ml } from '../../../../services/ml_api_service'; import { checkForAutoStartDatafeed, filterJobs, loadFullJob } from '../utils'; @@ -35,11 +34,6 @@ import { AnomalyDetectionEmptyState } from '../anomaly_detection_empty_state'; let blockingJobsRefreshTimeout = null; -const filterJobsDebounce = debounce((jobsSummaryList, filterClauses, callback) => { - const ss = filterJobs(jobsSummaryList, filterClauses); - callback(ss); -}, 500); - // 'isManagementTable' bool prop to determine when to configure table for use in Kibana management page export class JobsListView extends Component { constructor(props) { @@ -291,19 +285,10 @@ export class JobsListView extends Component { return; } - if (this._isFiltersSet === true) { - filterJobsDebounce(this.state.jobsSummaryList, filterClauses, (jobsSummaryList) => { - this.setState({ filteredJobsSummaryList: jobsSummaryList, filterClauses }, () => { - this.refreshSelectedJobs(); - }); - }); - } else { - // first use after page load, do not debounce. - const filteredJobsSummaryList = filterJobs(this.state.jobsSummaryList, filterClauses); - this.setState({ filteredJobsSummaryList, filterClauses }, () => { - this.refreshSelectedJobs(); - }); - } + const filteredJobsSummaryList = filterJobs(this.state.jobsSummaryList, filterClauses); + this.setState({ filteredJobsSummaryList, filterClauses }, () => { + this.refreshSelectedJobs(); + }); this._isFiltersSet = true; }; 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 302dc63da7e520..e5c66bcdd59bd6 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test-jest-helpers'; 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 a2341edf38f587..d45d93043e16bb 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 10bc1c7a966013..bcbbdec7b65c6e 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test-jest-helpers'; 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 5604ef40462403..8762cb4603807c 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 0107af3cf8c1e6..73391f3cba87f7 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 @@ -67,7 +67,7 @@ jest.mock('../../../../../../../../src/plugins/kibana_react/public', () => ({ }, })); -import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test-jest-helpers'; 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 f33879bfa872fd..0aa91a44458e7a 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 8e66dbd2742732..ee1879a8a3c7a7 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 edbee43151f21a..da470441caa98d 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 543ae2b85abfc0..13e2c1e2dc37b2 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test-jest-helpers'; 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 b4d32c387d1833..0bbb3f443f1aee 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 65fc96a62a9cbc..d46de282c59d92 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 @@ -14,7 +14,7 @@ jest.mock('../../../../capabilities/check_capabilities', () => ({ })); jest.mock('../../../../services/ml_api_service', () => 'ml'); -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 6082a2bbf67999..ed6ae3764fd2a6 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 09c37c724b7c96..c20b8485b7cd13 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 @@ -51,7 +51,7 @@ jest.mock('../../../../../../../../src/plugins/kibana_react/public', () => ({ }, })); -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 dc756fb4686bb0..039acc0bef1ebc 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 83226ad236a6d1..7935b7dce31858 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 0ae4a758278f11..e6a69e971a8641 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 204cb6036afd3e..4357dad093dad7 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 164d4d7eecbd43..add92b804ee394 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 @@ -12,7 +12,7 @@ jest.mock('../../../capabilities/check_capabilities', () => ({ })); jest.mock('../../../services/ml_api_service', () => 'ml'); -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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 a12e7336318308..ad3847e011371c 100644 --- a/x-pack/plugins/ml/public/application/settings/settings.test.tsx +++ b/x-pack/plugins/ml/public/application/settings/settings.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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 4faae22f981535..850a5855090032 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 @@ -8,7 +8,7 @@ //import mockOverallSwimlaneData from './__mocks__/mock_overall_swimlane.json'; import moment from 'moment-timezone'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; import { TimeseriesChart } from './timeseries_chart'; diff --git a/x-pack/plugins/ml/public/maps/anomaly_source.tsx b/x-pack/plugins/ml/public/maps/anomaly_source.tsx index fa3fce1747a2e2..e2d92a730d95af 100644 --- a/x-pack/plugins/ml/public/maps/anomaly_source.tsx +++ b/x-pack/plugins/ml/public/maps/anomaly_source.tsx @@ -15,7 +15,7 @@ import { VectorSourceRequestMeta, } from '../../../maps/common'; import { AbstractSourceDescriptor, MapExtent } from '../../../maps/common/descriptor_types'; -import { ITooltipProperty } from '../../../maps/public'; +import { ITooltipProperty, GEOJSON_FEATURE_ID_PROPERTY_NAME } from '../../../maps/public'; import { AnomalySourceField, AnomalySourceTooltipProperty, @@ -247,6 +247,9 @@ export class AnomalySource implements IVectorSource { async getTooltipProperties(properties: { [p: string]: any } | null): Promise { const tooltipProperties: ITooltipProperty[] = []; for (const key in properties) { + if (key === GEOJSON_FEATURE_ID_PROPERTY_NAME) { + continue; + } if (properties.hasOwnProperty(key)) { const label = ANOMALY_SOURCE_FIELDS[key]?.label; if (label) { diff --git a/x-pack/plugins/monitoring/public/alerts/alert_form.test.tsx b/x-pack/plugins/monitoring/public/alerts/alert_form.test.tsx index a95eedb2b4cb19..ff58887c88c12e 100644 --- a/x-pack/plugins/monitoring/public/alerts/alert_form.test.tsx +++ b/x-pack/plugins/monitoring/public/alerts/alert_form.test.tsx @@ -10,7 +10,7 @@ */ import React, { Fragment, lazy } from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { ReactWrapper, mount } from 'enzyme'; import { act } from 'react-dom/test-utils'; import { coreMock } from 'src/core/public/mocks'; diff --git a/x-pack/plugins/monitoring/public/alerts/components/param_details_form/use_derived_index_pattern.tsx b/x-pack/plugins/monitoring/public/alerts/components/param_details_form/use_derived_index_pattern.tsx index 1a4d88d690b845..1f133176a743e8 100644 --- a/x-pack/plugins/monitoring/public/alerts/components/param_details_form/use_derived_index_pattern.tsx +++ b/x-pack/plugins/monitoring/public/alerts/components/param_details_form/use_derived_index_pattern.tsx @@ -5,15 +5,16 @@ * 2.0. */ +import { DataViewFieldBase } from '@kbn/es-query'; import { useEffect, useState } from 'react'; -import { DataPublicPluginStart, IFieldType, IIndexPattern } from 'src/plugins/data/public'; +import { DataPublicPluginStart, IIndexPattern } from 'src/plugins/data/public'; +import { prefixIndexPattern } from '../../../../common/ccs_utils'; import { INDEX_PATTERN_BEATS, INDEX_PATTERN_ELASTICSEARCH, INDEX_PATTERN_KIBANA, INDEX_PATTERN_LOGSTASH, } from '../../../../common/constants'; -import { prefixIndexPattern } from '../../../../common/ccs_utils'; import { MonitoringConfig } from '../../../types'; const INDEX_PATTERNS = `${INDEX_PATTERN_ELASTICSEARCH},${INDEX_PATTERN_KIBANA},${INDEX_PATTERN_LOGSTASH},${INDEX_PATTERN_BEATS}`; @@ -24,7 +25,7 @@ export const useDerivedIndexPattern = ( ): { loading: boolean; derivedIndexPattern: IIndexPattern } => { const indexPattern = prefixIndexPattern(config || ({} as MonitoringConfig), INDEX_PATTERNS, '*'); const [loading, setLoading] = useState(true); - const [fields, setFields] = useState([]); + const [fields, setFields] = useState([]); useEffect(() => { (async function fetchData() { const result = await data.indexPatterns.getFieldsForWildcard({ diff --git a/x-pack/plugins/monitoring/public/application/pages/page_template.tsx b/x-pack/plugins/monitoring/public/application/pages/page_template.tsx index c951d325c13f4a..37ac69a56e40dd 100644 --- a/x-pack/plugins/monitoring/public/application/pages/page_template.tsx +++ b/x-pack/plugins/monitoring/public/application/pages/page_template.tsx @@ -20,8 +20,9 @@ import { } from '../../lib/setup_mode'; import { SetupModeFeature } from '../../../common/enums'; import { AlertsDropdown } from '../../alerts/alerts_dropdown'; -import { ActionMenu } from '../../components/action_menu'; import { useRequestErrorHandler } from '../hooks/use_request_error_handler'; +import { HeaderMenuPortal } from '../../../../observability/public'; +import { HeaderActionMenuContext } from '../../application/contexts/header_action_menu_context'; export interface TabMenuItem { id: string; @@ -53,6 +54,7 @@ export const PageTemplate: React.FC = ({ const history = useHistory(); const [hasError, setHasError] = useState(false); const handleRequestError = useRequestErrorHandler(); + const { setHeaderActionMenu, theme$ } = useContext(HeaderActionMenuContext); const getPageDataResponseHandler = useCallback( (result: any) => { @@ -104,9 +106,11 @@ export const PageTemplate: React.FC = ({ return (
- - - + {setHeaderActionMenu && theme$ && ( + + + + )} {tabs && ( diff --git a/x-pack/plugins/monitoring/public/components/action_menu/index.tsx b/x-pack/plugins/monitoring/public/components/action_menu/index.tsx deleted file mode 100644 index c1de80ccaf2429..00000000000000 --- a/x-pack/plugins/monitoring/public/components/action_menu/index.tsx +++ /dev/null @@ -1,35 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React, { useContext, useEffect } from 'react'; -import { - KibanaContextProvider, - toMountPoint, - useKibana, -} from '../../../../../../src/plugins/kibana_react/public'; -import { HeaderActionMenuContext } from '../../application/contexts/header_action_menu_context'; - -export const ActionMenu: React.FC<{}> = ({ children }) => { - const { services } = useKibana(); - const { setHeaderActionMenu } = useContext(HeaderActionMenuContext); - useEffect(() => { - if (setHeaderActionMenu) { - setHeaderActionMenu((element) => { - const mount = toMountPoint( - {children}, - { theme$: services.theme?.theme$ } - ); - return mount(element); - }); - return () => { - setHeaderActionMenu(undefined); - }; - } - }, [children, setHeaderActionMenu, services]); - - return null; -}; diff --git a/x-pack/plugins/monitoring/public/components/cluster/overview/helpers.test.js b/x-pack/plugins/monitoring/public/components/cluster/overview/helpers.test.js index 47cc1bef53caaf..942065263912da 100644 --- a/x-pack/plugins/monitoring/public/components/cluster/overview/helpers.test.js +++ b/x-pack/plugins/monitoring/public/components/cluster/overview/helpers.test.js @@ -6,7 +6,7 @@ */ import React from 'react'; -import { renderWithIntl } from '@kbn/test/jest'; +import { renderWithIntl } from '@kbn/test-jest-helpers'; import { BytesUsage, BytesPercentageUsage } from './helpers'; describe('Bytes Usage', () => { diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/__snapshots__/cells.test.js.snap b/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/__snapshots__/cells.test.js.snap index ce94dd2a61a800..5535520c67a8e4 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/__snapshots__/cells.test.js.snap +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/__snapshots__/cells.test.js.snap @@ -2,7 +2,7 @@ exports[`Node Listing Metric Cell should format N/A as the metric for an offline node 1`] = `
N/A
diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/cells.js b/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/cells.js index 528b3bed3df7b7..1b6121f2784969 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/cells.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/cells.js @@ -27,7 +27,7 @@ const TRENDING_UP = i18n.translate('xpack.monitoring.elasticsearch.node.cells.tr }); function OfflineCell() { - return
N/A
; + return
N/A
; } const getDirection = (slope) => { @@ -56,88 +56,80 @@ function MetricCell({ isOnline, metric = {}, isPercent, ...props }) { const onButtonClick = () => setIsPopoverOpen((isPopoverOpen) => !isPopoverOpen); const closePopover = () => setIsPopoverOpen(false); - if (isOnline) { - const { lastVal, maxVal, minVal, slope } = get(metric, 'summary', {}); - const format = get(metric, 'metric.format'); - const units = get(metric, 'metric.units'); + if (!isOnline) { + return ; + } - const tooltipItems = [ - { - title: i18n.translate('xpack.monitoring.elasticsearch.node.cells.tooltip.trending', { - defaultMessage: 'Trending', - }), - description: getDirection(slope), - }, - { - title: i18n.translate('xpack.monitoring.elasticsearch.node.cells.tooltip.max', { - defaultMessage: 'Max value', - }), - description: metricVal(maxVal, format, isPercent, units), - }, - { - title: i18n.translate('xpack.monitoring.elasticsearch.node.cells.tooltip.min', { - defaultMessage: 'Min value', - }), - description: metricVal(minVal, format, isPercent, units), - }, - ]; + const { lastVal, maxVal, minVal, slope } = get(metric, 'summary', {}); + const format = get(metric, 'metric.format'); + const units = get(metric, 'metric.units'); - const iconLabel = i18n.translate( - 'xpack.monitoring.elasticsearch.node.cells.tooltip.iconLabel', - { - defaultMessage: 'More information about this metric', - } - ); + const tooltipItems = [ + { + title: i18n.translate('xpack.monitoring.elasticsearch.node.cells.tooltip.trending', { + defaultMessage: 'Trending', + }), + description: getDirection(slope), + }, + { + title: i18n.translate('xpack.monitoring.elasticsearch.node.cells.tooltip.max', { + defaultMessage: 'Max value', + }), + description: metricVal(maxVal, format, isPercent, units), + }, + { + title: i18n.translate('xpack.monitoring.elasticsearch.node.cells.tooltip.min', { + defaultMessage: 'Min value', + }), + description: metricVal(minVal, format, isPercent, units), + }, + ]; - const button = ( - - ); + const iconLabel = i18n.translate('xpack.monitoring.elasticsearch.node.cells.tooltip.iconLabel', { + defaultMessage: 'More information about this metric', + }); - return ( - - - - - - -
- - - - {i18n.translate('xpack.monitoring.elasticsearch.node.cells.tooltip.preface', { - defaultMessage: 'Applies to current time period', - })} - -
-
-
- - {metricVal(lastVal, format, isPercent)} - -
-
-
- ); - } + const button = ( + + ); - return ; + return ( + + + + + + +
+ + + + {i18n.translate('xpack.monitoring.elasticsearch.node.cells.tooltip.preface', { + defaultMessage: 'Applies to current time period', + })} + +
+
+
+ + {metricVal(lastVal, format, isPercent)} + +
+
+
+ ); } export { OfflineCell, MetricCell }; diff --git a/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/cells.test.js b/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/cells.test.js index 250b9f63912216..f2ef0484928fcd 100644 --- a/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/cells.test.js +++ b/x-pack/plugins/monitoring/public/components/elasticsearch/nodes/cells.test.js @@ -6,7 +6,7 @@ */ import React from 'react'; -import { renderWithIntl } from '@kbn/test/jest'; +import { renderWithIntl } from '@kbn/test-jest-helpers'; import { MetricCell } from './cells'; describe('Node Listing Metric Cell', () => { diff --git a/x-pack/plugins/monitoring/public/components/kuery_bar/index.tsx b/x-pack/plugins/monitoring/public/components/kuery_bar/index.tsx index ca0a8122772f35..6d79266fe3cc6e 100644 --- a/x-pack/plugins/monitoring/public/components/kuery_bar/index.tsx +++ b/x-pack/plugins/monitoring/public/components/kuery_bar/index.tsx @@ -5,12 +5,12 @@ * 2.0. */ +import { fromKueryExpression } from '@kbn/es-query'; import { i18n } from '@kbn/i18n'; - import React, { useEffect, useState } from 'react'; -import { WithKueryAutocompletion } from './with_kuery_autocompletion'; +import { IIndexPattern, QuerySuggestion } from '../../../../../../src/plugins/data/public'; import { AutocompleteField } from './autocomplete_field'; -import { esKuery, IIndexPattern, QuerySuggestion } from '../../../../../../src/plugins/data/public'; +import { WithKueryAutocompletion } from './with_kuery_autocompletion'; type LoadSuggestionsFn = ( e: string, @@ -31,7 +31,7 @@ interface Props { function validateQuery(query: string) { try { - esKuery.fromKueryExpression(query); + fromKueryExpression(query); } catch (err) { return false; } diff --git a/x-pack/plugins/monitoring/public/components/no_data/checker_errors.test.js b/x-pack/plugins/monitoring/public/components/no_data/checker_errors.test.js index d293494fcd4c4c..1c33f68458fd00 100644 --- a/x-pack/plugins/monitoring/public/components/no_data/checker_errors.test.js +++ b/x-pack/plugins/monitoring/public/components/no_data/checker_errors.test.js @@ -7,7 +7,7 @@ import React from 'react'; import { boomify, forbidden } from '@hapi/boom'; -import { renderWithIntl } from '@kbn/test/jest'; +import { renderWithIntl } from '@kbn/test-jest-helpers'; import { CheckerErrors } from './checker_errors'; describe('CheckerErrors', () => { diff --git a/x-pack/plugins/monitoring/public/components/no_data/explanations/collection_enabled/collection_enabled.test.js b/x-pack/plugins/monitoring/public/components/no_data/explanations/collection_enabled/collection_enabled.test.js index b66793d840ebb2..95dc62abdf9d25 100644 --- a/x-pack/plugins/monitoring/public/components/no_data/explanations/collection_enabled/collection_enabled.test.js +++ b/x-pack/plugins/monitoring/public/components/no_data/explanations/collection_enabled/collection_enabled.test.js @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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/collection_interval.test.js b/x-pack/plugins/monitoring/public/components/no_data/explanations/collection_interval/collection_interval.test.js index a5af179a050b74..95ffad81b902d7 100644 --- a/x-pack/plugins/monitoring/public/components/no_data/explanations/collection_interval/collection_interval.test.js +++ b/x-pack/plugins/monitoring/public/components/no_data/explanations/collection_interval/collection_interval.test.js @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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/exporters.test.js b/x-pack/plugins/monitoring/public/components/no_data/explanations/exporters/exporters.test.js index 9958c6671d30b7..47dbf5f1ab5861 100644 --- a/x-pack/plugins/monitoring/public/components/no_data/explanations/exporters/exporters.test.js +++ b/x-pack/plugins/monitoring/public/components/no_data/explanations/exporters/exporters.test.js @@ -6,7 +6,7 @@ */ import React from 'react'; -import { renderWithIntl } from '@kbn/test/jest'; +import { renderWithIntl } from '@kbn/test-jest-helpers'; import { ExplainExporters, ExplainExportersCloud } from './exporters'; jest.mock('../../../../legacy_shims', () => ({ diff --git a/x-pack/plugins/monitoring/public/components/no_data/explanations/plugin_enabled/plugin_enabled.test.js b/x-pack/plugins/monitoring/public/components/no_data/explanations/plugin_enabled/plugin_enabled.test.js index c28c7563e59746..dd57cd3bd1c509 100644 --- a/x-pack/plugins/monitoring/public/components/no_data/explanations/plugin_enabled/plugin_enabled.test.js +++ b/x-pack/plugins/monitoring/public/components/no_data/explanations/plugin_enabled/plugin_enabled.test.js @@ -6,7 +6,7 @@ */ import React from 'react'; -import { renderWithIntl } from '@kbn/test/jest'; +import { renderWithIntl } from '@kbn/test-jest-helpers'; import { ExplainPluginEnabled } from './plugin_enabled'; describe('ExplainPluginEnabled', () => { diff --git a/x-pack/plugins/monitoring/public/components/no_data/no_data.test.js b/x-pack/plugins/monitoring/public/components/no_data/no_data.test.js index 17ee5148e5d116..a522d01037603e 100644 --- a/x-pack/plugins/monitoring/public/components/no_data/no_data.test.js +++ b/x-pack/plugins/monitoring/public/components/no_data/no_data.test.js @@ -6,7 +6,7 @@ */ import React from 'react'; -import { renderWithIntl } from '@kbn/test/jest'; +import { renderWithIntl } from '@kbn/test-jest-helpers'; import { NoData } from '.'; const enabler = {}; diff --git a/x-pack/plugins/monitoring/public/components/no_data/reasons/reason_found.test.js b/x-pack/plugins/monitoring/public/components/no_data/reasons/reason_found.test.js index 6cec3261093086..96b0ceb4cb83df 100644 --- a/x-pack/plugins/monitoring/public/components/no_data/reasons/reason_found.test.js +++ b/x-pack/plugins/monitoring/public/components/no_data/reasons/reason_found.test.js @@ -6,7 +6,7 @@ */ import React from 'react'; -import { renderWithIntl } from '@kbn/test/jest'; +import { renderWithIntl } from '@kbn/test-jest-helpers'; import { ReasonFound } from '.'; jest.mock('../../../legacy_shims', () => ({ diff --git a/x-pack/plugins/monitoring/public/components/no_data/reasons/we_tried.test.js b/x-pack/plugins/monitoring/public/components/no_data/reasons/we_tried.test.js index 186676776021e9..5fd3947c3bb1c1 100644 --- a/x-pack/plugins/monitoring/public/components/no_data/reasons/we_tried.test.js +++ b/x-pack/plugins/monitoring/public/components/no_data/reasons/we_tried.test.js @@ -6,7 +6,7 @@ */ import React from 'react'; -import { renderWithIntl } from '@kbn/test/jest'; +import { renderWithIntl } from '@kbn/test-jest-helpers'; import { WeTried } from '.'; describe('WeTried', () => { diff --git a/x-pack/plugins/monitoring/public/components/page_loading/page_loading.test.js b/x-pack/plugins/monitoring/public/components/page_loading/page_loading.test.js index f7973231f41b02..07e3e89dce9a13 100644 --- a/x-pack/plugins/monitoring/public/components/page_loading/page_loading.test.js +++ b/x-pack/plugins/monitoring/public/components/page_loading/page_loading.test.js @@ -6,7 +6,7 @@ */ import React from 'react'; -import { renderWithIntl } from '@kbn/test/jest'; +import { renderWithIntl } from '@kbn/test-jest-helpers'; 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 1428418ad37057..dcb4821e1819ab 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { renderWithIntl } from '@kbn/test/jest'; +import { renderWithIntl } from '@kbn/test-jest-helpers'; import { SummaryStatus } from './summary_status'; describe('Summary Status Component', () => { diff --git a/x-pack/plugins/monitoring/public/lib/kuery.ts b/x-pack/plugins/monitoring/public/lib/kuery.ts index 19706d7664c22c..67f58360bc27ae 100644 --- a/x-pack/plugins/monitoring/public/lib/kuery.ts +++ b/x-pack/plugins/monitoring/public/lib/kuery.ts @@ -5,7 +5,8 @@ * 2.0. */ -import { esKuery, IIndexPattern } from '../../../../../src/plugins/data/public'; +import { fromKueryExpression, toElasticsearchQuery } from '@kbn/es-query'; +import { IIndexPattern } from '../../../../../src/plugins/data/public'; export const convertKueryToElasticSearchQuery = ( kueryExpression: string, @@ -13,9 +14,7 @@ export const convertKueryToElasticSearchQuery = ( ) => { try { return kueryExpression - ? JSON.stringify( - esKuery.toElasticsearchQuery(esKuery.fromKueryExpression(kueryExpression), indexPattern) - ) + ? JSON.stringify(toElasticsearchQuery(fromKueryExpression(kueryExpression), indexPattern)) : ''; } catch (err) { return ''; diff --git a/x-pack/plugins/monitoring/server/lib/details/get_series.ts b/x-pack/plugins/monitoring/server/lib/details/get_series.ts index 3a053b16aad7cd..58e1aac0884b69 100644 --- a/x-pack/plugins/monitoring/server/lib/details/get_series.ts +++ b/x-pack/plugins/monitoring/server/lib/details/get_series.ts @@ -22,28 +22,10 @@ import { import { formatUTCTimestampForTimezone } from '../format_timezone'; import { getNewIndexPatterns } from '../cluster/get_index_patterns'; import { Globals } from '../../static_globals'; +import type { Metric } from '../metrics/metrics'; type SeriesBucket = Bucket & { metric_mb_deriv?: { normalized_value: number } }; -interface Metric { - app: string; - derivative: boolean; - mbField?: string; - aggs: any; - getDateHistogramSubAggs?: Function; - dateHistogramSubAggs?: any; - metricAgg: string; - field: string; - timestampField: string; - calculation: ( - b: SeriesBucket, - key: string, - metric: Metric, - defaultSizeInSeconds: number - ) => number | null; - serialize: () => string; -} - /** * Derivative metrics for the first two agg buckets are unusable. For the first bucket, there * simply is no derivative metric (as calculating a derivative requires two adjacent buckets). For @@ -72,7 +54,12 @@ function getUuid(req: LegacyRequest, metric: Metric) { } } -function defaultCalculation(bucket: SeriesBucket, key: string) { +function defaultCalculation( + bucket: SeriesBucket, + key: string, + metric?: Metric, + defaultSizeInSeconds?: number +) { const legacyValue: number = get(bucket, key, null); const mbValue = bucket.metric_mb_deriv?.normalized_value ?? null; let value; @@ -142,7 +129,7 @@ async function fetchSeries( } else { dateHistogramSubAggs = { metric: { - [metric.metricAgg]: { + [metric.metricAgg!]: { field: metric.field, }, }, @@ -150,7 +137,7 @@ async function fetchSeries( }; if (metric.mbField) { Reflect.set(dateHistogramSubAggs, 'metric_mb', { - [metric.metricAgg]: { + [metric.metricAgg!]: { field: metric.mbField, }, }); diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_metric_aggs.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_metric_aggs.ts index ea2940ee1589ca..4ed6e8970edadb 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_metric_aggs.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/get_metric_aggs.ts @@ -33,7 +33,7 @@ export function getMetricAggs(listingMetrics: string[]) { // if metric does not have custom agg defined metricAgg = { metric: { - [metric.metricAgg]: { + [metric.metricAgg!]: { // max, sum, etc field: metric.field, }, @@ -49,7 +49,7 @@ export function getMetricAggs(listingMetrics: string[]) { aggItems = { ...aggItems, - ...convertMetricNames(metricName, metric.aggs || metricAgg), + ...convertMetricNames(metricName, metric.aggs ? metric.aggs : metricAgg!), }; }); diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/map_nodes_metrics.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/map_nodes_metrics.ts index 099b32dc1e65d6..8313689b38fec8 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/map_nodes_metrics.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/get_nodes/map_nodes_metrics.ts @@ -8,6 +8,7 @@ import { get, map, min, max, last } from 'lodash'; import { filterPartialBuckets } from '../../../filter_partial_buckets'; import { metrics } from '../../../metrics'; +import { Metric } from '../../../metrics/metrics'; import { Bucket } from '../../../../types'; type MetricBucket = Bucket & { metric_deriv?: { value: number; normalized_value: number } }; @@ -35,10 +36,7 @@ function calcSlope(data: Array<{ x: number; y: number }>) { return null; // convert possible NaN to `null` for JSON-friendliness } -const mapBuckets = ( - bucket: MetricBucket, - metric: { derivative: boolean; calculation: (b: Bucket) => number | null } -) => { +const mapBuckets = (bucket: MetricBucket, metric: Metric) => { const x = bucket.key; if (metric.calculation) { diff --git a/x-pack/plugins/monitoring/server/lib/metrics/__snapshots__/metrics.test.js.snap b/x-pack/plugins/monitoring/server/lib/metrics/__snapshots__/metrics.test.js.snap index edb76085e68343..50fff3734b1a58 100644 --- a/x-pack/plugins/monitoring/server/lib/metrics/__snapshots__/metrics.test.js.snap +++ b/x-pack/plugins/monitoring/server/lib/metrics/__snapshots__/metrics.test.js.snap @@ -32,15 +32,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "HTTP Requests received by agent configuration managemen", + "docType": undefined, "field": "beats_stats.metrics.apm-server.acm.request.count", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Count", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Requests Agent Configuration Management", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_acm_response_count": ApmEventsRateClusterMetric { @@ -73,15 +82,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "HTTP requests responded to by APM Server", + "docType": undefined, "field": "beats_stats.metrics.apm-server.acm.response.count", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Count", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Response Count Agent Configuration Management", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_acm_response_errors_count": ApmEventsRateClusterMetric { @@ -114,15 +132,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "HTTP errors count", + "docType": undefined, "field": "beats_stats.metrics.apm-server.acm.response.errors.count", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Error Count", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Response Error Count Agent Configuration Management", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_acm_response_errors_forbidden": ApmEventsRateClusterMetric { @@ -155,15 +182,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Forbidden HTTP requests rejected count", + "docType": undefined, "field": "beats_stats.metrics.apm-server.acm.response.errors.forbidden", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Count", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Response Errors Agent Configuration Management", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_acm_response_errors_invalidquery": ApmEventsRateClusterMetric { @@ -196,15 +232,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Invalid HTTP query", + "docType": undefined, "field": "beats_stats.metrics.apm-server.acm.response.errors.invalidquery", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Invalid Query", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Response Invalid Query Errors Agent Configuration Management", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_acm_response_errors_method": ApmEventsRateClusterMetric { @@ -237,15 +282,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "HTTP requests rejected due to incorrect HTTP method", + "docType": undefined, "field": "beats_stats.metrics.apm-server.acm.response.errors.method", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Method", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Response Method Errors Agent Configuration Management", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_acm_response_errors_unauthorized": ApmEventsRateClusterMetric { @@ -278,15 +332,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Unauthorized HTTP requests rejected count", + "docType": undefined, "field": "beats_stats.metrics.apm-server.acm.response.errors.unauthorized", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Unauthorized", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Response Unauthorized Errors Agent Configuration Management", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_acm_response_errors_unavailable": ApmEventsRateClusterMetric { @@ -319,15 +382,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Unavailable HTTP response count. Possible misconfiguration or unsupported version of Kibana", + "docType": undefined, "field": "beats_stats.metrics.apm-server.acm.response.errors.unavailable", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Unavailable", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Response Unavailable Errors Agent Configuration Management", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_acm_response_valid_notmodified": ApmEventsRateClusterMetric { @@ -360,15 +432,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "304 Not modified response count", + "docType": undefined, "field": "beats_stats.metrics.apm-server.acm.response.valid.notmodified", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Not Modified", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Response Not Modified Agent Configuration Management", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_acm_response_valid_ok": ApmEventsRateClusterMetric { @@ -401,15 +482,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "200 OK response count", + "docType": undefined, "field": "beats_stats.metrics.apm-server.acm.response.valid.ok", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "OK", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Response OK Count Agent Configuration Management", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_cgroup_cpu": QuotaMetric { @@ -446,12 +536,16 @@ Object { }, "app": "apm", "calculation": [Function], + "dateHistogramSubAggs": undefined, "derivative": true, "description": "CPU Usage time compared to the CPU quota shown in percentage. If CPU quotas are not set, then no data will be shown.", + "docType": undefined, "field": "beats_stats.metrics.beat.cpu.total.value", "fieldSource": "beats_stats.metrics.beat.cgroup", "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Cgroup CPU Utilization", + "mbField": undefined, "metricAgg": "max", "periodsField": "cpu.stats.periods", "quotaField": "cpu.cfs.quota.us", @@ -462,82 +556,141 @@ Object { "uuidField": "beats_stats.beat.uuid", }, "apm_cgroup_memory_limit": ApmMetric { + "aggs": undefined, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Memory limit of the container", + "docType": undefined, "field": "beats_stats.metrics.beat.cgroup.memory.mem.limit.bytes", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Memory Limit", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Memory", "units": "B", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "apm_cgroup_memory_usage": ApmMetric { + "aggs": undefined, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Memory usage of the container", + "docType": undefined, "field": "beats_stats.metrics.beat.cgroup.memory.mem.usage.bytes", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Memory Utilization (cgroup)", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Memory", "units": "B", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "apm_cpu_total": ApmCpuUtilizationMetric { + "aggs": undefined, "app": "apm", "calculation": [Function], + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Percentage of CPU time spent executing (user+kernel mode) for the APM process", + "docType": undefined, "field": "beats_stats.metrics.beat.cpu.total.value", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Total", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "CPU Utilization", "units": "%", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "apm_mem_alloc": ApmMetric { + "aggs": undefined, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Allocated memory", + "docType": undefined, "field": "beats_stats.metrics.beat.memstats.memory_alloc", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Allocated Memory", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Memory", "units": "B", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "apm_mem_gc_next": ApmMetric { + "aggs": undefined, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Limit of allocated memory at which garbage collection will occur", + "docType": undefined, "field": "beats_stats.metrics.beat.memstats.gc_next", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "GC Next", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Memory", "units": "B", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "apm_mem_rss": ApmMetric { + "aggs": undefined, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Resident set size of memory reserved by the APM service from the OS", + "docType": undefined, "field": "beats_stats.metrics.beat.memstats.rss", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Process Total", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Memory", "units": "B", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "apm_output_events_acked": ApmEventsRateClusterMetric { @@ -570,15 +723,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Events processed by the output (including retries)", + "docType": undefined, "field": "beats_stats.metrics.libbeat.output.events.acked", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Acked", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Output Acked Events Rate", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_output_events_active": ApmEventsRateClusterMetric { @@ -611,15 +773,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Events processed by the output (including retries)", + "docType": undefined, "field": "beats_stats.metrics.libbeat.output.events.active", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Active", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Output Active Events Rate", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_output_events_dropped": ApmEventsRateClusterMetric { @@ -652,15 +823,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Events processed by the output (including retries)", + "docType": undefined, "field": "beats_stats.metrics.libbeat.output.events.dropped", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Dropped", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Output Dropped Events Rate", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_output_events_failed": ApmEventsRateClusterMetric { @@ -693,15 +873,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Events processed by the output (including retries)", + "docType": undefined, "field": "beats_stats.metrics.libbeat.output.events.failed", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Failed", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Output Failed Events Rate", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_output_events_total": ApmEventsRateClusterMetric { @@ -734,15 +923,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Events processed by the output (including retries)", + "docType": undefined, "field": "beats_stats.metrics.libbeat.output.events.total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Total", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Output Events Rate", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_processor_error_transformations": ApmEventsRateClusterMetric { @@ -775,15 +973,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Error events processed", + "docType": undefined, "field": "beats_stats.metrics.apm-server.processor.error.transformations", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Error", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Transformations", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_processor_metric_transformations": ApmEventsRateClusterMetric { @@ -816,15 +1023,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Metric events processed", + "docType": undefined, "field": "beats_stats.metrics.apm-server.processor.metric.transformations", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Metric", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Transformations", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_processor_span_transformations": ApmEventsRateClusterMetric { @@ -857,15 +1073,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Span events processed", + "docType": undefined, "field": "beats_stats.metrics.apm-server.processor.span.transformations", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Span", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Transformations", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_processor_transaction_transformations": ApmEventsRateClusterMetric { @@ -898,15 +1123,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Transaction events processed", + "docType": undefined, "field": "beats_stats.metrics.apm-server.processor.transaction.transformations", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Transaction", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Processed Events", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_requests": ApmEventsRateClusterMetric { @@ -939,15 +1173,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "HTTP Requests received by server", + "docType": undefined, "field": "beats_stats.metrics.apm-server.server.request.count", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Requested", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Request Count Intake API", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_responses_count": ApmEventsRateClusterMetric { @@ -980,15 +1223,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "HTTP Requests responded to by server", + "docType": undefined, "field": "beats_stats.metrics.apm-server.server.response.count", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Total", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Response Count Intake API", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_responses_errors_closed": ApmEventsRateClusterMetric { @@ -1021,15 +1273,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "HTTP Requests rejected during server shutdown", + "docType": undefined, "field": "beats_stats.metrics.apm-server.server.response.errors.closed", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Closed", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Closed", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_responses_errors_concurrency": ApmEventsRateClusterMetric { @@ -1062,15 +1323,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "HTTP Requests rejected due to overall concurrency limit breach", + "docType": undefined, "field": "beats_stats.metrics.apm-server.server.response.errors.concurrency", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Concurrency", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Concurrency", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_responses_errors_decode": ApmEventsRateClusterMetric { @@ -1103,15 +1373,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "HTTP Requests rejected to due decoding errors - invalid json, incorrect data type for entity", + "docType": undefined, "field": "beats_stats.metrics.apm-server.server.response.errors.decode", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Decode", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Decode", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_responses_errors_forbidden": ApmEventsRateClusterMetric { @@ -1144,15 +1423,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Forbidden HTTP Requests rejected - CORS violation, disabled enpoint", + "docType": undefined, "field": "beats_stats.metrics.apm-server.server.response.errors.forbidden", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Forbidden", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Forbidden", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_responses_errors_internal": ApmEventsRateClusterMetric { @@ -1185,15 +1473,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "HTTP Requests rejected due to a miscellaneous internal error", + "docType": undefined, "field": "beats_stats.metrics.apm-server.server.response.errors.internal", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Internal", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Internal", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_responses_errors_method": ApmEventsRateClusterMetric { @@ -1226,15 +1523,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "HTTP Requests rejected due to incorrect HTTP method", + "docType": undefined, "field": "beats_stats.metrics.apm-server.server.response.errors.method", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Method", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Method", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_responses_errors_queue": ApmEventsRateClusterMetric { @@ -1267,15 +1573,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "HTTP Requests rejected to due internal queue filling up", + "docType": undefined, "field": "beats_stats.metrics.apm-server.server.response.errors.queue", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Queue", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Queue", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_responses_errors_ratelimit": ApmEventsRateClusterMetric { @@ -1308,15 +1623,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "HTTP Requests rejected to due excessive rate limit", + "docType": undefined, "field": "beats_stats.metrics.apm-server.server.response.errors.ratelimit", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Rate limit", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Rate limit", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_responses_errors_toolarge": ApmEventsRateClusterMetric { @@ -1349,15 +1673,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "HTTP Requests rejected due to excessive payload size", + "docType": undefined, "field": "beats_stats.metrics.apm-server.server.response.errors.toolarge", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Too large", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Response Errors Intake API", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_responses_errors_unauthorized": ApmEventsRateClusterMetric { @@ -1390,15 +1723,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "HTTP Requests rejected due to invalid secret token", + "docType": undefined, "field": "beats_stats.metrics.apm-server.server.response.errors.unauthorized", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Unauthorized", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Unauthorized", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_responses_errors_validate": ApmEventsRateClusterMetric { @@ -1431,15 +1773,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "HTTP Requests rejected due to payload validation error", + "docType": undefined, "field": "beats_stats.metrics.apm-server.server.response.errors.validate", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Validate", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Validate", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_responses_valid_accepted": ApmEventsRateClusterMetric { @@ -1472,15 +1823,24 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "HTTP Requests successfully reporting new events", + "docType": undefined, "field": "beats_stats.metrics.apm-server.server.response.valid.accepted", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Accepted", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Accepted", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_responses_valid_ok": ApmEventsRateClusterMetric { @@ -1513,79 +1873,138 @@ Object { }, }, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "200 OK response count", + "docType": undefined, "field": "beats_stats.metrics.apm-server.server.response.valid.ok", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Ok", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Ok", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "apm_system_os_load_1": ApmMetric { + "aggs": undefined, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Load average over the last 1 minute", + "docType": undefined, "field": "beats_stats.metrics.system.load.1", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "1m", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "System Load", "units": "", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "apm_system_os_load_15": ApmMetric { + "aggs": undefined, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Load average over the last 15 minutes", + "docType": undefined, "field": "beats_stats.metrics.system.load.15", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "15m", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "System Load", "units": "", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "apm_system_os_load_5": ApmMetric { + "aggs": undefined, "app": "apm", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Load average over the last 5 minutes", + "docType": undefined, "field": "beats_stats.metrics.system.load.5", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "5m", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "System Load", "units": "", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "app_search_total_engines": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Current number of App Search engines within the Enterprise Search deployment.", + "docType": undefined, "field": "enterprisesearch.stats.product_usage.app_search.total_engines", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "App Search Engines", + "mbField": undefined, "metricAgg": "avg", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "units": "", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "beat_bytes_written": BeatsByteRateMetric { + "aggs": undefined, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Bytes written to the output (consists of size of network headers and compressed payload)", + "docType": undefined, "field": "beats_stats.metrics.libbeat.output.write.bytes", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Bytes Sent", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Throughput", "units": "/s", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "beat_cluster_output_events_ack_rate": BeatsEventsRateClusterMetric { @@ -1618,15 +2037,24 @@ Object { }, }, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Events acknowledged by the output (includes events dropped by the output)", + "docType": undefined, "field": "beats_stats.metrics.libbeat.output.events.acked", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Acknowledged", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Events Rate", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "beat_cluster_output_events_dropped_rate": BeatsEventsRateClusterMetric { @@ -1659,15 +2087,24 @@ Object { }, }, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "(Fatal drop) Events dropped by the output as being \\"invalid.\\" The output still acknowledges the event for the Beat to remove it from the queue.", + "docType": undefined, "field": "beats_stats.metrics.libbeat.output.events.dropped", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Dropped in Output", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Fail Rates", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "beat_cluster_output_events_total": BeatsEventsRateClusterMetric { @@ -1700,15 +2137,24 @@ Object { }, }, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Events processed by the output (including retries)", + "docType": undefined, "field": "beats_stats.metrics.libbeat.output.events.total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Emitted", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Events Rate", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "beat_cluster_output_read_bytes_rate": BeatsByteRateClusterMetric { @@ -1741,15 +2187,24 @@ Object { }, }, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Bytes read in response from the output", + "docType": undefined, "field": "beats_stats.metrics.libbeat.output.read.bytes", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Bytes Received", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Throughput", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "beat_cluster_output_receiving_errors": BeatsEventsRateClusterMetric { @@ -1782,15 +2237,24 @@ Object { }, }, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Errors in reading the response from the output", + "docType": undefined, "field": "beats_stats.metrics.libbeat.output.read.errors", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Receiving", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Output Errors", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "beat_cluster_output_sending_errors": BeatsEventsRateClusterMetric { @@ -1823,15 +2287,24 @@ Object { }, }, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Errors in writing the response from the output", + "docType": undefined, "field": "beats_stats.metrics.libbeat.output.write.errors", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Sending", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Output Errors", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "beat_cluster_output_write_bytes_rate": BeatsByteRateClusterMetric { @@ -1864,15 +2337,24 @@ Object { }, }, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Bytes written to the output (consists of size of network headers and compressed payload)", + "docType": undefined, "field": "beats_stats.metrics.libbeat.output.write.bytes", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Bytes Sent", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Throughput", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "beat_cluster_pipeline_events_dropped_rate": BeatsEventsRateClusterMetric { @@ -1905,15 +2387,24 @@ Object { }, }, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Events that have been dropped after N retries (N = max_retries setting)", + "docType": undefined, "field": "beats_stats.metrics.libbeat.pipeline.events.dropped", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Dropped in Pipeline", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Fail Rates", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "beat_cluster_pipeline_events_emitted_rate": BeatsEventsRateClusterMetric { @@ -1946,15 +2437,24 @@ Object { }, }, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Events added to the event pipeline queue", + "docType": undefined, "field": "beats_stats.metrics.libbeat.pipeline.events.published", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Queued", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Events Rate", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "beat_cluster_pipeline_events_failed_rate": BeatsEventsRateClusterMetric { @@ -1987,15 +2487,24 @@ Object { }, }, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Failures that happened before event was added to the publishing pipeline (output was disabled or publisher client closed)", + "docType": undefined, "field": "beats_stats.metrics.libbeat.pipeline.events.failed", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Failed in Pipeline", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Fail Rates", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "beat_cluster_pipeline_events_retry_rate": BeatsEventsRateClusterMetric { @@ -2028,15 +2537,24 @@ Object { }, }, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Events in the pipeline that are trying again to be sent to the output", + "docType": undefined, "field": "beats_stats.metrics.libbeat.pipeline.events.retry", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Retry in Pipeline", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Fail Rates", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "beat_cluster_pipeline_events_total_rate": BeatsEventsRateClusterMetric { @@ -2069,263 +2587,461 @@ Object { }, }, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "All events newly created in the publishing pipeline", + "docType": undefined, "field": "beats_stats.metrics.libbeat.pipeline.events.total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Total", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Events Rate", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "beat_cpu_utilization": BeatsCpuUtilizationMetric { + "aggs": undefined, "app": "beats", "calculation": [Function], + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Percentage of CPU time spent executing (user+kernel mode) for the Beat process", + "docType": undefined, "field": "beats_stats.metrics.beat.cpu.total.value", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Total", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "CPU Utilization", "units": "%", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "beat_handles_open": BeatsMetric { + "aggs": undefined, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Count of open file handlers", + "docType": undefined, "field": "beats_stats.metrics.beat.handles.open", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Open Handles", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Open Handles", "units": "", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "beat_mem_alloc": BeatsMetric { + "aggs": undefined, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Private memory in active use by the Beat", + "docType": undefined, "field": "beats_stats.metrics.beat.memstats.memory_alloc", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Active", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Memory", "units": "B", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "beat_mem_gc_next": BeatsMetric { + "aggs": undefined, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Limit of allocated memory at which garbage collection will occur", + "docType": undefined, "field": "beats_stats.metrics.beat.memstats.gc_next", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "GC Next", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Memory", "units": "B", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "beat_mem_rss": BeatsMetric { + "aggs": undefined, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Resident set size of memory reserved by the Beat from the OS", + "docType": undefined, "field": "beats_stats.metrics.beat.memstats.rss", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Process Total", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Memory", "units": "B", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "beat_output_events_ack_rate": BeatsEventsRateMetric { + "aggs": undefined, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Events acknowledged by the output (includes events dropped by the output)", + "docType": undefined, "field": "beats_stats.metrics.libbeat.output.events.acked", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Acknowledged", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Events Rate", "units": "/s", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "beat_output_events_dropped_rate": BeatsEventsRateMetric { + "aggs": undefined, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "(Fatal drop) Events dropped by the output as being \\"invalid.\\" The output still acknowledges the event for the Beat to remove it from the queue.", + "docType": undefined, "field": "beats_stats.metrics.libbeat.output.events.dropped", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Dropped in Output", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Fail Rates", "units": "/s", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "beat_output_events_total": BeatsEventsRateMetric { + "aggs": undefined, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Events processed by the output (including retries)", + "docType": undefined, "field": "beats_stats.metrics.libbeat.output.events.total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Emitted", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Events Rate", "units": "/s", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "beat_output_receiving_errors": BeatsEventsRateMetric { + "aggs": undefined, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Errors in reading the response from the output", + "docType": undefined, "field": "beats_stats.metrics.libbeat.output.read.errors", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Receiving", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Output Errors", "units": "/s", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "beat_output_sending_errors": BeatsEventsRateMetric { + "aggs": undefined, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Errors in writing the response from the output", + "docType": undefined, "field": "beats_stats.metrics.libbeat.output.write.errors", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Sending", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Output Errors", "units": "/s", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "beat_output_write_bytes_rate": BeatsByteRateMetric { + "aggs": undefined, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Bytes read in response from the output", + "docType": undefined, "field": "beats_stats.metrics.libbeat.output.read.bytes", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Bytes Received", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Throughput", "units": "/s", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "beat_pipeline_events_dropped_rate": BeatsEventsRateMetric { + "aggs": undefined, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Events that have been dropped after N retries (N = max_retries setting)", + "docType": undefined, "field": "beats_stats.metrics.libbeat.pipeline.events.dropped", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Dropped in Pipeline", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Fail Rates", "units": "/s", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "beat_pipeline_events_emitted_rate": BeatsEventsRateMetric { + "aggs": undefined, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Events added to the event pipeline queue", + "docType": undefined, "field": "beats_stats.metrics.libbeat.pipeline.events.published", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Queued", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Events Rate", "units": "/s", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "beat_pipeline_events_failed_rate": BeatsEventsRateMetric { + "aggs": undefined, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Failures that happened before event was added to the publishing pipeline (output was disabled or publisher client closed)", + "docType": undefined, "field": "beats_stats.metrics.libbeat.pipeline.events.failed", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Failed in Pipeline", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Fail Rates", "units": "/s", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "beat_pipeline_events_retry_rate": BeatsEventsRateMetric { + "aggs": undefined, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Events in the pipeline that are trying again to be sent to the output", + "docType": undefined, "field": "beats_stats.metrics.libbeat.pipeline.events.retry", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Retry in Pipeline", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Fail Rates", "units": "/s", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "beat_pipeline_events_total_rate": BeatsEventsRateMetric { + "aggs": undefined, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "New events sent to the publishing pipeline", + "docType": undefined, "field": "beats_stats.metrics.libbeat.pipeline.events.total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "New", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "Events Rate", "units": "/s", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "beat_system_os_load_1": BeatsMetric { + "aggs": undefined, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Load average over the last 1 minute", + "docType": undefined, "field": "beats_stats.metrics.system.load.1", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "1m", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "System Load", "units": "", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "beat_system_os_load_15": BeatsMetric { + "aggs": undefined, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Load average over the last 15 minutes", + "docType": undefined, "field": "beats_stats.metrics.system.load.15", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "15m", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "System Load", "units": "", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "beat_system_os_load_5": BeatsMetric { + "aggs": undefined, "app": "beats", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Load average over the last 5 minutes", + "docType": undefined, "field": "beats_stats.metrics.system.load.5", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "5m", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "beats_stats.timestamp", "title": "System Load", "units": "", + "usageField": undefined, "uuidField": "beats_stats.beat.uuid", }, "ccr_sync_lag_ops": DifferenceMetric { @@ -2343,32 +3059,49 @@ Object { }, "app": "elasticsearch", "calculation": [Function], + "dateHistogramSubAggs": undefined, "derivative": false, "description": "The number of operations the follower index is lagging behind the leader.", + "docType": undefined, "field": "", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "getFields": [Function], "label": "Ops delay", + "mbField": undefined, "metricAgg": "sum", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Ops delay", "type": "ccr", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "ccr_sync_lag_time": MillisecondsToSecondsMetric { + "aggs": undefined, "app": "elasticsearch", "calculation": [Function], + "dateHistogramSubAggs": undefined, "derivative": false, "description": "The amount of time the follower index is lagging behind the leader.", + "docType": undefined, "field": "ccr_stats.time_since_last_read_millis", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Fetch delay", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Fetch delay", "type": "ccr", "units": "s", + "usageField": undefined, "uuidField": "source_node.uuid", }, "cluster_index_latency": LatencyMetric { @@ -2400,43 +3133,71 @@ Object { }, "app": "elasticsearch", "calculation": [Function], + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Average latency for indexing documents, which is time it takes to index documents divided by number that were indexed. This only considers primary shards.", + "docType": undefined, "field": "indices_stats._all.primaries.indexing.index_total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Indexing Latency", + "mbField": undefined, "metricAgg": "sum", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "type": "cluster", "units": "ms", + "usageField": undefined, "uuidField": "source_node.uuid", }, "cluster_index_request_rate_primary": RequestRateMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Number of documents being indexed for primary shards.", + "docType": undefined, "field": "indices_stats._all.primaries.indexing.index_total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Primary Shards", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Indexing Rate", "type": "index", "units": "/s", + "usageField": undefined, "uuidField": "source_node.uuid", }, "cluster_index_request_rate_total": RequestRateMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Number of documents being indexed for primary and replica shards.", + "docType": undefined, "field": "indices_stats._all.total.indexing.index_total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Total Shards", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Indexing Rate", "type": "index", "units": "/s", + "usageField": undefined, "uuidField": "source_node.uuid", }, "cluster_query_latency": LatencyMetric { @@ -2468,311 +3229,559 @@ Object { }, "app": "elasticsearch", "calculation": [Function], + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Average latency for searching, which is time it takes to execute searches divided by number of searches submitted. This considers primary and replica shards.", + "docType": undefined, "field": "indices_stats._all.total.search.query_total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Search Latency", + "mbField": undefined, "metricAgg": "sum", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "type": "cluster", "units": "ms", + "usageField": undefined, "uuidField": "source_node.uuid", }, "cluster_search_request_rate": RequestRateMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Number of search requests being executed across primary and replica shards. A single search can run against multiple shards!", + "docType": undefined, "field": "indices_stats._all.total.search.query_total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Total Shards", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Search Rate", "type": "cluster", "units": "/s", + "usageField": undefined, "uuidField": "source_node.uuid", }, "crawler_workers_active": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Currently active App Search crawler workers.", + "docType": undefined, "field": "enterprisesearch.health.crawler.workers.active", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Active", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "units": "", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "crawler_workers_total": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "The number of crawler workers configured across all instances of App Search.", + "docType": undefined, "field": "enterprisesearch.health.crawler.workers.pool_size", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Total", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "title": "Crawler Workers", "units": "", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "enterprise_search_daemon_threads_current": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Currently running JVM daemon threads used by the application.", + "docType": undefined, "field": "enterprisesearch.health.jvm.threads.daemon", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Daemon Threads", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "units": "", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "enterprise_search_gc_rate": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "The rate of JVM garbage collector invocations across the fleet.", + "docType": undefined, "field": "enterprisesearch.health.jvm.gc.collection_count", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "JVM GC Rate", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "units": "/s", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "enterprise_search_gc_time": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Time spent performing JVM garbage collections.", + "docType": undefined, "field": "enterprisesearch.health.jvm.gc.collection_time.ms", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Time spent on JVM garbage collection", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "units": "ms", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "enterprise_search_heap_committed": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "The amount of memory JVM has allocated from the OS and is available to the application.", + "docType": undefined, "field": "enterprisesearch.health.jvm.memory_usage.heap_committed.bytes", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Committed", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "units": "bytes", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "enterprise_search_heap_total": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Maximum amount of JVM heap memory available to the application.", + "docType": undefined, "field": "enterprisesearch.health.jvm.memory_usage.heap_max.bytes", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Total", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "title": "JVM Heap Usage", "units": "bytes", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "enterprise_search_heap_used": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Current amount of JVM Heam memory used by the application.", + "docType": undefined, "field": "enterprisesearch.health.jvm.memory_usage.heap_used.bytes", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Used", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "units": "bytes", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "enterprise_search_http_1xx_rate": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Outgoing HTTP 1xx responses across all instances in the deployment.", + "docType": undefined, "field": "enterprisesearch.stats.http.responses.1xx", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "1xx", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "title": "HTTP Responses", "units": "/s", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "enterprise_search_http_2xx_rate": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Outgoing HTTP 2xx responses across all instances in the deployment.", + "docType": undefined, "field": "enterprisesearch.stats.http.responses.2xx", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "2xx", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "units": "/s", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "enterprise_search_http_3xx_rate": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Outgoing HTTP 3xx responses across all instances in the deployment.", + "docType": undefined, "field": "enterprisesearch.stats.http.responses.3xx", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "3xx", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "units": "/s", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "enterprise_search_http_4xx_rate": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Outgoing HTTP 4xx responses across all instances in the deployment.", + "docType": undefined, "field": "enterprisesearch.stats.http.responses.4xx", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "4xx", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "units": "/s", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "enterprise_search_http_5xx_rate": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Outgoing HTTP 5xx responses across all instances in the deployment.", + "docType": undefined, "field": "enterprisesearch.stats.http.responses.5xx", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "5xx", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "units": "/s", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "enterprise_search_http_bytes_received_rate": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Incoming HTTP traffic rate across all instances in the deployment.", + "docType": undefined, "field": "enterprisesearch.stats.http.network.received.bytes", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Received", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "title": "HTTP Traffic", "units": "/s", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "enterprise_search_http_bytes_received_total": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Total number of bytes received by all instances in the deployment.", + "docType": undefined, "field": "enterprisesearch.stats.http.network.received.bytes", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "HTTP Bytes Received", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "units": "bytes", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "enterprise_search_http_bytes_sent_rate": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Outgoing HTTP traffic across all instances in the deployment.", + "docType": undefined, "field": "enterprisesearch.stats.http.network.sent.bytes", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Sent", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "units": "/s", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "enterprise_search_http_bytes_sent_total": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Total number of bytes sent by all instances in the deployment.", + "docType": undefined, "field": "enterprisesearch.stats.http.network.sent.bytes", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "HTTP Bytes Sent", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "units": "bytes", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "enterprise_search_http_connections_current": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Currently open incoming HTTP connections across all instances.", + "docType": undefined, "field": "enterprisesearch.stats.http.connections.current", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Open HTTP Connections", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "units": "", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "enterprise_search_http_connections_rate": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "The rate of incoming HTTP connections across all instances.", + "docType": undefined, "field": "enterprisesearch.stats.http.connections.total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "HTTP Connections Rate", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "units": "/s", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "enterprise_search_jvm_finalizer_queue": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Number of objects within the JVM heap waiting for the finalizer thread.", + "docType": undefined, "field": "enterprisesearch.health.jvm.memory_usage.object_pending_finalization_count", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "JVM Objects Pending Finalization", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "units": "", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "enterprise_search_threads_current": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Currently running JVM threads used by the application.", + "docType": undefined, "field": "enterprisesearch.health.jvm.threads.current", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Active Threads", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "title": "JVM Threads", "units": "", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "enterprise_search_threads_rate": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Currently running JVM threads used by the application.", + "docType": undefined, "field": "enterprisesearch.health.jvm.threads.total_started", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Thread Creation Rate", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "units": "/s", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "index_document_count": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Total number of documents, only including primary shards.", + "docType": undefined, "field": "index_stats.primaries.docs.count", + "fieldSource": undefined, "format": "0,0.[0]a", + "getDateHistogramSubAggs": undefined, "label": "Document Count", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "type": "index", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_index_latency": LatencyMetric { @@ -2804,155 +3813,263 @@ Object { }, "app": "elasticsearch", "calculation": [Function], + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Average latency for indexing documents, which is time it takes to index documents divided by number that were indexed. This only considers primary shards.", + "docType": undefined, "field": "index_stats.primaries.indexing.index_total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Indexing Latency", + "mbField": undefined, "metricAgg": "sum", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Latency", "type": "cluster", "units": "ms", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_indexing_primaries_time": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Amount of time spent performing index operations on primary shards only.", + "docType": undefined, "field": "index_stats.primaries.indexing.index_time_in_millis", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Indexing (Primaries)", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Request Time", "type": "index", "units": "ms", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_indexing_total": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Amount of indexing operations.", + "docType": undefined, "field": "index_stats.primaries.indexing.index_total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Index Total", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Request Rate", "type": "index", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_indexing_total_time": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Amount of time spent performing index operations on primary and replica shards.", + "docType": undefined, "field": "index_stats.total.indexing.index_time_in_millis", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Indexing", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Request Time", "type": "index", "units": "ms", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_mem_fielddata": IndexMemoryMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Heap memory used by Fielddata (e.g., global ordinals or explicitly enabled fielddata on text fields). This is for the same shards, but not a part of Lucene Total.", + "docType": undefined, "field": "index_stats.total.fielddata.memory_size_in_bytes", + "fieldSource": undefined, "format": "0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Fielddata", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Index Memory", "type": "index", "units": "B", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_mem_fixed_bit_set": SingleIndexMemoryMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Heap memory used by Fixed Bit Sets (e.g., deeply nested documents). This is a part of Lucene Total.", + "docType": undefined, "field": "index_stats.total.segments.fixed_bit_set_memory_in_bytes", + "fieldSource": undefined, "format": "0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Fixed Bitsets", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Index Memory - Lucene", "type": "index", "units": "B", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_mem_query_cache": IndexMemoryMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Heap memory used by Query Cache (e.g., cached filters). This is for the same shards, but not a part of Lucene Total.", + "docType": undefined, "field": "index_stats.total.query_cache.memory_size_in_bytes", + "fieldSource": undefined, "format": "0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Query Cache", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Index Memory - Elasticsearch", "type": "index", "units": "B", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_mem_request_cache": IndexMemoryMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Heap memory used by Request Cache (e.g., instant aggregations). This is for the same shards, but not a part of Lucene Total.", + "docType": undefined, "field": "index_stats.total.request_cache.memory_size_in_bytes", + "fieldSource": undefined, "format": "0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Request Cache", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Index Memory", "type": "index", "units": "B", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_mem_versions": SingleIndexMemoryMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Heap memory used by Versioning (e.g., updates and deletes). This is NOT a part of Lucene Total.", + "docType": undefined, "field": "index_stats.total.segments.version_map_memory_in_bytes", + "fieldSource": undefined, "format": "0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Version Map", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Index Memory", "type": "index", "units": "B", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_mem_writer": SingleIndexMemoryMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Heap memory used by the Index Writer. This is NOT a part of Lucene Total.", + "docType": undefined, "field": "index_stats.total.segments.index_writer_memory_in_bytes", + "fieldSource": undefined, "format": "0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Index Writer", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Index Memory", "type": "index", "units": "B", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_merge_rate": RequestRateMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Amount in bytes of merged segments. Larger numbers indicate heavier disk activity.", + "docType": undefined, "field": "index_stats.total.merges.total_size_in_bytes", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Merge Rate", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "type": "index", "units": "/s", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_query_latency": LatencyMetric { @@ -2984,276 +4101,474 @@ Object { }, "app": "elasticsearch", "calculation": [Function], + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Average latency for searching, which is time it takes to execute searches divided by number of searches submitted. This considers primary and replica shards.", + "docType": undefined, "field": "index_stats.total.search.query_total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Search Latency", + "mbField": undefined, "metricAgg": "sum", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "type": "cluster", "units": "ms", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_refresh_time": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Time spent on Elasticsearch refresh for primary and replica shards.", + "docType": undefined, "field": "index_stats.total.refresh.total_time_in_millis", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Total Refresh Time", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "type": "index", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_request_rate_primary": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Number of documents being indexed for primary shards.", + "docType": undefined, "field": "index_stats.primaries.indexing.index_total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Primary Shards", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Indexing Rate", "type": "index", "units": "/s", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_request_rate_total": RequestRateMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Number of documents being indexed for primary and replica shards.", + "docType": undefined, "field": "index_stats.total.indexing.index_total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Total Shards", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Indexing Rate", "type": "index", "units": "/s", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_search_request_rate": RequestRateMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Number of search requests being executed across primary and replica shards. A single search can run against multiple shards!", + "docType": undefined, "field": "index_stats.total.search.query_total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Total Shards", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Search Rate", "type": "index", "units": "/s", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_searching_time": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Amount of time spent performing search operations (per shard).", + "docType": undefined, "field": "index_stats.total.search.query_time_in_millis", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Search", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Request Time", "type": "index", "units": "ms", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_searching_total": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Amount of search operations (per shard).", + "docType": undefined, "field": "index_stats.total.search.query_total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Search Total", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Request Rate", "type": "index", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_segment_count_primaries": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Number of segments for primary shards.", + "docType": undefined, "field": "index_stats.primaries.segments.count", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Primaries", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Segment Count", "type": "index", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_segment_count_total": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Number of segments for primary and replica shards.", + "docType": undefined, "field": "index_stats.total.segments.count", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Total", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Segment Count", "type": "index", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_segment_merge_primaries_size": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Size of merges on primary shards.", + "docType": undefined, "field": "index_stats.primaries.merges.total_size_in_bytes", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Merges (Primaries)", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Disk", "type": "index", "units": "B", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_segment_merge_total_size": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Size of merges on primary and replica shards.", + "docType": undefined, "field": "index_stats.total.merges.total_size_in_bytes", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Merges", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Disk", "type": "index", "units": "B", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_segment_refresh_primaries_time": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Amount of time spent to perform refresh operations on primary shards.", + "docType": undefined, "field": "index_stats.primaries.refresh.total_time_in_millis", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Primaries", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Refresh Time", "type": "index", "units": "ms", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_segment_refresh_total_time": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Amount of time spent to perform refresh operations on primary and replica shards.", + "docType": undefined, "field": "index_stats.total.refresh.total_time_in_millis", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Total", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Refresh Time", "type": "index", "units": "ms", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_store_primaries_size": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Size of primary shards on disk.", + "docType": undefined, "field": "index_stats.primaries.store.size_in_bytes", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Store (Primaries)", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Disk", "type": "index", "units": "B", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_store_total_size": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Size of primary and replica shards on disk.", + "docType": undefined, "field": "index_stats.total.store.size_in_bytes", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Store", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Disk", "type": "index", "units": "B", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_throttle_time": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Amount of time spent with index throttling, which indicates slow merging.", + "docType": undefined, "field": "index_stats.primaries.indexing.throttle_time_in_millis", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Index Throttling Time", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "type": "index", "units": "ms", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_throttling_indexing_primaries_time": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Amount of time spent throttling index operations on primary shards.", + "docType": undefined, "field": "index_stats.primaries.indexing.throttle_time_in_millis", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Indexing (Primaries)", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Throttle Time", "type": "index", "units": "ms", + "usageField": undefined, "uuidField": "source_node.uuid", }, "index_throttling_indexing_total_time": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Amount of time spent throttling index operations on primary and replica shards.", + "docType": undefined, "field": "index_stats.total.indexing.throttle_time_in_millis", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Indexing", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Throttle Time", "type": "index", "units": "ms", + "usageField": undefined, "uuidField": "source_node.uuid", }, "kibana_average_concurrent_connections": KibanaMetric { + "aggs": undefined, "app": "kibana", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Total number of open socket connections to the Kibana instance.", + "docType": undefined, "field": "kibana_stats.concurrent_connections", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "HTTP Connections", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "kibana_stats.timestamp", "units": "", + "usageField": undefined, "uuidField": "kibana_stats.kibana.uuid", }, "kibana_average_response_times": KibanaMetric { + "aggs": undefined, "app": "kibana", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Average response time for client requests to the Kibana instance.", + "docType": undefined, "field": "kibana_stats.response_times.average", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Average", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "kibana_stats.timestamp", "title": "Client Response Time", "units": "ms", + "usageField": undefined, "uuidField": "kibana_stats.kibana.uuid", }, "kibana_cluster_average_response_times": KibanaEventsRateClusterMetric { @@ -3286,15 +4601,24 @@ Object { }, }, "app": "kibana", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Average response time for client requests to the Kibana instance.", + "docType": undefined, "field": "kibana_stats.response_times.average", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Average", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "kibana_stats.timestamp", "title": "Client Response Time", "units": "ms", + "usageField": undefined, "uuidField": "cluster_uuid", }, "kibana_cluster_max_response_times": KibanaEventsRateClusterMetric { @@ -3327,15 +4651,24 @@ Object { }, }, "app": "kibana", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Maximum response time for client requests to the Kibana instance.", + "docType": undefined, "field": "kibana_stats.response_times.max", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Max", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "kibana_stats.timestamp", "title": "Client Response Time", "units": "ms", + "usageField": undefined, "uuidField": "cluster_uuid", }, "kibana_cluster_requests": KibanaEventsRateClusterMetric { @@ -3368,128 +4701,227 @@ Object { }, }, "app": "kibana", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Total number of client requests received by the Kibana instance.", + "docType": undefined, "field": "kibana_stats.requests.total", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Client Requests", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "kibana_stats.timestamp", "units": "", + "usageField": undefined, "uuidField": "cluster_uuid", }, "kibana_max_response_times": KibanaMetric { + "aggs": undefined, "app": "kibana", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Maximum response time for client requests to the Kibana instance.", + "docType": undefined, "field": "kibana_stats.response_times.max", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Max", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "kibana_stats.timestamp", "title": "Client Response Time", "units": "ms", + "usageField": undefined, "uuidField": "kibana_stats.kibana.uuid", }, "kibana_memory_heap_size_limit": KibanaMetric { + "aggs": undefined, "app": "kibana", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Limit of memory usage before garbage collection.", + "docType": undefined, "field": "kibana_stats.process.memory.heap.size_limit", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Heap Size Limit", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "kibana_stats.timestamp", "title": "Memory Size", "units": "B", + "usageField": undefined, "uuidField": "kibana_stats.kibana.uuid", }, "kibana_memory_size": KibanaMetric { + "aggs": undefined, "app": "kibana", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Total heap used by Kibana running in Node.js.", + "docType": undefined, "field": "kibana_stats.process.memory.resident_set_size_in_bytes", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Memory Size", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "kibana_stats.timestamp", "title": "Memory Size", "units": "B", + "usageField": undefined, "uuidField": "kibana_stats.kibana.uuid", }, "kibana_os_load_15m": KibanaMetric { + "aggs": undefined, "app": "kibana", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Load average over the last 15 minutes.", + "docType": undefined, "field": "kibana_stats.os.load.15m", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "15m", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "kibana_stats.timestamp", "title": "System Load", "units": "", + "usageField": undefined, "uuidField": "kibana_stats.kibana.uuid", }, "kibana_os_load_1m": KibanaMetric { + "aggs": undefined, "app": "kibana", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Load average over the last minute.", + "docType": undefined, "field": "kibana_stats.os.load.1m", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "1m", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "kibana_stats.timestamp", "title": "System Load", "units": "", + "usageField": undefined, "uuidField": "kibana_stats.kibana.uuid", }, "kibana_os_load_5m": KibanaMetric { + "aggs": undefined, "app": "kibana", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Load average over the last 5 minutes.", + "docType": undefined, "field": "kibana_stats.os.load.5m", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "5m", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "kibana_stats.timestamp", "title": "System Load", "units": "", + "usageField": undefined, "uuidField": "kibana_stats.kibana.uuid", }, "kibana_process_delay": KibanaMetric { + "aggs": undefined, "app": "kibana", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Delay in Kibana server event loops. Longer delays may indicate blocking events in server thread, such as synchronous functions taking large amount of CPU time.", + "docType": undefined, "field": "kibana_stats.process.event_loop_delay", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Event Loop Delay", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "kibana_stats.timestamp", "units": "ms", + "usageField": undefined, "uuidField": "kibana_stats.kibana.uuid", }, "kibana_requests_disconnects": KibanaMetric { + "aggs": undefined, "app": "kibana", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Total number of client disconnects to the Kibana instance.", + "docType": undefined, "field": "kibana_stats.requests.disconnects", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Client Disconnects", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "kibana_stats.timestamp", "units": "", + "usageField": undefined, "uuidField": "kibana_stats.kibana.uuid", }, "kibana_requests_total": KibanaMetric { + "aggs": undefined, "app": "kibana", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Total number of client requests received by the Kibana instance.", + "docType": undefined, "field": "kibana_stats.requests.total", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Client Requests", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "kibana_stats.timestamp", "units": "", + "usageField": undefined, "uuidField": "kibana_stats.kibana.uuid", }, "logstash_cluster_events_input_rate": LogstashEventsRateClusterMetric { @@ -3522,14 +4954,23 @@ Object { }, }, "app": "logstash", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Number of events received per second by all Logstash nodes at the inputs stage.", + "docType": undefined, "field": "logstash_stats.events.in", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Events Received Rate", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "logstash_cluster_events_latency": LogstashEventsLatencyClusterMetric { @@ -3581,14 +5022,22 @@ Object { }, "app": "logstash", "calculation": [Function], + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Average time spent by events in the filter and output stages, which is the total time it takes to process events divided by number of events emitted.", + "docType": undefined, "field": "logstash_stats.events.out", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Event Latency", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "units": "ms", + "usageField": undefined, "uuidField": "cluster_uuid", }, "logstash_cluster_events_output_rate": LogstashEventsRateClusterMetric { @@ -3621,52 +5070,89 @@ Object { }, }, "app": "logstash", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Number of events emitted per second by all Logstash nodes at the outputs stage.", + "docType": undefined, "field": "logstash_stats.events.out", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Events Emitted Rate", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "units": "/s", + "usageField": undefined, "uuidField": "cluster_uuid", }, "logstash_cluster_pipeline_nodes_count": LogstashPipelineNodeCountMetric { + "aggs": undefined, "app": "logstash", "calculation": [Function], + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Number of nodes on which the Logstash pipeline is running.", + "docType": undefined, "field": "logstash_stats.logstash.uuid", + "fieldSource": undefined, "format": "0,0.[00]", "getDateHistogramSubAggs": [Function], "label": "Pipeline Node Count", + "mbField": undefined, + "metricAgg": undefined, + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "units": "", + "usageField": undefined, "uuidField": "logstash_stats.logstash.uuid", }, "logstash_cluster_pipeline_throughput": LogstashPipelineThroughputMetric { + "aggs": undefined, "app": "logstash", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Number of events emitted per second by the Logstash pipeline at the outputs stage.", + "docType": undefined, "field": "logstash_stats.pipelines.events.out", + "fieldSource": undefined, "format": "0,0.[00]", "getDateHistogramSubAggs": [Function], "label": "Pipeline Throughput", "mbField": "logstash.node.stats.pipelines.events.out", + "metricAgg": undefined, + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "units": "e/s", + "usageField": undefined, "uuidField": "logstash_stats.logstash.uuid", }, "logstash_events_input_rate": LogstashEventsRateMetric { + "aggs": undefined, "app": "logstash", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Number of events received per second by the Logstash node at the inputs stage.", + "docType": undefined, "field": "logstash_stats.events.in", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Events Received Rate", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "units": "/s", + "usageField": undefined, "uuidField": "logstash_stats.logstash.uuid", }, "logstash_events_latency": LogstashEventsLatencyMetric { @@ -3698,39 +5184,67 @@ Object { }, "app": "logstash", "calculation": [Function], + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Average time spent by events in the filter and output stages, which is the total time it takes to process events divided by number of events emitted.", + "docType": undefined, "field": "logstash_stats.events.out", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Event Latency", + "mbField": undefined, "metricAgg": "sum", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "units": "ms", + "usageField": undefined, "uuidField": "logstash_stats.logstash.uuid", }, "logstash_events_output_rate": LogstashEventsRateMetric { + "aggs": undefined, "app": "logstash", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Number of events emitted per second by the Logstash node at the outputs stage.", + "docType": undefined, "field": "logstash_stats.events.out", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Events Emitted Rate", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "units": "/s", + "usageField": undefined, "uuidField": "logstash_stats.logstash.uuid", }, "logstash_node_cgroup_periods": LogstashMetric { + "aggs": undefined, "app": "logstash", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "The number of sampling periods from the Completely Fair Scheduler (CFS). Compare against the number of times throttled.", + "docType": undefined, "field": "logstash_stats.os.cgroup.cpu.stat.number_of_elapsed_periods", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Cgroup Elapsed Periods", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "title": "Cgroup CFS Stats", "units": "", + "usageField": undefined, "uuidField": "logstash_stats.logstash.uuid", }, "logstash_node_cgroup_quota": QuotaMetric { @@ -3767,12 +5281,16 @@ Object { }, "app": "logstash", "calculation": [Function], + "dateHistogramSubAggs": undefined, "derivative": true, "description": "CPU Usage time compared to the CPU quota shown in percentage. If CPU quotas are not set, then no data will be shown.", + "docType": undefined, "field": "logstash_stats.process.cpu.percent", "fieldSource": "logstash_stats.os.cgroup", "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Cgroup CPU Utilization", + "mbField": undefined, "metricAgg": "max", "periodsField": "cpu.stat.number_of_elapsed_periods", "quotaField": "cpu.cfs_quota_micros", @@ -3816,12 +5334,16 @@ Object { }, "app": "logstash", "calculation": [Function], + "dateHistogramSubAggs": undefined, "derivative": true, "description": "CPU Usage time compared to the CPU quota shown in percentage. If CPU quotas are not set, then no data will be shown.", + "docType": undefined, "field": "logstash_stats.process.cpu.percent", "fieldSource": "logstash_stats.os.cgroup", "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "CPU Utilization", + "mbField": undefined, "metricAgg": "max", "periodsField": "cpu.stat.number_of_elapsed_periods", "quotaField": "cpu.cfs_quota_micros", @@ -3831,148 +5353,257 @@ Object { "uuidField": "logstash_stats.logstash.uuid", }, "logstash_node_cgroup_throttled": LogstashMetric { + "aggs": undefined, "app": "logstash", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "The amount of throttled time, reported in nanoseconds, of the Cgroup.", + "docType": undefined, "field": "logstash_stats.os.cgroup.cpu.stat.time_throttled_nanos", + "fieldSource": undefined, "format": "0,0.[0]a", + "getDateHistogramSubAggs": undefined, "label": "Cgroup Throttling", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "title": "Cgroup CPU Performance", "units": "ns", + "usageField": undefined, "uuidField": "logstash_stats.logstash.uuid", }, "logstash_node_cgroup_throttled_count": LogstashMetric { + "aggs": undefined, "app": "logstash", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "The number of times that the CPU was throttled by the Cgroup.", + "docType": undefined, "field": "logstash_stats.os.cgroup.cpu.stat.number_of_times_throttled", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Cgroup Throttled Count", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "title": "Cgroup CFS Stats", "units": "", + "usageField": undefined, "uuidField": "logstash_stats.logstash.uuid", }, "logstash_node_cgroup_usage": LogstashMetric { + "aggs": undefined, "app": "logstash", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "The usage, reported in nanoseconds, of the Cgroup. Compare this with the throttling to discover issues.", + "docType": undefined, "field": "logstash_stats.os.cgroup.cpuacct.usage_nanos", + "fieldSource": undefined, "format": "0,0.[0]a", + "getDateHistogramSubAggs": undefined, "label": "Cgroup Usage", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "title": "Cgroup CPU Performance", "units": "ns", + "usageField": undefined, "uuidField": "logstash_stats.logstash.uuid", }, "logstash_node_cpu_utilization": LogstashMetric { + "aggs": undefined, "app": "logstash", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Percentage of CPU usage reported by the OS (100% is the max).", + "docType": undefined, "field": "logstash_stats.process.cpu.percent", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "CPU Utilization", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "units": "%", + "usageField": undefined, "uuidField": "logstash_stats.logstash.uuid", }, "logstash_node_jvm_mem_max_in_bytes": LogstashMetric { + "aggs": undefined, "app": "logstash", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Total heap available to Logstash running in the JVM.", + "docType": undefined, "field": "logstash_stats.jvm.mem.heap_max_in_bytes", + "fieldSource": undefined, "format": "0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Max Heap", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "title": "JVM Heap", "units": "B", + "usageField": undefined, "uuidField": "logstash_stats.logstash.uuid", }, "logstash_node_jvm_mem_used_in_bytes": LogstashMetric { + "aggs": undefined, "app": "logstash", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Total heap used by Logstash running in the JVM.", + "docType": undefined, "field": "logstash_stats.jvm.mem.heap_used_in_bytes", + "fieldSource": undefined, "format": "0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Used Heap", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "title": "JVM Heap", "units": "B", + "usageField": undefined, "uuidField": "logstash_stats.logstash.uuid", }, "logstash_node_pipeline_nodes_count": LogstashPipelineNodeCountMetric { + "aggs": undefined, "app": "logstash", "calculation": [Function], + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Number of nodes on which the Logstash pipeline is running.", + "docType": undefined, "field": "logstash_stats.logstash.uuid", + "fieldSource": undefined, "format": "0,0.[00]", "getDateHistogramSubAggs": [Function], "label": "Pipeline Node Count", + "mbField": undefined, + "metricAgg": undefined, + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "units": "", + "usageField": undefined, "uuidField": "logstash_stats.logstash.uuid", }, "logstash_node_pipeline_throughput": LogstashPipelineThroughputMetric { + "aggs": undefined, "app": "logstash", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Number of events emitted per second by the Logstash pipeline at the outputs stage.", + "docType": undefined, "field": "logstash_stats.pipelines.events.out", + "fieldSource": undefined, "format": "0,0.[00]", "getDateHistogramSubAggs": [Function], "label": "Pipeline Throughput", "mbField": "logstash.node.stats.pipelines.events.out", + "metricAgg": undefined, + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "units": "e/s", + "usageField": undefined, "uuidField": "logstash_stats.logstash.uuid", }, "logstash_os_load_15m": LogstashMetric { + "aggs": undefined, "app": "logstash", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Load average over the last 15 minutes.", + "docType": undefined, "field": "logstash_stats.os.cpu.load_average.15m", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "15m", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "title": "System Load", "units": "", + "usageField": undefined, "uuidField": "logstash_stats.logstash.uuid", }, "logstash_os_load_1m": LogstashMetric { + "aggs": undefined, "app": "logstash", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Load average over the last minute.", + "docType": undefined, "field": "logstash_stats.os.cpu.load_average.1m", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "1m", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "title": "System Load", "units": "", + "usageField": undefined, "uuidField": "logstash_stats.logstash.uuid", }, "logstash_os_load_5m": LogstashMetric { + "aggs": undefined, "app": "logstash", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Load average over the last 5 minutes.", + "docType": undefined, "field": "logstash_stats.os.cpu.load_average.5m", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "5m", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "title": "System Load", "units": "", + "usageField": undefined, "uuidField": "logstash_stats.logstash.uuid", }, "logstash_pipeline_max_queue_size": LogstashPipelineQueueSizeMetric { + "aggs": undefined, "app": "logstash", "calculation": [Function], "dateHistogramSubAggs": Object { @@ -4004,14 +5635,23 @@ Object { }, "derivative": false, "description": "Maximum size set for the persistent queues on this node.", + "docType": undefined, "field": "logstash_stats.pipelines.queue.max_queue_size_in_bytes", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Max Queue Size", + "mbField": undefined, + "metricAgg": undefined, + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "units": "B", + "usageField": undefined, "uuidField": "logstash_stats.logstash.uuid", }, "logstash_pipeline_queue_size": LogstashPipelineQueueSizeMetric { + "aggs": undefined, "app": "logstash", "calculation": [Function], "dateHistogramSubAggs": Object { @@ -4043,39 +5683,67 @@ Object { }, "derivative": false, "description": "Current size of all persistent queues in the Logstash pipelines on this node.", + "docType": undefined, "field": "logstash_stats.pipelines.queue.queue_size_in_bytes", + "fieldSource": undefined, "format": "0,0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Queue Size", + "mbField": undefined, + "metricAgg": undefined, + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "title": "Persistent Queue Size", "units": "B", + "usageField": undefined, "uuidField": "logstash_stats.logstash.uuid", }, "logstash_queue_events_count": LogstashMetric { + "aggs": undefined, "app": "logstash", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Average number of events in the persistent queue waiting to be processed by the filter and output stages.", + "docType": undefined, "field": "logstash_stats.queue.events_count", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Events Queued", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "logstash_stats.timestamp", "title": "Persistent Queue Events", "units": "", + "usageField": undefined, "uuidField": "logstash_stats.logstash.uuid", }, "node_cgroup_periods": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "The number of sampling periods from the Completely Fair Scheduler (CFS). Compare against the number of times throttled.", + "docType": undefined, "field": "node_stats.os.cgroup.cpu.stat.number_of_elapsed_periods", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Cgroup Elapsed Periods", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Cgroup CFS Stats", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_cgroup_quota": QuotaMetric { @@ -4112,12 +5780,16 @@ Object { }, "app": "elasticsearch", "calculation": [Function], + "dateHistogramSubAggs": undefined, "derivative": true, "description": "CPU Usage time compared to the CPU quota shown in percentage. If CPU quotas are not set, then no data will be shown.", + "docType": undefined, "field": "node_stats.process.cpu.percent", "fieldSource": "node_stats.os.cgroup", "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Cgroup CPU Utilization", + "mbField": undefined, "metricAgg": "max", "periodsField": "cpu.stat.number_of_elapsed_periods", "quotaField": "cpu.cfs_quota_micros", @@ -4162,12 +5834,16 @@ Object { }, "app": "elasticsearch", "calculation": [Function], + "dateHistogramSubAggs": undefined, "derivative": true, "description": "CPU Usage time compared to the CPU quota shown in percentage. If CPU quotas are not set, then no data will be shown.", + "docType": undefined, "field": "node_stats.process.cpu.percent", "fieldSource": "node_stats.os.cgroup", "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "CPU Utilization", + "mbField": undefined, "metricAgg": "max", "periodsField": "cpu.stat.number_of_elapsed_periods", "quotaField": "cpu.cfs_quota_micros", @@ -4178,71 +5854,121 @@ Object { "uuidField": "source_node.uuid", }, "node_cgroup_throttled": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "The amount of throttled time, reported in nanoseconds, of the cgroup.", + "docType": undefined, "field": "node_stats.os.cgroup.cpu.stat.time_throttled_nanos", + "fieldSource": undefined, "format": "0,0.[0]a", + "getDateHistogramSubAggs": undefined, "label": "Cgroup Throttling", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Cgroup CPU Performance", "type": "node", "units": "ns", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_cgroup_throttled_count": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "The number of times that the CPU was throttled by the cgroup.", + "docType": undefined, "field": "node_stats.os.cgroup.cpu.stat.number_of_times_throttled", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Cgroup Throttled Count", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Cgroup CFS Stats", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_cgroup_usage": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "The usage, reported in nanoseconds, of the cgroup. Compare this with the throttling to discover issues.", + "docType": undefined, "field": "node_stats.os.cgroup.cpuacct.usage_nanos", + "fieldSource": undefined, "format": "0,0.[0]a", + "getDateHistogramSubAggs": undefined, "label": "Cgroup Usage", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Cgroup CPU Performance", "type": "node", "units": "ns", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_cpu_utilization": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Percentage of CPU usage for the Elasticsearch process.", + "docType": undefined, "field": "node_stats.process.cpu.percent", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "CPU Utilization", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "type": "node", "units": "%", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_free_space": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Free disk space available on the node.", + "docType": undefined, "field": "node_stats.fs.total.available_in_bytes", + "fieldSource": undefined, "format": "0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Disk Free Space", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_index_latency": LatencyMetric { @@ -4274,163 +6000,272 @@ Object { }, "app": "elasticsearch", "calculation": [Function], + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Average latency for indexing documents, which is time it takes to index documents divided by number that were indexed. This considers any shard located on this node, including replicas.", + "docType": undefined, "field": "node_stats.indices.indexing.index_total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Indexing", + "mbField": undefined, "metricAgg": "sum", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Latency", "type": "node", "units": "ms", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_index_mem_fielddata": IndexMemoryMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Heap memory used by Fielddata (e.g., global ordinals or explicitly enabled fielddata on text fields). This is for the same shards, but not a part of Lucene Total.", + "docType": undefined, "field": "node_stats.indices.fielddata.memory_size_in_bytes", + "fieldSource": undefined, "format": "0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Fielddata", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Index Memory", "type": "node", "units": "B", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_index_mem_fixed_bit_set": NodeIndexMemoryMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Heap memory used by Fixed Bit Sets (e.g., deeply nested documents). This is a part of Lucene Total.", + "docType": undefined, "field": "node_stats.indices.segments.fixed_bit_set_memory_in_bytes", + "fieldSource": undefined, "format": "0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Fixed Bitsets", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Index Memory - Lucene", "type": "node", "units": "B", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_index_mem_query_cache": IndexMemoryMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Heap memory used by Query Cache (e.g., cached filters). This is for the same shards, but not a part of Lucene Total.", + "docType": undefined, "field": "node_stats.indices.query_cache.memory_size_in_bytes", + "fieldSource": undefined, "format": "0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Query Cache", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Index Memory - Elasticsearch", "type": "node", "units": "B", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_index_mem_request_cache": IndexMemoryMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Heap memory used by Request Cache (e.g., instant aggregations). This is for the same shards, but not a part of Lucene Total.", + "docType": undefined, "field": "node_stats.indices.request_cache.memory_size_in_bytes", + "fieldSource": undefined, "format": "0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Request Cache", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Index Memory", "type": "node", "units": "B", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_index_mem_versions": NodeIndexMemoryMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Heap memory used by Versioning (e.g., updates and deletes). This is NOT a part of Lucene Total.", + "docType": undefined, "field": "node_stats.indices.segments.version_map_memory_in_bytes", + "fieldSource": undefined, "format": "0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Version Map", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Index Memory", "type": "node", "units": "B", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_index_mem_writer": NodeIndexMemoryMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Heap memory used by the Index Writer. This is NOT a part of Lucene Total.", + "docType": undefined, "field": "node_stats.indices.segments.index_writer_memory_in_bytes", + "fieldSource": undefined, "format": "0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Index Writer", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Index Memory", "type": "node", "units": "B", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_index_threads_get_queue": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Number of GET operations in the queue.", + "docType": undefined, "field": "node_stats.thread_pool.get.queue", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "GET Queue", + "mbField": undefined, "metricAgg": "max", "min": 0, + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Read Threads", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_index_threads_get_rejected": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Number of GET operations that have been rejected, which occurs when the queue is full.", + "docType": undefined, "field": "node_stats.thread_pool.get.rejected", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "GET Rejections", + "mbField": undefined, "metricAgg": "max", "min": 0, + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Read Threads", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_index_threads_search_queue": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Number of search operations in the queue (e.g., shard level searches).", + "docType": undefined, "field": "node_stats.thread_pool.search.queue", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Search Queue", + "mbField": undefined, "metricAgg": "max", "min": 0, + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Read Threads", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_index_threads_search_rejected": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Number of search operations that have been rejected, which occurs when the queue is full.", + "docType": undefined, "field": "node_stats.thread_pool.search.rejected", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Search Rejections", + "mbField": undefined, "metricAgg": "max", "min": 0, + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Read Threads", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_index_threads_write_queue": WriteThreadPoolQueueMetric { + "aggs": undefined, "app": "elasticsearch", "calculation": [Function], "dateHistogramSubAggs": Object { @@ -4452,17 +6287,25 @@ Object { }, "derivative": false, "description": "Number of index, bulk, and write operations in the queue. The bulk threadpool was renamed to write in 6.3, and the index threadpool is deprecated.", + "docType": undefined, "field": "node_stats.thread_pool.write.queue", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Write Queue", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Indexing Threads", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_index_threads_write_rejected": WriteThreadPoolRejectedMetric { + "aggs": undefined, "app": "elasticsearch", "calculation": [Function], "dateHistogramSubAggs": Object { @@ -4505,154 +6348,261 @@ Object { }, "derivative": false, "description": "Number of index, bulk, and write operations that have been rejected, which occurs when the queue is full. The bulk threadpool was renamed to write in 6.3, and the index threadpool is deprecated.", + "docType": undefined, "field": "node_stats.thread_pool.write.rejected", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Write Rejections", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Indexing Threads", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_index_time": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Amount of time spent on indexing operations.", + "docType": undefined, "field": "node_stats.indices.indexing.index_time_in_millis", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Index Time", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Indexing Time", "type": "node", "units": "ms", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_index_total": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Amount of indexing operations.", + "docType": undefined, "field": "node_stats.indices.indexing.index_total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Indexing Total", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Request Rate", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_jvm_gc_old_count": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Number of old Garbage Collections.", + "docType": undefined, "field": "node_stats.jvm.gc.collectors.old.collection_count", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Old", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "GC Rate", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_jvm_gc_old_time": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Time spent performing old Garbage Collections.", + "docType": undefined, "field": "node_stats.jvm.gc.collectors.old.collection_time_in_millis", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Old", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "GC Duration", "type": "node", "units": "ms", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_jvm_gc_young_count": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Number of young Garbage Collections.", + "docType": undefined, "field": "node_stats.jvm.gc.collectors.young.collection_count", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Young", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "GC Rate", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_jvm_gc_young_time": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Time spent performing young Garbage Collections.", + "docType": undefined, "field": "node_stats.jvm.gc.collectors.young.collection_time_in_millis", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Young", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "GC Duration", "type": "node", "units": "ms", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_jvm_mem_max_in_bytes": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Total heap available to Elasticsearch running in the JVM.", + "docType": undefined, "field": "node_stats.jvm.mem.heap_max_in_bytes", + "fieldSource": undefined, "format": "0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Max Heap", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "JVM Heap", "type": "node", "units": "B", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_jvm_mem_percent": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Total heap used by Elasticsearch running in the JVM.", + "docType": undefined, "field": "node_stats.jvm.mem.heap_used_percent", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Used Heap", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "JVM Heap", "type": "node", "units": "%", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_jvm_mem_used_in_bytes": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Total heap used by Elasticsearch running in the JVM.", + "docType": undefined, "field": "node_stats.jvm.mem.heap_used_in_bytes", + "fieldSource": undefined, "format": "0.0 b", + "getDateHistogramSubAggs": undefined, "label": "Used Heap", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "JVM Heap", "type": "node", "units": "B", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_load_average": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Load average over the last minute.", + "docType": undefined, "field": "node_stats.os.cpu.load_average.1m", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "1m", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "System Load", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_query_latency": LatencyMetric { @@ -4684,335 +6634,573 @@ Object { }, "app": "elasticsearch", "calculation": [Function], + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Average latency for searching, which is time it takes to execute searches divided by number of searches submitted. This considers primary and replica shards.", + "docType": undefined, "field": "node_stats.indices.search.query_total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Search", + "mbField": undefined, "metricAgg": "sum", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Latency", "type": "node", "units": "ms", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_search_total": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Amount of search operations (per shard).", + "docType": undefined, "field": "node_stats.indices.search.query_total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Search Total", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Request Rate", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_segment_count": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Maximum segment count for primary and replica shards on this node.", + "docType": undefined, "field": "node_stats.indices.segments.count", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Segment Count", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_threads_queued_bulk": ThreadPoolQueueMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Number of bulk indexing operations waiting to be processed on this node. A single bulk request can create multiple bulk operations.", + "docType": undefined, "field": "node_stats.thread_pool.bulk.queue", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Bulk", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Thread Queue", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_threads_queued_generic": ThreadPoolQueueMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Number of generic (internal) operations waiting to be processed on this node.", + "docType": undefined, "field": "node_stats.thread_pool.generic.queue", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Generic", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Thread Queue", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_threads_queued_get": ThreadPoolQueueMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Number of get operations waiting to be processed on this node.", + "docType": undefined, "field": "node_stats.thread_pool.get.queue", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Get", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Thread Queue", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_threads_queued_index": ThreadPoolQueueMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Number of non-bulk, index operations waiting to be processed on this node.", + "docType": undefined, "field": "node_stats.thread_pool.index.queue", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Index", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Thread Queue", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_threads_queued_management": ThreadPoolQueueMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Number of management (internal) operations waiting to be processed on this node.", + "docType": undefined, "field": "node_stats.thread_pool.management.queue", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Management", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Thread Queue", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_threads_queued_search": ThreadPoolQueueMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Number of search operations waiting to be processed on this node. A single search request can create multiple search operations.", + "docType": undefined, "field": "node_stats.thread_pool.search.queue", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Search", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Thread Queue", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_threads_queued_watcher": ThreadPoolQueueMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Number of Watcher operations waiting to be processed on this node.", + "docType": undefined, "field": "node_stats.thread_pool.watcher.queue", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Watcher", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Thread Queue", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_threads_rejected_bulk": ThreadPoolRejectedMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Bulk rejections. These occur when the queue is full.", + "docType": undefined, "field": "node_stats.thread_pool.bulk.rejected", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Bulk", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Thread Rejections", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_threads_rejected_generic": ThreadPoolRejectedMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Generic (internal) rejections. These occur when the queue is full.", + "docType": undefined, "field": "node_stats.thread_pool.generic.rejected", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Generic", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Thread Rejections", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_threads_rejected_get": ThreadPoolRejectedMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Get rejections. These occur when the queue is full.", + "docType": undefined, "field": "node_stats.thread_pool.get.rejected", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Get", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Thread Rejections", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_threads_rejected_index": ThreadPoolRejectedMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Index rejections. These occur when the queue is full. You should look at bulk indexing.", + "docType": undefined, "field": "node_stats.thread_pool.index.rejected", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Index", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Thread Rejections", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_threads_rejected_management": ThreadPoolRejectedMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Get (internal) rejections. These occur when the queue is full.", + "docType": undefined, "field": "node_stats.thread_pool.management.rejected", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Management", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Thread Rejections", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_threads_rejected_search": ThreadPoolRejectedMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Search rejections. These occur when the queue is full. This can indicate over-sharding.", + "docType": undefined, "field": "node_stats.thread_pool.search.rejected", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Search", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Thread Rejections", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_threads_rejected_watcher": ThreadPoolRejectedMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Watch rejections. These occur when the queue is full. This can indicate stuck-Watches.", + "docType": undefined, "field": "node_stats.thread_pool.watcher.rejected", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Watcher", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Thread Rejections", "type": "node", "units": "", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_throttle_index_time": ElasticsearchMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Amount of time spent with index throttling, which indicates slow disks on a node.", + "docType": undefined, "field": "node_stats.indices.indexing.throttle_time_in_millis", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Index Throttling Time", + "mbField": undefined, "metricAgg": "max", "min": 0, + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Indexing Time", "type": "node", "units": "ms", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_total_cumul_io": RequestRateMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Total I/O. (This metric is not supported on all platforms and may display N/A if I/O data is unavailable.)", + "docType": undefined, "field": "node_stats.fs.io_stats.total.operations", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Total I/O", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "I/O Operations Rate", "type": "node", "units": "/s", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_total_read_io": RequestRateMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Total Read I/O. (This metric is not supported on all platforms and may display N/A if I/O data is unavailable.)", + "docType": undefined, "field": "node_stats.fs.io_stats.total.read_operations", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Total Read I/O", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "I/O Operations Rate", "type": "node", "units": "/s", + "usageField": undefined, "uuidField": "source_node.uuid", }, "node_total_write_io": RequestRateMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Total Write I/O. (This metric is not supported on all platforms and may display N/A if I/O data is unavailable.)", + "docType": undefined, "field": "node_stats.fs.io_stats.total.write_operations", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Total Write I/O", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "I/O Operations Rate", "type": "node", "units": "/s", + "usageField": undefined, "uuidField": "source_node.uuid", }, "search_request_rate": RequestRateMetric { + "aggs": undefined, "app": "elasticsearch", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": true, "description": "Number of search requests being executed across primary and replica shards. A single search can run against multiple shards!", + "docType": undefined, "field": "index_stats.total.search.query_total", + "fieldSource": undefined, "format": "0,0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Total Shards", + "mbField": undefined, "metricAgg": "max", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "timestamp", "title": "Search Rate", "type": "cluster", "units": "/s", + "usageField": undefined, "uuidField": "source_node.uuid", }, "workplace_search_total_org_sources": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Current number of Workplace Search org-wide content sources within the Enterprise Search deployment.", + "docType": undefined, "field": "enterprisesearch.stats.product_usage.workplace_search.total_org_sources", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Org Sources", + "mbField": undefined, "metricAgg": "avg", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "title": "Workpace Search Content Sources", "units": "", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, "workplace_search_total_private_sources": EnterpriseSearchMetric { + "aggs": undefined, "app": "enterprise_search", + "calculation": undefined, + "dateHistogramSubAggs": undefined, "derivative": false, "description": "Current number of Workplace Search private content sources within the Enterprise Search deployment.", + "docType": undefined, "field": "enterprisesearch.stats.product_usage.workplace_search.total_private_sources", + "fieldSource": undefined, "format": "0.[00]", + "getDateHistogramSubAggs": undefined, "label": "Private Sources", + "mbField": undefined, "metricAgg": "avg", + "periodsField": undefined, + "quotaField": undefined, "timestampField": "@timestamp", "units": "", + "usageField": undefined, "uuidField": "enterprisesearch.cluster_uuid", }, } diff --git a/x-pack/plugins/monitoring/server/lib/metrics/apm/classes.ts b/x-pack/plugins/monitoring/server/lib/metrics/apm/classes.ts index 4a97e7823999b3..89decb1ed07624 100644 --- a/x-pack/plugins/monitoring/server/lib/metrics/apm/classes.ts +++ b/x-pack/plugins/monitoring/server/lib/metrics/apm/classes.ts @@ -8,14 +8,17 @@ /* eslint-disable max-classes-per-file */ import { i18n } from '@kbn/i18n'; -// @ts-ignore -import { ClusterMetric, Metric } from '../classes'; + +import { ClusterMetric, Metric, MetricOptions } from '../classes'; import { SMALL_FLOAT, LARGE_FLOAT } from '../../../../common/formatting'; import { NORMALIZED_DERIVATIVE_UNIT } from '../../../../common/constants'; +type ApmClusterMetricOptions = Pick< + MetricOptions, + 'field' | 'title' | 'label' | 'description' | 'derivative' | 'format' | 'metricAgg' | 'units' +>; export class ApmClusterMetric extends ClusterMetric { - // @ts-ignore - constructor(opts) { + constructor(opts: ApmClusterMetricOptions) { super({ ...opts, app: 'apm', @@ -31,9 +34,12 @@ export class ApmClusterMetric extends ClusterMetric { } } +type ApmMetricOptions = Pick< + MetricOptions, + 'title' | 'label' | 'description' | 'field' | 'format' | 'metricAgg' | 'units' | 'derivative' +>; export class ApmMetric extends Metric { - // @ts-ignore - constructor(opts) { + constructor(opts: ApmMetricOptions) { super({ ...opts, app: 'apm', @@ -51,9 +57,12 @@ export class ApmMetric extends Metric { export type ApmMetricFields = ReturnType; +type ApmCpuUtilizationMetricOptions = Pick< + MetricOptions, + 'title' | 'label' | 'description' | 'field' +>; export class ApmCpuUtilizationMetric extends ApmMetric { - // @ts-ignore - constructor(opts) { + constructor(opts: ApmCpuUtilizationMetricOptions) { super({ ...opts, format: SMALL_FLOAT, @@ -62,12 +71,13 @@ export class ApmCpuUtilizationMetric extends ApmMetric { derivative: true, }); - /* - * Convert a counter of milliseconds of utilization time into a percentage of the bucket size - */ - // @ts-ignore - this.calculation = ({ metric_deriv: metricDeriv } = {}, _key, _metric, bucketSizeInSeconds) => { - if (metricDeriv) { + this.calculation = ( + { metric_deriv: metricDeriv } = { metric_deriv: undefined }, + _key, + _metric, + bucketSizeInSeconds + ) => { + if (metricDeriv && bucketSizeInSeconds) { const { value: metricDerivValue } = metricDeriv; const bucketSizeInMillis = bucketSizeInSeconds * 1000; @@ -80,9 +90,13 @@ export class ApmCpuUtilizationMetric extends ApmMetric { } } +type ApmEventsRateClusterMetricOptions = Pick< + ApmClusterMetricOptions, + 'field' | 'title' | 'label' | 'description' +>; + export class ApmEventsRateClusterMetric extends ApmClusterMetric { - // @ts-ignore - constructor(opts) { + constructor(opts: ApmEventsRateClusterMetricOptions) { super({ ...opts, derivative: true, @@ -93,7 +107,6 @@ export class ApmEventsRateClusterMetric extends ApmClusterMetric { }), }); - // @ts-ignore this.aggs = { beats_uuids: { terms: { @@ -103,7 +116,6 @@ export class ApmEventsRateClusterMetric extends ApmClusterMetric { aggs: { event_rate_per_beat: { max: { - // @ts-ignore field: this.field, }, }, diff --git a/x-pack/plugins/monitoring/server/lib/metrics/apm/metrics.js b/x-pack/plugins/monitoring/server/lib/metrics/apm/metrics.ts similarity index 100% rename from x-pack/plugins/monitoring/server/lib/metrics/apm/metrics.js rename to x-pack/plugins/monitoring/server/lib/metrics/apm/metrics.ts index 7c779f31c684b8..8cd3941be13383 100644 --- a/x-pack/plugins/monitoring/server/lib/metrics/apm/metrics.js +++ b/x-pack/plugins/monitoring/server/lib/metrics/apm/metrics.ts @@ -5,9 +5,9 @@ * 2.0. */ +import { i18n } from '@kbn/i18n'; import { LARGE_BYTES, LARGE_FLOAT } from '../../../../common/formatting'; import { ApmMetric, ApmCpuUtilizationMetric, ApmEventsRateClusterMetric } from './classes'; -import { i18n } from '@kbn/i18n'; import { QuotaMetric } from '../classes'; const instanceSystemLoadTitle = i18n.translate( diff --git a/x-pack/plugins/monitoring/server/lib/metrics/beats/classes.ts b/x-pack/plugins/monitoring/server/lib/metrics/beats/classes.ts index 78e731cee88812..44241882d5077e 100644 --- a/x-pack/plugins/monitoring/server/lib/metrics/beats/classes.ts +++ b/x-pack/plugins/monitoring/server/lib/metrics/beats/classes.ts @@ -8,8 +8,8 @@ /* eslint-disable max-classes-per-file */ import { i18n } from '@kbn/i18n'; -// @ts-ignore -import { ClusterMetric, Metric } from '../classes'; + +import { ClusterMetric, ClusterMetricOptions, Metric, MetricOptions } from '../classes'; import { SMALL_FLOAT, LARGE_FLOAT, LARGE_BYTES } from '../../../../common/formatting'; import { NORMALIZED_DERIVATIVE_UNIT } from '../../../../common/constants'; @@ -17,9 +17,13 @@ const perSecondUnitLabel = i18n.translate('xpack.monitoring.metrics.beats.perSec defaultMessage: '/s', }); +type BeatsClusterMetricOptions = Pick< + ClusterMetricOptions, + 'derivative' | 'format' | 'metricAgg' | 'units' | 'field' | 'label' | 'description' +>; + export class BeatsClusterMetric extends ClusterMetric { - // @ts-ignore - constructor(opts) { + constructor(opts: BeatsClusterMetricOptions) { super({ ...opts, app: 'beats', @@ -35,9 +39,14 @@ export class BeatsClusterMetric extends ClusterMetric { } } +type BeatsEventsRateClusterMetricOptions = Pick< + ClusterMetricOptions, + 'field' | 'title' | 'label' | 'description' +> & + Partial>; + export class BeatsEventsRateClusterMetric extends BeatsClusterMetric { - // @ts-ignore - constructor(opts) { + constructor(opts: BeatsEventsRateClusterMetricOptions) { super({ ...opts, derivative: true, @@ -45,7 +54,6 @@ export class BeatsEventsRateClusterMetric extends BeatsClusterMetric { metricAgg: 'max', units: perSecondUnitLabel, }); - // @ts-ignore this.aggs = { beats_uuids: { @@ -56,7 +64,6 @@ export class BeatsEventsRateClusterMetric extends BeatsClusterMetric { aggs: { event_rate_per_beat: { max: { - // @ts-ignore field: this.field, }, }, @@ -79,9 +86,13 @@ export class BeatsEventsRateClusterMetric extends BeatsClusterMetric { } } +type BeatsMetricOptions = Pick< + MetricOptions, + 'field' | 'title' | 'label' | 'description' | 'format' | 'metricAgg' | 'units' | 'derivative' +>; + export class BeatsMetric extends Metric { - // @ts-ignore - constructor(opts) { + constructor(opts: BeatsMetricOptions) { super({ ...opts, app: 'beats', @@ -99,9 +110,12 @@ export class BeatsMetric extends Metric { export type BeatsMetricFields = ReturnType; +type BeatsByteRateClusterMetricOptions = Pick< + ClusterMetricOptions, + 'field' | 'title' | 'label' | 'description' +>; export class BeatsByteRateClusterMetric extends BeatsEventsRateClusterMetric { - // @ts-ignore - constructor(opts) { + constructor(opts: BeatsByteRateClusterMetricOptions) { super({ ...opts, format: LARGE_BYTES, @@ -109,9 +123,12 @@ export class BeatsByteRateClusterMetric extends BeatsEventsRateClusterMetric { } } +type BeatsEventsRateMetricOptions = Pick< + MetricOptions, + 'field' | 'title' | 'label' | 'description' +>; export class BeatsEventsRateMetric extends BeatsMetric { - // @ts-ignore - constructor(opts) { + constructor(opts: BeatsEventsRateMetricOptions) { super({ ...opts, format: LARGE_FLOAT, @@ -122,9 +139,10 @@ export class BeatsEventsRateMetric extends BeatsMetric { } } +type BeatsByteRateMetricOptions = Pick; + export class BeatsByteRateMetric extends BeatsMetric { - // @ts-ignore - constructor(opts) { + constructor(opts: BeatsByteRateMetricOptions) { super({ ...opts, format: LARGE_BYTES, @@ -135,9 +153,13 @@ export class BeatsByteRateMetric extends BeatsMetric { } } +type BeatsCpuUtilizationMetricOptions = Pick< + MetricOptions, + 'field' | 'title' | 'label' | 'description' +>; + export class BeatsCpuUtilizationMetric extends BeatsMetric { - // @ts-ignore - constructor(opts) { + constructor(opts: BeatsCpuUtilizationMetricOptions) { super({ ...opts, format: SMALL_FLOAT, @@ -149,9 +171,14 @@ export class BeatsCpuUtilizationMetric extends BeatsMetric { /* * Convert a counter of milliseconds of utilization time into a percentage of the bucket size */ - // @ts-ignore - this.calculation = ({ metric_deriv: metricDeriv } = {}, _key, _metric, bucketSizeInSeconds) => { - if (metricDeriv) { + + this.calculation = ( + { metric_deriv: metricDeriv } = { metric_deriv: undefined }, + _key, + _metric, + bucketSizeInSeconds + ) => { + if (metricDeriv && bucketSizeInSeconds) { const { value } = metricDeriv; const bucketSizeInMillis = bucketSizeInSeconds * 1000; diff --git a/x-pack/plugins/monitoring/server/lib/metrics/beats/metrics.js b/x-pack/plugins/monitoring/server/lib/metrics/beats/metrics.ts similarity index 100% rename from x-pack/plugins/monitoring/server/lib/metrics/beats/metrics.js rename to x-pack/plugins/monitoring/server/lib/metrics/beats/metrics.ts index c9d1c015e22d69..6bf7cf67208b1d 100644 --- a/x-pack/plugins/monitoring/server/lib/metrics/beats/metrics.js +++ b/x-pack/plugins/monitoring/server/lib/metrics/beats/metrics.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { i18n } from '@kbn/i18n'; import { BeatsEventsRateClusterMetric, BeatsByteRateClusterMetric, @@ -14,7 +15,6 @@ import { BeatsMetric, } from './classes'; import { LARGE_FLOAT, LARGE_BYTES, SMALL_FLOAT } from '../../../../common/formatting'; -import { i18n } from '@kbn/i18n'; const eventsRateTitle = i18n.translate('xpack.monitoring.metrics.beats.eventsRateTitle', { defaultMessage: 'Events Rate', diff --git a/x-pack/plugins/monitoring/server/lib/metrics/classes/cluster_metric.js b/x-pack/plugins/monitoring/server/lib/metrics/classes/cluster_metric.ts similarity index 68% rename from x-pack/plugins/monitoring/server/lib/metrics/classes/cluster_metric.js rename to x-pack/plugins/monitoring/server/lib/metrics/classes/cluster_metric.ts index 984b896052c47a..bf995ffa592a7d 100644 --- a/x-pack/plugins/monitoring/server/lib/metrics/classes/cluster_metric.js +++ b/x-pack/plugins/monitoring/server/lib/metrics/classes/cluster_metric.ts @@ -5,10 +5,14 @@ * 2.0. */ -import { Metric } from './metric'; +import { Metric, MetricOptions } from './metric'; + +export type ClusterMetricOptions = MetricOptions & { + uuidField: string; +}; export class ClusterMetric extends Metric { - constructor(opts) { + constructor(opts: ClusterMetricOptions) { super({ ...opts, uuidField: 'cluster_uuid', diff --git a/x-pack/plugins/monitoring/server/lib/metrics/classes/index.js b/x-pack/plugins/monitoring/server/lib/metrics/classes/index.ts similarity index 77% rename from x-pack/plugins/monitoring/server/lib/metrics/classes/index.js rename to x-pack/plugins/monitoring/server/lib/metrics/classes/index.ts index e0f19d47c964e8..ae8fb55b173ca0 100644 --- a/x-pack/plugins/monitoring/server/lib/metrics/classes/index.js +++ b/x-pack/plugins/monitoring/server/lib/metrics/classes/index.ts @@ -8,3 +8,6 @@ export { Metric } from './metric'; export { ClusterMetric } from './cluster_metric'; export { QuotaMetric } from './quota_metric'; + +export type { MetricOptions } from './metric'; +export type { ClusterMetricOptions } from './cluster_metric'; diff --git a/x-pack/plugins/monitoring/server/lib/metrics/classes/metric.js b/x-pack/plugins/monitoring/server/lib/metrics/classes/metric.ts similarity index 57% rename from x-pack/plugins/monitoring/server/lib/metrics/classes/metric.js rename to x-pack/plugins/monitoring/server/lib/metrics/classes/metric.ts index ba175ad35988ba..8c2c54cd2f4ed5 100644 --- a/x-pack/plugins/monitoring/server/lib/metrics/classes/metric.js +++ b/x-pack/plugins/monitoring/server/lib/metrics/classes/metric.ts @@ -8,9 +8,57 @@ import _ from 'lodash'; import { MissingRequiredError } from '../../error_missing_required'; +interface RequiredMetricOptions { + field: string; + label: string; + description: string; + format: string; + units: string; + timestampField: string; + [key: string]: string | boolean | number; +} + +interface OptionalMetricOptions { + app?: string; + metricAgg?: string; + mbField?: string; + type?: string; +} + +interface DefaultMetricOptions { + derivative?: boolean; +} + +export type MetricOptions = RequiredMetricOptions & OptionalMetricOptions & DefaultMetricOptions; + export class Metric { - constructor(opts) { - const props = { + public field!: string; + public docType?: string; + public label!: string; + public description!: string; + public format!: string; + public units!: string; + public timestampField!: string; + public app?: string; + public metricAgg?: string; + public mbField?: string; + public derivative: boolean = false; + public aggs?: object; + public dateHistogramSubAggs?: object; + public getDateHistogramSubAggs?: (options: any) => object; + public calculation?: ( + bucket: any, + key?: string, + metric?: Metric, + defaultSizeInSeconds?: number + ) => number | null; + public fieldSource?: string; + public usageField?: string; + public periodsField?: string; + public quotaField?: string; + + constructor(opts: MetricOptions) { + const props: Required = { derivative: false, }; @@ -22,14 +70,15 @@ export class Metric { units: opts.units, timestampField: opts.timestampField, }; + this.checkRequiredParams(requireds); + _.assign(this, _.defaults(opts, props)); } - checkRequiredParams(requireds) { + checkRequiredParams(requireds: RequiredParams) { const undefKey = _.findKey(requireds, _.isUndefined); if (undefKey) { - console.log(`Missing required field: [${undefKey}]`); throw new MissingRequiredError(undefKey); } } @@ -68,7 +117,7 @@ export class Metric { return fields && fields.length ? fields[0].split('.')[0] : null; } - static calculateLatency(timeInMillis, totalEvents) { + static calculateLatency(timeInMillis: number | null, totalEvents: number | null) { if (timeInMillis === null || totalEvents === null) { return null; } else if (timeInMillis < 0 || totalEvents < 0) { diff --git a/x-pack/plugins/monitoring/server/lib/metrics/classes/quota_metric.js b/x-pack/plugins/monitoring/server/lib/metrics/classes/quota_metric.ts similarity index 85% rename from x-pack/plugins/monitoring/server/lib/metrics/classes/quota_metric.js rename to x-pack/plugins/monitoring/server/lib/metrics/classes/quota_metric.ts index 4912338bcb335b..8e1cb8930f8042 100644 --- a/x-pack/plugins/monitoring/server/lib/metrics/classes/quota_metric.js +++ b/x-pack/plugins/monitoring/server/lib/metrics/classes/quota_metric.ts @@ -6,12 +6,26 @@ */ import { get } from 'lodash'; -import { Metric } from './metric'; +import { Metric, MetricOptions } from './metric'; import { LARGE_FLOAT } from '../../../../common/formatting'; import { NORMALIZED_DERIVATIVE_UNIT } from '../../../../common/constants'; +type QuotaMetricOptions = Pick< + MetricOptions, + | 'fieldSource' + | 'usageField' + | 'periodsField' + | 'quotaField' + | 'field' + | 'label' + | 'description' + | 'app' + | 'timestampField' +> & + Partial>; + export class QuotaMetric extends Metric { - constructor(opts) { + constructor(opts: QuotaMetricOptions) { super({ ...opts, format: LARGE_FLOAT, @@ -51,7 +65,7 @@ export class QuotaMetric extends Metric { }, }; - this.calculation = (bucket) => { + this.calculation = (bucket: object) => { const quota = get(bucket, 'quota.value'); const deltaUsageDerivNormalizedValue = get(bucket, 'usage_deriv.normalized_value'); const periodsDerivNormalizedValue = get(bucket, 'periods_deriv.normalized_value'); diff --git a/x-pack/plugins/monitoring/server/lib/metrics/elasticsearch/classes.js b/x-pack/plugins/monitoring/server/lib/metrics/elasticsearch/classes.ts similarity index 71% rename from x-pack/plugins/monitoring/server/lib/metrics/elasticsearch/classes.js rename to x-pack/plugins/monitoring/server/lib/metrics/elasticsearch/classes.ts index 2141b30b372902..a70299c3fa42d0 100644 --- a/x-pack/plugins/monitoring/server/lib/metrics/elasticsearch/classes.js +++ b/x-pack/plugins/monitoring/server/lib/metrics/elasticsearch/classes.ts @@ -5,14 +5,22 @@ * 2.0. */ +/* eslint-disable max-classes-per-file */ + import _ from 'lodash'; -import { Metric } from '../classes'; +import { i18n } from '@kbn/i18n'; +import { Metric, MetricOptions } from '../classes'; import { LARGE_FLOAT, SMALL_FLOAT, SMALL_BYTES } from '../../../../common/formatting'; import { NORMALIZED_DERIVATIVE_UNIT } from '../../../../common/constants'; -import { i18n } from '@kbn/i18n'; + +type ElasticsearchMetricOptions = Pick< + MetricOptions, + 'format' | 'metricAgg' | 'field' | 'label' | 'description' | 'units' | 'derivative' +> & + Partial> & { type: string; min?: number }; export class ElasticsearchMetric extends Metric { - constructor(opts) { + constructor(opts: ElasticsearchMetricOptions) { super({ ...opts, app: 'elasticsearch', @@ -31,8 +39,18 @@ export class ElasticsearchMetric extends Metric { } } +type DifferenceMetricOptions = Pick< + MetricOptions, + 'description' | 'format' | 'metricAgg' | 'units' | 'label' | 'title' +> & { + type: string; + fieldSource: string; + metric: string; + metric2: string; +}; + export class DifferenceMetric extends ElasticsearchMetric { - constructor({ fieldSource, metric, metric2, ...opts }) { + constructor({ fieldSource, metric, metric2, ...opts }: DifferenceMetricOptions) { super({ ...opts, field: '', // NOTE: this is not used for this @@ -56,14 +74,21 @@ export class DifferenceMetric extends ElasticsearchMetric { this.getFields = () => [`${fieldSource}.${metric}`, `${fieldSource}.${metric2}`]; - this.calculation = (bucket) => { + this.calculation = (bucket: object) => { return _.get(bucket, 'metric_max.value') - _.get(bucket, 'metric2_max.value'); }; } } +type LatencyMetricOptions = Pick & + Partial> & { + type: string; + fieldSource: string; + metric: string; + }; + export class LatencyMetric extends ElasticsearchMetric { - constructor({ metric, fieldSource, ...opts }) { + constructor({ metric, fieldSource, ...opts }: LatencyMetricOptions) { super({ ...opts, format: LARGE_FLOAT, @@ -117,7 +142,7 @@ export class LatencyMetric extends ElasticsearchMetric { }, }; - this.calculation = (bucket) => { + this.calculation = (bucket: object) => { const timeInMillisDeriv = _.get(bucket, 'event_time_in_millis_deriv.normalized_value', null); const totalEventsDeriv = _.get(bucket, 'event_total_deriv.normalized_value', null); @@ -126,8 +151,12 @@ export class LatencyMetric extends ElasticsearchMetric { } } +type RequestRateMetricOptions = Pick & + Partial> & { + type: string; + }; export class RequestRateMetric extends ElasticsearchMetric { - constructor(opts) { + constructor(opts: RequestRateMetricOptions) { super({ ...opts, derivative: true, @@ -140,8 +169,10 @@ export class RequestRateMetric extends ElasticsearchMetric { } } +type ThreadPoolQueueMetricOptions = Pick & + Partial>; export class ThreadPoolQueueMetric extends ElasticsearchMetric { - constructor(opts) { + constructor(opts: ThreadPoolQueueMetricOptions) { super({ ...opts, title: 'Thread Queue', @@ -153,8 +184,11 @@ export class ThreadPoolQueueMetric extends ElasticsearchMetric { } } +type ThreadPoolRejectedMetricOptions = Pick & + Partial>; + export class ThreadPoolRejectedMetric extends ElasticsearchMetric { - constructor(opts) { + constructor(opts: ThreadPoolRejectedMetricOptions) { super({ ...opts, title: 'Thread Rejections', @@ -174,8 +208,11 @@ export class ThreadPoolRejectedMetric extends ElasticsearchMetric { * @see NodeIndexMemoryMetric * @see SingleIndexMemoryMetric */ + +type IndexMemoryMetricOptions = Pick & + Partial> & { type: string }; export class IndexMemoryMetric extends ElasticsearchMetric { - constructor(opts) { + constructor(opts: IndexMemoryMetricOptions) { super({ title: 'Index Memory', ...opts, @@ -186,8 +223,11 @@ export class IndexMemoryMetric extends ElasticsearchMetric { } } +type NodeIndexMemoryMetricOptions = Pick & + Partial>; + export class NodeIndexMemoryMetric extends IndexMemoryMetric { - constructor(opts) { + constructor(opts: NodeIndexMemoryMetricOptions) { super({ ...opts, type: 'node', @@ -198,8 +238,11 @@ export class NodeIndexMemoryMetric extends IndexMemoryMetric { } } +type IndicesMemoryMetricOptions = Pick & + Partial>; + export class IndicesMemoryMetric extends IndexMemoryMetric { - constructor(opts) { + constructor(opts: IndicesMemoryMetricOptions) { super({ ...opts, type: 'cluster', @@ -210,8 +253,11 @@ export class IndicesMemoryMetric extends IndexMemoryMetric { } } +type SingleIndexMemoryMetricOptions = Pick & + Partial>; + export class SingleIndexMemoryMetric extends IndexMemoryMetric { - constructor(opts) { + constructor(opts: SingleIndexMemoryMetricOptions) { super({ ...opts, type: 'index', @@ -222,8 +268,11 @@ export class SingleIndexMemoryMetric extends IndexMemoryMetric { } } +type WriteThreadPoolQueueMetricOptions = Pick & + Partial>; + export class WriteThreadPoolQueueMetric extends ElasticsearchMetric { - constructor(opts) { + constructor(opts: WriteThreadPoolQueueMetricOptions) { super({ ...opts, field: 'node_stats.thread_pool.write.queue', // in 7.0, we can only check for this threadpool @@ -244,8 +293,7 @@ export class WriteThreadPoolQueueMetric extends ElasticsearchMetric { max: { field: 'node_stats.thread_pool.write.queue' }, }, }; - - this.calculation = (bucket) => { + this.calculation = (bucket: object) => { const index = _.get(bucket, 'index.value', null); const bulk = _.get(bucket, 'bulk.value', null); const write = _.get(bucket, 'write.value', null); @@ -260,8 +308,13 @@ export class WriteThreadPoolQueueMetric extends ElasticsearchMetric { } } +type WriteThreadPoolRejectedMetricOptions = Pick< + MetricOptions, + 'label' | 'description' | 'field' | 'title' +>; + export class WriteThreadPoolRejectedMetric extends ElasticsearchMetric { - constructor(opts) { + constructor(opts: WriteThreadPoolRejectedMetricOptions) { super({ ...opts, field: 'node_stats.thread_pool.write.rejected', // in 7.0, we can only check for this threadpool @@ -303,14 +356,13 @@ export class WriteThreadPoolRejectedMetric extends ElasticsearchMetric { }, }, }; - - this.calculation = (bucket) => { + this.calculation = (bucket: object) => { const index = _.get(bucket, 'index_deriv.normalized_value', null); const bulk = _.get(bucket, 'bulk_deriv.normalized_value', null); const write = _.get(bucket, 'write_deriv.normalized_value', null); if (index !== null || bulk !== null || write !== null) { - const valueOrZero = (value) => (value < 0 ? 0 : value || 0); + const valueOrZero = (value: number) => (value < 0 ? 0 : value || 0); return valueOrZero(index) + valueOrZero(bulk) + valueOrZero(write); } @@ -321,16 +373,20 @@ export class WriteThreadPoolRejectedMetric extends ElasticsearchMetric { } } +type MillisecondsToSecondsMetricOptions = Pick< + MetricOptions, + 'label' | 'description' | 'field' | 'title' | 'format' | 'metricAgg' | 'units' +> & { type: string }; + export class MillisecondsToSecondsMetric extends ElasticsearchMetric { - constructor(opts) { + constructor(opts: MillisecondsToSecondsMetricOptions) { super({ ...opts, units: i18n.translate('xpack.monitoring.metrics.es.secondsUnitLabel', { defaultMessage: 's', }), }); - - this.calculation = (bucket) => { + this.calculation = (bucket: object) => { return _.get(bucket, 'metric.value') / 1000; }; } diff --git a/x-pack/plugins/monitoring/server/lib/metrics/elasticsearch/metrics.js b/x-pack/plugins/monitoring/server/lib/metrics/elasticsearch/metrics.ts similarity index 100% rename from x-pack/plugins/monitoring/server/lib/metrics/elasticsearch/metrics.js rename to x-pack/plugins/monitoring/server/lib/metrics/elasticsearch/metrics.ts index 83841b0ecb39e7..c62a27000c8788 100644 --- a/x-pack/plugins/monitoring/server/lib/metrics/elasticsearch/metrics.js +++ b/x-pack/plugins/monitoring/server/lib/metrics/elasticsearch/metrics.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { i18n } from '@kbn/i18n'; import { QuotaMetric } from '../classes'; import { RequestRateMetric, @@ -27,7 +28,6 @@ import { LARGE_BYTES, LARGE_ABBREVIATED, } from '../../../../common/formatting'; -import { i18n } from '@kbn/i18n'; const indexingRateTitle = i18n.translate('xpack.monitoring.metrics.es.indexingRateTitle', { defaultMessage: 'Indexing Rate', // title to use for the chart diff --git a/x-pack/plugins/monitoring/server/lib/metrics/enterprise_search/classes.ts b/x-pack/plugins/monitoring/server/lib/metrics/enterprise_search/classes.ts index b1e2ab691c0e72..a97aa7d91f88af 100644 --- a/x-pack/plugins/monitoring/server/lib/metrics/enterprise_search/classes.ts +++ b/x-pack/plugins/monitoring/server/lib/metrics/enterprise_search/classes.ts @@ -5,12 +5,16 @@ * 2.0. */ -// @ts-ignore -import { Metric } from '../classes'; +import { Metric, MetricOptions } from '../classes'; + +type EnterpriseSearchMetricOptions = Pick< + MetricOptions, + 'field' | 'metricAgg' | 'label' | 'description' | 'format' | 'units' +> & + Partial>; export class EnterpriseSearchMetric extends Metric { - // @ts-ignore - constructor(opts) { + constructor(opts: EnterpriseSearchMetricOptions) { super({ ...opts, app: 'enterprise_search', diff --git a/x-pack/plugins/monitoring/server/lib/metrics/enterprise_search/metrics.js b/x-pack/plugins/monitoring/server/lib/metrics/enterprise_search/metrics.ts similarity index 100% rename from x-pack/plugins/monitoring/server/lib/metrics/enterprise_search/metrics.js rename to x-pack/plugins/monitoring/server/lib/metrics/enterprise_search/metrics.ts index 39a8475471d120..8955bfe59bf115 100644 --- a/x-pack/plugins/monitoring/server/lib/metrics/enterprise_search/metrics.js +++ b/x-pack/plugins/monitoring/server/lib/metrics/enterprise_search/metrics.ts @@ -5,9 +5,9 @@ * 2.0. */ +import { i18n } from '@kbn/i18n'; import { EnterpriseSearchMetric } from './classes'; import { LARGE_BYTES, SMALL_FLOAT, LARGE_FLOAT } from '../../../../common/formatting'; -import { i18n } from '@kbn/i18n'; const perSecondUnitLabel = i18n.translate('xpack.monitoring.metrics.entSearch.perSecondUnitLabel', { defaultMessage: '/s', diff --git a/x-pack/plugins/monitoring/server/lib/metrics/index.ts b/x-pack/plugins/monitoring/server/lib/metrics/index.ts index 50f477c27f49a1..12c19cdd4b8702 100644 --- a/x-pack/plugins/monitoring/server/lib/metrics/index.ts +++ b/x-pack/plugins/monitoring/server/lib/metrics/index.ts @@ -5,17 +5,13 @@ * 2.0. */ -// @ts-ignore export { ElasticsearchMetric } from './elasticsearch/classes'; -// @ts-ignore export { KibanaClusterMetric, KibanaMetric } from './kibana/classes'; export type { ApmMetricFields } from './apm/classes'; export { ApmMetric, ApmClusterMetric } from './apm/classes'; -// @ts-ignore export { LogstashClusterMetric, LogstashMetric } from './logstash/classes'; export type { BeatsMetricFields } from './beats/classes'; export { BeatsClusterMetric, BeatsMetric } from './beats/classes'; export { EnterpriseSearchMetric } from './enterprise_search/classes'; export type { EnterpriseSearchMetricFields } from './enterprise_search/classes'; -// @ts-ignore export { metrics } from './metrics'; diff --git a/x-pack/plugins/monitoring/server/lib/metrics/kibana/classes.js b/x-pack/plugins/monitoring/server/lib/metrics/kibana/classes.ts similarity index 68% rename from x-pack/plugins/monitoring/server/lib/metrics/kibana/classes.js rename to x-pack/plugins/monitoring/server/lib/metrics/kibana/classes.ts index fccd50c8e763c5..84c2d60b43fe22 100644 --- a/x-pack/plugins/monitoring/server/lib/metrics/kibana/classes.js +++ b/x-pack/plugins/monitoring/server/lib/metrics/kibana/classes.ts @@ -5,11 +5,19 @@ * 2.0. */ -import { ClusterMetric, Metric } from '../classes'; +/* eslint-disable max-classes-per-file */ + +import { ClusterMetric, Metric, MetricOptions } from '../classes'; import { NORMALIZED_DERIVATIVE_UNIT } from '../../../../common/constants'; +type KibanaClusterMetricOptions = Pick< + MetricOptions, + 'field' | 'label' | 'description' | 'format' | 'units' | 'metricAgg' +> & + Partial>; + export class KibanaClusterMetric extends ClusterMetric { - constructor(opts) { + constructor(opts: KibanaClusterMetricOptions) { super({ ...opts, app: 'kibana', @@ -25,8 +33,14 @@ export class KibanaClusterMetric extends ClusterMetric { } } +type KibanaEventsRateClusterMetricOptions = Pick< + MetricOptions, + 'field' | 'label' | 'description' | 'format' | 'units' +> & + Partial>; + export class KibanaEventsRateClusterMetric extends KibanaClusterMetric { - constructor(opts) { + constructor(opts: KibanaEventsRateClusterMetricOptions) { super({ ...opts, metricAgg: 'max', @@ -63,8 +77,14 @@ export class KibanaEventsRateClusterMetric extends KibanaClusterMetric { } } +type KibanaMetricOptions = Pick< + MetricOptions, + 'field' | 'label' | 'description' | 'format' | 'metricAgg' | 'units' +> & + Partial>; + export class KibanaMetric extends Metric { - constructor(opts) { + constructor(opts: KibanaMetricOptions) { super({ ...opts, app: 'kibana', diff --git a/x-pack/plugins/monitoring/server/lib/metrics/kibana/metrics.js b/x-pack/plugins/monitoring/server/lib/metrics/kibana/metrics.ts similarity index 100% rename from x-pack/plugins/monitoring/server/lib/metrics/kibana/metrics.js rename to x-pack/plugins/monitoring/server/lib/metrics/kibana/metrics.ts index 1cf156f97597ce..e6db13e222251f 100644 --- a/x-pack/plugins/monitoring/server/lib/metrics/kibana/metrics.js +++ b/x-pack/plugins/monitoring/server/lib/metrics/kibana/metrics.ts @@ -5,9 +5,9 @@ * 2.0. */ +import { i18n } from '@kbn/i18n'; import { KibanaEventsRateClusterMetric, KibanaMetric } from './classes'; import { LARGE_FLOAT, SMALL_FLOAT, LARGE_BYTES } from '../../../../common/formatting'; -import { i18n } from '@kbn/i18n'; const clientResponseTimeTitle = i18n.translate( 'xpack.monitoring.metrics.kibana.clientResponseTimeTitle', diff --git a/x-pack/plugins/monitoring/server/lib/metrics/logstash/classes.js b/x-pack/plugins/monitoring/server/lib/metrics/logstash/classes.ts similarity index 77% rename from x-pack/plugins/monitoring/server/lib/metrics/logstash/classes.js rename to x-pack/plugins/monitoring/server/lib/metrics/logstash/classes.ts index 234a1ac89f66d2..6fcd757e3c6c3a 100644 --- a/x-pack/plugins/monitoring/server/lib/metrics/logstash/classes.js +++ b/x-pack/plugins/monitoring/server/lib/metrics/logstash/classes.ts @@ -5,11 +5,13 @@ * 2.0. */ +/* eslint-disable max-classes-per-file */ + import _ from 'lodash'; -import { ClusterMetric, Metric } from '../classes'; +import { i18n } from '@kbn/i18n'; +import { ClusterMetric, Metric, MetricOptions } from '../classes'; import { LARGE_FLOAT } from '../../../../common/formatting'; import { NORMALIZED_DERIVATIVE_UNIT } from '../../../../common/constants'; -import { i18n } from '@kbn/i18n'; const msTimeUnitLabel = i18n.translate('xpack.monitoring.metrics.logstash.msTimeUnitLabel', { defaultMessage: 'ms', @@ -18,8 +20,14 @@ const perSecondUnitLabel = i18n.translate('xpack.monitoring.metrics.logstash.per defaultMessage: '/s', }); +type LogstashClusterMetricOptions = Pick< + MetricOptions, + 'field' | 'label' | 'description' | 'format' | 'metricAgg' | 'units' +> & + Partial>; + export class LogstashClusterMetric extends ClusterMetric { - constructor(opts) { + constructor(opts: LogstashClusterMetricOptions) { super({ ...opts, app: 'logstash', @@ -35,8 +43,13 @@ export class LogstashClusterMetric extends ClusterMetric { } } +type LogstashEventsLatencyClusterMetricOptions = Pick< + MetricOptions, + 'field' | 'label' | 'description' +>; + export class LogstashEventsLatencyClusterMetric extends LogstashClusterMetric { - constructor(opts) { + constructor(opts: LogstashEventsLatencyClusterMetricOptions) { super({ ...opts, format: LARGE_FLOAT, @@ -90,18 +103,23 @@ export class LogstashEventsLatencyClusterMetric extends LogstashClusterMetric { }, }, }; + } - this.calculation = (bucket) => { - const timeInMillisDeriv = _.get(bucket, 'events_time_in_millis_deriv.normalized_value', null); - const totalEventsDeriv = _.get(bucket, 'events_total_deriv.normalized_value', null); + public calculation = (bucket: object) => { + const timeInMillisDeriv = _.get(bucket, 'events_time_in_millis_deriv.normalized_value', null); + const totalEventsDeriv = _.get(bucket, 'events_total_deriv.normalized_value', null); - return Metric.calculateLatency(timeInMillisDeriv, totalEventsDeriv); - }; - } + return Metric.calculateLatency(timeInMillisDeriv, totalEventsDeriv); + }; } +type LogstashEventsRateClusterMetricOptions = Pick< + MetricOptions, + 'field' | 'label' | 'description' +>; + export class LogstashEventsRateClusterMetric extends LogstashClusterMetric { - constructor(opts) { + constructor(opts: LogstashEventsRateClusterMetricOptions) { super({ ...opts, derivative: true, @@ -141,8 +159,14 @@ export class LogstashEventsRateClusterMetric extends LogstashClusterMetric { } } +type LogstashMetricOptions = Pick< + MetricOptions, + 'field' | 'label' | 'description' | 'units' | 'derivative' | 'metricAgg' | 'format' +> & + Partial>; + export class LogstashMetric extends Metric { - constructor(opts) { + constructor(opts: LogstashMetricOptions) { super({ ...opts, app: 'logstash', @@ -158,8 +182,10 @@ export class LogstashMetric extends Metric { } } +type LogstashEventsLatencyMetricOptions = Pick; + export class LogstashEventsLatencyMetric extends LogstashMetric { - constructor(opts) { + constructor(opts: LogstashEventsLatencyMetricOptions) { super({ ...opts, format: LARGE_FLOAT, @@ -189,8 +215,7 @@ export class LogstashEventsLatencyMetric extends LogstashMetric { }, }, }; - - this.calculation = (bucket) => { + this.calculation = (bucket: object) => { const timeInMillisDeriv = _.get(bucket, 'events_time_in_millis_deriv.normalized_value', null); const totalEventsDeriv = _.get(bucket, 'events_total_deriv.normalized_value', null); @@ -199,8 +224,10 @@ export class LogstashEventsLatencyMetric extends LogstashMetric { } } +type LogstashEventsRateMetricOptions = Pick; + export class LogstashEventsRateMetric extends LogstashMetric { - constructor(opts) { + constructor(opts: LogstashEventsRateMetricOptions) { super({ ...opts, derivative: true, @@ -211,8 +238,14 @@ export class LogstashEventsRateMetric extends LogstashMetric { } } +type LogstashPipelineQueueSizeMetricOptions = Pick< + MetricOptions, + 'field' | 'label' | 'description' | 'format' | 'units' +> & + Partial>; + export class LogstashPipelineQueueSizeMetric extends LogstashMetric { - constructor(opts) { + constructor(opts: LogstashPipelineQueueSizeMetricOptions) { super({ ...opts }); this.dateHistogramSubAggs = { @@ -242,19 +275,32 @@ export class LogstashPipelineQueueSizeMetric extends LogstashMetric { }, }, }; - - this.calculation = (bucket) => _.get(bucket, 'pipelines.total_queue_size_for_node.value'); + this.calculation = (bucket: object) => { + return _.get(bucket, 'pipelines.total_queue_size_for_node.value'); + }; } } +type LogstashPipelineThroughputMetricOptions = Pick< + MetricOptions, + 'field' | 'label' | 'description' | 'format' | 'units' +> & + Partial> & { + mbField?: string; + }; + export class LogstashPipelineThroughputMetric extends LogstashMetric { - constructor(opts) { + constructor(opts: LogstashPipelineThroughputMetricOptions) { super({ ...opts, derivative: true, }); - this.getDateHistogramSubAggs = ({ pipeline }) => { + this.getDateHistogramSubAggs = ({ + pipeline, + }: { + pipeline: { uuids: string[]; id: string }; + }) => { return { metric_deriv: { derivative: { @@ -336,15 +382,30 @@ export class LogstashPipelineThroughputMetric extends LogstashMetric { } } +type LogstashPipelineNodeCountMetricOptions = Pick< + MetricOptions, + 'field' | 'label' | 'description' | 'format' | 'units' +> & + Partial>; + export class LogstashPipelineNodeCountMetric extends LogstashMetric { - constructor(opts) { + constructor(opts: LogstashPipelineNodeCountMetricOptions) { super({ ...opts, derivative: false, }); - this.getDateHistogramSubAggs = ({ pageOfPipelines }) => { - const termAggExtras = {}; + this.getDateHistogramSubAggs = ({ + pageOfPipelines, + }: { + pageOfPipelines: Array<{ id: string }>; + }) => { + const termAggExtras: { + include: string[]; + } = { + include: [], + }; + if (pageOfPipelines) { termAggExtras.include = pageOfPipelines.map((pipeline) => pipeline.id); } @@ -404,14 +465,14 @@ export class LogstashPipelineNodeCountMetric extends LogstashMetric { }; }; - this.calculation = (bucket) => { - const pipelineNodesCounts = {}; + this.calculation = (bucket: object) => { + const pipelineNodesCounts: any = {}; const legacyPipelineBuckets = _.get(bucket, 'pipelines_nested.by_pipeline_id.buckets', []); const mbPiplineBuckets = _.get(bucket, 'pipelines_mb_nested.by_pipeline_id.buckets', []); const pipelineBuckets = legacyPipelineBuckets.length ? legacyPipelineBuckets : mbPiplineBuckets; - pipelineBuckets.forEach((pipelineBucket) => { + pipelineBuckets.forEach((pipelineBucket: any) => { pipelineNodesCounts[pipelineBucket.key] = _.get(pipelineBucket, 'to_root.node_count.value'); }); diff --git a/x-pack/plugins/monitoring/server/lib/metrics/logstash/metrics.js b/x-pack/plugins/monitoring/server/lib/metrics/logstash/metrics.ts similarity index 100% rename from x-pack/plugins/monitoring/server/lib/metrics/logstash/metrics.js rename to x-pack/plugins/monitoring/server/lib/metrics/logstash/metrics.ts index a140cd7bcc3707..87024a6de86ab3 100644 --- a/x-pack/plugins/monitoring/server/lib/metrics/logstash/metrics.js +++ b/x-pack/plugins/monitoring/server/lib/metrics/logstash/metrics.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { i18n } from '@kbn/i18n'; import { QuotaMetric } from '../classes'; import { LogstashEventsRateClusterMetric, @@ -22,7 +23,6 @@ import { SMALL_BYTES, LARGE_ABBREVIATED, } from '../../../../common/formatting'; -import { i18n } from '@kbn/i18n'; const instanceSystemLoadTitle = i18n.translate( 'xpack.monitoring.metrics.logstash.systemLoadTitle', diff --git a/x-pack/plugins/monitoring/server/lib/metrics/metrics.js b/x-pack/plugins/monitoring/server/lib/metrics/metrics.ts similarity index 84% rename from x-pack/plugins/monitoring/server/lib/metrics/metrics.js rename to x-pack/plugins/monitoring/server/lib/metrics/metrics.ts index 58cc61f6bbdc5d..cb787d10c7cb8b 100644 --- a/x-pack/plugins/monitoring/server/lib/metrics/metrics.js +++ b/x-pack/plugins/monitoring/server/lib/metrics/metrics.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { Metric } from './classes/metric'; import { metrics as elasticsearchMetrics } from './elasticsearch/metrics'; import { metrics as kibanaMetrics } from './kibana/metrics'; import { metrics as logstashMetrics } from './logstash/metrics'; @@ -12,7 +13,9 @@ import { metrics as beatsMetrics } from './beats/metrics'; import { metrics as apmMetrics } from './apm/metrics'; import { metrics as entSearchMetrics } from './enterprise_search/metrics'; -export const metrics = { +export type { Metric } from './classes/metric'; + +export const metrics: { [key: string]: Metric } = { ...elasticsearchMetrics, ...kibanaMetrics, ...logstashMetrics, diff --git a/x-pack/plugins/observability/kibana.json b/x-pack/plugins/observability/kibana.json index dff163c57d5f62..505c8cfe79c03f 100644 --- a/x-pack/plugins/observability/kibana.json +++ b/x-pack/plugins/observability/kibana.json @@ -35,7 +35,8 @@ "data", "dataViews", "kibanaReact", - "kibanaUtils" + "kibanaUtils", + "lens" ], "extraPublicDirs": [ "common" diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/constants/constants.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/constants/constants.ts index d01d579daf91a8..286ad7005c2cbb 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/constants/constants.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/constants/constants.ts @@ -63,10 +63,11 @@ import { SYNTHETICS_STEP_DURATION, SYNTHETICS_STEP_NAME, } from './field_names/synthetics'; +import { DOCUMENT_FIELD_NAME } from '../../../../../../../lens/common/constants'; export const DEFAULT_TIME = { from: 'now-1h', to: 'now' }; -export const RECORDS_FIELD = 'Records'; +export const RECORDS_FIELD = DOCUMENT_FIELD_NAME; export const RECORDS_PERCENTAGE_FIELD = 'RecordsPercentage'; export const FieldLabels: Record = { diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes.test.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes.test.ts index 9c636edaac1973..430cf84c077cab 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes.test.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes.test.ts @@ -394,7 +394,7 @@ describe('Lens Attribute', () => { label: 'Part of count() / overall_sum(count())', operationType: 'count', scale: 'ratio', - sourceField: 'Records', + sourceField: RECORDS_FIELD, }, 'y-axis-column-layer0X1': { customLabel: true, @@ -408,7 +408,7 @@ describe('Lens Attribute', () => { label: 'Part of count() / overall_sum(count())', operationType: 'count', scale: 'ratio', - sourceField: 'Records', + sourceField: RECORDS_FIELD, }, 'y-axis-column-layer0X2': { customLabel: true, @@ -609,7 +609,7 @@ describe('Lens Attribute', () => { label: 'Part of count() / overall_sum(count())', operationType: 'count', scale: 'ratio', - sourceField: 'Records', + sourceField: RECORDS_FIELD, }, 'y-axis-column-layer0X1': { customLabel: true, @@ -623,7 +623,7 @@ describe('Lens Attribute', () => { label: 'Part of count() / overall_sum(count())', operationType: 'count', scale: 'ratio', - sourceField: 'Records', + sourceField: RECORDS_FIELD, }, 'y-axis-column-layer0X2': { customLabel: true, diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_columns/overall_column.tsx b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_columns/overall_column.tsx index 44b40944dfd079..35121f6df94b35 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_columns/overall_column.tsx +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_columns/overall_column.tsx @@ -12,6 +12,7 @@ import { FormulaIndexPatternColumn, OverallSumIndexPatternColumn, } from '../../../../../../../lens/public'; +import { RECORDS_FIELD } from '../constants'; export function getDistributionInPercentageColumn({ label, @@ -50,7 +51,7 @@ export function getDistributionInPercentageColumn({ operationType: 'count', isBucketed: false, scale: 'ratio', - sourceField: 'Records', + sourceField: RECORDS_FIELD, customLabel: true, filter: { query: columnFilter ?? '', language: 'kuery' }, }; diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute.ts index ba4b4a3bce4d9d..e92d4f430ae7b5 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute.ts @@ -4,6 +4,8 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ +import { RECORDS_FIELD } from '../constants'; + export const sampleAttribute = { description: '', references: [ @@ -88,7 +90,7 @@ export const sampleAttribute = { label: 'Part of count() / overall_sum(count())', operationType: 'count', scale: 'ratio', - sourceField: 'Records', + sourceField: RECORDS_FIELD, }, 'y-axis-column-layer0X1': { customLabel: true, @@ -102,7 +104,7 @@ export const sampleAttribute = { label: 'Part of count() / overall_sum(count())', operationType: 'count', scale: 'ratio', - sourceField: 'Records', + sourceField: RECORDS_FIELD, }, 'y-axis-column-layer0X2': { customLabel: true, diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute_cwv.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute_cwv.ts index f595e7a1478129..0230f5643ada8d 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute_cwv.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute_cwv.ts @@ -4,6 +4,8 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ +import { RECORDS_FIELD } from '../constants'; + export const sampleAttributeCoreWebVital = { description: '', references: [ @@ -59,7 +61,7 @@ export const sampleAttributeCoreWebVital = { label: 'Average', operationType: 'count', scale: 'ratio', - sourceField: 'Records', + sourceField: RECORDS_FIELD, }, 'y-axis-column-2': { dataType: 'number', @@ -71,7 +73,7 @@ export const sampleAttributeCoreWebVital = { label: 'Poor', operationType: 'count', scale: 'ratio', - sourceField: 'Records', + sourceField: RECORDS_FIELD, }, 'y-axis-column-layer0': { dataType: 'number', @@ -84,7 +86,7 @@ export const sampleAttributeCoreWebVital = { label: 'Good', operationType: 'count', scale: 'ratio', - sourceField: 'Records', + sourceField: RECORDS_FIELD, }, }, incompleteColumns: {}, diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute_kpi.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute_kpi.ts index 52ccdc2918e4c2..6da949896aa5fa 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute_kpi.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute_kpi.ts @@ -4,6 +4,8 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ +import { RECORDS_FIELD } from '../constants'; + export const sampleAttributeKpi = { description: '', references: [ @@ -46,7 +48,7 @@ export const sampleAttributeKpi = { label: 'Page views', operationType: 'count', scale: 'ratio', - sourceField: 'Records', + sourceField: RECORDS_FIELD, }, }, incompleteColumns: {}, diff --git a/x-pack/plugins/observability/public/index.ts b/x-pack/plugins/observability/public/index.ts index d855d0178192ed..550969191fa878 100644 --- a/x-pack/plugins/observability/public/index.ts +++ b/x-pack/plugins/observability/public/index.ts @@ -102,5 +102,7 @@ export type { SeriesConfig, ConfigProps } from './components/shared/exploratory_ export { ReportTypes, REPORT_METRIC_FIELD, + RECORDS_PERCENTAGE_FIELD, + RECORDS_FIELD, } from './components/shared/exploratory_view/configurations/constants'; export { ExploratoryViewContextProvider } from './components/shared/exploratory_view/contexts/exploratory_view_config'; diff --git a/x-pack/plugins/osquery/cypress/tasks/integrations.ts b/x-pack/plugins/osquery/cypress/tasks/integrations.ts index 673f2091760a65..ebf8668483d1c0 100644 --- a/x-pack/plugins/osquery/cypress/tasks/integrations.ts +++ b/x-pack/plugins/osquery/cypress/tasks/integrations.ts @@ -13,10 +13,10 @@ import { DATA_COLLECTION_SETUP_STEP, } from '../screens/integrations'; -export const addIntegration = (agent = 'Default fleet') => { +export const addIntegration = (agentPolicy = 'Default Fleet Server policy') => { cy.getBySel(ADD_POLICY_BTN).click(); cy.getBySel(DATA_COLLECTION_SETUP_STEP).find('.euiLoadingSpinner').should('not.exist'); - cy.getBySel('comboBoxInput').click().type(`${agent} {downArrow} {enter}`); + cy.getBySel('agentPolicySelect').select(agentPolicy); cy.getBySel(CREATE_PACKAGE_POLICY_SAVE_BTN).click(); // sometimes agent is assigned to default policy, sometimes not closeModalIfVisible(); diff --git a/x-pack/plugins/osquery/kibana.json b/x-pack/plugins/osquery/kibana.json index a499b2b75ee685..63f75b233f73b0 100644 --- a/x-pack/plugins/osquery/kibana.json +++ b/x-pack/plugins/osquery/kibana.json @@ -8,7 +8,7 @@ }, "kibanaVersion": "kibana", "optionalPlugins": ["fleet", "home", "usageCollection", "lens"], - "requiredBundles": ["esUiShared", "fleet", "kibanaUtils", "kibanaReact"], + "requiredBundles": ["esUiShared", "fleet", "kibanaUtils", "kibanaReact", "lens"], "requiredPlugins": [ "actions", "data", diff --git a/x-pack/plugins/osquery/public/packs/pack_queries_status_table.tsx b/x-pack/plugins/osquery/public/packs/pack_queries_status_table.tsx index 2bfe75e2833aaf..8b8d361611a2da 100644 --- a/x-pack/plugins/osquery/public/packs/pack_queries_status_table.tsx +++ b/x-pack/plugins/osquery/public/packs/pack_queries_status_table.tsx @@ -30,6 +30,7 @@ import { PieVisualizationState, TermsIndexPatternColumn, } from '../../../lens/public'; +import { DOCUMENT_FIELD_NAME as RECORDS_FIELD } from '../../../lens/common/constants'; import { FilterStateStore, DataView } from '../../../../../src/plugins/data/common'; import { useKibana } from '../common/lib/kibana'; import { OsqueryManagerPackagePolicyInputStream } from '../../common/types'; @@ -91,7 +92,7 @@ function getLensAttributes( }, } as TermsIndexPatternColumn, 'ed999e9d-204c-465b-897f-fe1a125b39ed': { - sourceField: 'Records', + sourceField: RECORDS_FIELD, isBucketed: false, dataType: 'number', scale: 'ratio', diff --git a/x-pack/plugins/painless_lab/kibana.json b/x-pack/plugins/painless_lab/kibana.json index 1f59bf30bb761f..6032d5ccc0d8df 100644 --- a/x-pack/plugins/painless_lab/kibana.json +++ b/x-pack/plugins/painless_lab/kibana.json @@ -1,6 +1,6 @@ { "id": "painlessLab", - "version": "8.1.0", + "version": "8.2.0", "kibanaVersion": "kibana", "owner": { "name": "Stack Management", diff --git a/x-pack/plugins/remote_clusters/__jest__/client_integration/add/remote_clusters_add.helpers.tsx b/x-pack/plugins/remote_clusters/__jest__/client_integration/add/remote_clusters_add.helpers.tsx index a47e6c023a161f..a4debdc6ae9640 100644 --- a/x-pack/plugins/remote_clusters/__jest__/client_integration/add/remote_clusters_add.helpers.tsx +++ b/x-pack/plugins/remote_clusters/__jest__/client_integration/add/remote_clusters_add.helpers.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; import { RemoteClusterAdd } from '../../../public/application/sections'; import { createRemoteClustersStore } from '../../../public/application/store'; diff --git a/x-pack/plugins/remote_clusters/__jest__/client_integration/add/remote_clusters_add.test.ts b/x-pack/plugins/remote_clusters/__jest__/client_integration/add/remote_clusters_add.test.ts index 0727bc0c9ba2d8..28332f71ca6aca 100644 --- a/x-pack/plugins/remote_clusters/__jest__/client_integration/add/remote_clusters_add.test.ts +++ b/x-pack/plugins/remote_clusters/__jest__/client_integration/add/remote_clusters_add.test.ts @@ -6,7 +6,7 @@ */ import { SinonFakeServer } from 'sinon'; -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; import { act } from 'react-dom/test-utils'; import { setupEnvironment, RemoteClustersActions } from '../helpers'; diff --git a/x-pack/plugins/remote_clusters/__jest__/client_integration/edit/remote_clusters_edit.helpers.tsx b/x-pack/plugins/remote_clusters/__jest__/client_integration/edit/remote_clusters_edit.helpers.tsx index 2259396bf33f20..86f75c12424e76 100644 --- a/x-pack/plugins/remote_clusters/__jest__/client_integration/edit/remote_clusters_edit.helpers.tsx +++ b/x-pack/plugins/remote_clusters/__jest__/client_integration/edit/remote_clusters_edit.helpers.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed, TestBedConfig } from '@kbn/test/jest'; +import { registerTestBed, TestBedConfig } from '@kbn/test-jest-helpers'; import React from 'react'; import { RemoteClusterEdit } from '../../../public/application/sections'; diff --git a/x-pack/plugins/remote_clusters/__jest__/client_integration/edit/remote_clusters_edit.test.tsx b/x-pack/plugins/remote_clusters/__jest__/client_integration/edit/remote_clusters_edit.test.tsx index 2913de94bc2dd8..47aac3f924b964 100644 --- a/x-pack/plugins/remote_clusters/__jest__/client_integration/edit/remote_clusters_edit.test.tsx +++ b/x-pack/plugins/remote_clusters/__jest__/client_integration/edit/remote_clusters_edit.test.tsx @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; import { RemoteClusterForm } from '../../../public/application/sections/components/remote_cluster_form'; import { RemoteClustersActions, setupEnvironment } from '../helpers'; diff --git a/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/index.ts b/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/index.ts index 4cfe1fb41a835d..b2a7e2d90dc64c 100644 --- a/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/index.ts +++ b/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -export { nextTick, getRandomString, findTestSubject } from '@kbn/test/jest'; +export { nextTick, getRandomString, findTestSubject } from '@kbn/test-jest-helpers'; export { setupEnvironment } from './setup_environment'; export type { RemoteClustersActions } from './remote_clusters_actions'; export { createRemoteClustersActions } from './remote_clusters_actions'; diff --git a/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_actions.ts b/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_actions.ts index ba0c424793838a..3a2d4be3e060dd 100644 --- a/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_actions.ts +++ b/x-pack/plugins/remote_clusters/__jest__/client_integration/helpers/remote_clusters_actions.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { TestBed } from '@kbn/test/jest'; +import { TestBed } from '@kbn/test-jest-helpers'; import { act } from 'react-dom/test-utils'; export interface RemoteClustersActions { docsButtonExists: () => boolean; 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 d05ddbd1800e4e..9aeef5d684f3fe 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 @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; -import { registerTestBed, findTestSubject } from '@kbn/test/jest'; +import { registerTestBed, findTestSubject } from '@kbn/test-jest-helpers'; import { RemoteClusterList } from '../../../public/application/sections/remote_cluster_list'; import { createRemoteClustersStore } from '../../../public/application/store'; diff --git a/x-pack/plugins/remote_clusters/__jest__/client_integration/list/remote_clusters_list.test.js b/x-pack/plugins/remote_clusters/__jest__/client_integration/list/remote_clusters_list.test.js index 209c224618f78e..a6987fa19d1eef 100644 --- a/x-pack/plugins/remote_clusters/__jest__/client_integration/list/remote_clusters_list.test.js +++ b/x-pack/plugins/remote_clusters/__jest__/client_integration/list/remote_clusters_list.test.js @@ -77,6 +77,51 @@ describe('', () => { }); }); + describe('can search', () => { + let table; + let component; + let form; + + const remoteClusters = [ + { + name: 'simple_remote_cluster', + seeds: ['127.0.0.1:2000', '127.0.0.2:3000'], + }, + { + name: 'remote_cluster_with_proxy', + proxyAddress: '192.168.0.1:80', + mode: PROXY_MODE, + }, + ]; + + beforeEach(async () => { + httpRequestsMockHelpers.setLoadRemoteClustersResponse(remoteClusters); + + await act(async () => { + ({ table, component, form } = setup()); + }); + + component.update(); + }); + + test('without any search params it should show all clusters', () => { + const { tableCellsValues } = table.getMetaData('remoteClusterListTable'); + expect(tableCellsValues.length).toBe(2); + }); + + test('search by seed works', () => { + form.setInputValue('remoteClusterSearch', 'simple'); + const { tableCellsValues } = table.getMetaData('remoteClusterListTable'); + expect(tableCellsValues.length).toBe(1); + }); + + test('search by proxyAddress works', () => { + form.setInputValue('remoteClusterSearch', 'proxy'); + const { tableCellsValues } = table.getMetaData('remoteClusterListTable'); + expect(tableCellsValues.length).toBe(1); + }); + }); + describe('when there are multiple pages of remote clusters', () => { let table; let actions; @@ -91,10 +136,18 @@ describe('', () => { ]; for (let i = 0; i < 29; i++) { - remoteClusters.push({ - name: `name${i}`, - seeds: [], - }); + if (i % 2 === 0) { + remoteClusters.push({ + name: `cluster-${i}`, + seeds: [], + }); + } else { + remoteClusters.push({ + name: `cluster_with_proxy-${i}`, + proxyAddress: `127.0.0.1:10${i}`, + mode: PROXY_MODE, + }); + } } beforeEach(async () => { diff --git a/x-pack/plugins/remote_clusters/common/constants.ts b/x-pack/plugins/remote_clusters/common/constants.ts index 072d6d437b8b99..86910640191e3e 100644 --- a/x-pack/plugins/remote_clusters/common/constants.ts +++ b/x-pack/plugins/remote_clusters/common/constants.ts @@ -20,7 +20,7 @@ export const PLUGIN = { }, }; -export const MAJOR_VERSION = '8.1.0'; +export const MAJOR_VERSION = '8.2.0'; export const API_BASE_PATH = '/api/remote_clusters'; diff --git a/x-pack/plugins/remote_clusters/fixtures/remote_cluster.js b/x-pack/plugins/remote_clusters/fixtures/remote_cluster.js index d6bbe99f7b5d79..d750636b762342 100644 --- a/x-pack/plugins/remote_clusters/fixtures/remote_cluster.js +++ b/x-pack/plugins/remote_clusters/fixtures/remote_cluster.js @@ -5,7 +5,7 @@ * 2.0. */ -import { getRandomString } from '@kbn/test/jest'; +import { getRandomString } from '@kbn/test-jest-helpers'; import { SNIFF_MODE } from '../common/constants'; diff --git a/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/remote_cluster_table/remote_cluster_table.js b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/remote_cluster_table/remote_cluster_table.js index 0b3a272f5bdc41..b53c735ef9fbb2 100644 --- a/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/remote_cluster_table/remote_cluster_table.js +++ b/x-pack/plugins/remote_clusters/public/application/sections/remote_cluster_list/remote_cluster_table/remote_cluster_table.js @@ -31,13 +31,22 @@ const getFilteredClusters = (clusters, queryText) => { const normalizedSearchText = queryText.toLowerCase(); return clusters.filter((cluster) => { - const { name, seeds } = cluster; + const { name, seeds, proxyAddress } = cluster; const normalizedName = name.toLowerCase(); + if (normalizedName.toLowerCase().includes(normalizedSearchText)) { return true; } - return seeds.some((seed) => seed.includes(normalizedSearchText)); + if (proxyAddress && proxyAddress.toLowerCase().includes(normalizedSearchText)) { + return true; + } + + if (seeds) { + return seeds.some((seed) => seed.includes(normalizedSearchText)); + } + + return false; }); } else { return clusters; @@ -81,6 +90,11 @@ export class RemoteClusterTable extends Component { } onSearch = ({ query }) => { + // There's no need to update the state if there arent any search params + if (!query) { + return; + } + const { clusters } = this.props; const { text } = query; diff --git a/x-pack/plugins/reporting/public/management/__test__/report_listing.test.helpers.tsx b/x-pack/plugins/reporting/public/management/__test__/report_listing.test.helpers.tsx index 3030994c5ed32a..3200a3305ebcd2 100644 --- a/x-pack/plugins/reporting/public/management/__test__/report_listing.test.helpers.tsx +++ b/x-pack/plugins/reporting/public/management/__test__/report_listing.test.helpers.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; import { act } from 'react-dom/test-utils'; import { Observable } from 'rxjs'; import { SerializableRecord } from '@kbn/utility-types'; diff --git a/x-pack/plugins/reporting/public/share_context_menu/reporting_panel_content/reporting_panel_content.test.tsx b/x-pack/plugins/reporting/public/share_context_menu/reporting_panel_content/reporting_panel_content.test.tsx index ef3e9940238c11..82dfe8e167dfa4 100644 --- a/x-pack/plugins/reporting/public/share_context_menu/reporting_panel_content/reporting_panel_content.test.tsx +++ b/x-pack/plugins/reporting/public/share_context_menu/reporting_panel_content/reporting_panel_content.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { httpServiceMock, notificationServiceMock, diff --git a/x-pack/plugins/reporting/server/lib/tasks/execute_report.ts b/x-pack/plugins/reporting/server/lib/tasks/execute_report.ts index dd3f93ad2c0c6c..dbd11943f70e45 100644 --- a/x-pack/plugins/reporting/server/lib/tasks/execute_report.ts +++ b/x-pack/plugins/reporting/server/lib/tasks/execute_report.ts @@ -358,13 +358,13 @@ export class ExecuteReportTask implements ReportingTask { stream.end(); - eventLog.logExecutionComplete({ byteSize: stream.bytesWritten }); - await promisify(finished)(stream, { readable: false }); report._seq_no = stream.getSeqNo()!; report._primary_term = stream.getPrimaryTerm()!; + eventLog.logExecutionComplete({ byteSize: stream.bytesWritten }); + if (output) { this.logger.debug(`Job output size: ${stream.bytesWritten} bytes.`); report = await this._completeJob(report, { diff --git a/x-pack/plugins/rollup/fixtures/job.js b/x-pack/plugins/rollup/fixtures/job.js index 53c63e14c96ccb..d0086d134c60b6 100644 --- a/x-pack/plugins/rollup/fixtures/job.js +++ b/x-pack/plugins/rollup/fixtures/job.js @@ -5,7 +5,7 @@ * 2.0. */ -import { getRandomString } from '@kbn/test/jest'; +import { getRandomString } from '@kbn/test-jest-helpers'; 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 e1f9ec2b3a315c..fa63639ef4d064 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; 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 b2c738a033b3cb..ba82e3b9b9f5e8 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; 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 d52f3fa35a5441..d9fbf796c64d63 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 @@ -7,7 +7,7 @@ import { Pager } from '@elastic/eui'; -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; 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 ef5a191b994c61..c897eed6c477e2 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 @@ -11,7 +11,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 { getRandomString, findTestSubject } from '@kbn/test/jest'; +export { getRandomString, findTestSubject } from '@kbn/test-jest-helpers'; export { wrapComponent } from './setup_context'; 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 d81bdd30933006..613980868edbec 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; 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 36550d904fa39f..92eb2bf62cc2f0 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 @@ -7,7 +7,7 @@ import { act } from 'react-dom/test-utils'; -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; 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 f4c59334b88752..5f64e0cfe34bff 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; 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/rule_registry/common/assets/field_maps/experimental_rule_field_map.test.ts b/x-pack/plugins/rule_registry/common/assets/field_maps/experimental_rule_field_map.test.ts new file mode 100644 index 00000000000000..d3ed9ff937a0c1 --- /dev/null +++ b/x-pack/plugins/rule_registry/common/assets/field_maps/experimental_rule_field_map.test.ts @@ -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 + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { experimentalRuleFieldMap } from './experimental_rule_field_map'; + +// This test purely exists to see what the resultant mappings are and +// make it obvious when some dependency results in the mappings changing +it('matches snapshot', () => { + expect(experimentalRuleFieldMap).toMatchInlineSnapshot(` + Object { + "kibana.alert.evaluation.threshold": Object { + "scaling_factor": 100, + "type": "scaled_float", + }, + "kibana.alert.evaluation.value": Object { + "scaling_factor": 100, + "type": "scaled_float", + }, + "kibana.alert.instance.id": Object { + "required": true, + "type": "keyword", + }, + } + `); +}); diff --git a/x-pack/plugins/rule_registry/common/assets/field_maps/technical_rule_field_map.test.ts b/x-pack/plugins/rule_registry/common/assets/field_maps/technical_rule_field_map.test.ts new file mode 100644 index 00000000000000..916174f225415e --- /dev/null +++ b/x-pack/plugins/rule_registry/common/assets/field_maps/technical_rule_field_map.test.ts @@ -0,0 +1,233 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { technicalRuleFieldMap } from './technical_rule_field_map'; + +// This test purely exists to see what the resultant mappings are and +// make it obvious when some dependency results in the mappings changing +it('matches snapshot', () => { + expect(technicalRuleFieldMap).toMatchInlineSnapshot(` + Object { + "@timestamp": Object { + "array": false, + "required": true, + "type": "date", + }, + "ecs.version": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "event.action": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "event.kind": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.alert.action_group": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.alert.duration.us": Object { + "type": "long", + }, + "kibana.alert.end": Object { + "type": "date", + }, + "kibana.alert.reason": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.alert.risk_score": Object { + "array": false, + "required": false, + "type": "float", + }, + "kibana.alert.rule.author": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.alert.rule.category": Object { + "array": false, + "required": true, + "type": "keyword", + }, + "kibana.alert.rule.consumer": Object { + "required": true, + "type": "keyword", + }, + "kibana.alert.rule.created_at": Object { + "array": false, + "required": false, + "type": "date", + }, + "kibana.alert.rule.created_by": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.alert.rule.description": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.alert.rule.enabled": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.alert.rule.execution.uuid": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.alert.rule.from": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.alert.rule.interval": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.alert.rule.license": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.alert.rule.name": Object { + "array": false, + "required": true, + "type": "keyword", + }, + "kibana.alert.rule.note": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.alert.rule.parameters": Object { + "ignore_above": 4096, + "type": "flattened", + }, + "kibana.alert.rule.producer": Object { + "required": true, + "type": "keyword", + }, + "kibana.alert.rule.references": Object { + "array": true, + "required": false, + "type": "keyword", + }, + "kibana.alert.rule.rule_id": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.alert.rule.rule_name_override": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.alert.rule.rule_type_id": Object { + "required": true, + "type": "keyword", + }, + "kibana.alert.rule.tags": Object { + "array": true, + "required": false, + "type": "keyword", + }, + "kibana.alert.rule.to": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.alert.rule.type": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.alert.rule.updated_at": Object { + "array": false, + "required": false, + "type": "date", + }, + "kibana.alert.rule.updated_by": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.alert.rule.uuid": Object { + "array": false, + "required": true, + "type": "keyword", + }, + "kibana.alert.rule.version": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.alert.severity": Object { + "type": "keyword", + }, + "kibana.alert.start": Object { + "type": "date", + }, + "kibana.alert.status": Object { + "required": true, + "type": "keyword", + }, + "kibana.alert.system_status": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.alert.uuid": Object { + "required": true, + "type": "keyword", + }, + "kibana.alert.workflow_reason": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.alert.workflow_status": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.alert.workflow_user": Object { + "array": false, + "required": false, + "type": "keyword", + }, + "kibana.space_ids": Object { + "array": true, + "required": true, + "type": "keyword", + }, + "kibana.version": Object { + "array": false, + "required": false, + "type": "version", + }, + "tags": Object { + "array": true, + "required": false, + "type": "keyword", + }, + } + `); +}); diff --git a/x-pack/plugins/runtime_fields/public/test_utils.ts b/x-pack/plugins/runtime_fields/public/test_utils.ts index 1c052cd666e568..637ef68b1726d3 100644 --- a/x-pack/plugins/runtime_fields/public/test_utils.ts +++ b/x-pack/plugins/runtime_fields/public/test_utils.ts @@ -5,5 +5,5 @@ * 2.0. */ -export type { TestBed } from '@kbn/test/jest'; -export { registerTestBed } from '@kbn/test/jest'; +export type { TestBed } from '@kbn/test-jest-helpers'; +export { registerTestBed } from '@kbn/test-jest-helpers'; 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 91fda67046f93e..007786722ca52c 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; 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 ef93896e7fe3ec..ac8df87086e57e 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; 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 27109c05270326..a4a1f8864e883f 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; 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 caa858c41d7020..d6c7a0afbf38d0 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; 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 8e495e7d2c49e4..f92e2b2a5167c3 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 @@ -8,7 +8,7 @@ import 'brace'; import 'brace/mode/json'; -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; 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 fef3c2e46958fa..64cd05f3fa0a57 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; 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 4cc7b0e5db9666..daba54949efe8b 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed } from '@kbn/test/jest'; +import { registerTestBed } from '@kbn/test-jest-helpers'; 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 4e9f1a6692eb92..fb733226553996 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 @@ -8,7 +8,7 @@ import { act } from '@testing-library/react'; import React from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import type { AuthenticatedUser } from '../../common/model'; 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 f6fcf36a12ee67..a7a43077fbc464 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 @@ -10,7 +10,7 @@ import { act } from '@testing-library/react'; import React from 'react'; import ReactMarkdown from 'react-markdown'; -import { findTestSubject, mountWithIntl, nextTick } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; 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 eba918e0721108..f775d158a3ec06 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 @@ -7,7 +7,7 @@ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { AuthenticationStatePage } from './authentication_state_page'; diff --git a/x-pack/plugins/security/public/authentication/logged_out/logged_out_page.test.tsx b/x-pack/plugins/security/public/authentication/logged_out/logged_out_page.test.tsx index 8647edd2ba06ae..d21cf1bb5677cd 100644 --- a/x-pack/plugins/security/public/authentication/logged_out/logged_out_page.test.tsx +++ b/x-pack/plugins/security/public/authentication/logged_out/logged_out_page.test.tsx @@ -8,7 +8,7 @@ import { EuiButton } from '@elastic/eui'; import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import { LoggedOutPage } from './logged_out_page'; 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 a9bbcaab74ab0d..9de62907261c17 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 @@ -11,7 +11,7 @@ import type { ReactWrapper } from 'enzyme'; import React from 'react'; import ReactMarkdown from 'react-markdown'; -import { findTestSubject, mountWithIntl, nextTick, shallowWithIntl } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl, nextTick, shallowWithIntl } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import { LoginForm, MessageType, PageMode } from './login_form'; 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 c01777a1064902..65073552212595 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 @@ -10,7 +10,7 @@ import { act } from '@testing-library/react'; import { shallow } from 'enzyme'; import React from 'react'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import { AUTH_PROVIDER_HINT_QUERY_STRING_PARAMETER } from '../../../common/constants'; 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 42915e841b3a75..66b2408338391d 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 @@ -9,7 +9,7 @@ import { EuiButton } from '@elastic/eui'; import { act } from '@testing-library/react'; import React from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import { mockAuthenticatedUser } from '../../../common/model/authenticated_user.mock'; 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 3abcc07042e828..bde0980613b22b 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 @@ -7,7 +7,7 @@ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { RoleComboBox } from './role_combo_box'; 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 17a6fb0bb84b3a..55b6cbee4783aa 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 @@ -9,7 +9,7 @@ import { EuiConfirmModal } from '@elastic/eui'; import { act } from '@testing-library/react'; import React from 'react'; -import { findTestSubject, mountWithIntl, nextTick } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import type { RoleMapping } from '../../../../../common/model'; 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 e3e5929428164c..92ce48cda0cd23 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 @@ -7,7 +7,7 @@ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { SectionLoading } from './section_loading'; 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 af7a2fb8d52404..083b742a21fe75 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 @@ -8,11 +8,11 @@ // 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 '@kbn/test/target_node/jest/utils/stub_web_worker'; +import '@kbn/test-jest-helpers/target_node/stub_web_worker'; import React from 'react'; -import { findTestSubject, mountWithIntl, nextTick } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import type { PublicMethodsOf } from '@kbn/utility-types'; import { coreMock, scopedHistoryMock } from 'src/core/public/mocks'; import { KibanaContextProvider } from 'src/plugins/kibana_react/public'; 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 3e18437a52ece1..dd3bd25a745ca5 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 @@ -7,7 +7,7 @@ import React from 'react'; -import { findTestSubject, mountWithIntl } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl } from '@kbn/test-jest-helpers'; import type { PublicMethodsOf } from '@kbn/utility-types'; import { coreMock } from 'src/core/public/mocks'; 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 a82b089f6630e0..14cc6db062987b 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 @@ -7,7 +7,7 @@ import React from 'react'; -import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import { AddRoleTemplateButton } from './add_role_template_button'; 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 367fdaadca96ea..6d34dbffded8b1 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 @@ -8,7 +8,7 @@ import { EuiComboBox } from '@elastic/eui'; import React from 'react'; -import { findTestSubject, mountWithIntl } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl } from '@kbn/test-jest-helpers'; import type { PublicMethodsOf } from '@kbn/utility-types'; import type { Role, RoleMapping } from '../../../../../common/model'; 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 844d7b48321c5d..c8df67e4f7b989 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 @@ -7,7 +7,7 @@ import React from 'react'; -import { findTestSubject, mountWithIntl } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl } from '@kbn/test-jest-helpers'; import { RoleTemplateEditor } from './role_template_editor'; 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 399d2fc2d2c912..2ada7e9730cb0c 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 @@ -7,7 +7,7 @@ import React from 'react'; -import { findTestSubject, mountWithIntl } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl } from '@kbn/test-jest-helpers'; import { AllRule, FieldRule } from '../../model'; import { AddRuleButton } from './add_rule_button'; 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 c81f3cc9da595a..e2e41e90be824a 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 @@ -8,7 +8,7 @@ import type { ReactWrapper } from 'enzyme'; import React from 'react'; -import { findTestSubject, mountWithIntl } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl } from '@kbn/test-jest-helpers'; import { FieldRule } from '../../model'; import { FieldRuleEditor } from './field_rule_editor'; 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 5a1122a88ac805..06437675a8270e 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,13 +10,13 @@ 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 '@kbn/test/target_node/jest/utils/stub_web_worker'; +import '@kbn/test-jest-helpers/target_node//stub_web_worker'; import React from 'react'; import { act } from 'react-dom/test-utils'; import type { monaco } from '@kbn/monaco'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { CodeEditorField } from 'src/plugins/kibana_react/public'; import { AllRule, AnyRule, ExceptAllRule, ExceptAnyRule, FieldRule } 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 c0da0ae42a7263..36b1390072408d 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 @@ -8,12 +8,12 @@ // 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 '@kbn/test/target_node/jest/utils/stub_web_worker'; +import '@kbn/test-jest-helpers/target_node/stub_web_worker'; import { EuiErrorBoundary } from '@elastic/eui'; import React from 'react'; -import { findTestSubject, mountWithIntl } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import { KibanaContextProvider } from 'src/plugins/kibana_react/public'; 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 8915bef293bc2d..07a458b6a48b9c 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 @@ -8,7 +8,7 @@ import { EuiContextMenuItem } from '@elastic/eui'; import React from 'react'; -import { findTestSubject, mountWithIntl, nextTick, shallowWithIntl } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl, nextTick, shallowWithIntl } from '@kbn/test-jest-helpers'; import { AllRule, AnyRule, ExceptAnyRule, FieldRule } from '../../model'; import { AddRuleButton } from './add_rule_button'; 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 fc48e2e1c8c9ed..9428e860acc096 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 @@ -7,7 +7,7 @@ import React from 'react'; -import { findTestSubject, mountWithIntl } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl } from '@kbn/test-jest-helpers'; import { AllRule, AnyRule, ExceptAllRule, ExceptAnyRule, FieldRule } from '../../model'; 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 d9009d49b592b5..3ac54cb7863fdb 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 @@ -9,7 +9,7 @@ import { EuiLink } from '@elastic/eui'; import { act } from '@testing-library/react'; import React from 'react'; -import { findTestSubject, mountWithIntl, nextTick } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import type { CoreStart } from 'src/core/public'; import { coreMock, scopedHistoryMock } from 'src/core/public/mocks'; import { KibanaContextProvider } from 'src/plugins/kibana_react/public'; 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 e37b440d2c0219..65c30d0a723ea6 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 @@ -8,7 +8,7 @@ import { EuiLink } from '@elastic/eui'; import React from 'react'; -import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import { CollapsiblePanel } from './collapsible_panel'; 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 1faf514e71925d..32d1e4fa6bafbf 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 @@ -8,7 +8,7 @@ import { EuiButtonEmpty, EuiConfirmModal } from '@elastic/eui'; import React from 'react'; -import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import { DeleteRoleButton } from './delete_role_button'; 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 a99e08fd5a8a60..e7c3490d2ce130 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 @@ -9,7 +9,7 @@ import { act } from '@testing-library/react'; import type { ReactWrapper } from 'enzyme'; import React from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import type { Capabilities } from 'src/core/public'; import { coreMock, scopedHistoryMock } from 'src/core/public/mocks'; import { dataPluginMock } from 'src/plugins/data/public/mocks'; 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 baeba5829562ed..816e3f43c9ddcf 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 { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import type { Role } from '../../../../../../common/model'; import { ClusterPrivileges } from './cluster_privileges'; 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 0ed93629569606..9585db6efda251 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 @@ -7,7 +7,7 @@ import React from 'react'; -import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import { licenseMock } from '../../../../../../common/licensing/index.mock'; 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 af701df39d8b1a..d61fd1e17e33b5 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 @@ -8,7 +8,7 @@ import { EuiButtonIcon, EuiComboBox, EuiTextArea } from '@elastic/eui'; import React from 'react'; -import { findTestSubject, mountWithIntl, nextTick, shallowWithIntl } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl, nextTick, shallowWithIntl } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import { 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 03c949d90e30aa..440d5132baa335 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 @@ -7,7 +7,7 @@ import React from 'react'; -import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import { KibanaContextProvider } from '../../../../../../../../../src/plugins/kibana_react/public'; 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 3fab9d86e4dd31..c236bf15e3bb75 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 @@ -9,7 +9,7 @@ import type { EuiButtonGroupProps, EuiCheckboxProps } from '@elastic/eui'; import { EuiAccordion, EuiButtonGroup, EuiCheckbox } from '@elastic/eui'; import type { ReactWrapper } from 'enzyme'; -import { findTestSubject } from '@kbn/test/jest'; +import { findTestSubject } from '@kbn/test-jest-helpers'; 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 0cc4c4281b38f0..4014a2a265abd6 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 @@ -8,7 +8,7 @@ import { EuiAccordion } from '@elastic/eui'; import React from 'react'; -import { findTestSubject, mountWithIntl } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl } from '@kbn/test-jest-helpers'; import type { KibanaFeature, SubFeatureConfig } from '../../../../../../../../features/public'; import type { Role } from '../../../../../../../common/model'; 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 cd1db2f9ce486e..0503ec1bf75f90 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 @@ -8,7 +8,7 @@ import { act } from '@testing-library/react'; import React from 'react'; -import { findTestSubject, mountWithIntl } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl } from '@kbn/test-jest-helpers'; import type { Role } from '../../../../../../../common/model'; import { kibanaFeatures } from '../../../../__fixtures__/kibana_features'; 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 d39d7acc6c3a16..c73dbb2616d2d3 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 @@ -9,7 +9,7 @@ import { EuiButtonGroup, EuiCheckbox } from '@elastic/eui'; import { act } from '@testing-library/react'; import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { KibanaFeature } from '../../../../../../../../features/public'; import type { Role } from '../../../../../../../common/model'; 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 dcd21703250068..7052f724cd1cc0 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 @@ -8,7 +8,7 @@ import { EuiIconTip } from '@elastic/eui'; import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { createFeature } from '../../../../__fixtures__/kibana_features'; import { SecuredFeature } from '../../../../model'; 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 6f5c729784bb12..3a70ff5713bd96 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 { EuiTableRow } from '@elastic/eui'; import type { ReactWrapper } from 'enzyme'; -import { findTestSubject } from '@kbn/test/jest'; +import { findTestSubject } from '@kbn/test-jest-helpers'; import type { Role, RoleKibanaPrivilege } from '../../../../../../../../common/model'; 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 b23566019b31ae..928a9f5d28fea2 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 @@ -8,7 +8,7 @@ import { act } from '@testing-library/react'; import React from 'react'; -import { findTestSubject, mountWithIntl } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import { spacesManagerMock } from '../../../../../../../../spaces/public/spaces_manager/mocks'; 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 93ed2d000bb0eb..0a3620aaa4114b 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 @@ -8,7 +8,7 @@ import { act } from '@testing-library/react'; import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import { spacesManagerMock } from '../../../../../../../../spaces/public/spaces_manager/mocks'; 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 77c8cdd69ec445..e3746e7fb10515 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 @@ -8,7 +8,7 @@ import { act } from '@testing-library/react'; import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import { SpaceAvatarInternal } from '../../../../../../../../spaces/public/space_avatar/space_avatar_internal'; 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 8aa2b77f8fc128..c4400abba2da2f 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 @@ -8,7 +8,7 @@ import { EuiText } from '@elastic/eui'; import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { PrivilegeDisplay } from './privilege_display'; 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 7976d76ff8d867..8eaae663e7e807 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 @@ -8,7 +8,7 @@ import { EuiButtonGroup } from '@elastic/eui'; import React from 'react'; -import { findTestSubject, mountWithIntl } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl } from '@kbn/test-jest-helpers'; import type { Space } from '../../../../../../../../spaces/public'; import type { Role } from '../../../../../../../common/model'; 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 6f00df3a4ee7b6..9b86ad54c4d35f 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 @@ -9,7 +9,7 @@ import { EuiBadge, EuiInMemoryTable } from '@elastic/eui'; import type { ReactWrapper } from 'enzyme'; import React from 'react'; -import { findTestSubject, mountWithIntl } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl } from '@kbn/test-jest-helpers'; import { KibanaFeature } from '../../../../../../../../features/public'; import type { Role, RoleKibanaPrivilege } from '../../../../../../../common/model'; 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 ebc82f28f54260..beaaf783f2f4df 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 @@ -7,7 +7,7 @@ import React from 'react'; -import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import { kibanaFeatures } from '../../../../__fixtures__/kibana_features'; import { createKibanaPrivileges } from '../../../../__fixtures__/kibana_privileges'; 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 031df26eb38f71..572822db3ca2a9 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 @@ -15,7 +15,7 @@ import { import { act } from '@testing-library/react'; import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import type { Space } from '../../../../../../spaces/public'; 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 aa507cf823effe..7041a61a850d04 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 @@ -9,7 +9,7 @@ import { EuiBasicTable, EuiIcon } from '@elastic/eui'; import type { ReactWrapper } from 'enzyme'; import React from 'react'; -import { findTestSubject, mountWithIntl } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl } from '@kbn/test-jest-helpers'; import type { PublicMethodsOf } from '@kbn/utility-types'; import { coreMock, scopedHistoryMock } from 'src/core/public/mocks'; 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 3d8c95d52f505e..cf1959f8a389fb 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 @@ -9,7 +9,7 @@ import { EuiFieldPassword } from '@elastic/eui'; import type { ReactWrapper } from 'enzyme'; import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import type { User } from '../../../../../common/model'; 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 5ce22b42e624fa..2668050645f332 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 @@ -7,7 +7,7 @@ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import { userAPIClientMock } from '../../index.mock'; 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 b340a915bc054d..898fec5709c564 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 @@ -10,7 +10,7 @@ import type { ReactWrapper } from 'enzyme'; import type { LocationDescriptorObject } from 'history'; import React from 'react'; -import { findTestSubject, mountWithIntl, nextTick } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import type { CoreStart, ScopedHistory } from 'src/core/public'; import { coreMock, scopedHistoryMock } from 'src/core/public/mocks'; 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 adaca23be5dae5..be74cca3d26716 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 @@ -9,7 +9,7 @@ import { EuiContextMenuItem, EuiHeaderSectionItemButton, EuiPopover } from '@ela import React from 'react'; import { BehaviorSubject } from 'rxjs'; -import { findTestSubject, mountWithIntl, nextTick, shallowWithIntl } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl, nextTick, shallowWithIntl } from '@kbn/test-jest-helpers'; import type { AuthenticatedUser } from '../../common/model'; import { mockAuthenticatedUser } from '../../common/model/authenticated_user.mock'; 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 f19b88dd91c345..21352f16d2354c 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 @@ -7,7 +7,7 @@ import { BehaviorSubject } from 'rxjs'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import type { ILicense } from '../../../licensing/public'; diff --git a/x-pack/plugins/security/public/security_checkup/security_checkup_service.test.ts b/x-pack/plugins/security/public/security_checkup/security_checkup_service.test.ts index 1c4a15a8cfb933..b71d42fb08adc2 100644 --- a/x-pack/plugins/security/public/security_checkup/security_checkup_service.test.ts +++ b/x-pack/plugins/security/public/security_checkup/security_checkup_service.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import type { DocLinksStart } from 'src/core/public'; import { coreMock } from 'src/core/public/mocks'; 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 ff6f510f64b28a..61ca8423fc6269 100644 --- a/x-pack/plugins/security/server/authorization/authorization_service.test.ts +++ b/x-pack/plugins/security/server/authorization/authorization_service.test.ts @@ -7,7 +7,7 @@ import { Subject } from 'rxjs'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { coreMock, elasticsearchServiceMock, loggingSystemMock } from 'src/core/server/mocks'; // Note: this import must be before other relative imports for the mocks to work as intended. 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 65fe1de0c962c0..0cbf04aac4f589 100644 --- a/x-pack/plugins/security/server/elasticsearch/elasticsearch_service.test.ts +++ b/x-pack/plugins/security/server/elasticsearch/elasticsearch_service.test.ts @@ -7,7 +7,7 @@ import { BehaviorSubject } from 'rxjs'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import type { CoreStatus } from 'src/core/server'; import { ServiceStatusLevels } from 'src/core/server'; import { coreMock, loggingSystemMock } from 'src/core/server/mocks'; 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 100d0b30082c6e..6570dca0801daf 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 @@ -7,7 +7,7 @@ import { Subject } from 'rxjs'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { coreMock, elasticsearchServiceMock, loggingSystemMock } from 'src/core/server/mocks'; import type { diff --git a/x-pack/plugins/security_solution/common/endpoint/data_generators/event_filter_generator.ts b/x-pack/plugins/security_solution/common/endpoint/data_generators/event_filter_generator.ts index 6c827d763bb345..daf96a3149649a 100644 --- a/x-pack/plugins/security_solution/common/endpoint/data_generators/event_filter_generator.ts +++ b/x-pack/plugins/security_solution/common/endpoint/data_generators/event_filter_generator.ts @@ -8,24 +8,30 @@ import type { CreateExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { ENDPOINT_EVENT_FILTERS_LIST_ID } from '@kbn/securitysolution-list-constants'; import { BaseDataGenerator } from './base_data_generator'; -import { getCreateExceptionListItemSchemaMock } from '../../../../lists/common/schemas/request/create_exception_list_item_schema.mock'; +import { ExceptionsListItemGenerator } from './exceptions_list_item_generator'; +import { BY_POLICY_ARTIFACT_TAG_PREFIX, GLOBAL_ARTIFACT_TAG } from '../service/artifacts'; -const EFFECT_SCOPE_TYPES = ['policy:', 'policy:all']; +const EFFECT_SCOPE_TYPES = [BY_POLICY_ARTIFACT_TAG_PREFIX, GLOBAL_ARTIFACT_TAG]; export class EventFilterGenerator extends BaseDataGenerator { generate(): CreateExceptionListItemSchema { - const overrides: Partial = { - name: `generator event ${this.randomString(5)}`, - list_id: ENDPOINT_EVENT_FILTERS_LIST_ID, - item_id: `generator_endpoint_event_filter_${this.randomUUID()}`, - os_types: [this.randomOSFamily()] as CreateExceptionListItemSchema['os_types'], - tags: [this.randomChoice(EFFECT_SCOPE_TYPES)], - namespace_type: 'agnostic', - meta: undefined, - }; - - return Object.assign>( - getCreateExceptionListItemSchemaMock(), - overrides + const eventFilterGenerator = new ExceptionsListItemGenerator(); + const eventFilterData: CreateExceptionListItemSchema = eventFilterGenerator.generateEventFilter( + { + name: `Generated event ${this.randomString(5)}`, + item_id: `generator_endpoint_event_filter_${this.randomUUID()}`, + list_id: ENDPOINT_EVENT_FILTERS_LIST_ID, + os_types: [this.randomOSFamily()] as CreateExceptionListItemSchema['os_types'], + tags: [this.randomChoice(EFFECT_SCOPE_TYPES)], + _version: undefined, + created_at: undefined, + created_by: undefined, + id: undefined, + tie_breaker_id: undefined, + updated_at: undefined, + updated_by: undefined, + } ); + + return eventFilterData; } } 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 8bf2bba491051a..c455ed1953c28c 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 { mount, shallow } from 'enzyme'; import React from 'react'; import { ThemeProvider } from 'styled-components'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { defaultToEmptyTag, diff --git a/x-pack/plugins/security_solution/public/common/components/events_viewer/index.test.tsx b/x-pack/plugins/security_solution/public/common/components/events_viewer/index.test.tsx index 9dd8bf59893c03..2ecae444879082 100644 --- a/x-pack/plugins/security_solution/public/common/components/events_viewer/index.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/events_viewer/index.test.tsx @@ -33,6 +33,11 @@ jest.mock('../../../timelines/containers', () => ({ jest.mock('../../components/url_state/normalize_time_range.ts'); +const mockUseCreateFieldButton = jest.fn().mockReturnValue(<>); +jest.mock('../../../timelines/components/create_field_button', () => ({ + useCreateFieldButton: (...params: unknown[]) => mockUseCreateFieldButton(...params), +})); + const mockUseResizeObserver: jest.Mock = useResizeObserver as jest.Mock; jest.mock('use-resize-observer/polyfilled'); mockUseResizeObserver.mockImplementation(() => ({})); @@ -87,4 +92,22 @@ describe('StatefulEventsViewer', () => { expect(wrapper.find(`InspectButtonContainer`).exists()).toBe(true); }); }); + + test('it closes field editor when unmounted', async () => { + const mockCloseEditor = jest.fn(); + mockUseCreateFieldButton.mockImplementation((_, __, fieldEditorActionsRef) => { + fieldEditorActionsRef.current = { closeEditor: mockCloseEditor }; + return <>; + }); + + const wrapper = mount( + + + + ); + expect(mockCloseEditor).not.toHaveBeenCalled(); + + wrapper.unmount(); + expect(mockCloseEditor).toHaveBeenCalled(); + }); }); diff --git a/x-pack/plugins/security_solution/public/common/components/events_viewer/index.tsx b/x-pack/plugins/security_solution/public/common/components/events_viewer/index.tsx index 97b0424168f0a1..9fa91ed25c995c 100644 --- a/x-pack/plugins/security_solution/public/common/components/events_viewer/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/events_viewer/index.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React, { useCallback, useMemo, useEffect } from 'react'; +import React, { useRef, useCallback, useMemo, useEffect } from 'react'; import { connect, ConnectedProps, useDispatch } from 'react-redux'; import deepEqual from 'fast-deep-equal'; import styled from 'styled-components'; @@ -29,7 +29,10 @@ import { CellValueElementProps } from '../../../timelines/components/timeline/ce import { FIELDS_WITHOUT_CELL_ACTIONS } from '../../lib/cell_actions/constants'; import { useKibana } from '../../lib/kibana'; import { GraphOverlay } from '../../../timelines/components/graph_overlay'; -import { useCreateFieldButton } from '../../../timelines/components/create_field_button'; +import { + CreateFieldEditorActions, + useCreateFieldButton, +} from '../../../timelines/components/create_field_button'; const EMPTY_CONTROL_COLUMNS: ControlColumnProps[] = []; @@ -121,6 +124,8 @@ const StatefulEventsViewerComponent: React.FC = ({ const tGridEventRenderedViewEnabled = useIsExperimentalFeatureEnabled( 'tGridEventRenderedViewEnabled' ); + const editorActionsRef = useRef(null); + useEffect(() => { if (createTimeline != null) { createTimeline({ @@ -137,6 +142,10 @@ const StatefulEventsViewerComponent: React.FC = ({ } return () => { deleteEventQuery({ id, inputId: 'global' }); + if (editorActionsRef.current) { + // eslint-disable-next-line react-hooks/exhaustive-deps + editorActionsRef.current.closeEditor(); + } }; // eslint-disable-next-line react-hooks/exhaustive-deps }, []); @@ -167,7 +176,7 @@ const StatefulEventsViewerComponent: React.FC = ({ }, [id, timelineQuery, globalQuery]); const bulkActions = useMemo(() => ({ onAlertStatusActionSuccess }), [onAlertStatusActionSuccess]); - const createFieldComponent = useCreateFieldButton(scopeId, id); + const createFieldComponent = useCreateFieldButton(scopeId, id, editorActionsRef); return ( <> 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 531ad1318e0e16..6c3dba5f2e22ba 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 { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { coreMock } from '../../../../../../../src/core/public/mocks'; import { getListMock } from '../../../../common/detection_engine/schemas/types/lists.mock'; 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 9bbd490f1ed16f..562c6a7250a5d5 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 @@ -7,7 +7,7 @@ import React from 'react'; import { ThemeProvider } from 'styled-components'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ExceptionsViewerUtility } from './exceptions_utility'; import { getMockTheme } from '../../../lib/kibana/kibana_react.mock'; 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 0c077aaea81a87..97f93b9732c02d 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 @@ -8,7 +8,7 @@ import { mount, shallow, ReactWrapper, ShallowWrapper } from 'enzyme'; import React from 'react'; import { removeExternalLinkText } from '@kbn/securitysolution-io-ts-utils'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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 a3d6cb50bef576..ebd1c0c4df1098 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { MlPopover } from './ml_popover'; diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/constants.ts b/x-pack/plugins/security_solution/public/management/pages/event_filters/constants.ts index a7261e31ed35ef..e58b489cdd2c61 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/constants.ts +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/constants.ts @@ -19,7 +19,7 @@ import { } from '@kbn/securitysolution-list-constants'; export const EVENT_FILTER_LIST_TYPE: ExceptionListType = ExceptionListTypeEnum.ENDPOINT_EVENTS; -export const EVENT_FILTER_LIST: CreateExceptionListSchema = { +export const EVENT_FILTER_LIST_DEFINITION: CreateExceptionListSchema = { name: ENDPOINT_EVENT_FILTERS_LIST_NAME, namespace_type: 'agnostic', description: ENDPOINT_EVENT_FILTERS_LIST_DESCRIPTION, diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/service/service_actions.ts b/x-pack/plugins/security_solution/public/management/pages/event_filters/service/service_actions.ts index 6bd0e9447d36fd..40de6de881431d 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/service/service_actions.ts +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/service/service_actions.ts @@ -16,7 +16,7 @@ import { HttpStart } from 'kibana/public'; import { EXCEPTION_LIST_ITEM_URL, EXCEPTION_LIST_URL, - EVENT_FILTER_LIST, + EVENT_FILTER_LIST_DEFINITION, ENDPOINT_EVENT_FILTERS_LIST_ID, } from '../constants'; import { Immutable } from '../../../../../common/endpoint/types'; @@ -24,7 +24,7 @@ import { Immutable } from '../../../../../common/endpoint/types'; async function createEventFilterList(http: HttpStart): Promise { try { await http.post(EXCEPTION_LIST_URL, { - body: JSON.stringify(EVENT_FILTER_LIST), + body: JSON.stringify(EVENT_FILTER_LIST_DEFINITION), }); } catch (err) { // Ignore 409 errors. List already created diff --git a/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/host_isolation_exceptions_list.tsx b/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/host_isolation_exceptions_list.tsx index b3dcc4a0fbc974..5af8863f3a5cce 100644 --- a/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/host_isolation_exceptions_list.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/host_isolation_exceptions_list.tsx @@ -50,7 +50,21 @@ type HostIsolationExceptionPaginatedContent = PaginatedContentProps< typeof ExceptionItem >; -/* eslint-disable complexity */ +const getPaginationObject = ({ + total = 0, + perPage = MANAGEMENT_DEFAULT_PAGE_SIZE, + page = 1, +}: { + total?: number; + perPage?: number; + page?: number; +}) => ({ + totalItemCount: total, + pageSize: perPage, + pageSizeOptions: [...MANAGEMENT_PAGE_SIZE_OPTIONS], + pageIndex: page - 1, +}); + export const HostIsolationExceptionsList = () => { const history = useHistory(); const privileges = useUserPrivileges().endpointPrivileges; @@ -102,12 +116,11 @@ export const HostIsolationExceptionsList = () => { }, }); - const pagination = { - totalItemCount: data?.total ?? 0, - pageSize: data?.per_page ?? MANAGEMENT_DEFAULT_PAGE_SIZE, - pageSizeOptions: [...MANAGEMENT_PAGE_SIZE_OPTIONS], - pageIndex: (data?.page ?? 1) - 1, - }; + const pagination = getPaginationObject({ + total: data?.total, + perPage: data?.per_page, + page: data?.page, + }); const listItems = data?.data || []; const allListItems = allData?.data || []; diff --git a/x-pack/plugins/security_solution/public/timelines/components/create_field_button/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/create_field_button/index.test.tsx index 6f3f3e8b87bc8b..0afb2bf6413517 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/create_field_button/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/create_field_button/index.test.tsx @@ -6,8 +6,8 @@ */ import { render, fireEvent, act, screen } from '@testing-library/react'; -import React from 'react'; -import { CreateFieldButton } from './index'; +import React, { MutableRefObject } from 'react'; +import { CreateFieldButton, CreateFieldEditorActions } from './index'; import { indexPatternFieldEditorPluginMock, Start, @@ -108,4 +108,38 @@ describe('CreateFieldButton', () => { fireEvent.click(screen.getByRole('button')); expect(onClickParam).toHaveBeenCalled(); }); + + it("stores 'closeEditor' in the actions ref when editor is open", async () => { + const mockCloseEditor = jest.fn(); + useKibanaMock().services.data.dataViews.get = () => Promise.resolve({} as DataView); + useKibanaMock().services.dataViewFieldEditor.openEditor = () => mockCloseEditor; + + const editorActionsRef: MutableRefObject = React.createRef(); + await act(async () => { + render( + undefined} + timelineId={TimelineId.detectionsPage} + editorActionsRef={editorActionsRef} + />, + { + wrapper: TestProviders, + } + ); + await runAllPromises(); + }); + + expect(editorActionsRef?.current).toBeNull(); + + fireEvent.click(screen.getByRole('button')); + + expect(mockCloseEditor).not.toHaveBeenCalled(); + expect(editorActionsRef?.current?.closeEditor).toBeDefined(); + + editorActionsRef!.current!.closeEditor(); + + expect(mockCloseEditor).toHaveBeenCalled(); + expect(editorActionsRef!.current).toBeNull(); + }); }); diff --git a/x-pack/plugins/security_solution/public/timelines/components/create_field_button/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/create_field_button/index.tsx index 04f23605efac57..8979a78d7aa465 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/create_field_button/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/create_field_button/index.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React, { useCallback, useEffect, useMemo, useState } from 'react'; +import React, { MutableRefObject, useCallback, useEffect, useMemo, useState } from 'react'; import { EuiButton } from '@elastic/eui'; import styled from 'styled-components'; @@ -23,17 +23,21 @@ import { useDeepEqualSelector } from '../../../common/hooks/use_selector'; import { DEFAULT_COLUMN_MIN_WIDTH } from '../timeline/body/constants'; import { defaultColumnHeaderType } from '../timeline/body/column_headers/default_headers'; +export type CreateFieldEditorActions = { closeEditor: () => void } | null; +type CreateFieldEditorActionsRef = MutableRefObject; + interface CreateFieldButtonProps { selectedDataViewId: string; onClick: () => void; timelineId: TimelineId; + editorActionsRef?: CreateFieldEditorActionsRef; } const StyledButton = styled(EuiButton)` margin-left: ${({ theme }) => theme.eui.paddingSizes.m}; `; export const CreateFieldButton = React.memo( - ({ selectedDataViewId, onClick: onClickParam, timelineId }) => { + ({ selectedDataViewId, onClick: onClickParam, timelineId, editorActionsRef }) => { const [dataView, setDataView] = useState(null); const dispatch = useDispatch(); @@ -52,7 +56,7 @@ export const CreateFieldButton = React.memo( const onClick = useCallback(() => { if (dataView) { - dataViewFieldEditor?.openEditor({ + const closeFieldEditor = dataViewFieldEditor?.openEditor({ ctx: { dataView }, onSave: async (field: DataViewField) => { // Fetch the updated list of fields @@ -72,6 +76,14 @@ export const CreateFieldButton = React.memo( ); }, }); + if (editorActionsRef) { + editorActionsRef.current = { + closeEditor: () => { + editorActionsRef.current = null; + closeFieldEditor(); + }, + }; + } } onClickParam(); }, [ @@ -82,6 +94,7 @@ export const CreateFieldButton = React.memo( selectedDataViewId, dispatch, timelineId, + editorActionsRef, ]); if ( @@ -116,7 +129,8 @@ CreateFieldButton.displayName = 'CreateFieldButton'; */ export const useCreateFieldButton = ( sourcererScope: SourcererScopeName, - timelineId: TimelineId + timelineId: TimelineId, + editorActionsRef?: CreateFieldEditorActionsRef ) => { const scopeIdSelector = useMemo(() => sourcererSelectors.scopeIdSelector(), []); const { missingPatterns, selectedDataViewId } = useDeepEqualSelector((state) => @@ -133,9 +147,10 @@ export const useCreateFieldButton = ( selectedDataViewId={selectedDataViewId} onClick={onClick} timelineId={timelineId} + editorActionsRef={editorActionsRef} /> ); return CreateFieldButtonComponent; - }, [missingPatterns.length, selectedDataViewId, timelineId]); + }, [missingPatterns.length, selectedDataViewId, timelineId, editorActionsRef]); }; 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 c130ea4c968143..1e6a4b15bf1242 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; import { useParams } from 'react-router-dom'; 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 54b405feeb1769..6a9d4a6bbdbe8b 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; import { useParams } from 'react-router-dom'; 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 607bccdbc039df..e00a23261e7471 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 { cloneDeep } from 'lodash/fp'; import moment from 'moment'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; import '../../../../common/mock/formatted_relative'; import { useDeepEqualSelector } from '../../../../common/hooks/use_selector'; 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 a215f028631236..24683cfdab548d 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 { cloneDeep } from 'lodash/fp'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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 794cd275528e48..e2184aaaec7738 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 { cloneDeep } from 'lodash/fp'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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 1c650b0ae0a111..55d230d118e254 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 { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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 2a77f872117f69..925ea396b7fa0a 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 { cloneDeep, omit } from 'lodash/fp'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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 bdb55aaf209694..5b17994a64530e 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 { EuiButtonIconProps } from '@elastic/eui'; import { cloneDeep, omit } from 'lodash/fp'; import React from 'react'; import { ThemeProvider } from 'styled-components'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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 e8960d2e0ad93b..89331ca8e33bfb 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 { cloneDeep, omit } from 'lodash/fp'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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 a92d3a4eac4b05..01e9c588f0ef50 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 { cloneDeep, omit } from 'lodash/fp'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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 c1aecd4a338250..55de25ff283e39 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 { cloneDeep } from 'lodash/fp'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; 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 a94777d0e573b9..d46cad3c43a988 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 { EuiButtonProps } from '@elastic/eui'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; import { ThemeProvider } from 'styled-components'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/column_headers/__snapshots__/index.test.tsx.snap b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/column_headers/__snapshots__/index.test.tsx.snap index 644a3c95baf081..2d625f678721bd 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/column_headers/__snapshots__/index.test.tsx.snap +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/column_headers/__snapshots__/index.test.tsx.snap @@ -658,6 +658,7 @@ exports[`ColumnHeaders rendering renders correctly against snapshot 1`] = ` ] } onSelectAll={[Function]} + show={true} showEventsSelect={false} showSelectAllCheckbox={false} sort={ diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/column_headers/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/column_headers/index.test.tsx index 59bdcf808ca422..aec28732f38afa 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/column_headers/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/column_headers/index.test.tsx @@ -16,7 +16,7 @@ import { Sort } from '../sort'; import { TestProviders } from '../../../../../common/mock/test_providers'; import { useMountAppended } from '../../../../../common/utils/use_mount_appended'; -import { ColumnHeadersComponent } from '.'; +import { ColumnHeadersComponent, ColumnHeadersComponentProps } from '.'; import { cloneDeep } from 'lodash/fp'; import { timelineActions } from '../../../../store/timeline'; import { TimelineTabs } from '../../../../../../common/types/timeline'; @@ -27,6 +27,11 @@ import { HeaderActions } from '../actions/header_actions'; jest.mock('../../../../../common/lib/kibana'); +const mockUseCreateFieldButton = jest.fn().mockReturnValue(<>); +jest.mock('../../../create_field_button', () => ({ + useCreateFieldButton: (...params: unknown[]) => mockUseCreateFieldButton(...params), +})); + const mockDispatch = jest.fn(); jest.mock('react-redux', () => { const original = jest.requireActual('react-redux'); @@ -46,33 +51,34 @@ describe('ColumnHeaders', () => { ...x, headerCellRender: HeaderActions, })); + const sort: Sort[] = [ + { + columnId: '@timestamp', + columnType: 'number', + sortDirection: Direction.desc, + }, + ]; + const defaultProps: ColumnHeadersComponentProps = { + actionsColumnWidth, + browserFields: mockBrowserFields, + columnHeaders: defaultHeaders, + isSelectAllChecked: false, + onSelectAll: jest.fn, + show: true, + showEventsSelect: false, + showSelectAllCheckbox: false, + sort, + tabType: TimelineTabs.query, + timelineId, + leadingControlColumns, + trailingControlColumns: [], + }; describe('rendering', () => { - const sort: Sort[] = [ - { - columnId: '@timestamp', - columnType: 'number', - sortDirection: Direction.desc, - }, - ]; - test('renders correctly against snapshot', () => { const wrapper = shallow( - + ); expect(wrapper.find('ColumnHeadersComponent')).toMatchSnapshot(); @@ -81,20 +87,7 @@ describe('ColumnHeaders', () => { test('it renders the field browser', () => { const wrapper = mount( - + ); @@ -104,20 +97,7 @@ describe('ColumnHeaders', () => { test('it renders every column header', () => { const wrapper = mount( - + ); @@ -166,18 +146,7 @@ describe('ColumnHeaders', () => { const wrapper = mount( ); @@ -210,18 +179,7 @@ describe('ColumnHeaders', () => { const wrapper = mount( ); @@ -249,18 +207,11 @@ describe('ColumnHeaders', () => { const wrapper = mount( ); @@ -287,18 +238,13 @@ describe('ColumnHeaders', () => { const wrapper = mount( ); @@ -307,4 +253,43 @@ describe('ColumnHeaders', () => { expect(wrapper.exists('[data-test-subj="test-header-action-cell"]')).toBeTruthy(); }); }); + + describe('Field Editor', () => { + test('Closes field editor when the timeline is unmounted', () => { + const mockCloseEditor = jest.fn(); + mockUseCreateFieldButton.mockImplementation((_, __, fieldEditorActionsRef) => { + fieldEditorActionsRef.current = { closeEditor: mockCloseEditor }; + return <>; + }); + + const wrapper = mount( + + + + ); + expect(mockCloseEditor).not.toHaveBeenCalled(); + + wrapper.unmount(); + expect(mockCloseEditor).toHaveBeenCalled(); + }); + + test('Closes field editor when the timeline is closed', () => { + const mockCloseEditor = jest.fn(); + mockUseCreateFieldButton.mockImplementation((_, __, fieldEditorActionsRef) => { + fieldEditorActionsRef.current = { closeEditor: mockCloseEditor }; + return <>; + }); + + const Proxy = (props: ColumnHeadersComponentProps) => ( + + + + ); + const wrapper = mount(); + expect(mockCloseEditor).not.toHaveBeenCalled(); + + wrapper.setProps({ ...defaultProps, show: false }); + expect(mockCloseEditor).toHaveBeenCalled(); + }); + }); }); diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/column_headers/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/column_headers/index.tsx index 80a9022105d2c9..ca1cdef903de84 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/column_headers/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/column_headers/index.tsx @@ -5,7 +5,7 @@ * 2.0. */ import deepEqual from 'fast-deep-equal'; -import React, { useState, useEffect, useCallback, useMemo } from 'react'; +import React, { useState, useEffect, useCallback, useMemo, useRef } from 'react'; import { Droppable, DraggableChildrenFn } from 'react-beautiful-dnd'; import { DragEffects } from '../../../../../common/components/drag_and_drop/draggable_wrapper'; @@ -34,15 +34,16 @@ import { Sort } from '../sort'; import { ColumnHeader } from './column_header'; import { SourcererScopeName } from '../../../../../common/store/sourcerer/model'; -import { useCreateFieldButton } from '../../../create_field_button'; +import { CreateFieldEditorActions, useCreateFieldButton } from '../../../create_field_button'; -interface Props { +export interface ColumnHeadersComponentProps { actionsColumnWidth: number; browserFields: BrowserFields; columnHeaders: ColumnHeaderOptions[]; isEventViewer?: boolean; isSelectAllChecked: boolean; onSelectAll: OnSelectAll; + show: boolean; showEventsSelect: boolean; showSelectAllCheckbox: boolean; sort: Sort[]; @@ -92,6 +93,7 @@ export const ColumnHeadersComponent = ({ isEventViewer = false, isSelectAllChecked, onSelectAll, + show, showEventsSelect, showSelectAllCheckbox, sort, @@ -99,8 +101,24 @@ export const ColumnHeadersComponent = ({ timelineId, leadingControlColumns, trailingControlColumns, -}: Props) => { +}: ColumnHeadersComponentProps) => { const [draggingIndex, setDraggingIndex] = useState(null); + const fieldEditorActionsRef = useRef(null); + + useEffect(() => { + return () => { + if (fieldEditorActionsRef.current) { + // eslint-disable-next-line react-hooks/exhaustive-deps + fieldEditorActionsRef.current.closeEditor(); + } + }; + }, []); + + useEffect(() => { + if (!show && fieldEditorActionsRef.current) { + fieldEditorActionsRef.current.closeEditor(); + } + }, [show]); const renderClone: DraggableChildrenFn = useCallback( (dragProvided, _dragSnapshot, rubric) => { @@ -174,7 +192,8 @@ export const ColumnHeadersComponent = ({ const createFieldComponent = useCreateFieldButton( SourcererScopeName.timeline, - timelineId as TimelineId + timelineId as TimelineId, + fieldEditorActionsRef ); const LeadingHeaderActions = useMemo(() => { @@ -300,6 +319,7 @@ export const ColumnHeaders = React.memo( prevProps.isEventViewer === nextProps.isEventViewer && prevProps.isSelectAllChecked === nextProps.isSelectAllChecked && prevProps.onSelectAll === nextProps.onSelectAll && + prevProps.show === nextProps.show && prevProps.showEventsSelect === nextProps.showEventsSelect && prevProps.showSelectAllCheckbox === nextProps.showSelectAllCheckbox && deepEqual(prevProps.sort, nextProps.sort) && diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/index.test.tsx index 5467dbab9845c0..db927e67ccc67e 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/index.test.tsx @@ -146,6 +146,7 @@ describe('Body', () => { selectedEventIds: {}, setSelected: jest.fn() as unknown as StatefulBodyProps['setSelected'], sort: mockSort, + show: true, showCheckboxes: false, tabType: TimelineTabs.query, totalPages: 1, diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/index.tsx index 7e7192610a2226..7257d4246f6fef 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/index.tsx @@ -89,6 +89,7 @@ export const BodyComponent = React.memo( setSelected, clearSelected, onRuleChange, + show, showCheckboxes, refetch, renderCellValue, @@ -244,6 +245,7 @@ export const BodyComponent = React.memo( isEventViewer={isEventViewer} isSelectAllChecked={isSelectAllChecked} onSelectAll={onSelectAll} + show={show} showEventsSelect={false} showSelectAllCheckbox={showCheckboxes} sort={sort} @@ -298,7 +300,8 @@ export const BodyComponent = React.memo( prevProps.renderCellValue === nextProps.renderCellValue && prevProps.rowRenderers === nextProps.rowRenderers && prevProps.showCheckboxes === nextProps.showCheckboxes && - prevProps.tabType === nextProps.tabType + prevProps.tabType === nextProps.tabType && + prevProps.show === nextProps.show ); BodyComponent.displayName = 'BodyComponent'; @@ -321,6 +324,7 @@ const makeMapStateToProps = () => { pinnedEventIds, selectedEventIds, showCheckboxes, + show, } = timeline; return { @@ -333,6 +337,7 @@ const makeMapStateToProps = () => { pinnedEventIds, selectedEventIds, showCheckboxes, + show, }; }; return mapStateToProps; 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 1e16fa2a401299..45b31a19693b77 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 @@ -13,7 +13,7 @@ import { TestBed, AsyncTestBedConfig, delay, -} from '@kbn/test/jest'; +} from '@kbn/test-jest-helpers'; import { SnapshotRestoreHome } from '../../../public/application/sections/home/home'; import { BASE_PATH } from '../../../public/application/constants'; import { WithAppDependencies } from './setup_environment'; 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 fdf8ea8d838681..51c41bc49bc3d7 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 @@ -14,8 +14,8 @@ import { setup as policyEditSetup } from './policy_edit.helpers'; import { setup as restoreSnapshotSetup } from './restore_snapshot.helpers'; import { setup as snapshotListSetup } from './snapshot_list.helpers'; -export type { TestBed } from '@kbn/test/jest'; -export { nextTick, getRandomString, findTestSubject, delay } from '@kbn/test/jest'; +export type { TestBed } from '@kbn/test-jest-helpers'; +export { nextTick, getRandomString, findTestSubject, delay } from '@kbn/test-jest-helpers'; 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 a6e7c4a4c10569..d921b96781d0cd 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed, AsyncTestBedConfig } from '@kbn/test/jest'; +import { registerTestBed, AsyncTestBedConfig } from '@kbn/test-jest-helpers'; 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 2014d22ffbfbce..461351e744125b 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed, AsyncTestBedConfig } from '@kbn/test/jest'; +import { registerTestBed, AsyncTestBedConfig } from '@kbn/test-jest-helpers'; 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 f097f6185fc7c2..c776a22ef98688 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { TestBed, SetupFunc } from '@kbn/test/jest'; +import { TestBed, SetupFunc } from '@kbn/test-jest-helpers'; 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 b369b20c122ebe..c6460078482bfd 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed, TestBed } from '@kbn/test/jest'; +import { registerTestBed, TestBed } from '@kbn/test-jest-helpers'; 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 f0563f2831a986..275c216d70664b 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed, AsyncTestBedConfig } from '@kbn/test/jest'; +import { registerTestBed, AsyncTestBedConfig } from '@kbn/test-jest-helpers'; 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 123ae0cbb1c2ed..86c93a6811bd4a 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 @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test/jest'; +import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test-jest-helpers'; import { RestoreSnapshot } from '../../../public/application/sections/restore_snapshot'; import { WithAppDependencies } from './setup_environment'; diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/snapshot_list.helpers.ts b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/snapshot_list.helpers.ts index 176e5714f13088..261976623144bb 100644 --- a/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/snapshot_list.helpers.ts +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/snapshot_list.helpers.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { TestBedConfig, registerTestBed, TestBed } from '@kbn/test/jest'; +import { TestBedConfig, registerTestBed, TestBed } from '@kbn/test-jest-helpers'; import { BASE_PATH } from '../../../public/application/constants'; import { SnapshotList } from '../../../public/application/sections/home/snapshot_list'; diff --git a/x-pack/plugins/snapshot_restore/test/fixtures/policy.ts b/x-pack/plugins/snapshot_restore/test/fixtures/policy.ts index 873d36fcc656e1..66d5b9557fae2e 100644 --- a/x-pack/plugins/snapshot_restore/test/fixtures/policy.ts +++ b/x-pack/plugins/snapshot_restore/test/fixtures/policy.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { getRandomString, getRandomNumber } from '@kbn/test/jest'; +import { getRandomString, getRandomNumber } from '@kbn/test-jest-helpers'; 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 b906a657f1ad7e..16f2bea61bc28a 100644 --- a/x-pack/plugins/snapshot_restore/test/fixtures/repository.ts +++ b/x-pack/plugins/snapshot_restore/test/fixtures/repository.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { getRandomString } from '@kbn/test/jest'; +import { getRandomString } from '@kbn/test-jest-helpers'; 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 8b385b5e830060..e7fad7f4a291f2 100644 --- a/x-pack/plugins/snapshot_restore/test/fixtures/snapshot.ts +++ b/x-pack/plugins/snapshot_restore/test/fixtures/snapshot.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { getRandomString, getRandomNumber } from '@kbn/test/jest'; +import { getRandomString, getRandomNumber } from '@kbn/test-jest-helpers'; 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 6e215b20e4f2ab..7352e769f7e557 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 @@ -9,7 +9,7 @@ import { EuiCallOut } from '@elastic/eui'; import { act } from '@testing-library/react'; import React from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { AdvancedSettingsSubtitle } from './advanced_settings_subtitle'; 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 95dd62a6680a69..e8b6766411d0c6 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 @@ -8,7 +8,7 @@ import { act } from '@testing-library/react'; import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { SpaceAvatarInternal } from '../../../space_avatar/space_avatar_internal'; import { AdvancedSettingsTitle } from './advanced_settings_title'; 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 9c69b172751cfb..a9da59c37739d2 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 @@ -8,7 +8,7 @@ import type { ReactWrapper } from 'enzyme'; import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import type { CopyModeControlProps } from './copy_mode_control'; import { CopyModeControl } from './copy_mode_control'; diff --git a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_internal.test.tsx b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_internal.test.tsx index a9768bea9d1ed7..858fddaf4698bf 100644 --- a/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_internal.test.tsx +++ b/x-pack/plugins/spaces/public/copy_saved_objects_to_space/components/copy_to_space_flyout_internal.test.tsx @@ -10,7 +10,7 @@ import Boom from '@hapi/boom'; import { act } from '@testing-library/react'; import React from 'react'; -import { findTestSubject, mountWithIntl, nextTick } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import type { Space } from '../../../common'; 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 96fe78e237a80f..ad183196039c6b 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 @@ -9,7 +9,7 @@ import { act } from '@testing-library/react'; import type { ReactWrapper } from 'enzyme'; import React from 'react'; -import { findTestSubject, mountWithIntl, nextTick, shallowWithIntl } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl, nextTick, shallowWithIntl } from '@kbn/test-jest-helpers'; import type { SummarizedCopyToSpaceResult } from '../lib'; import type { ImportRetry } from '../types'; diff --git a/x-pack/plugins/spaces/public/legacy_urls/components/legacy_url_conflict_internal.test.tsx b/x-pack/plugins/spaces/public/legacy_urls/components/legacy_url_conflict_internal.test.tsx index b999ae961d0f12..5f4f1f845717a7 100644 --- a/x-pack/plugins/spaces/public/legacy_urls/components/legacy_url_conflict_internal.test.tsx +++ b/x-pack/plugins/spaces/public/legacy_urls/components/legacy_url_conflict_internal.test.tsx @@ -10,7 +10,7 @@ import { act } from '@testing-library/react'; import React from 'react'; import { BehaviorSubject } from 'rxjs'; -import { findTestSubject, mountWithIntl } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import { LegacyUrlConflictInternal } from './legacy_url_conflict_internal'; 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 59c7dde71aedb2..4b1ad8a6fe01f6 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 @@ -8,7 +8,7 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; -import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import { spacesManagerMock } from '../../../spaces_manager/mocks'; import { ConfirmDeleteModal } from './confirm_delete_modal'; 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 0f26c69cac2bee..6a491e5303149b 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 @@ -7,7 +7,7 @@ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { UnauthorizedPrompt } from './unauthorized_prompt'; 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 f4ba960b2f3a47..5c9ed1b6a3283d 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 @@ -7,7 +7,7 @@ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { ConfirmAlterActiveSpaceModal } from './confirm_alter_active_space_modal'; diff --git a/x-pack/plugins/spaces/public/management/edit_space/customize_space/customize_space.test.tsx b/x-pack/plugins/spaces/public/management/edit_space/customize_space/customize_space.test.tsx index 42195317e6731c..cea22e31a82892 100644 --- a/x-pack/plugins/spaces/public/management/edit_space/customize_space/customize_space.test.tsx +++ b/x-pack/plugins/spaces/public/management/edit_space/customize_space/customize_space.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; -import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import { SpaceValidator } from '../../lib'; import { CustomizeSpace } from './customize_space'; 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 578da9b96611c4..ddc767163f0b57 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 @@ -8,7 +8,7 @@ import { EuiColorPicker, EuiFieldText, EuiLink } from '@elastic/eui'; import React from 'react'; -import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import { SpaceValidator } from '../../lib'; import { CustomizeSpaceAvatar } from './customize_space_avatar'; 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 900c032c8fbfa0..d3f95cadc051f6 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 @@ -7,7 +7,7 @@ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { notificationServiceMock } from 'src/core/public/mocks'; import type { 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 af6c546fcf56a7..5283cfe8ad1a3f 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 @@ -8,7 +8,7 @@ import type { EuiCheckboxProps } from '@elastic/eui'; import React from 'react'; -import { findTestSubject, mountWithIntl, nextTick, shallowWithIntl } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl, nextTick, shallowWithIntl } from '@kbn/test-jest-helpers'; import { DEFAULT_APP_CATEGORIES } from 'src/core/public'; import type { KibanaFeatureConfig } from '../../../../../features/public'; 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 465cb76c9e5bdf..55672e9896ea36 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 @@ -11,7 +11,7 @@ import { waitFor } from '@testing-library/react'; import type { ReactWrapper } from 'enzyme'; import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { DEFAULT_APP_CATEGORIES } from 'src/core/public'; import { notificationServiceMock, scopedHistoryMock } from 'src/core/public/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 d8fb026058dd0c..de3977ac792d0f 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 @@ -8,7 +8,7 @@ import { EuiBadge } from '@elastic/eui'; import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { ReservedSpaceBadge } from './reserved_space_badge'; 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 733044e638f5fb..125697c6f4e193 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 @@ -7,7 +7,7 @@ import React from 'react'; -import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import { SectionPanel } from './section_panel'; diff --git a/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_page.test.tsx b/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_page.test.tsx index bb1ea2914fc43c..8cff17b4dfe57e 100644 --- a/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_page.test.tsx +++ b/x-pack/plugins/spaces/public/management/spaces_grid/spaces_grid_page.test.tsx @@ -8,7 +8,7 @@ import { act } from '@testing-library/react'; import React from 'react'; -import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import { httpServiceMock, notificationServiceMock, scopedHistoryMock } from 'src/core/public/mocks'; import { KibanaFeature } from '../../../../features/public'; 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 3e1d77d0a45f13..563b3693bcd7b8 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 @@ -7,7 +7,7 @@ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { ManageSpacesButton } from './manage_spaces_button'; 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 d1282331027c26..8e5aa0c6769fe0 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 @@ -11,7 +11,7 @@ import { shallow } from 'enzyme'; import React from 'react'; import * as Rx from 'rxjs'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { SpaceAvatarInternal } from '../space_avatar/space_avatar_internal'; import type { SpacesManager } from '../spaces_manager'; diff --git a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout_internal.test.tsx b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout_internal.test.tsx index 6daea2413599aa..3c84b5da2796b2 100644 --- a/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout_internal.test.tsx +++ b/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout_internal.test.tsx @@ -11,7 +11,7 @@ import { act } from '@testing-library/react'; import type { ReactWrapper } from 'enzyme'; import React from 'react'; -import { findTestSubject, mountWithIntl, nextTick } from '@kbn/test/jest'; +import { findTestSubject, mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import type { SavedObjectReferenceWithContext } from 'src/core/public'; import { coreMock } from 'src/core/public/mocks'; diff --git a/x-pack/plugins/spaces/public/space_list/space_list_internal.test.tsx b/x-pack/plugins/spaces/public/space_list/space_list_internal.test.tsx index 39ae339fb7e187..cc365e943a5106 100644 --- a/x-pack/plugins/spaces/public/space_list/space_list_internal.test.tsx +++ b/x-pack/plugins/spaces/public/space_list/space_list_internal.test.tsx @@ -9,7 +9,7 @@ import { act } from '@testing-library/react'; import type { ReactWrapper } from 'enzyme'; import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import type { Space } from '../../common'; 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 e17c3e0078d427..7764bcc2c3b9c0 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 @@ -7,7 +7,7 @@ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import type { Space } from '../../common'; 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 d09177a915d992..f1e4b767b934cb 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import { coreMock } from 'src/core/public/mocks'; import { SpacesManager } from './spaces_manager'; 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 c082a75cc894b3..d8a1689ae3bd65 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 @@ -8,7 +8,7 @@ import * as Rx from 'rxjs'; import { first } from 'rxjs/operators'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; import type { Writable } from '@kbn/utility-types'; import type { CoreStatus, SavedObjectsRepository, ServiceStatusLevel } from 'src/core/server'; import { SavedObjectsErrorHelpers, ServiceStatusLevels } from 'src/core/server'; diff --git a/x-pack/plugins/stack_alerts/kibana.json b/x-pack/plugins/stack_alerts/kibana.json index 693bcf2f8dbca0..acd9dcb374d105 100644 --- a/x-pack/plugins/stack_alerts/kibana.json +++ b/x-pack/plugins/stack_alerts/kibana.json @@ -5,7 +5,7 @@ "githubTeam": "kibana-alerting-services" }, "server": true, - "version": "8.1.0", + "version": "8.2.0", "kibanaVersion": "kibana", "requiredPlugins": [ "alerting", diff --git a/x-pack/plugins/stack_alerts/public/alert_types/components/index_select_popover.test.tsx b/x-pack/plugins/stack_alerts/public/alert_types/components/index_select_popover.test.tsx index 3b7baac9b80e68..e5c8343fddf6d4 100644 --- a/x-pack/plugins/stack_alerts/public/alert_types/components/index_select_popover.test.tsx +++ b/x-pack/plugins/stack_alerts/public/alert_types/components/index_select_popover.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { IndexSelectPopover } from './index_select_popover'; import { EuiComboBox } from '@elastic/eui'; diff --git a/x-pack/plugins/stack_alerts/public/alert_types/es_query/expression.test.tsx b/x-pack/plugins/stack_alerts/public/alert_types/es_query/expression.test.tsx index 994eeadd50d3b0..7ecdcd6dbce388 100644 --- a/x-pack/plugins/stack_alerts/public/alert_types/es_query/expression.test.tsx +++ b/x-pack/plugins/stack_alerts/public/alert_types/es_query/expression.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import 'brace'; import { of } from 'rxjs'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { act } from 'react-dom/test-utils'; import EsQueryAlertTypeExpression from './expression'; import { dataPluginMock } from 'src/plugins/data/public/mocks'; diff --git a/x-pack/plugins/stack_alerts/public/alert_types/threshold/expression.test.tsx b/x-pack/plugins/stack_alerts/public/alert_types/threshold/expression.test.tsx index bf46df5eabfa7f..d0aaa9b8fda52a 100644 --- a/x-pack/plugins/stack_alerts/public/alert_types/threshold/expression.test.tsx +++ b/x-pack/plugins/stack_alerts/public/alert_types/threshold/expression.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { act } from 'react-dom/test-utils'; import IndexThresholdAlertTypeExpression, { DEFAULT_VALUES } from './expression'; import { dataPluginMock } from 'src/plugins/data/public/mocks'; diff --git a/x-pack/plugins/stack_alerts/public/alert_types/threshold/visualization.test.tsx b/x-pack/plugins/stack_alerts/public/alert_types/threshold/visualization.test.tsx index a27646c1643fa3..ed667b4940f29c 100644 --- a/x-pack/plugins/stack_alerts/public/alert_types/threshold/visualization.test.tsx +++ b/x-pack/plugins/stack_alerts/public/alert_types/threshold/visualization.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { act } from 'react-dom/test-utils'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { ThresholdVisualization } from './visualization'; import { DataPublicPluginStart } from 'src/plugins/data/public/types'; import { chartPluginMock } from 'src/plugins/charts/public/mocks'; diff --git a/x-pack/plugins/task_manager/kibana.json b/x-pack/plugins/task_manager/kibana.json index 36e68ca00af816..3c28df441a0abe 100644 --- a/x-pack/plugins/task_manager/kibana.json +++ b/x-pack/plugins/task_manager/kibana.json @@ -1,7 +1,7 @@ { "id": "taskManager", "server": true, - "version": "8.1.0", + "version": "8.2.0", "owner": { "name": "Kibana Alerting", "githubTeam": "kibana-alerting-services" diff --git a/x-pack/plugins/timelines/public/components/empty_value/empty_value.test.tsx b/x-pack/plugins/timelines/public/components/empty_value/empty_value.test.tsx index be9a086d8dc5b5..0e5ee638d29e8e 100644 --- a/x-pack/plugins/timelines/public/components/empty_value/empty_value.test.tsx +++ b/x-pack/plugins/timelines/public/components/empty_value/empty_value.test.tsx @@ -8,7 +8,7 @@ import { mount, shallow } from 'enzyme'; import React from 'react'; import { ThemeProvider } from 'styled-components'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { defaultToEmptyTag, diff --git a/x-pack/plugins/transform/public/app/common/navigation.tsx b/x-pack/plugins/transform/public/app/common/navigation.tsx index b847ac66de58e4..b146d4401c6338 100644 --- a/x-pack/plugins/transform/public/app/common/navigation.tsx +++ b/x-pack/plugins/transform/public/app/common/navigation.tsx @@ -13,5 +13,5 @@ import { SECTION_SLUG } from '../constants'; export const RedirectToTransformManagement: FC = () => ; export const RedirectToCreateTransform: FC<{ savedObjectId: string }> = ({ savedObjectId }) => ( - + ); diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx index e004a074a29229..75ed5c10f0483c 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_form.tsx @@ -486,18 +486,20 @@ export const StepDetailsForm: FC = React.memo( aria-label={i18n.translate( 'xpack.transform.stepDetailsForm.destinationIngestPipelineAriaLabel', { - defaultMessage: 'Select an ingest pipeline', + defaultMessage: 'Select an ingest pipeline (optional)', } )} placeholder={i18n.translate( 'xpack.transform.stepDetailsForm.destinationIngestPipelineComboBoxPlaceholder', { - defaultMessage: 'Select an ingest pipeline', + defaultMessage: 'Select an ingest pipeline (optional)', } )} singleSelection={{ asPlainText: true }} options={ingestPipelineNames.map((label: string) => ({ label }))} - selectedOptions={[{ label: destinationIngestPipeline }]} + selectedOptions={ + destinationIngestPipeline !== '' ? [{ label: destinationIngestPipeline }] : [] + } onChange={(options) => setDestinationIngestPipeline(options[0]?.label ?? '')} /> diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_summary.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_summary.tsx index 60423e0eb4eb01..ccf65074be8be0 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_summary.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_details/step_details_summary.tsx @@ -26,6 +26,7 @@ export const StepDetailsSummary: FC = React.memo((props transformFrequency, transformSettingsMaxPageSearchSize, destinationIndex, + destinationIngestPipeline, touched, indexPatternTimeField, } = props; @@ -78,6 +79,19 @@ export const StepDetailsSummary: FC = React.memo((props )} + {destinationIngestPipeline !== undefined && destinationIngestPipeline !== '' && ( + + {destinationIngestPipeline} + + )} + {isContinuousModeEnabled && ( { 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 a96e1fc3dcb5da..742e8981a1a1ad 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { EmailActionConnector } from '../types'; import EmailActionConnectorFields from './email_connector'; import * as hooks from './use_email_config'; 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 6a173cfd809260..1762fc0b39f8e6 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import EmailParamsFields from './email_params'; describe('EmailParamsFields renders', () => { diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/email/exchange_form.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/email/exchange_form.test.tsx index 2a08c9b19e6026..d87efe5134794d 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/email/exchange_form.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/email/exchange_form.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { EmailActionConnector } from '../types'; import ExchangeFormFields from './exchange_form'; 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 9ef498334ad3db..6aa7fde6d23e1a 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { act } from 'react-dom/test-utils'; import { EsIndexActionConnector } from '../types'; import IndexActionConnectorFields from './es_index_connector'; 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 75c4fe2d5a0559..6125255b3a52a6 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { act } from '@testing-library/react'; import ParamsFields from './es_index_params'; import { AlertHistoryEsIndexConnectorId } from '../../../../types'; 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 4859c25adcc06a..1c8c58c7c4a16a 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import JiraConnectorFields from './jira_connectors'; import { JiraActionConnector } from './types'; jest.mock('../../../../common/lib/kibana'); 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 8be15ddaa6bca7..0d10223af66cfe 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; 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 f67267a75ed334..6eb349b8f511c2 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { EventActionOptions, SeverityActionOptions } from '.././types'; import PagerDutyParamsFields from './pagerduty_params'; 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 35891f513be6b8..13459888ac365b 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import ResilientConnectorFields from './resilient_connectors'; import { ResilientActionConnector } from './types'; jest.mock('../../../../common/lib/kibana'); 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 eba971dd66db47..baaffb6721fc40 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ServerLogLevelOptions } from '.././types'; import ServerLogParamsFields from './server_log_params'; 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 03acb673bf5a46..786c84942e08f3 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 @@ -7,7 +7,7 @@ import React from 'react'; import { act } from '@testing-library/react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { useKibana } from '../../../../common/lib/kibana'; import { ActionConnectorFieldsSetCallbacks } from '../../../../types'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/servicenow_itsm_params.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/servicenow_itsm_params.test.tsx index bdb38d85a89237..a5804dc484cbbc 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/servicenow_itsm_params.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/servicenow_itsm_params.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { act } from '@testing-library/react'; import { ActionConnector } from '../../../../types'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/servicenow_sir_params.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/servicenow_sir_params.test.tsx index de331893ad0cf8..5fa15de0368443 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/servicenow_sir_params.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/servicenow_sir_params.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { act } from '@testing-library/react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ActionConnector } from '../../../../types'; import { useGetChoices } from './use_get_choices'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/update_connector.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/update_connector.test.tsx index ecb90051e78c2c..00cce14906e82b 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/update_connector.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/update_connector.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { UpdateConnector, Props } from './update_connector'; import { ServiceNowActionConnector } from './types'; jest.mock('../../../../common/lib/kibana'); 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 0a37165bd7f5f3..c0f6a17cae4fe9 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; 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 74ee201340cc03..6611b33e094b22 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import SlackParamsFields from './slack_params'; describe('SlackParamsFields renders', () => { diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/swimlane/swimlane_connectors.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/swimlane/swimlane_connectors.test.tsx index 4829156380e94a..47e5c09c13864d 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/swimlane/swimlane_connectors.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/swimlane/swimlane_connectors.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { act } from 'react-dom/test-utils'; import { SwimlaneActionConnector } from './types'; import SwimlaneActionConnectorFields from './swimlane_connectors'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/swimlane/swimlane_params.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/swimlane/swimlane_params.test.tsx index f1d7efca395512..03f20546b1003f 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/swimlane/swimlane_params.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/swimlane/swimlane_params.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import SwimlaneParamsFields from './swimlane_params'; import { SwimlaneConnectorType } from './types'; import { mappings } from './mocks'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/teams/teams_connectors.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/teams/teams_connectors.test.tsx index 5031b322812588..2d2b6d5052bb8a 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/teams/teams_connectors.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/teams/teams_connectors.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { act } from '@testing-library/react'; import { TeamsActionConnector } from '../types'; import TeamsActionFields from './teams_connectors'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/teams/teams_params.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/teams/teams_params.test.tsx index 9d5e86d413d934..cf0bfe9db0e978 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/teams/teams_params.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/teams/teams_params.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import TeamsParamsFields from './teams_params'; jest.mock('../../../../common/lib/kibana'); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/webhook/webhook_connectors.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/webhook/webhook_connectors.test.tsx index ea40c1ddfb1396..2579d8dd1a93b4 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/webhook/webhook_connectors.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/webhook/webhook_connectors.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { WebhookActionConnector } from '../types'; import WebhookActionConnectorFields from './webhook_connectors'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/webhook/webhook_params.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/webhook/webhook_params.test.tsx index 7c9ffaa23659b0..064d21b50e463e 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/webhook/webhook_params.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/webhook/webhook_params.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import WebhookParamsFields from './webhook_params'; import { MockCodeEditor } from '../../../code_editor.mock'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/json_editor_with_message_variables.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/json_editor_with_message_variables.test.tsx index 6a705798a9b7fa..068e4755be1659 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/json_editor_with_message_variables.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/json_editor_with_message_variables.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { JsonEditorWithMessageVariables } from './json_editor_with_message_variables'; import { MockCodeEditor } from '../code_editor.mock'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/text_area_with_message_variables.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/text_area_with_message_variables.test.tsx index 72ea099f87d260..0f3981391a49ca 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/text_area_with_message_variables.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/text_area_with_message_variables.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { TextAreaWithMessageVariables } from './text_area_with_message_variables'; describe('TextAreaWithMessageVariables', () => { diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/text_field_with_message_variables.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/text_field_with_message_variables.test.tsx index e0d74c5568c70d..43c7ac51591b51 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/text_field_with_message_variables.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/text_field_with_message_variables.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { TextFieldWithMessageVariables } from './text_field_with_message_variables'; describe('TextFieldWithMessageVariables', () => { diff --git a/x-pack/plugins/triggers_actions_ui/public/application/home.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/home.test.tsx index 3594374a54f167..51f80438c55cce 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/home.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/home.test.tsx @@ -8,7 +8,7 @@ import * as React from 'react'; import { RouteComponentProps, Router } from 'react-router-dom'; import { createMemoryHistory, createLocation } from 'history'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import TriggersActionsUIHome, { MatchParams } from './home'; import { useKibana } from '../common/lib/kibana'; jest.mock('../common/lib/kibana'); 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 5a4d682ff573bb..4addfc3833aab2 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 @@ -6,7 +6,7 @@ */ import * as React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { actionTypeRegistryMock } from '../../action_type_registry.mock'; import { UserConfiguredActionConnector, 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 f7c15dade55e38..ace563aa96b9ec 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 @@ -6,7 +6,7 @@ */ import React, { lazy } from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { EuiAccordion } from '@elastic/eui'; import { coreMock } from '../../../../../../../src/core/public/mocks'; import { act } from 'react-dom/test-utils'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_form.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_form.test.tsx index e8590595b9d614..e04b96b6839cf5 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_form.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_form.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ import * as React from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { ActionTypeForm } from './action_type_form'; import { actionTypeRegistryMock } from '../../action_type_registry.mock'; import { 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 e15916138af717..e8a0287d900263 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 @@ -6,7 +6,7 @@ */ import * as React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { coreMock } from '../../../../../../../src/core/public/mocks'; import { actionTypeRegistryMock } from '../../action_type_registry.mock'; import { ActionTypeMenu } from './action_type_menu'; 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 8dbe5f105a0f70..9870786e5d3cc1 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 @@ -6,7 +6,7 @@ */ import * as React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { coreMock } from '../../../../../../../src/core/public/mocks'; import ConnectorAddFlyout from './connector_add_flyout'; import { actionTypeRegistryMock } from '../../action_type_registry.mock'; 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 1502b4255767d1..0666f8be394d8d 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 @@ -6,7 +6,7 @@ */ import * as React from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { act } from 'react-dom/test-utils'; 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 e6d3c0bde81137..e2bc9d44b147c9 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 @@ -6,7 +6,7 @@ */ import * as React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { coreMock } from '../../../../../../../src/core/public/mocks'; import { actionTypeRegistryMock } from '../../action_type_registry.mock'; import { ConnectorValidationResult, GenericValidationResult } from '../../../types'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connectors_selection.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connectors_selection.test.tsx index 6c383913a3c0f9..1ecb651314ba9a 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connectors_selection.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connectors_selection.test.tsx @@ -7,7 +7,7 @@ import * as React from 'react'; import { render, screen } from '@testing-library/react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { EuiThemeProvider } from '../../../../../../../src/plugins/kibana_react/common'; import { ConnectorsSelection } from './connectors_selection'; 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 7a3edcf4cb948d..cc928d5c30fd95 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 @@ -16,7 +16,7 @@ import { } from '../../../types'; import { actionTypeRegistryMock } from '../../action_type_registry.mock'; import { EuiFormRow, EuiFieldText, EuiText, EuiLink, EuiForm, EuiSelect } from '@elastic/eui'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; jest.mock('../../../common/lib/kibana'); const mockedActionParamsFields = lazy(async () => ({ 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 d477fcd0ddf742..1de8ad97af891a 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 @@ -8,7 +8,7 @@ import * as React from 'react'; // eslint-disable-next-line @kbn/eslint/module_migration import { ThemeProvider } from 'styled-components'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import ActionsConnectorsList from './actions_connectors_list'; import { coreMock } from '../../../../../../../../src/core/public/mocks'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.test.tsx index b92b4289ea905e..e12322c3b84ad4 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.test.tsx @@ -8,7 +8,7 @@ import * as React from 'react'; import uuid from 'uuid'; import { shallow } from 'enzyme'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { act } from '@testing-library/react'; import { AlertDetails } from './alert_details'; import { Rule, ActionType, RuleTypeModel, RuleType } from '../../../../types'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details_route.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details_route.test.tsx index 770b273b02c29b..9bfb8f20744de4 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details_route.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details_route.test.tsx @@ -8,7 +8,7 @@ import * as React from 'react'; import uuid from 'uuid'; import { shallow } from 'enzyme'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { act } from 'react-dom/test-utils'; import { createMemoryHistory, createLocation } from 'history'; import { ToastsApi } from 'kibana/public'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alerts.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alerts.test.tsx index 075f6dedeb06ab..909a562224ef76 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alerts.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alerts.test.tsx @@ -8,7 +8,7 @@ import * as React from 'react'; import uuid from 'uuid'; import { shallow } from 'enzyme'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { act } from 'react-dom/test-utils'; import { Alerts, AlertListItem, alertToListItem } from './alerts'; import { Rule, AlertSummary, AlertStatus, RuleType } from '../../../../types'; 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 3187021518c9cd..7e45dd8ac636ac 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 @@ -7,7 +7,7 @@ import uuid from 'uuid'; import React, { FunctionComponent } from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; 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_conditions.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_conditions.test.tsx index f4ed8d0b05a85f..07f7b1475b92fa 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_conditions.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_conditions.test.tsx @@ -6,7 +6,7 @@ */ import * as React from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { act } from 'react-dom/test-utils'; import { ReactWrapper } from 'enzyme'; import { AlertConditions, ActionGroupWithCondition } from './alert_conditions'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_conditions_group.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_conditions_group.test.tsx index f730f73a417ba5..49a2ec087a2b81 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_conditions_group.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_conditions_group.test.tsx @@ -6,7 +6,7 @@ */ import * as React from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { act } from 'react-dom/test-utils'; import { ReactWrapper } from 'enzyme'; import { AlertConditionsGroup } from './alert_conditions_group'; 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 226734ca46a676..ec33756cfec4a6 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 @@ -6,7 +6,7 @@ */ import * as React from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; 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 37741dcaab6e5c..49803c0cc419df 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 @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; 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_notify_when.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_notify_when.test.tsx index 1534e0ed4f6b8f..c15f249fd76888 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_notify_when.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_notify_when.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { ReactWrapper } from 'enzyme'; import { act } from 'react-dom/test-utils'; import { Rule } from '../../../types'; 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 ce94ef75ac1562..2ca32ec04cd70a 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 @@ -6,7 +6,7 @@ */ import * as React from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; 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/alerts_list/components/collapsed_item_actions.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/collapsed_item_actions.test.tsx index a54bc67244b35f..a036feea0fbcb5 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/collapsed_item_actions.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/collapsed_item_actions.test.tsx @@ -6,7 +6,7 @@ */ import * as React from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { CollapsedItemActions } from './collapsed_item_actions'; import { act } from 'react-dom/test-utils'; import { ruleTypeRegistryMock } from '../../../rule_type_registry.mock'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/rule_enabled_switch.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/rule_enabled_switch.test.tsx index da75faeda95e9a..0773d6c9c5ed0d 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/rule_enabled_switch.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/rule_enabled_switch.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { RuleEnabledSwitch, ComponentOpts } from './rule_enabled_switch'; describe('RuleEnabledSwitch', () => { diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/execution_duration_chart.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/execution_duration_chart.test.tsx index f524ff4426b6a9..f98f82e412f86f 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/execution_duration_chart.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/execution_duration_chart.test.tsx @@ -6,7 +6,7 @@ */ import * as React from 'react'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; import { act } from 'react-dom/test-utils'; import { ExecutionDurationChart, padOrTruncateDurations } from './execution_duration_chart'; 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 653c0ebadcfae4..bb94e1d38757ab 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 @@ -7,7 +7,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { ThresholdExpression } from './threshold'; describe('threshold expression', () => { diff --git a/x-pack/plugins/triggers_actions_ui/public/common/expression_items/value.test.tsx b/x-pack/plugins/triggers_actions_ui/public/common/expression_items/value.test.tsx index e9a3dce84e1497..6ff6206db456a9 100644 --- a/x-pack/plugins/triggers_actions_ui/public/common/expression_items/value.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/common/expression_items/value.test.tsx @@ -9,7 +9,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { act } from 'react-dom/test-utils'; import { ValueExpression } from './value'; -import { mountWithIntl, nextTick } from '@kbn/test/jest'; +import { mountWithIntl, nextTick } from '@kbn/test-jest-helpers'; describe('value expression', () => { it('renders description and value', () => { 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 889b6377b16b54..663161f5ebd2dc 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 @@ -19,7 +19,7 @@ import { HELLO_WORLD_EMBEDDABLE, } from '../../../../src/plugins/embeddable/public/tests/fixtures'; -import { nextTick } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; 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 b4134ddd17395b..f31e2552fa717e 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 @@ -12,7 +12,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 '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; test('Removing custom time range from badge resets embeddable back to container time', async () => { const container = new TimeRangeContainer( diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/app/app.helpers.tsx b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/app/app.helpers.tsx index 55c8c7f721a49e..25e38b4111e50d 100644 --- a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/app/app.helpers.tsx +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/app/app.helpers.tsx @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test/jest'; +import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test-jest-helpers'; import { App } from '../../../public/application/app'; import { WithAppDependencies } from '../helpers'; diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/es_deprecation_logs/es_deprecation_logs.helpers.ts b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/es_deprecation_logs/es_deprecation_logs.helpers.ts index 11784d02695051..31bbcd01a7320d 100644 --- a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/es_deprecation_logs/es_deprecation_logs.helpers.ts +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/es_deprecation_logs/es_deprecation_logs.helpers.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test/jest'; +import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test-jest-helpers'; import { EsDeprecationLogs } from '../../../public/application/components/es_deprecation_logs'; import { WithAppDependencies } from '../helpers'; diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/es_deprecations/es_deprecations.helpers.ts b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/es_deprecations/es_deprecations.helpers.ts index 28ec1983cbedae..08d53d1eaca7ec 100644 --- a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/es_deprecations/es_deprecations.helpers.ts +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/es_deprecations/es_deprecations.helpers.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test/jest'; +import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test-jest-helpers'; import { EsDeprecations } from '../../../public/application/components/es_deprecations'; import { WithAppDependencies } from '../helpers'; diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/kibana_deprecations/kibana_deprecations.helpers.ts b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/kibana_deprecations/kibana_deprecations.helpers.ts index 8d14a211786c4f..9f98496ac2edf5 100644 --- a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/kibana_deprecations/kibana_deprecations.helpers.ts +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/kibana_deprecations/kibana_deprecations.helpers.ts @@ -5,7 +5,12 @@ * 2.0. */ import { act } from 'react-dom/test-utils'; -import { registerTestBed, TestBed, AsyncTestBedConfig, findTestSubject } from '@kbn/test/jest'; +import { + registerTestBed, + TestBed, + AsyncTestBedConfig, + findTestSubject, +} from '@kbn/test-jest-helpers'; import { KibanaDeprecations } from '../../../public/application/components'; import { WithAppDependencies } from '../helpers'; diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/overview.helpers.ts b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/overview.helpers.ts index 34abaed727bd34..30a531091f1666 100644 --- a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/overview.helpers.ts +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/overview.helpers.ts @@ -6,7 +6,7 @@ */ import { act } from 'react-dom/test-utils'; -import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test/jest'; +import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test-jest-helpers'; import { Overview } from '../../../public/application/components/overview'; import { WithAppDependencies } from '../helpers'; diff --git a/x-pack/plugins/uptime/common/constants/rest_api.ts b/x-pack/plugins/uptime/common/constants/rest_api.ts index 2c369579b01500..f1b0b69ba61ec2 100644 --- a/x-pack/plugins/uptime/common/constants/rest_api.ts +++ b/x-pack/plugins/uptime/common/constants/rest_api.ts @@ -41,4 +41,5 @@ export enum API_URLS { SERVICE_LOCATIONS = '/internal/uptime/service/locations', SYNTHETICS_MONITORS = '/internal/uptime/service/monitors', RUN_ONCE_MONITOR = '/internal/uptime/service/monitors/run_once', + TRIGGER_MONITOR = '/internal/uptime/service/monitors/trigger', } diff --git a/x-pack/plugins/uptime/common/runtime_types/monitor/state.ts b/x-pack/plugins/uptime/common/runtime_types/monitor/state.ts index fc2cd42500d6c1..d43fd5ad001f23 100644 --- a/x-pack/plugins/uptime/common/runtime_types/monitor/state.ts +++ b/x-pack/plugins/uptime/common/runtime_types/monitor/state.ts @@ -27,6 +27,7 @@ export const StateType = t.intersection([ monitor: t.intersection([ t.partial({ name: t.string, + duration: t.type({ us: t.number }), }), t.type({ type: t.string, @@ -73,6 +74,7 @@ export const MonitorSummaryType = t.intersection([ t.partial({ histogram: HistogramType, minInterval: t.number, + configId: t.string, }), ]); diff --git a/x-pack/plugins/uptime/common/runtime_types/monitor_management/state.ts b/x-pack/plugins/uptime/common/runtime_types/monitor_management/state.ts index 1fa96451053a8b..8119fbca4b9e77 100644 --- a/x-pack/plugins/uptime/common/runtime_types/monitor_management/state.ts +++ b/x-pack/plugins/uptime/common/runtime_types/monitor_management/state.ts @@ -10,6 +10,8 @@ import * as t from 'io-ts'; export const FetchMonitorManagementListQueryArgsType = t.partial({ page: t.number, perPage: t.number, + sortField: t.string, + sortOrder: t.union([t.literal('desc'), t.literal('asc')]), search: t.string, searchFields: t.array(t.string), }); diff --git a/x-pack/plugins/uptime/common/runtime_types/ping/ping.ts b/x-pack/plugins/uptime/common/runtime_types/ping/ping.ts index f4a9fe31b2885f..989d6d8ef941a0 100644 --- a/x-pack/plugins/uptime/common/runtime_types/ping/ping.ts +++ b/x-pack/plugins/uptime/common/runtime_types/ping/ping.ts @@ -220,6 +220,7 @@ export const PingType = t.intersection([ service: t.partial({ name: t.string, }), + config_id: t.string, }), ]); diff --git a/x-pack/plugins/uptime/e2e/fixtures/es_archiver/browser/mappings.json b/x-pack/plugins/uptime/e2e/fixtures/es_archiver/browser/mappings.json index 416b157b35a675..c022a7ab042494 100644 --- a/x-pack/plugins/uptime/e2e/fixtures/es_archiver/browser/mappings.json +++ b/x-pack/plugins/uptime/e2e/fixtures/es_archiver/browser/mappings.json @@ -10,7 +10,7 @@ "mappings": { "_meta": { "beat": "heartbeat", - "version": "8.1.0" + "version": "8.2.0" }, "date_detection": false, "dynamic_templates": [ @@ -7759,4 +7759,4 @@ } } } -} \ No newline at end of file +} diff --git a/x-pack/plugins/uptime/public/components/common/charts/chart_empty_state.test.tsx b/x-pack/plugins/uptime/public/components/common/charts/chart_empty_state.test.tsx index 9d8aa3d4d091f0..1f185b964b668f 100644 --- a/x-pack/plugins/uptime/public/components/common/charts/chart_empty_state.test.tsx +++ b/x-pack/plugins/uptime/public/components/common/charts/chart_empty_state.test.tsx @@ -6,7 +6,7 @@ */ import { ChartEmptyState } from './chart_empty_state'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; import { FormattedMessage } from '@kbn/i18n-react'; diff --git a/x-pack/plugins/uptime/public/components/common/charts/chart_wrapper.test.tsx b/x-pack/plugins/uptime/public/components/common/charts/chart_wrapper.test.tsx index 25b316344b32a5..37354104cf8716 100644 --- a/x-pack/plugins/uptime/public/components/common/charts/chart_wrapper.test.tsx +++ b/x-pack/plugins/uptime/public/components/common/charts/chart_wrapper.test.tsx @@ -8,8 +8,8 @@ import React from 'react'; import { EuiSpacer } from '@elastic/eui'; import { mount } from 'enzyme'; -import { nextTick } from '@kbn/test/jest'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { nextTick } from '@kbn/test-jest-helpers'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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/donut_chart.test.tsx b/x-pack/plugins/uptime/public/components/common/charts/donut_chart.test.tsx index ee01235a75fd7d..ff83c51900cdfa 100644 --- a/x-pack/plugins/uptime/public/components/common/charts/donut_chart.test.tsx +++ b/x-pack/plugins/uptime/public/components/common/charts/donut_chart.test.tsx @@ -6,7 +6,7 @@ */ import { DonutChart } from './donut_chart'; -import { renderWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { renderWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; describe('DonutChart component', () => { diff --git a/x-pack/plugins/uptime/public/components/common/charts/donut_chart_legend.test.tsx b/x-pack/plugins/uptime/public/components/common/charts/donut_chart_legend.test.tsx index f2f9757afce071..3e5a5c25396802 100644 --- a/x-pack/plugins/uptime/public/components/common/charts/donut_chart_legend.test.tsx +++ b/x-pack/plugins/uptime/public/components/common/charts/donut_chart_legend.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { renderWithIntl } from '@kbn/test/jest'; +import { renderWithIntl } from '@kbn/test-jest-helpers'; import { DonutChartLegend } from './donut_chart_legend'; diff --git a/x-pack/plugins/uptime/public/components/common/charts/donut_chart_legend_row.test.tsx b/x-pack/plugins/uptime/public/components/common/charts/donut_chart_legend_row.test.tsx index 1b73b80bacd57a..cae142b2a4f798 100644 --- a/x-pack/plugins/uptime/public/components/common/charts/donut_chart_legend_row.test.tsx +++ b/x-pack/plugins/uptime/public/components/common/charts/donut_chart_legend_row.test.tsx @@ -6,7 +6,7 @@ */ import { DonutChartLegendRow } from './donut_chart_legend_row'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; describe('DonutChartLegendRow', () => { diff --git a/x-pack/plugins/uptime/public/components/common/location_link.test.tsx b/x-pack/plugins/uptime/public/components/common/location_link.test.tsx index 177015b93d3f31..285ee6cb47725f 100644 --- a/x-pack/plugins/uptime/public/components/common/location_link.test.tsx +++ b/x-pack/plugins/uptime/public/components/common/location_link.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; import { LocationLink } from './location_link'; diff --git a/x-pack/plugins/uptime/public/components/common/monitor_page_link.test.tsx b/x-pack/plugins/uptime/public/components/common/monitor_page_link.test.tsx index 317af4c083ca2e..9bd7db2de7f6b3 100644 --- a/x-pack/plugins/uptime/public/components/common/monitor_page_link.test.tsx +++ b/x-pack/plugins/uptime/public/components/common/monitor_page_link.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { MonitorPageLink } from './monitor_page_link'; describe('MonitorPageLink component', () => { diff --git a/x-pack/plugins/uptime/public/components/monitor/ml/confirm_delete.test.tsx b/x-pack/plugins/uptime/public/components/monitor/ml/confirm_delete.test.tsx index c88349282b7b4e..5f46169901e577 100644 --- a/x-pack/plugins/uptime/public/components/monitor/ml/confirm_delete.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/ml/confirm_delete.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { ConfirmJobDeletion } from './confirm_delete'; describe('ML Confirm Job Delete', () => { diff --git a/x-pack/plugins/uptime/public/components/monitor/ping_list/expanded_row.test.tsx b/x-pack/plugins/uptime/public/components/monitor/ping_list/expanded_row.test.tsx index dd42a148907939..f87501a79e964d 100644 --- a/x-pack/plugins/uptime/public/components/monitor/ping_list/expanded_row.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/ping_list/expanded_row.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { mountWithIntl, renderWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { mountWithIntl, renderWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; 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/ping_headers.test.tsx b/x-pack/plugins/uptime/public/components/monitor/ping_list/ping_headers.test.tsx index aa1f85556bc5f8..8bc9f2b7fed51b 100644 --- a/x-pack/plugins/uptime/public/components/monitor/ping_list/ping_headers.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/ping_list/ping_headers.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; import { PingHeaders } from './headers'; diff --git a/x-pack/plugins/uptime/public/components/monitor/status_details/availability_reporting/tag_label.test.tsx b/x-pack/plugins/uptime/public/components/monitor/status_details/availability_reporting/tag_label.test.tsx index 76ec33ccc5fe24..d4dd2f6f0678ba 100644 --- a/x-pack/plugins/uptime/public/components/monitor/status_details/availability_reporting/tag_label.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/status_details/availability_reporting/tag_label.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { renderWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { renderWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import { TagLabel } from './tag_label'; describe('TagLabel component', () => { diff --git a/x-pack/plugins/uptime/public/components/monitor/status_details/status_by_location.test.tsx b/x-pack/plugins/uptime/public/components/monitor/status_details/status_by_location.test.tsx index d86b7f13604dd6..d7e8f70475f541 100644 --- a/x-pack/plugins/uptime/public/components/monitor/status_details/status_by_location.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/status_details/status_by_location.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { renderWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { renderWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import { MonitorLocation } from '../../../../common/runtime_types'; import { StatusByLocations } from './index'; diff --git a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/actions.test.tsx b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/actions.test.tsx index de85ee7e70e352..fd868214d4db9e 100644 --- a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/actions.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/actions.test.tsx @@ -18,11 +18,11 @@ import { spyOnUseFetcher } from '../../../lib/helper/spy_use_fetcher'; import { Actions } from './actions'; describe('', () => { - const setRefresh = jest.fn(); + const onUpdate = jest.fn(); const useFetcher = spyOnUseFetcher({}); it('navigates to edit monitor flow on edit pencil', () => { - render(); + render(); expect(screen.getByLabelText('Edit monitor')).toHaveAttribute( 'href', @@ -34,7 +34,7 @@ describe('', () => { useFetcher.mockImplementation(originalUseFetcher); const deleteMonitor = jest.spyOn(fetchers, 'deleteMonitor'); const id = 'test-id'; - render(); + render(); expect(deleteMonitor).not.toBeCalled(); @@ -45,11 +45,11 @@ describe('', () => { it('calls set refresh when deletion is successful', () => { const id = 'test-id'; - render(); + render(); userEvent.click(screen.getByLabelText('Delete monitor')); - expect(setRefresh).toBeCalledWith(true); + expect(onUpdate).toHaveBeenCalled(); }); it('shows loading spinner while waiting for monitor to delete', () => { @@ -59,7 +59,7 @@ describe('', () => { status: FETCH_STATUS.LOADING, refetch: () => {}, }); - render(); + render(); expect(screen.getByLabelText('Deleting monitor...')).toBeInTheDocument(); }); diff --git a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/actions.tsx b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/actions.tsx index e3a63cec4a355f..6c85ae3d8a2a04 100644 --- a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/actions.tsx +++ b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/actions.tsx @@ -15,11 +15,11 @@ import { useKibana } from '../../../../../../../src/plugins/kibana_react/public' interface Props { id: string; - setRefresh: React.Dispatch>; isDisabled?: boolean; + onUpdate: () => void; } -export const Actions = ({ id, setRefresh, isDisabled }: Props) => { +export const Actions = ({ id, onUpdate, isDisabled }: Props) => { const [isDeleting, setIsDeleting] = useState(false); const { basePath } = useContext(UptimeSettingsContext); @@ -46,13 +46,13 @@ export const Actions = ({ id, setRefresh, isDisabled }: Props) => { toastLifeTimeMs: 3000, }); } else if (status === FETCH_STATUS.SUCCESS) { - setRefresh(true); + onUpdate(); notifications.toasts.success({ title:

{MONITOR_DELETE_SUCCESS_LABEL}

, toastLifeTimeMs: 3000, }); } - }, [setIsDeleting, setRefresh, notifications.toasts, status]); + }, [setIsDeleting, onUpdate, notifications.toasts, status]); // TODO: Add popovers to icons return ( diff --git a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_enabled.test.tsx b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_enabled.test.tsx index 5130a8bfb51329..8ce9b719c065c3 100644 --- a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_enabled.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_enabled.test.tsx @@ -15,7 +15,7 @@ import { spyOnUseFetcher } from '../../../lib/helper/spy_use_fetcher'; import { MonitorEnabled } from './monitor_enabled'; describe('', () => { - const setRefresh = jest.fn(); + const onUpdate = jest.fn(); const testMonitor = { [ConfigKey.MONITOR_TYPE]: DataStream.HTTP, [ConfigKey.ENABLED]: true, @@ -34,7 +34,7 @@ describe('', () => { }); it('correctly renders "enabled" state', () => { - render(); + render(); const switchButton = screen.getByRole('switch') as HTMLButtonElement; assertMonitorEnabled(switchButton); @@ -45,7 +45,7 @@ describe('', () => { ); @@ -54,7 +54,7 @@ describe('', () => { }); it('toggles on click', () => { - render(); + render(); const switchButton = screen.getByRole('switch') as HTMLButtonElement; userEvent.click(switchButton); @@ -70,7 +70,7 @@ describe('', () => { refetch: () => {}, }); - render(); + render(); const switchButton = screen.getByRole('switch') as HTMLButtonElement; userEvent.click(switchButton); diff --git a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_enabled.tsx b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_enabled.tsx index 70daaaa6c19e9b..2913043aca72ea 100644 --- a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_enabled.tsx +++ b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_enabled.tsx @@ -16,11 +16,11 @@ import { setMonitor } from '../../../state/api'; interface Props { id: string; monitor: SyntheticsMonitor; - setRefresh: React.Dispatch>; + onUpdate: () => void; isDisabled?: boolean; } -export const MonitorEnabled = ({ id, monitor, setRefresh, isDisabled }: Props) => { +export const MonitorEnabled = ({ id, monitor, onUpdate, isDisabled }: Props) => { const [isEnabled, setIsEnabled] = useState(null); const { notifications } = useKibana(); @@ -53,7 +53,7 @@ export const MonitorEnabled = ({ id, monitor, setRefresh, isDisabled }: Props) = ), toastLifeTimeMs: 3000, }); - setRefresh(true); + onUpdate(); } }, [status]); // eslint-disable-line react-hooks/exhaustive-deps diff --git a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.test.tsx b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.test.tsx index d352ccef51a944..8f9f643ac0f9fe 100644 --- a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.test.tsx @@ -5,24 +5,24 @@ * 2.0. */ -import React from 'react'; import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; +import React from 'react'; +import { ConfigKey, DataStream, HTTPFields, ScheduleUnit } from '../../../../common/runtime_types'; import { render } from '../../../lib/helper/rtl_helpers'; -import { DataStream, HTTPFields, ScheduleUnit } from '../../../../common/runtime_types'; -import { MonitorManagementList } from './monitor_list'; import { MonitorManagementList as MonitorManagementListState } from '../../../state/reducers/monitor_management'; +import { MonitorManagementList, MonitorManagementListPageState } from './monitor_list'; -describe('', () => { - const setRefresh = jest.fn(); - const setPageSize = jest.fn(); - const setPageIndex = jest.fn(); +describe('', () => { + const onUpdate = jest.fn(); + const onPageStateChange = jest.fn(); const monitors = []; for (let i = 0; i < 12; i++) { monitors.push({ id: `test-monitor-id-${i}`, attributes: { name: `test-monitor-${i}`, + enabled: true, schedule: { unit: ScheduleUnit.MINUTES, number: `${i}`, @@ -53,13 +53,20 @@ describe('', () => { } as MonitorManagementListState, }; + const pageState: MonitorManagementListPageState = { + pageIndex: 1, + pageSize: 10, + sortField: ConfigKey.NAME, + sortOrder: 'asc', + }; + it.each(monitors)('navigates to edit monitor flow on edit pencil', (monitor) => { render( , { state } ); @@ -79,10 +86,10 @@ describe('', () => { it('handles changing per page', () => { render( , { state } ); @@ -91,23 +98,22 @@ describe('', () => { userEvent.click(screen.getByText('10 rows')); - expect(setPageSize).toBeCalledWith(10); + expect(onPageStateChange).toBeCalledWith(expect.objectContaining({ pageSize: 10 })); }); - it('handles refreshing and changing page when navigating to the next page', () => { - render( + it('handles refreshing and changing page when navigating to the next page', async () => { + const { getByTestId } = render( , { state } ); - userEvent.click(screen.getByTestId('pagination-button-next')); + userEvent.click(getByTestId('pagination-button-next')); - expect(setPageIndex).toBeCalledWith(2); - expect(setRefresh).toBeCalledWith(true); + expect(onPageStateChange).toBeCalledWith(expect.objectContaining({ pageIndex: 2 })); }); }); diff --git a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.tsx b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.tsx index 5ef50978bdfa43..77b08c3ea7ee1b 100644 --- a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.tsx +++ b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.tsx @@ -4,139 +4,177 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import React, { useContext, useMemo, useCallback } from 'react'; +import { + Criteria, + EuiBasicTable, + EuiBasicTableColumn, + EuiLink, + EuiPanel, + EuiSpacer, +} from '@elastic/eui'; +import { EuiTableSortingType } from '@elastic/eui/src/components/basic_table/table_types'; import { i18n } from '@kbn/i18n'; -import { EuiBasicTable, EuiPanel, EuiSpacer, EuiLink } from '@elastic/eui'; -import { SyntheticsMonitorSavedObject } from '../../../../common/types'; -import { MonitorManagementList as MonitorManagementListState } from '../../../state/reducers/monitor_management'; -import { MonitorFields, SyntheticsMonitor } from '../../../../common/runtime_types'; +import React, { useCallback, useContext, useMemo } from 'react'; +import { + CommonFields, + ConfigKey, + FetchMonitorManagementListQueryArgs, + ICMPSimpleFields, + MonitorFields, + ServiceLocations, + SyntheticsMonitorWithId, + TCPSimpleFields, +} from '../../../../common/runtime_types'; import { UptimeSettingsContext } from '../../../contexts'; +import { useBreakpoints } from '../../../hooks'; +import { MonitorManagementList as MonitorManagementListState } from '../../../state/reducers/monitor_management'; +import * as labels from '../../overview/monitor_list/translations'; import { Actions } from './actions'; +import { MonitorEnabled } from './monitor_enabled'; import { MonitorLocations } from './monitor_locations'; import { MonitorTags } from './tags'; -import { MonitorEnabled } from './monitor_enabled'; -import * as labels from '../../overview/monitor_list/translations'; import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; +export interface MonitorManagementListPageState { + pageIndex: number; + pageSize: number; + sortField: keyof MonitorFields; + sortOrder: NonNullable; +} + interface Props { - setPageSize: React.Dispatch>; - setPageIndex: React.Dispatch>; - setRefresh: React.Dispatch>; + pageState: MonitorManagementListPageState; monitorList: MonitorManagementListState; + onPageStateChange: (state: MonitorManagementListPageState) => void; + onUpdate: () => void; } export const MonitorManagementList = ({ + pageState: { pageIndex, pageSize, sortField, sortOrder }, monitorList: { list, error: { monitorList: error }, loading: { monitorList: loading }, }, - setRefresh, - setPageSize, - setPageIndex, + onPageStateChange, + onUpdate, }: Props) => { - const { total, perPage, page: pageIndex } = list as MonitorManagementListState['list']; - const monitors = list.monitors as SyntheticsMonitorSavedObject[]; const { basePath } = useContext(UptimeSettingsContext); + const isXl = useBreakpoints().up('xl'); - const pagination = useMemo( - () => ({ - pageIndex: pageIndex - 1, // page index for EuiBasicTable is base 0 - pageSize: perPage, - totalItemCount: total || 0, - pageSizeOptions: [10, 25, 50, 100], - }), - [pageIndex, perPage, total] + const { total } = list as MonitorManagementListState['list']; + const monitors: SyntheticsMonitorWithId[] = useMemo( + () => list.monitors.map((monitor) => ({ ...monitor.attributes, id: monitor.id })), + [list.monitors] ); const handleOnChange = useCallback( - ({ page = {} }) => { + ({ + page = { index: 0, size: 10 }, + sort = { field: ConfigKey.NAME, direction: 'asc' }, + }: Criteria) => { const { index, size } = page; + const { field, direction } = sort; - setPageIndex(index + 1); // page index for Saved Objects is base 1 - setPageSize(size); - setRefresh(true); + onPageStateChange({ + pageIndex: index + 1, // page index for Saved Objects is base 1 + pageSize: size, + sortField: field as keyof MonitorFields, + sortOrder: direction, + }); }, - [setPageIndex, setPageSize, setRefresh] + [onPageStateChange] ); + const pagination = { + pageIndex: pageIndex - 1, // page index for EuiBasicTable is base 0 + pageSize, + totalItemCount: total || 0, + pageSizeOptions: [10, 25, 50, 100], + }; + + const sorting: EuiTableSortingType = { + sort: { + field: sortField as keyof SyntheticsMonitorWithId, + direction: sortOrder, + }, + }; + const canEdit: boolean = !!useKibana().services?.application?.capabilities.uptime.save; const columns = [ { align: 'left' as const, + field: ConfigKey.NAME as string, name: i18n.translate('xpack.uptime.monitorManagement.monitorList.monitorName', { defaultMessage: 'Monitor name', }), - render: ({ - attributes: { name }, - id, - }: { - attributes: Partial; - id: string; - }) => ( + sortable: true, + render: (name: string, { id }: SyntheticsMonitorWithId) => ( {name} ), - truncateText: true, }, { align: 'left' as const, - field: 'attributes', + field: ConfigKey.MONITOR_TYPE, name: i18n.translate('xpack.uptime.monitorManagement.monitorList.monitorType', { defaultMessage: 'Monitor type', }), - render: ({ type }: SyntheticsMonitor) => type, + sortable: true, }, { align: 'left' as const, - field: 'attributes', + field: ConfigKey.TAGS, name: i18n.translate('xpack.uptime.monitorManagement.monitorList.tags', { defaultMessage: 'Tags', }), - render: ({ tags }: SyntheticsMonitor) => (tags ? : null), + render: (tags: string[]) => (tags ? : null), }, { align: 'left' as const, - field: 'attributes', + field: ConfigKey.LOCATIONS, name: i18n.translate('xpack.uptime.monitorManagement.monitorList.locations', { defaultMessage: 'Locations', }), - render: ({ locations }: SyntheticsMonitor) => + render: (locations: ServiceLocations) => locations ? : null, }, { align: 'left' as const, - field: 'attributes', + field: ConfigKey.SCHEDULE, name: i18n.translate('xpack.uptime.monitorManagement.monitorList.schedule', { defaultMessage: 'Schedule', }), - render: ({ schedule }: SyntheticsMonitor) => `@every ${schedule?.number}${schedule?.unit}`, + render: (schedule: CommonFields[ConfigKey.SCHEDULE]) => + `@every ${schedule?.number}${schedule?.unit}`, }, { align: 'left' as const, - field: 'attributes', + field: ConfigKey.URLS, name: i18n.translate('xpack.uptime.monitorManagement.monitorList.URL', { defaultMessage: 'URL', }), - render: (attributes: MonitorFields) => attributes.urls || attributes.hosts, + sortable: true, + render: (urls: string, { hosts }: TCPSimpleFields | ICMPSimpleFields) => urls || hosts, truncateText: true, + textOnly: true, }, { align: 'left' as const, - field: 'attributes', + field: ConfigKey.ENABLED as string, name: i18n.translate('xpack.uptime.monitorManagement.monitorList.enabled', { defaultMessage: 'Enabled', }), - render: (attributes: SyntheticsMonitor, record: SyntheticsMonitorSavedObject) => ( + render: (_enabled: boolean, monitor: SyntheticsMonitorWithId) => ( ), }, @@ -146,9 +184,9 @@ export const MonitorManagementList = ({ name: i18n.translate('xpack.uptime.monitorManagement.monitorList.actions', { defaultMessage: 'Actions', }), - render: (id: string) => , + render: (id: string) => , }, - ]; + ] as Array>; return ( @@ -164,8 +202,9 @@ export const MonitorManagementList = ({ itemId="monitor_id" items={monitors} columns={columns} - tableLayout={'auto'} + tableLayout={isXl ? 'auto' : 'fixed'} pagination={pagination} + sorting={sorting} onChange={handleOnChange} noItemsMessage={loading ? labels.LOADING : labels.NO_DATA_MESSAGE} /> diff --git a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_locations.tsx b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_locations.tsx index 859f644a31fdfa..a228f42d7d52ee 100644 --- a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_locations.tsx +++ b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_locations.tsx @@ -22,13 +22,13 @@ export const MonitorLocations = ({ locations }: Props) => { const locationsToDisplay = locations.slice(0, toDisplay); return ( - + {locationsToDisplay.map((location: ServiceLocation) => ( {location.label} diff --git a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/tags.tsx b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/tags.tsx index 04adfd8418e670..be2baab7603914 100644 --- a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/tags.tsx +++ b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/tags.tsx @@ -19,10 +19,15 @@ export const MonitorTags = ({ tags }: Props) => { const tagsToDisplay = tags.slice(0, toDisplay); return ( - + {tagsToDisplay.map((tag) => ( // filtering only makes sense in monitor list, where we have summary - + {tag} ))} diff --git a/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/browser/browser_test_results.tsx b/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/browser/browser_test_results.tsx index d5dd333f7f6c70..5dc893356b214c 100644 --- a/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/browser/browser_test_results.tsx +++ b/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/browser/browser_test_results.tsx @@ -20,7 +20,7 @@ interface Props { export const BrowserTestRunResult = ({ monitorId }: Props) => { const { data, loading, stepEnds, journeyStarted, summaryDoc, stepListData } = useBrowserRunOnceMonitors({ - monitorId, + configId: monitorId, }); const hits = data?.hits.hits; diff --git a/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/browser/use_browser_run_once_monitors.test.tsx b/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/browser/use_browser_run_once_monitors.test.tsx index 3a126e6f69e999..f467bb642a13e6 100644 --- a/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/browser/use_browser_run_once_monitors.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/browser/use_browser_run_once_monitors.test.tsx @@ -26,7 +26,7 @@ describe('useBrowserRunOnceMonitors', function () { }, }); - const { result } = renderHook(() => useBrowserRunOnceMonitors({ monitorId: 'test-id' }), { + const { result } = renderHook(() => useBrowserRunOnceMonitors({ configId: 'test-id' }), { wrapper: WrappedHelper, }); diff --git a/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/browser/use_browser_run_once_monitors.ts b/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/browser/use_browser_run_once_monitors.ts index 41f2b1cbe11f81..d051eaebe392e5 100644 --- a/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/browser/use_browser_run_once_monitors.ts +++ b/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/browser/use_browser_run_once_monitors.ts @@ -15,10 +15,12 @@ import { fetchJourneySteps } from '../../../../state/api/journey'; import { isStepEnd } from '../../../synthetics/check_steps/steps_list'; export const useBrowserEsResults = ({ - monitorId, + configId, + testRunId, lastRefresh, }: { - monitorId: string; + configId: string; + testRunId?: string; lastRefresh: number; }) => { const { settings } = useSelector(selectDynamicSettings); @@ -37,7 +39,7 @@ export const useBrowserEsResults = ({ filter: [ { term: { - config_id: monitorId, + config_id: configId, }, }, { @@ -45,28 +47,47 @@ export const useBrowserEsResults = ({ 'synthetics.type': ['heartbeat/summary', 'journey/start'], }, }, + ...(testRunId + ? [ + { + term: { + test_run_id: testRunId, + }, + }, + ] + : []), ], }, }, }, size: 10, }), - [monitorId, settings?.heartbeatIndices, lastRefresh], + [configId, settings?.heartbeatIndices, lastRefresh], { name: 'TestRunData' } ); }; -export const useBrowserRunOnceMonitors = ({ monitorId }: { monitorId: string }) => { - const { refreshTimer, lastRefresh } = useTickTick(); +export const useBrowserRunOnceMonitors = ({ + configId, + testRunId, + skipDetails = false, + refresh = true, +}: { + configId: string; + testRunId?: string; + refresh?: boolean; + skipDetails?: boolean; +}) => { + const { refreshTimer, lastRefresh } = useTickTick(3 * 1000, refresh); const [checkGroupId, setCheckGroupId] = useState(''); const [stepEnds, setStepEnds] = useState([]); const [summary, setSummary] = useState(); - const { data, loading } = useBrowserEsResults({ monitorId, lastRefresh }); + const { data, loading } = useBrowserEsResults({ configId, testRunId, lastRefresh }); const { data: stepListData } = useFetcher(() => { - if (checkGroupId) { + if (checkGroupId && !skipDetails) { return fetchJourneySteps({ checkGroup: checkGroupId, }); diff --git a/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/simple/simple_test_results.tsx b/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/simple/simple_test_results.tsx index 97097285d0bbc9..507082c7fefb18 100644 --- a/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/simple/simple_test_results.tsx +++ b/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/simple/simple_test_results.tsx @@ -15,7 +15,7 @@ interface Props { } export function SimpleTestResults({ monitorId }: Props) { const [summaryDocs, setSummaryDocs] = useState([]); - const { summaryDoc, loading } = useSimpleRunOnceMonitors({ monitorId }); + const { summaryDoc, loading } = useSimpleRunOnceMonitors({ configId: monitorId }); useEffect(() => { if (summaryDoc) { diff --git a/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/simple/use_simple_run_once_monitors.ts b/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/simple/use_simple_run_once_monitors.ts index 816f9b019c45a9..fc43844103f252 100644 --- a/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/simple/use_simple_run_once_monitors.ts +++ b/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/simple/use_simple_run_once_monitors.ts @@ -12,8 +12,14 @@ import { Ping } from '../../../../../common/runtime_types'; import { createEsParams, useEsSearch } from '../../../../../../observability/public'; import { useTickTick } from '../use_tick_tick'; -export const useSimpleRunOnceMonitors = ({ monitorId }: { monitorId: string }) => { - const { refreshTimer, lastRefresh } = useTickTick(); +export const useSimpleRunOnceMonitors = ({ + configId, + testRunId, +}: { + configId: string; + testRunId?: string; +}) => { + const { refreshTimer, lastRefresh } = useTickTick(2 * 1000, false); const { settings } = useSelector(selectDynamicSettings); @@ -31,7 +37,7 @@ export const useSimpleRunOnceMonitors = ({ monitorId }: { monitorId: string }) = filter: [ { term: { - config_id: monitorId, + config_id: configId, }, }, { @@ -39,13 +45,22 @@ export const useSimpleRunOnceMonitors = ({ monitorId }: { monitorId: string }) = field: 'summary', }, }, + ...(testRunId + ? [ + { + term: { + test_run_id: testRunId, + }, + }, + ] + : []), ], }, }, }, size: 10, }), - [monitorId, settings?.heartbeatIndices, lastRefresh], + [configId, settings?.heartbeatIndices, lastRefresh], { name: 'TestRunData' } ); diff --git a/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/test_result_header.tsx b/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/test_result_header.tsx index 51b120c3c7e5ed..00caa48e5dc08f 100644 --- a/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/test_result_header.tsx +++ b/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/test_result_header.tsx @@ -63,7 +63,7 @@ export function TestResultHeader({ doc, title, summaryDocs, journeyStarted, isCo - {journeyStarted ? IN_PROGRESS : PENDING_LABEL} + {journeyStarted ? IN_PROGRESS_LABEL : PENDING_LABEL} @@ -86,7 +86,7 @@ export function TestResultHeader({ doc, title, summaryDocs, journeyStarted, isCo ); } -const PENDING_LABEL = i18n.translate('xpack.uptime.monitorManagement.pending', { +export const PENDING_LABEL = i18n.translate('xpack.uptime.monitorManagement.pending', { defaultMessage: 'PENDING', }); @@ -98,7 +98,7 @@ const COMPLETED_LABEL = i18n.translate('xpack.uptime.monitorManagement.completed defaultMessage: 'COMPLETED', }); -const IN_PROGRESS = i18n.translate('xpack.uptime.monitorManagement.inProgress', { +export const IN_PROGRESS_LABEL = i18n.translate('xpack.uptime.monitorManagement.inProgress', { defaultMessage: 'IN PROGRESS', }); diff --git a/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/use_tick_tick.ts b/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/use_tick_tick.ts index ff9b9f3f6154d0..ce6d88806144c9 100644 --- a/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/use_tick_tick.ts +++ b/x-pack/plugins/uptime/public/components/monitor_management/test_now_mode/use_tick_tick.ts @@ -8,13 +8,18 @@ import { useEffect, useState, useContext } from 'react'; import { UptimeRefreshContext } from '../../../contexts'; -export function useTickTick() { - const { refreshApp, lastRefresh } = useContext(UptimeRefreshContext); +export function useTickTick(interval?: number, refresh = true) { + const { refreshApp } = useContext(UptimeRefreshContext); + + const [nextTick, setNextTick] = useState(Date.now()); const [tickTick] = useState(() => setInterval(() => { - refreshApp(); - }, 5 * 1000) + if (refresh) { + refreshApp(); + } + setNextTick(Date.now()); + }, interval ?? 5 * 1000) ); useEffect(() => { @@ -23,5 +28,5 @@ export function useTickTick() { }; }, [tickTick]); - return { refreshTimer: tickTick, lastRefresh }; + return { refreshTimer: tickTick, lastRefresh: nextTick }; } diff --git a/x-pack/plugins/uptime/public/components/overview/alerts/alert_field_number.test.tsx b/x-pack/plugins/uptime/public/components/overview/alerts/alert_field_number.test.tsx index 32e16f1ae88ebe..62823b4ca87d61 100644 --- a/x-pack/plugins/uptime/public/components/overview/alerts/alert_field_number.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/alerts/alert_field_number.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; import { AlertFieldNumber, handleAlertFieldNumberChange } from './alert_field_number'; describe('AlertFieldNumber', () => { diff --git a/x-pack/plugins/uptime/public/components/overview/alerts/monitor_expressions/down_number_select.test.tsx b/x-pack/plugins/uptime/public/components/overview/alerts/monitor_expressions/down_number_select.test.tsx index 0598b675cab357..1290d4cb4ceba8 100644 --- a/x-pack/plugins/uptime/public/components/overview/alerts/monitor_expressions/down_number_select.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/alerts/monitor_expressions/down_number_select.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { renderWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { renderWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import { DownNoExpressionSelect } from './down_number_select'; describe('DownNoExpressionSelect component', () => { diff --git a/x-pack/plugins/uptime/public/components/overview/alerts/monitor_expressions/time_expression_select.test.tsx b/x-pack/plugins/uptime/public/components/overview/alerts/monitor_expressions/time_expression_select.test.tsx index 4ce9720cfc4ced..87caf3f7cb3b6c 100644 --- a/x-pack/plugins/uptime/public/components/overview/alerts/monitor_expressions/time_expression_select.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/alerts/monitor_expressions/time_expression_select.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { renderWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { renderWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import { TimeExpressionSelect } from './time_expression_select'; describe('TimeExpressionSelect component', () => { diff --git a/x-pack/plugins/uptime/public/components/overview/alerts/monitor_status_alert/add_filter_btn.test.tsx b/x-pack/plugins/uptime/public/components/overview/alerts/monitor_status_alert/add_filter_btn.test.tsx index 5b32d9bc019920..f8f9e5a84bc5c3 100644 --- a/x-pack/plugins/uptime/public/components/overview/alerts/monitor_status_alert/add_filter_btn.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/alerts/monitor_status_alert/add_filter_btn.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { shallowWithIntl, mountWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl, mountWithIntl } from '@kbn/test-jest-helpers'; import { AddFilterButton } from './add_filter_btn'; import { EuiButtonEmpty, EuiContextMenuItem } from '@elastic/eui'; diff --git a/x-pack/plugins/uptime/public/components/overview/alerts/monitor_status_alert/old_alert_callout.test.tsx b/x-pack/plugins/uptime/public/components/overview/alerts/monitor_status_alert/old_alert_callout.test.tsx index 5300b218b4d007..f0c41480f51726 100644 --- a/x-pack/plugins/uptime/public/components/overview/alerts/monitor_status_alert/old_alert_callout.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/alerts/monitor_status_alert/old_alert_callout.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { OldAlertCallOut } from './old_alert_call_out'; describe('OldAlertCallOut', () => { diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/monitor_status_column.test.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/monitor_status_column.test.tsx index c05cc1e4b2a92a..02fe666b794641 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/monitor_status_column.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/monitor_status_column.test.tsx @@ -229,7 +229,12 @@ describe('MonitorListStatusColumn', () => { it('provides expected tooltip and display times', async () => { const { getByText } = render( - + ); @@ -244,7 +249,12 @@ describe('MonitorListStatusColumn', () => { it('can handle a non-numeric timestamp value', () => { const { getByText } = render( - + ); @@ -259,6 +269,7 @@ describe('MonitorListStatusColumn', () => { ping.observer!.geo!.name! === 'Islamabad')} /> @@ -278,6 +289,7 @@ describe('MonitorListStatusColumn', () => { status="up" timestamp={new Date().toString()} summaryPings={summaryPings} + monitorType="http" /> ); @@ -295,6 +307,7 @@ describe('MonitorListStatusColumn', () => { diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/monitor_status_column.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/monitor_status_column.tsx index 6960bb56328520..60baedaa7830c0 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/monitor_status_column.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/monitor_status_column.tsx @@ -5,13 +5,23 @@ * 2.0. */ -import React, { useContext } from 'react'; -import moment from 'moment'; +import React, { useCallback, useContext } from 'react'; +import moment, { Moment } from 'moment'; import { i18n } from '@kbn/i18n'; import styled from 'styled-components'; -import { EuiFlexGroup, EuiFlexItem, EuiText, EuiToolTip, EuiBadge, EuiSpacer } from '@elastic/eui'; +import { + EuiFlexGroup, + EuiFlexItem, + EuiText, + EuiToolTip, + EuiBadge, + EuiSpacer, + EuiHighlight, + EuiHorizontalRule, +} from '@elastic/eui'; +import { useDispatch, useSelector } from 'react-redux'; import { parseTimestamp } from '../parse_timestamp'; -import { Ping } from '../../../../../common/runtime_types'; +import { DataStream, Ping } from '../../../../../common/runtime_types'; import { STATUS, SHORT_TIMESPAN_LOCALE, @@ -22,10 +32,18 @@ import { import { UptimeThemeContext } from '../../../../contexts'; import { euiStyled } from '../../../../../../../../src/plugins/kibana_react/common'; import { STATUS_DOWN_LABEL, STATUS_UP_LABEL } from '../../../common/translations'; +import { MonitorProgress } from './progress/monitor_progress'; +import { refreshedMonitorSelector } from '../../../../state/reducers/monitor_list'; +import { testNowRunSelector } from '../../../../state/reducers/test_now_runs'; +import { clearTestNowMonitorAction } from '../../../../state/actions'; interface MonitorListStatusColumnProps { + configId?: string; + monitorId?: string; status: string; + monitorType: string; timestamp: string; + duration?: number; summaryPings: Ping[]; } @@ -63,7 +81,7 @@ export const getShortTimeStamp = (timeStamp: moment.Moment, relative = false) => shortTimestamp = timeStamp.fromNow(); } - // Reset it so, it does't impact other part of the app + // Reset it so, it doesn't impact other part of the app moment.locale(prevLocale); return shortTimestamp; } else { @@ -144,7 +162,11 @@ export const getLocationStatus = (summaryPings: Ping[], status: string) => { }; export const MonitorListStatusColumn = ({ + monitorType, + configId, + monitorId, status, + duration, summaryPings = [], timestamp: tsString, }: MonitorListStatusColumnProps) => { @@ -156,16 +178,39 @@ export const MonitorListStatusColumn = ({ const { statusMessage, locTooltip } = getLocationStatus(summaryPings, status); + const dispatch = useDispatch(); + + const stopProgressTrack = useCallback(() => { + if (configId) { + dispatch(clearTestNowMonitorAction(configId)); + } + }, [configId, dispatch]); + + const refreshedMonitorIds = useSelector(refreshedMonitorSelector); + + const testNowRun = useSelector(testNowRunSelector(configId)); + return (
- + - - {getHealthMessage(status)} - + {testNowRun && configId && testNowRun?.testRunId ? ( + + ) : ( + + {getHealthMessage(status)} + + )} @@ -183,20 +228,39 @@ export const MonitorListStatusColumn = ({ - {timestamp.toLocaleString()} - + <> + + {timestamp.fromNow()} + + + + {timestamp.toLocaleString()} + + } > - - Checked {getShortTimeStamp(timestamp)} - + {monitorId && refreshedMonitorIds?.includes(monitorId) ? ( + + {getCheckedLabel(timestamp)} + + ) : ( + + {getCheckedLabel(timestamp)} + + )}
); }; +const getCheckedLabel = (timestamp: Moment) => { + return i18n.translate('xpack.uptime.monitorList.statusColumn.checkedTimestamp', { + defaultMessage: 'Checked {timestamp}', + values: { timestamp: getShortTimeStamp(timestamp) }, + }); +}; + const PaddedText = euiStyled(EuiText)` padding-right: ${(props) => props.theme.eui.paddingSizes.xs}; `; diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/progress/browser_monitor_progress.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/progress/browser_monitor_progress.tsx new file mode 100644 index 00000000000000..c0453573693c49 --- /dev/null +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/progress/browser_monitor_progress.tsx @@ -0,0 +1,89 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { EuiBadge, EuiProgress } from '@elastic/eui'; +import React, { useEffect, useState } from 'react'; +import { useBrowserRunOnceMonitors } from '../../../../monitor_management/test_now_mode/browser/use_browser_run_once_monitors'; +import { + IN_PROGRESS_LABEL, + PENDING_LABEL, +} from '../../../../monitor_management/test_now_mode/test_result_header'; + +export const BrowserMonitorProgress = ({ + configId, + testRunId, + duration, + isUpdating, + updateMonitorStatus, +}: { + configId: string; + testRunId: string; + duration: number; + isUpdating: boolean; + updateMonitorStatus: () => void; +}) => { + const { journeyStarted, summaryDoc, data } = useBrowserRunOnceMonitors({ + configId, + testRunId, + refresh: false, + skipDetails: true, + }); + + const [startTime, setStartTime] = useState(Date.now()); + const [passedTime, setPassedTime] = useState(0); + + useEffect(() => { + if (summaryDoc) { + updateMonitorStatus(); + } + }, [updateMonitorStatus, summaryDoc]); + + useEffect(() => { + const interVal = setInterval(() => { + if (journeyStarted) { + setPassedTime((Date.now() - startTime) * 1000); + } + }, 500); + const startTimeValue = startTime; + return () => { + if ((Date.now() - startTimeValue) * 1000 > duration) { + clearInterval(interVal); + } + }; + }, [data, duration, journeyStarted, startTime]); + + useEffect(() => { + if (journeyStarted) { + setStartTime(Date.now()); + } + }, [journeyStarted]); + + if (isUpdating || passedTime > duration) { + return ( + <> + {IN_PROGRESS_LABEL} + + + ); + } + + return ( + + {journeyStarted ? ( + <> + {IN_PROGRESS_LABEL} + + + ) : ( + <> + {PENDING_LABEL} + + + )} + + ); +}; diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/progress/monitor_progress.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/progress/monitor_progress.tsx new file mode 100644 index 00000000000000..e4fc0cf90e87b2 --- /dev/null +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/progress/monitor_progress.tsx @@ -0,0 +1,61 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { useEffect } from 'react'; +import { useSelector } from 'react-redux'; +import { SimpleMonitorProgress } from './simple_monitor_progress'; +import { BrowserMonitorProgress } from './browser_monitor_progress'; +import { DataStream } from '../../../../../../common/runtime_types'; +import { useUpdatedMonitor } from './use_updated_monitor'; +import { refreshedMonitorSelector } from '../../../../../state/reducers/monitor_list'; + +export const MonitorProgress = ({ + monitorId, + configId, + testRunId, + duration, + monitorType, + stopProgressTrack, +}: { + monitorId: string; + configId: string; + testRunId: string; + duration: number; + monitorType: DataStream; + stopProgressTrack: () => void; +}) => { + const { updateMonitorStatus, isUpdating } = useUpdatedMonitor({ + testRunId, + monitorId, + }); + + const refreshedMonitorId = useSelector(refreshedMonitorSelector); + + useEffect(() => { + if (refreshedMonitorId.includes(monitorId)) { + stopProgressTrack(); + } + }, [isUpdating, monitorId, refreshedMonitorId, stopProgressTrack]); + + return monitorType === 'browser' ? ( + + ) : ( + + ); +}; diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/progress/simple_monitor_progress.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/progress/simple_monitor_progress.tsx new file mode 100644 index 00000000000000..d51ae3f4e9dff2 --- /dev/null +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/progress/simple_monitor_progress.tsx @@ -0,0 +1,62 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { EuiBadge, EuiProgress } from '@elastic/eui'; +import React, { useEffect, useRef, useState } from 'react'; +import { useSimpleRunOnceMonitors } from '../../../../monitor_management/test_now_mode/simple/use_simple_run_once_monitors'; +import { IN_PROGRESS_LABEL } from '../../../../monitor_management/test_now_mode/test_result_header'; + +export const SimpleMonitorProgress = ({ + monitorId, + testRunId, + duration, + isUpdating, + updateMonitorStatus, +}: { + monitorId: string; + testRunId: string; + duration: number; + isUpdating: boolean; + updateMonitorStatus: () => void; +}) => { + const { summaryDoc, data } = useSimpleRunOnceMonitors({ + configId: monitorId, + testRunId, + }); + + const startTime = useRef(Date.now()); + + const [passedTime, setPassedTime] = useState(Date.now()); + + useEffect(() => { + if (summaryDoc) { + updateMonitorStatus(); + } + }, [updateMonitorStatus, summaryDoc]); + + useEffect(() => { + setPassedTime(Date.now() - startTime.current); + }, [data]); + + const passedTimeMicro = passedTime * 1000; + + if (isUpdating || passedTimeMicro > duration) { + return ( + <> + {IN_PROGRESS_LABEL} + + + ); + } + + return ( + + {IN_PROGRESS_LABEL} + + + ); +}; diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/progress/use_updated_monitor.ts b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/progress/use_updated_monitor.ts new file mode 100644 index 00000000000000..b76971d4079e33 --- /dev/null +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/progress/use_updated_monitor.ts @@ -0,0 +1,44 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { useCallback } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { getUpdatedMonitor, setUpdatingMonitorId } from '../../../../../state/actions'; +import { isUpdatingMonitorSelector } from '../../../../../state/reducers/monitor_list'; + +export const useUpdatedMonitor = ({ + testRunId, + monitorId, +}: { + testRunId: string; + monitorId: string; +}) => { + const dispatch = useDispatch(); + + const isUpdatingMonitors = useSelector(isUpdatingMonitorSelector); + + const updateMonitorStatus = useCallback(() => { + if (testRunId) { + dispatch( + getUpdatedMonitor.get({ + dateRangeStart: 'now-10m', + dateRangeEnd: 'now', + filters: JSON.stringify({ + bool: { + should: [{ match_phrase: { test_run_id: testRunId } }], + minimum_should_match: 1, + }, + }), + pageSize: 1, + }) + ); + dispatch(setUpdatingMonitorId(monitorId)); + } + }, [dispatch, monitorId, testRunId]); + + return { updateMonitorStatus, isUpdating: isUpdatingMonitors.includes(monitorId) }; +}; diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/test_now_col.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/test_now_col.tsx new file mode 100644 index 00000000000000..de32c874ae24c3 --- /dev/null +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/test_now_col.tsx @@ -0,0 +1,60 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { i18n } from '@kbn/i18n'; +import { useDispatch, useSelector } from 'react-redux'; +import { EuiButtonIcon, EuiLoadingSpinner, EuiToolTip } from '@elastic/eui'; +import { testNowMonitorAction } from '../../../../state/actions'; +import { testNowRunSelector } from '../../../../state/reducers/test_now_runs'; + +export const TestNowColumn = ({ + monitorId, + configId, +}: { + monitorId: string; + configId?: string; +}) => { + const dispatch = useDispatch(); + + const testNowRun = useSelector(testNowRunSelector(configId)); + + if (!configId) { + return <>--; + } + + const testNowClick = () => { + dispatch(testNowMonitorAction.get(configId)); + }; + + if (testNowRun && testNowRun.status === 'loading') { + return ; + } + + return ( + + testNowClick()} + isDisabled={Boolean(testNowRun)} + aria-label={TEST_NOW_ARIA_LABEL} + /> + + ); +}; + +export const TEST_NOW_ARIA_LABEL = i18n.translate('xpack.uptime.monitorList.testNow.AriaLabel', { + defaultMessage: 'CLick to run test now', +}); + +export const TEST_NOW_LABEL = i18n.translate('xpack.uptime.monitorList.testNow.label', { + defaultMessage: 'Test now', +}); + +export const TEST_SCHEDULED_LABEL = i18n.translate('xpack.uptime.monitorList.testNow.scheduled', { + defaultMessage: 'Test is already scheduled', +}); diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list.test.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list.test.tsx index de077931167c18..0eafd3c2fd52ad 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list.test.tsx @@ -16,7 +16,6 @@ import { MonitorSummary, } from '../../../../common/runtime_types'; import { MonitorListComponent, noItemsMessage } from './monitor_list'; -import * as redux from 'react-redux'; import moment from 'moment'; import { IHttpFetchError, ResponseErrorBody } from '../../../../../../../src/core/public'; import { mockMoment } from '../../../lib/helper/test_helpers'; @@ -56,7 +55,7 @@ const testFooPings: Ping[] = [ const testFooSummary: MonitorSummary = { monitor_id: 'foo', state: { - monitor: { type: 'http' }, + monitor: { type: 'http', duration: { us: 1000 } }, summaryPings: testFooPings, summary: { up: 1, @@ -91,7 +90,7 @@ const testBarPings: Ping[] = [ const testBarSummary: MonitorSummary = { monitor_id: 'bar', state: { - monitor: { type: 'http' }, + monitor: { type: 'http', duration: { us: 1000 } }, summaryPings: testBarPings, summary: { up: 2, @@ -129,12 +128,6 @@ describe('MonitorList component', () => { }; beforeEach(() => { - const useDispatchSpy = jest.spyOn(redux, 'useDispatch'); - useDispatchSpy.mockReturnValue(jest.fn()); - - const useSelectorSpy = jest.spyOn(redux, 'useSelector'); - useSelectorSpy.mockReturnValue(true); - localStorageMock = { getItem: jest.fn().mockImplementation(() => '25'), setItem: jest.fn(), @@ -156,6 +149,7 @@ describe('MonitorList component', () => { }} pageSize={10} setPageSize={jest.fn()} + refreshedMonitorIds={[]} /> ); expect(await findByText(NO_DATA_MESSAGE)).toBeInTheDocument(); @@ -170,6 +164,7 @@ describe('MonitorList component', () => { }} pageSize={10} setPageSize={jest.fn()} + refreshedMonitorIds={[]} /> ); @@ -190,6 +185,7 @@ describe('MonitorList component', () => { }} pageSize={10} setPageSize={jest.fn()} + refreshedMonitorIds={[]} /> ); @@ -226,6 +222,7 @@ describe('MonitorList component', () => { }} pageSize={10} setPageSize={jest.fn()} + refreshedMonitorIds={[]} /> ); @@ -254,6 +251,7 @@ describe('MonitorList component', () => { }} pageSize={10} setPageSize={jest.fn()} + refreshedMonitorIds={[]} /> ); @@ -283,6 +281,7 @@ describe('MonitorList component', () => { }} pageSize={10} setPageSize={jest.fn()} + refreshedMonitorIds={[]} /> ); diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list.tsx index fd9c072b9004f8..2dd4ed7bed4819 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list.tsx @@ -32,15 +32,19 @@ import { CertStatusColumn } from './columns/cert_status_column'; import { MonitorListHeader } from './monitor_list_header'; import { TAGS_LABEL, URL_LABEL } from '../../common/translations'; import { EnableMonitorAlert } from './columns/enable_alert'; -import { STATUS_ALERT_COLUMN } from './translations'; +import { STATUS_ALERT_COLUMN, TEST_NOW_COLUMN } from './translations'; import { MonitorNameColumn } from './columns/monitor_name_col'; import { MonitorTags } from '../../common/monitor_tags'; import { useMonitorHistogram } from './use_monitor_histogram'; +import { euiStyled } from '../../../../../../../src/plugins/kibana_react/common'; +import { TestNowColumn } from './columns/test_now_col'; +import { useUptimeSettingsContext } from '../../../contexts/uptime_settings_context'; interface Props extends MonitorListProps { pageSize: number; setPageSize: (val: number) => void; monitorList: MonitorList; + refreshedMonitorIds: string[]; } export const noItemsMessage = (loading: boolean, filters?: string) => { @@ -52,8 +56,15 @@ export const MonitorListComponent: ({ filters, monitorList: { list, error, loading }, pageSize, + refreshedMonitorIds, setPageSize, -}: Props) => any = ({ filters, monitorList: { list, error, loading }, pageSize, setPageSize }) => { +}: Props) => any = ({ + filters, + refreshedMonitorIds = [], + monitorList: { list, error, loading }, + pageSize, + setPageSize, +}) => { const [expandedDrawerIds, updateExpandedDrawerIds] = useState([]); const { width } = useWindowSize(); const [hideExtraColumns, setHideExtraColumns] = useState(false); @@ -94,6 +105,8 @@ export const MonitorListComponent: ({ }, {}); }; + const { config } = useUptimeSettingsContext(); + const columns = [ ...[ { @@ -103,12 +116,27 @@ export const MonitorListComponent: ({ mobileOptions: { fullWidth: true, }, - render: (status: string, { state: { timestamp, summaryPings } }: MonitorSummary) => { + render: ( + status: string, + { + monitor_id: monitorId, + state: { + timestamp, + summaryPings, + monitor: { type, duration }, + }, + configId, + }: MonitorSummary + ) => { return ( ); }, @@ -166,20 +194,31 @@ export const MonitorListComponent: ({ }, ] : []), - ...[ - { - align: 'center' as const, - field: '', - name: STATUS_ALERT_COLUMN, - width: '100px', - render: (item: MonitorSummary) => ( - - ), - }, - ], + { + align: 'center' as const, + field: '', + name: STATUS_ALERT_COLUMN, + width: '100px', + render: (item: MonitorSummary) => ( + + ), + }, + ...(config.ui?.monitorManagement?.enabled + ? [ + { + align: 'center' as const, + field: '', + name: TEST_NOW_COLUMN, + width: '100px', + render: (item: MonitorSummary) => ( + + ), + }, + ] + : []), ...(!hideExtraColumns ? [ { @@ -205,7 +244,7 @@ export const MonitorListComponent: ({ ]; return ( - + toggleDrawer(monitorId), 'aria-label': labels.getExpandDrawerLabel(monitorId), }) - : undefined + : ({ monitor_id: monitorId }) => ({ + className: refreshedMonitorIds.includes(monitorId) ? 'refresh-row' : undefined, + }) } /> @@ -253,6 +294,17 @@ export const MonitorListComponent: ({
-
+ ); }; + +const WrapperPanel = euiStyled(EuiPanel)` + &&& { + .refresh-row{ + background-color: #f0f4fb; + -webkit-transition: background-color 3000ms linear; + -ms-transition: background-color 3000ms linear; + transition: background-color 3000ms linear; + } + } +`; diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_container.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_container.tsx index e753d07f9db391..d01f9365a7ac04 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_container.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_container.tsx @@ -7,7 +7,7 @@ import React, { useContext, useEffect, useState } from 'react'; import { useSelector, useDispatch } from 'react-redux'; -import { getMonitorList } from '../../../state/actions'; +import { clearRefreshedMonitorId, getMonitorList } from '../../../state/actions'; import { esKuerySelector, monitorListSelector } from '../../../state/selectors'; import { MonitorListComponent } from './monitor_list'; import { useUrlParams } from '../../../hooks'; @@ -15,6 +15,7 @@ import { UptimeRefreshContext } from '../../../contexts'; import { getConnectorsAction, getMonitorAlertsAction } from '../../../state/alerts/alerts'; import { useMappingCheck } from '../../../hooks/use_mapping_check'; import { useOverviewFilterCheck } from '../../../hooks/use_overview_filter_check'; +import { refreshedMonitorSelector } from '../../../state/reducers/monitor_list'; export interface MonitorListProps { filters?: string; @@ -43,6 +44,8 @@ export const MonitorList: React.FC = (props) => { const { lastRefresh } = useContext(UptimeRefreshContext); + const refreshedMonitorIds = useSelector(refreshedMonitorSelector); + const monitorList = useSelector(monitorListSelector); useMappingCheck(monitorList.error); @@ -81,12 +84,23 @@ export const MonitorList: React.FC = (props) => { dispatch(getConnectorsAction.get()); }, [dispatch]); + useEffect(() => { + if (refreshedMonitorIds) { + refreshedMonitorIds.forEach((id) => { + setTimeout(() => { + dispatch(clearRefreshedMonitorId(id)); + }, 5 * 1000); + }); + } + }, [dispatch, refreshedMonitorIds]); + return ( ); }; diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/integration_group.test.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/integration_group.test.tsx index c4de51f68a17aa..5f502850635410 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/integration_group.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/integration_group.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { MonitorSummary, makePing } from '../../../../../common/runtime_types'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; 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/integration_link.test.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/integration_link.test.tsx index dacdf38b1207f8..7f4926f994b1f9 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/integration_link.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/integration_link.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { IntegrationLink } from './actions_popover/integration_link'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; describe('IntegrationLink component', () => { it('renders without errors', () => { diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/most_recent_error.test.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/most_recent_error.test.tsx index f0f330807ffbf2..111a8a18ccad55 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/most_recent_error.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/most_recent_error.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl, renderWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl, renderWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; import moment from 'moment'; import { BrowserRouter as Router } from 'react-router-dom'; diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_page_size_select.test.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_page_size_select.test.tsx index c8da376a7a8cd7..9b7e2a1917835b 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_page_size_select.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_page_size_select.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { MonitorListPageSizeSelectComponent } from './monitor_list_page_size_select'; -import { mountWithIntl } from '@kbn/test/jest'; +import { mountWithIntl } from '@kbn/test-jest-helpers'; describe('MonitorListPageSizeSelect', () => { it('updates the state when selection changes', () => { diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/translations.ts b/x-pack/plugins/uptime/public/components/overview/monitor_list/translations.ts index fdb50bc295ddae..ba006884a42cb6 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/translations.ts +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/translations.ts @@ -73,3 +73,7 @@ export const RESPONSE_ANOMALY_SCORE = i18n.translate( export const STATUS_ALERT_COLUMN = i18n.translate('xpack.uptime.monitorList.statusAlert.label', { defaultMessage: 'Status alert', }); + +export const TEST_NOW_COLUMN = i18n.translate('xpack.uptime.monitorList.testNow.label', { + defaultMessage: 'Test now', +}); diff --git a/x-pack/plugins/uptime/public/components/overview/snapshot/snapshot.test.tsx b/x-pack/plugins/uptime/public/components/overview/snapshot/snapshot.test.tsx index 184f6b73cc7aba..3cea8199544d4d 100644 --- a/x-pack/plugins/uptime/public/components/overview/snapshot/snapshot.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/snapshot/snapshot.test.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import { SnapshotComponent } from './snapshot'; import { Snapshot } from '../../../../common/runtime_types/snapshot'; import * as hook from './use_snap_shot'; diff --git a/x-pack/plugins/uptime/public/components/overview/snapshot_heading.test.tsx b/x-pack/plugins/uptime/public/components/overview/snapshot_heading.test.tsx index 04874a4177e07e..f3616345a6f9b1 100644 --- a/x-pack/plugins/uptime/public/components/overview/snapshot_heading.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/snapshot_heading.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; import { SnapshotHeading } from './snapshot/snapshot_heading'; diff --git a/x-pack/plugins/uptime/public/components/overview/synthetics_callout.test.tsx b/x-pack/plugins/uptime/public/components/overview/synthetics_callout.test.tsx index ec9e5f958ec3a5..0d2dc15f557256 100644 --- a/x-pack/plugins/uptime/public/components/overview/synthetics_callout.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/synthetics_callout.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; import { SyntheticsCallout } from './synthetics_callout'; diff --git a/x-pack/plugins/uptime/public/components/synthetics/console_event.test.tsx b/x-pack/plugins/uptime/public/components/synthetics/console_event.test.tsx index b80613dbfece50..6a3c6d02151edc 100644 --- a/x-pack/plugins/uptime/public/components/synthetics/console_event.test.tsx +++ b/x-pack/plugins/uptime/public/components/synthetics/console_event.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; import { ConsoleEvent } from './console_event'; diff --git a/x-pack/plugins/uptime/public/components/synthetics/empty_journey.test.tsx b/x-pack/plugins/uptime/public/components/synthetics/empty_journey.test.tsx index 854006ba393565..cdbf69af0f8740 100644 --- a/x-pack/plugins/uptime/public/components/synthetics/empty_journey.test.tsx +++ b/x-pack/plugins/uptime/public/components/synthetics/empty_journey.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { shallowWithIntl } from '@kbn/test/jest'; +import { shallowWithIntl } from '@kbn/test-jest-helpers'; import React from 'react'; import { EmptyJourney } from './empty_journey'; diff --git a/x-pack/plugins/uptime/public/lib/__mocks__/uptime_store.mock.ts b/x-pack/plugins/uptime/public/lib/__mocks__/uptime_store.mock.ts index 9593a84f08dad1..bc09ef0514ef3f 100644 --- a/x-pack/plugins/uptime/public/lib/__mocks__/uptime_store.mock.ts +++ b/x-pack/plugins/uptime/public/lib/__mocks__/uptime_store.mock.ts @@ -59,6 +59,7 @@ export const mockState: AppState = { summaries: [], }, loading: false, + refreshedMonitorIds: [], }, monitorManagementList: { list: { @@ -115,4 +116,7 @@ export const mockState: AppState = { cacheSize: 0, hitCount: [], }, + testNowRuns: { + testNowRuns: [], + }, }; diff --git a/x-pack/plugins/uptime/public/lib/helper/enzyme_helpers.tsx b/x-pack/plugins/uptime/public/lib/helper/enzyme_helpers.tsx index 04ecc6bc9c72d7..b8e1c055dce495 100644 --- a/x-pack/plugins/uptime/public/lib/helper/enzyme_helpers.tsx +++ b/x-pack/plugins/uptime/public/lib/helper/enzyme_helpers.tsx @@ -10,7 +10,7 @@ import { Router } from 'react-router-dom'; import { MemoryHistory } from 'history/createMemoryHistory'; import { createMemoryHistory, History } from 'history'; // eslint-disable-next-line import/no-extraneous-dependencies -import { mountWithIntl, renderWithIntl, shallowWithIntl } from '@kbn/test/jest'; +import { mountWithIntl, renderWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import { MountWithReduxProvider } from './helper_with_redux'; import { AppState } from '../../state'; import { mockState } from '../__mocks__/uptime_store.mock'; diff --git a/x-pack/plugins/uptime/public/pages/monitor_management/monitor_management.tsx b/x-pack/plugins/uptime/public/pages/monitor_management/monitor_management.tsx index aa4a9ca995b1b4..0ad9dbd6b06e75 100644 --- a/x-pack/plugins/uptime/public/pages/monitor_management/monitor_management.tsx +++ b/x-pack/plugins/uptime/public/pages/monitor_management/monitor_management.tsx @@ -5,37 +5,82 @@ * 2.0. */ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useReducer, useCallback, Reducer } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { useTrackPageview } from '../../../../observability/public'; +import { ConfigKey } from '../../../common/runtime_types'; import { getMonitors } from '../../state/actions'; import { monitorManagementListSelector } from '../../state/selectors'; -import { MonitorManagementList } from '../../components/monitor_management/monitor_list/monitor_list'; +import { + MonitorManagementList, + MonitorManagementListPageState, +} from '../../components/monitor_management/monitor_list/monitor_list'; import { useMonitorManagementBreadcrumbs } from './use_monitor_management_breadcrumbs'; export const MonitorManagementPage: React.FC = () => { - const [refresh, setRefresh] = useState(true); - const [pageIndex, setPageIndex] = useState(1); // saved objects page index is base 1 - const [pageSize, setPageSize] = useState(10); // saved objects page index is base 1 + const [pageState, dispatchPageAction] = useReducer( + monitorManagementPageReducer, + { + pageIndex: 1, // saved objects page index is base 1 + pageSize: 10, + sortOrder: 'asc', + sortField: ConfigKey.NAME, + } + ); + + const onPageStateChange = useCallback( + (state) => { + dispatchPageAction({ type: 'update', payload: state }); + }, + [dispatchPageAction] + ); + + const onUpdate = useCallback(() => { + dispatchPageAction({ type: 'refresh' }); + }, [dispatchPageAction]); + useTrackPageview({ app: 'uptime', path: 'manage-monitors' }); useTrackPageview({ app: 'uptime', path: 'manage-monitors', delay: 15000 }); useMonitorManagementBreadcrumbs(); const dispatch = useDispatch(); const monitorList = useSelector(monitorManagementListSelector); + const { pageIndex, pageSize, sortField, sortOrder } = pageState as MonitorManagementListPageState; + useEffect(() => { - if (refresh) { - dispatch(getMonitors({ page: pageIndex, perPage: pageSize })); - setRefresh(false); - } - }, [dispatch, refresh, pageIndex, pageSize]); + dispatch(getMonitors({ page: pageIndex, perPage: pageSize, sortField, sortOrder })); + }, [dispatch, pageState, pageIndex, pageSize, sortField, sortOrder]); return ( ); }; + +type MonitorManagementPageAction = + | { + type: 'update'; + payload: MonitorManagementListPageState; + } + | { type: 'refresh' }; + +const monitorManagementPageReducer: Reducer< + MonitorManagementListPageState, + MonitorManagementPageAction +> = (state: MonitorManagementListPageState, action: MonitorManagementPageAction) => { + switch (action.type) { + case 'update': + return { + ...state, + ...action.payload, + }; + case 'refresh': + return { ...state }; + default: + throw new Error(`Action "${(action as MonitorManagementPageAction)?.type}" not recognizable`); + } +}; diff --git a/x-pack/plugins/uptime/public/state/actions/monitor_list.ts b/x-pack/plugins/uptime/public/state/actions/monitor_list.ts index a85c0004545e4b..b86853dcfbefe9 100644 --- a/x-pack/plugins/uptime/public/state/actions/monitor_list.ts +++ b/x-pack/plugins/uptime/public/state/actions/monitor_list.ts @@ -7,9 +7,25 @@ import { createAction } from 'redux-actions'; import { FetchMonitorStatesQueryArgs, MonitorSummariesResult } from '../../../common/runtime_types'; +import { createAsyncAction } from './utils'; +import { TestNowResponse } from '../api'; export const getMonitorList = createAction('GET_MONITOR_LIST'); export const getMonitorListSuccess = createAction( 'GET_MONITOR_LIST_SUCCESS' ); export const getMonitorListFailure = createAction('GET_MONITOR_LIST_FAIL'); + +export const setUpdatingMonitorId = createAction('SET_UPDATING_MONITOR_ID'); +export const clearRefreshedMonitorId = createAction('CLEAR_REFRESH_MONITOR_ID'); + +export const testNowMonitorAction = createAsyncAction( + 'TEST_NOW_MONITOR_ACTION' +); + +export const clearTestNowMonitorAction = createAction('CLEAR_TEST_NOW_MONITOR_ACTION'); + +export const getUpdatedMonitor = createAsyncAction< + FetchMonitorStatesQueryArgs, + MonitorSummariesResult +>('GET_UPDATED_MONITOR'); diff --git a/x-pack/plugins/uptime/public/state/api/monitor_management.ts b/x-pack/plugins/uptime/public/state/api/monitor_management.ts index 06a49df596d13a..ec2806907baa16 100644 --- a/x-pack/plugins/uptime/public/state/api/monitor_management.ts +++ b/x-pack/plugins/uptime/public/state/api/monitor_management.ts @@ -67,3 +67,13 @@ export const runOnceMonitor = async ({ }): Promise<{ errors: Array<{ error: Error }> }> => { return await apiService.post(API_URLS.RUN_ONCE_MONITOR + `/${id}`, monitor); }; + +export interface TestNowResponse { + errors?: Array<{ error: Error }>; + testRunId: string; + monitorId: string; +} + +export const testNowMonitor = async (configId: string): Promise => { + return await apiService.get(API_URLS.TRIGGER_MONITOR + `/${configId}`); +}; diff --git a/x-pack/plugins/uptime/public/state/api/utils.ts b/x-pack/plugins/uptime/public/state/api/utils.ts index 8dcef2239ca222..833a6845d6343f 100644 --- a/x-pack/plugins/uptime/public/state/api/utils.ts +++ b/x-pack/plugins/uptime/public/state/api/utils.ts @@ -5,41 +5,11 @@ * 2.0. */ -import { PathReporter } from 'io-ts/lib/PathReporter'; import { isRight } from 'fp-ts/lib/Either'; +import { formatErrors } from '@kbn/securitysolution-io-ts-utils'; import { HttpFetchQuery, HttpSetup } from 'src/core/public'; -import * as t from 'io-ts'; import { FETCH_STATUS, AddInspectorRequest } from '../../../../observability/public'; -function isObject(value: unknown) { - const type = typeof value; - return value != null && (type === 'object' || type === 'function'); -} - -/** - * @deprecated Use packages/kbn-securitysolution-io-ts-utils/src/format_errors/index.ts - */ -export const formatErrors = (errors: t.Errors): string[] => { - return errors.map((error) => { - if (error.message != null) { - return error.message; - } else { - const keyContext = error.context - .filter( - (entry) => entry.key != null && !Number.isInteger(+entry.key) && entry.key.trim() !== '' - ) - .map((entry) => entry.key) - .join('.'); - - const nameContext = error.context.find((entry) => entry.type?.name?.length > 0); - const suppliedValue = - keyContext !== '' ? keyContext : nameContext != null ? nameContext.type.name : ''; - const value = isObject(error.value) ? JSON.stringify(error.value) : error.value; - return `Invalid value "${value}" supplied to "${suppliedValue}"`; - } - }); -}; - class ApiService { private static instance: ApiService; private _http!: HttpSetup; @@ -109,6 +79,8 @@ class ApiService { body: JSON.stringify(data), }); + this.addInspectorRequest?.({ data: response, status: FETCH_STATUS.SUCCESS, loading: false }); + if (decodeType) { const decoded = decodeType.decode(response); if (isRight(decoded)) { @@ -116,7 +88,7 @@ class ApiService { } else { // eslint-disable-next-line no-console console.warn( - `API ${apiUrl} is not returning expected response, ${PathReporter.report(decoded)}` + `API ${apiUrl} is not returning expected response, ${formatErrors(decoded.left)}` ); } } @@ -136,7 +108,7 @@ class ApiService { } else { // eslint-disable-next-line no-console console.warn( - `API ${apiUrl} is not returning expected response, ${PathReporter.report(decoded)}` + `API ${apiUrl} is not returning expected response, ${formatErrors(decoded.left)}` ); } } diff --git a/x-pack/plugins/uptime/public/state/effects/index.ts b/x-pack/plugins/uptime/public/state/effects/index.ts index b1a51c5df096c6..07b04f8c27c3db 100644 --- a/x-pack/plugins/uptime/public/state/effects/index.ts +++ b/x-pack/plugins/uptime/public/state/effects/index.ts @@ -7,7 +7,11 @@ import { fork } from 'redux-saga/effects'; import { fetchMonitorDetailsEffect } from './monitor'; -import { fetchMonitorListEffect } from './monitor_list'; +import { + fetchMonitorListEffect, + fetchRunNowMonitorEffect, + fetchUpdatedMonitorEffect, +} from './monitor_list'; import { fetchMonitorManagementEffect } from './monitor_management'; import { fetchMonitorStatusEffect } from './monitor_status'; import { fetchDynamicSettingsEffect, setDynamicSettingsEffect } from './dynamic_settings'; @@ -27,6 +31,7 @@ import { export function* rootEffect() { yield fork(fetchMonitorDetailsEffect); yield fork(fetchMonitorListEffect); + yield fork(fetchUpdatedMonitorEffect); yield fork(fetchMonitorManagementEffect); yield fork(fetchMonitorStatusEffect); yield fork(fetchDynamicSettingsEffect); @@ -42,4 +47,5 @@ export function* rootEffect() { yield fork(fetchScreenshotBlocks); yield fork(generateBlockStatsOnPut); yield fork(pruneBlockCache); + yield fork(fetchRunNowMonitorEffect); } diff --git a/x-pack/plugins/uptime/public/state/effects/monitor_list.ts b/x-pack/plugins/uptime/public/state/effects/monitor_list.ts index 154d32ca47a7e8..35322c37681902 100644 --- a/x-pack/plugins/uptime/public/state/effects/monitor_list.ts +++ b/x-pack/plugins/uptime/public/state/effects/monitor_list.ts @@ -5,9 +5,15 @@ * 2.0. */ -import { takeLatest } from 'redux-saga/effects'; -import { getMonitorList, getMonitorListSuccess, getMonitorListFailure } from '../actions'; -import { fetchMonitorList } from '../api'; +import { takeEvery, takeLatest } from 'redux-saga/effects'; +import { + getMonitorList, + getMonitorListSuccess, + getMonitorListFailure, + getUpdatedMonitor, + testNowMonitorAction, +} from '../actions'; +import { fetchMonitorList, testNowMonitor } from '../api'; import { fetchEffectFactory } from './fetch_effect'; export function* fetchMonitorListEffect() { @@ -16,3 +22,17 @@ export function* fetchMonitorListEffect() { fetchEffectFactory(fetchMonitorList, getMonitorListSuccess, getMonitorListFailure) ); } + +export function* fetchUpdatedMonitorEffect() { + yield takeLatest( + getUpdatedMonitor.get, + fetchEffectFactory(fetchMonitorList, getUpdatedMonitor.success, getUpdatedMonitor.fail) + ); +} + +export function* fetchRunNowMonitorEffect() { + yield takeEvery( + testNowMonitorAction.get, + fetchEffectFactory(testNowMonitor, testNowMonitorAction.success, testNowMonitorAction.fail) + ); +} diff --git a/x-pack/plugins/uptime/public/state/reducers/index.ts b/x-pack/plugins/uptime/public/state/reducers/index.ts index 0142d271159ce9..2b6986c88b746e 100644 --- a/x-pack/plugins/uptime/public/state/reducers/index.ts +++ b/x-pack/plugins/uptime/public/state/reducers/index.ts @@ -23,6 +23,7 @@ import { journeyReducer } from './journey'; import { networkEventsReducer } from './network_events'; import { syntheticsReducer } from './synthetics'; import { monitorManagementListReducer } from './monitor_management'; +import { testNowRunsReducer } from './test_now_runs'; export const rootReducer = combineReducers({ monitor: monitorReducer, @@ -42,4 +43,5 @@ export const rootReducer = combineReducers({ journeys: journeyReducer, networkEvents: networkEventsReducer, synthetics: syntheticsReducer, + testNowRuns: testNowRunsReducer, }); diff --git a/x-pack/plugins/uptime/public/state/reducers/monitor_list.ts b/x-pack/plugins/uptime/public/state/reducers/monitor_list.ts index 2e833bd033c46e..8083b50367fe7b 100644 --- a/x-pack/plugins/uptime/public/state/reducers/monitor_list.ts +++ b/x-pack/plugins/uptime/public/state/reducers/monitor_list.ts @@ -7,13 +7,24 @@ import { handleActions, Action } from 'redux-actions'; import { IHttpFetchError, ResponseErrorBody } from 'src/core/public'; -import { getMonitorList, getMonitorListSuccess, getMonitorListFailure } from '../actions'; +import { + getMonitorList, + getMonitorListSuccess, + getMonitorListFailure, + getUpdatedMonitor, + clearRefreshedMonitorId, + setUpdatingMonitorId, +} from '../actions'; import { MonitorSummariesResult } from '../../../common/runtime_types'; +import { AppState } from '../index'; +import { TestNowResponse } from '../api'; export interface MonitorList { - error?: IHttpFetchError; loading: boolean; + refreshedMonitorIds?: string[]; + isUpdating?: string[]; list: MonitorSummariesResult; + error?: IHttpFetchError; } export const initialState: MonitorList = { @@ -23,9 +34,13 @@ export const initialState: MonitorList = { summaries: [], }, loading: false, + refreshedMonitorIds: [], }; -type Payload = MonitorSummariesResult & IHttpFetchError; +type Payload = MonitorSummariesResult & + IHttpFetchError & + string & + TestNowResponse; export const monitorListReducer = handleActions( { @@ -50,6 +65,64 @@ export const monitorListReducer = handleActions( error: action.payload, loading: false, }), + [String(setUpdatingMonitorId)]: (state: MonitorList, action: Action) => ({ + ...state, + isUpdating: [...(state.isUpdating ?? []), action.payload], + }), + [String(getUpdatedMonitor.get)]: (state: MonitorList) => ({ + ...state, + }), + [String(getUpdatedMonitor.success)]: ( + state: MonitorList, + action: Action + ) => { + const summaries = state.list.summaries; + + const newSummary = action.payload.summaries?.[0]; + + if (!newSummary) { + return { ...state, isUpdating: [] }; + } + + return { + ...state, + loading: false, + error: undefined, + isUpdating: state.isUpdating?.filter((item) => item !== newSummary.monitor_id), + refreshedMonitorIds: [...(state.refreshedMonitorIds ?? []), newSummary.monitor_id], + list: { + ...state.list, + summaries: summaries.map((summary) => { + if (summary.monitor_id === newSummary.monitor_id) { + return newSummary; + } + return summary; + }), + }, + }; + }, + [String(getUpdatedMonitor.fail)]: ( + state: MonitorList, + action: Action> + ) => ({ + ...state, + error: action.payload, + loading: false, + isUpdating: [], + }), + [String(clearRefreshedMonitorId)]: (state: MonitorList, action: Action) => ({ + ...state, + refreshedMonitorIds: (state.refreshedMonitorIds ?? []).filter( + (item) => item !== action.payload + ), + }), }, initialState ); + +export const refreshedMonitorSelector = ({ monitorList }: AppState) => { + return monitorList.refreshedMonitorIds ?? []; +}; + +export const isUpdatingMonitorSelector = ({ monitorList }: AppState) => + monitorList.isUpdating ?? []; diff --git a/x-pack/plugins/uptime/public/state/reducers/test_now_runs.ts b/x-pack/plugins/uptime/public/state/reducers/test_now_runs.ts new file mode 100644 index 00000000000000..4b0ce493ba13ca --- /dev/null +++ b/x-pack/plugins/uptime/public/state/reducers/test_now_runs.ts @@ -0,0 +1,82 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { createReducer, PayloadAction } from '@reduxjs/toolkit'; +import { WritableDraft } from 'immer/dist/types/types-external'; +import { clearTestNowMonitorAction, testNowMonitorAction } from '../actions'; +import { TestNowResponse } from '../api'; +import { AppState } from '../index'; + +export enum TestRunStats { + LOADING = 'loading', + IN_PROGRESS = 'in-progress', + COMPLETED = 'completed', +} + +interface TestNowRun { + monitorId: string; + testRunId?: string; + status: TestRunStats; +} + +export interface TestNowRunsState { + testNowRuns: TestNowRun[]; +} + +export const initialState: TestNowRunsState = { + testNowRuns: [], +}; + +export const testNowRunsReducer = createReducer(initialState, (builder) => { + builder + .addCase( + String(testNowMonitorAction.get), + (state: WritableDraft, action: PayloadAction) => ({ + ...state, + testNowRuns: [ + ...state.testNowRuns, + { monitorId: action.payload, status: TestRunStats.LOADING }, + ], + }) + ) + .addCase( + String(testNowMonitorAction.success), + (state: WritableDraft, { payload }: PayloadAction) => ({ + ...state, + testNowRuns: state.testNowRuns.map((tRun) => + tRun.monitorId === payload.monitorId + ? { + monitorId: payload.monitorId, + testRunId: payload.testRunId, + status: TestRunStats.IN_PROGRESS, + } + : tRun + ), + }) + ) + .addCase( + String(testNowMonitorAction.fail), + (state: WritableDraft, action: PayloadAction) => ({ + ...state, + testNowRuns: [...(state.testNowRuns ?? [])], + }) + ) + .addCase( + String(clearTestNowMonitorAction), + (state: WritableDraft, action: PayloadAction) => ({ + ...state, + testNowRuns: state.testNowRuns.filter((tRun) => tRun.monitorId !== action.payload), + }) + ); +}); + +export const testNowRunsSelector = ({ testNowRuns }: AppState) => testNowRuns.testNowRuns; + +export const testNowRunSelector = + (monitorId?: string) => + ({ testNowRuns }: AppState) => + testNowRuns.testNowRuns.find((tRun) => monitorId && monitorId === tRun.monitorId); diff --git a/x-pack/plugins/uptime/server/lib/adapters/framework/adapter_types.ts b/x-pack/plugins/uptime/server/lib/adapters/framework/adapter_types.ts index bbdccf5616f0d9..c6f5eae2e9d82d 100644 --- a/x-pack/plugins/uptime/server/lib/adapters/framework/adapter_types.ts +++ b/x-pack/plugins/uptime/server/lib/adapters/framework/adapter_types.ts @@ -6,7 +6,7 @@ */ import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; -import type { SavedObjectsClientContract, IScopedClusterClient } from 'src/core/server'; +import type { SavedObjectsClientContract, IScopedClusterClient, Logger } from 'src/core/server'; import { ObservabilityPluginSetup } from '../../../../../observability/server'; import { EncryptedSavedObjectsPluginSetup, @@ -51,6 +51,7 @@ export interface UptimeServerSetup { encryptedSavedObjects: EncryptedSavedObjectsPluginStart; syntheticsService: SyntheticsService; kibanaVersion: string; + logger: Logger; } export interface UptimeCorePluginsSetup { diff --git a/x-pack/plugins/uptime/server/lib/adapters/telemetry/kibana_telemetry_adapter.ts b/x-pack/plugins/uptime/server/lib/adapters/telemetry/kibana_telemetry_adapter.ts index f72af3311affe0..de09c686d4441e 100644 --- a/x-pack/plugins/uptime/server/lib/adapters/telemetry/kibana_telemetry_adapter.ts +++ b/x-pack/plugins/uptime/server/lib/adapters/telemetry/kibana_telemetry_adapter.ts @@ -11,6 +11,7 @@ import { CollectorFetchContext, UsageCollectionSetup } from 'src/plugins/usage_c import { PageViewParams, UptimeTelemetry, Usage } from './types'; import { savedObjectsAdapter } from '../../saved_objects/saved_objects'; import { UptimeESClient, createUptimeESClient } from '../../lib'; +import { createEsQuery } from '../../../../common/utils/es_search'; interface UptimeTelemetryCollector { [key: number]: UptimeTelemetry; @@ -215,7 +216,7 @@ export class KibanaTelemetryAdapter { savedObjectsClient: SavedObjectsClientContract ) { const dynamicSettings = await savedObjectsAdapter.getUptimeDynamicSettings(savedObjectsClient); - const params = { + const params = createEsQuery({ index: dynamicSettings.heartbeatIndices, body: { query: { @@ -229,6 +230,11 @@ export class KibanaTelemetryAdapter { }, }, }, + { + exists: { + field: 'summary', + }, + }, ], }, }, @@ -271,9 +277,9 @@ export class KibanaTelemetryAdapter { }, }, }, - }; + }); - const { body: result } = await callCluster.search(params); + const { body: result } = await callCluster.search(params, 'telemetryLog'); const numberOfUniqueMonitors: number = result?.aggregations?.unique_monitors?.value ?? 0; const numberOfUniqueLocations: number = result?.aggregations?.unique_locations?.value ?? 0; @@ -318,6 +324,11 @@ export class KibanaTelemetryAdapter { }, }, }, + { + exists: { + field: 'summary', + }, + }, { term: { 'monitor.fleet_managed': true, @@ -356,7 +367,7 @@ export class KibanaTelemetryAdapter { }, }; - const { body: result } = await callCluster.search(params); + const { body: result } = await callCluster.search(params, 'telemetryLogFleet'); const numberOfUniqueMonitors: number = result?.aggregations?.unique_monitors?.value ?? 0; const monitorNameStats = result?.aggregations?.monitor_name; diff --git a/x-pack/plugins/uptime/server/lib/adapters/telemetry/types.ts b/x-pack/plugins/uptime/server/lib/adapters/telemetry/types.ts index eceee3505dd7e9..7095ae8e38ab53 100644 --- a/x-pack/plugins/uptime/server/lib/adapters/telemetry/types.ts +++ b/x-pack/plugins/uptime/server/lib/adapters/telemetry/types.ts @@ -12,6 +12,7 @@ export interface PageViewParams { autoRefreshEnabled: boolean; autorefreshInterval: number; refreshTelemetryHistory?: boolean; + refreshEsData?: boolean; } export interface Stats { diff --git a/x-pack/plugins/uptime/server/lib/requests/search/refine_potential_matches.ts b/x-pack/plugins/uptime/server/lib/requests/search/refine_potential_matches.ts index f8357e80665739..5a714fd2514d87 100644 --- a/x-pack/plugins/uptime/server/lib/requests/search/refine_potential_matches.ts +++ b/x-pack/plugins/uptime/server/lib/requests/search/refine_potential_matches.ts @@ -83,11 +83,13 @@ export const summaryPingsToSummary = (summaryPings: Ping[]): MonitorSummary => { const latest = summaryPings[summaryPings.length - 1]; return { monitor_id: latest.monitor.id, + configId: latest.config_id, state: { timestamp: latest.timestamp, monitor: { name: latest.monitor?.name, type: latest.monitor?.type, + duration: latest.monitor?.duration, }, url: latest.url ?? {}, summary: { diff --git a/x-pack/plugins/uptime/server/lib/synthetics_service/get_service_locations.test.ts b/x-pack/plugins/uptime/server/lib/synthetics_service/get_service_locations.test.ts index 1d70199291e1d6..b2644d53e49d99 100644 --- a/x-pack/plugins/uptime/server/lib/synthetics_service/get_service_locations.test.ts +++ b/x-pack/plugins/uptime/server/lib/synthetics_service/get_service_locations.test.ts @@ -6,6 +6,7 @@ */ import axios from 'axios'; import { getServiceLocations } from './get_service_locations'; + jest.mock('axios'); const mockedAxios = axios as jest.Mocked; @@ -27,7 +28,15 @@ describe('getServiceLocations', function () { }); it('should return parsed locations', async () => { const locations = await getServiceLocations({ - manifestUrl: 'http://local.dev', + config: { + service: { + manifestUrl: 'http://local.dev', + }, + }, + // @ts-ignore + logger: { + error: jest.fn(), + }, }); expect(locations).toEqual({ diff --git a/x-pack/plugins/uptime/server/lib/synthetics_service/get_service_locations.ts b/x-pack/plugins/uptime/server/lib/synthetics_service/get_service_locations.ts index 54686b282bbb48..a58c4dd421cbef 100644 --- a/x-pack/plugins/uptime/server/lib/synthetics_service/get_service_locations.ts +++ b/x-pack/plugins/uptime/server/lib/synthetics_service/get_service_locations.ts @@ -11,16 +11,19 @@ import { ServiceLocations, ServiceLocationsApiResponse, } from '../../../common/runtime_types'; +import { UptimeServerSetup } from '../adapters/framework'; -export async function getServiceLocations({ manifestUrl }: { manifestUrl?: string }) { +export async function getServiceLocations(server: UptimeServerSetup) { const locations: ServiceLocations = []; - if (!manifestUrl) { + if (!server.config.service!.manifestUrl!) { return { locations }; } try { - const { data } = await axios.get<{ locations: Record }>(manifestUrl); + const { data } = await axios.get<{ locations: Record }>( + server.config.service!.manifestUrl! + ); Object.entries(data.locations).forEach(([locationId, location]) => { locations.push({ @@ -33,6 +36,7 @@ export async function getServiceLocations({ manifestUrl }: { manifestUrl?: strin return { locations } as ServiceLocationsApiResponse; } catch (e) { + server.logger.error(e); return { locations: [], } as ServiceLocationsApiResponse; diff --git a/x-pack/plugins/uptime/server/lib/synthetics_service/synthetics_service.ts b/x-pack/plugins/uptime/server/lib/synthetics_service/synthetics_service.ts index 054bceec48571c..20f11fe3b8900a 100644 --- a/x-pack/plugins/uptime/server/lib/synthetics_service/synthetics_service.ts +++ b/x-pack/plugins/uptime/server/lib/synthetics_service/synthetics_service.ts @@ -104,9 +104,7 @@ export class SyntheticsService { async run() { const { state } = taskInstance; - const { manifestUrl } = service.config; - - getServiceLocations({ manifestUrl }).then((result) => { + getServiceLocations(service.server).then((result) => { service.locations = result.locations; service.apiClient.locations = result.locations; }); @@ -181,7 +179,15 @@ export class SyntheticsService { }; } - async pushConfigs(request?: KibanaRequest, configs?: SyntheticsMonitorWithId[]) { + async pushConfigs( + request?: KibanaRequest, + configs?: Array< + SyntheticsMonitorWithId & { + fields_under_root?: boolean; + fields?: { config_id: string }; + } + > + ) { const monitors = this.formatConfigs(configs || (await this.getMonitorConfigs())); if (monitors.length === 0) { this.logger.debug('No monitor found which can be pushed to service.'); @@ -228,6 +234,32 @@ export class SyntheticsService { } } + async triggerConfigs( + request?: KibanaRequest, + configs?: Array< + SyntheticsMonitorWithId & { + fields_under_root?: boolean; + fields?: { config_id: string; test_run_id: string }; + } + > + ) { + const monitors = this.formatConfigs(configs || (await this.getMonitorConfigs())); + if (monitors.length === 0) { + return; + } + const data = { + monitors, + output: await this.getOutput(request), + }; + + try { + return await this.apiClient.runOnce(data); + } catch (e) { + this.logger.error(e); + throw e; + } + } + async deleteConfigs(request: KibanaRequest, configs: SyntheticsMonitorWithId[]) { const data = { monitors: this.formatConfigs(configs), diff --git a/x-pack/plugins/uptime/server/plugin.ts b/x-pack/plugins/uptime/server/plugin.ts index d9446b2e5e1db7..df88f895f2f7d1 100644 --- a/x-pack/plugins/uptime/server/plugin.ts +++ b/x-pack/plugins/uptime/server/plugin.ts @@ -72,6 +72,7 @@ export class Plugin implements PluginType { router: core.http.createRouter(), cloud: plugins.cloud, kibanaVersion: this.initContext.env.packageInfo.version, + logger: this.logger, } as UptimeServerSetup; if (this.server?.config?.service?.enabled) { diff --git a/x-pack/plugins/uptime/server/rest_api/index.ts b/x-pack/plugins/uptime/server/rest_api/index.ts index 383d999f29cc68..780a67c0941e1b 100644 --- a/x-pack/plugins/uptime/server/rest_api/index.ts +++ b/x-pack/plugins/uptime/server/rest_api/index.ts @@ -37,6 +37,7 @@ import { addSyntheticsMonitorRoute } from './synthetics_service/add_monitor'; import { editSyntheticsMonitorRoute } from './synthetics_service/edit_monitor'; import { deleteSyntheticsMonitorRoute } from './synthetics_service/delete_monitor'; import { runOnceSyntheticsMonitorRoute } from './synthetics_service/run_once_monitor'; +import { testNowMonitorRoute } from './synthetics_service/test_now_monitor'; export * from './types'; export { createRouteWithAuth } from './create_route_with_auth'; @@ -69,4 +70,5 @@ export const restApiRoutes: UMRestApiRouteFactory[] = [ editSyntheticsMonitorRoute, deleteSyntheticsMonitorRoute, runOnceSyntheticsMonitorRoute, + testNowMonitorRoute, ]; diff --git a/x-pack/plugins/uptime/server/rest_api/synthetics_service/add_monitor.ts b/x-pack/plugins/uptime/server/rest_api/synthetics_service/add_monitor.ts index 1750466b6c3e68..38def648f6e5cd 100644 --- a/x-pack/plugins/uptime/server/rest_api/synthetics_service/add_monitor.ts +++ b/x-pack/plugins/uptime/server/rest_api/synthetics_service/add_monitor.ts @@ -38,6 +38,10 @@ export const addSyntheticsMonitorRoute: UMRestApiRouteFactory = () => ({ { ...newMonitor.attributes, id: newMonitor.id, + fields: { + config_id: newMonitor.id, + }, + fields_under_root: true, }, ]); diff --git a/x-pack/plugins/uptime/server/rest_api/synthetics_service/edit_monitor.ts b/x-pack/plugins/uptime/server/rest_api/synthetics_service/edit_monitor.ts index a95876d8d3ea62..530716f709f647 100644 --- a/x-pack/plugins/uptime/server/rest_api/synthetics_service/edit_monitor.ts +++ b/x-pack/plugins/uptime/server/rest_api/synthetics_service/edit_monitor.ts @@ -47,6 +47,10 @@ export const editSyntheticsMonitorRoute: UMRestApiRouteFactory = () => ({ { ...(editMonitor.attributes as SyntheticsMonitor), id: editMonitor.id, + fields: { + config_id: editMonitor.id, + }, + fields_under_root: true, }, ]); diff --git a/x-pack/plugins/uptime/server/rest_api/synthetics_service/get_monitor.ts b/x-pack/plugins/uptime/server/rest_api/synthetics_service/get_monitor.ts index c35e1a33ed2153..6fd3ab6d2873be 100644 --- a/x-pack/plugins/uptime/server/rest_api/synthetics_service/get_monitor.ts +++ b/x-pack/plugins/uptime/server/rest_api/synthetics_service/get_monitor.ts @@ -41,12 +41,13 @@ export const getAllSyntheticsMonitorRoute: UMRestApiRouteFactory = () => ({ query: schema.object({ page: schema.maybe(schema.number()), perPage: schema.maybe(schema.number()), + sortField: schema.maybe(schema.string()), + sortOrder: schema.maybe(schema.oneOf([schema.literal('desc'), schema.literal('asc')])), search: schema.maybe(schema.string()), }), }, handler: async ({ request, savedObjectsClient }): Promise => { - const { perPage = 50, page, search } = request.query; - + const { perPage = 50, page, sortField, sortOrder, search } = request.query; // TODO: add query/filtering params const { saved_objects: monitors, @@ -56,6 +57,8 @@ export const getAllSyntheticsMonitorRoute: UMRestApiRouteFactory = () => ({ type: syntheticsMonitorType, perPage, page, + sortField, + sortOrder, filter: search ? `${syntheticsMonitorType}.attributes.name: ${search}` : '', }); return { diff --git a/x-pack/plugins/uptime/server/rest_api/synthetics_service/get_service_locations.ts b/x-pack/plugins/uptime/server/rest_api/synthetics_service/get_service_locations.ts index 907b8a9ce36214..cfaab8a7fe9005 100644 --- a/x-pack/plugins/uptime/server/rest_api/synthetics_service/get_service_locations.ts +++ b/x-pack/plugins/uptime/server/rest_api/synthetics_service/get_service_locations.ts @@ -18,6 +18,6 @@ export const getServiceLocationsRoute: UMRestApiRouteFactory = () => ({ return { locations: server.syntheticsService.locations }; } - return getServiceLocations({ manifestUrl: server.config.service!.manifestUrl! }); + return getServiceLocations(server); }, }); diff --git a/x-pack/plugins/uptime/server/rest_api/synthetics_service/monitor_validation.ts b/x-pack/plugins/uptime/server/rest_api/synthetics_service/monitor_validation.ts index 9f14c414e5cad2..446eaa5847319c 100644 --- a/x-pack/plugins/uptime/server/rest_api/synthetics_service/monitor_validation.ts +++ b/x-pack/plugins/uptime/server/rest_api/synthetics_service/monitor_validation.ts @@ -6,7 +6,7 @@ */ import { isLeft } from 'fp-ts/lib/Either'; -import { PathReporter } from 'io-ts/lib/PathReporter'; +import { formatErrors } from '@kbn/securitysolution-io-ts-utils'; import { BrowserFieldsCodec, @@ -49,7 +49,7 @@ export function validateMonitor(monitorFields: MonitorFields): { return { valid: false, reason: `Monitor type is invalid`, - details: PathReporter.report(decodedType).join(' | '), + details: formatErrors(decodedType.left).join(' | '), payload: monitorFields, }; } @@ -72,7 +72,7 @@ export function validateMonitor(monitorFields: MonitorFields): { return { valid: false, reason: `Monitor is not a valid monitor of type ${monitorType}`, - details: PathReporter.report(decodedMonitor).join(' | '), + details: formatErrors(decodedMonitor.left).join(' | '), payload: monitorFields, }; } diff --git a/x-pack/plugins/uptime/server/rest_api/synthetics_service/test_now_monitor.ts b/x-pack/plugins/uptime/server/rest_api/synthetics_service/test_now_monitor.ts new file mode 100644 index 00000000000000..2ad270db213fbd --- /dev/null +++ b/x-pack/plugins/uptime/server/rest_api/synthetics_service/test_now_monitor.ts @@ -0,0 +1,48 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import { schema } from '@kbn/config-schema'; +import { v4 as uuidv4 } from 'uuid'; +import { SyntheticsMonitor } from '../../../common/runtime_types'; +import { UMRestApiRouteFactory } from '../types'; +import { API_URLS } from '../../../common/constants'; +import { syntheticsMonitorType } from '../../lib/saved_objects/synthetics_monitor'; + +export const testNowMonitorRoute: UMRestApiRouteFactory = () => ({ + method: 'GET', + path: API_URLS.TRIGGER_MONITOR + '/{monitorId}', + validate: { + params: schema.object({ + monitorId: schema.string({ minLength: 1, maxLength: 1024 }), + }), + }, + handler: async ({ request, savedObjectsClient, response, server }): Promise => { + const { monitorId } = request.params; + const monitor = await savedObjectsClient.get( + syntheticsMonitorType, + monitorId + ); + + const { syntheticsService } = server; + + const testRunId = uuidv4(); + + const errors = await syntheticsService.triggerConfigs(request, [ + { + ...monitor.attributes, + id: monitorId, + fields_under_root: true, + fields: { config_id: monitorId, test_run_id: testRunId }, + }, + ]); + + if (errors && errors?.length > 0) { + return { errors, testRunId, monitorId }; + } + + return { testRunId, monitorId }; + }, +}); diff --git a/x-pack/plugins/uptime/server/rest_api/telemetry/log_page_view.ts b/x-pack/plugins/uptime/server/rest_api/telemetry/log_page_view.ts index ec7de05dd2cf1f..eb3447d85424b5 100644 --- a/x-pack/plugins/uptime/server/rest_api/telemetry/log_page_view.ts +++ b/x-pack/plugins/uptime/server/rest_api/telemetry/log_page_view.ts @@ -21,18 +21,25 @@ export const createLogPageViewRoute: UMRestApiRouteFactory = () => ({ dateEnd: schema.string(), autoRefreshEnabled: schema.boolean(), autorefreshInterval: schema.number(), + refreshEsData: schema.maybe(schema.boolean()), refreshTelemetryHistory: schema.maybe(schema.boolean()), }), }, handler: async ({ savedObjectsClient, uptimeEsClient, request }): Promise => { const pageView = request.body as PageViewParams; if (pageView.refreshTelemetryHistory) { + // this is primarily only used for API testing KibanaTelemetryAdapter.clearLocalTelemetry(); } - await KibanaTelemetryAdapter.countNoOfUniqueMonitorAndLocations( - uptimeEsClient, - savedObjectsClient - ); + + if (pageView.refreshEsData) { + // this is primarily only used for API testing + + await KibanaTelemetryAdapter.countNoOfUniqueMonitorAndLocations( + uptimeEsClient, + savedObjectsClient + ); + } await KibanaTelemetryAdapter.countNoOfUniqueFleetManagedMonitors(uptimeEsClient); return KibanaTelemetryAdapter.countPageView(pageView as PageViewParams); }, diff --git a/x-pack/plugins/watcher/__fixtures__/watch.ts b/x-pack/plugins/watcher/__fixtures__/watch.ts index 36991187b6bd47..a05f100c89f191 100644 --- a/x-pack/plugins/watcher/__fixtures__/watch.ts +++ b/x-pack/plugins/watcher/__fixtures__/watch.ts @@ -6,7 +6,7 @@ */ import { Moment } from 'moment'; -import { getRandomString } from '@kbn/test/jest'; +import { getRandomString } from '@kbn/test-jest-helpers'; interface Watch { id: string; diff --git a/x-pack/plugins/watcher/__fixtures__/watch_history.ts b/x-pack/plugins/watcher/__fixtures__/watch_history.ts index 9ebc343fcddd65..d7fab9fc80d29b 100644 --- a/x-pack/plugins/watcher/__fixtures__/watch_history.ts +++ b/x-pack/plugins/watcher/__fixtures__/watch_history.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { getRandomString } from '@kbn/test/jest'; +import { getRandomString } from '@kbn/test-jest-helpers'; interface WatchHistory { startTime: string; 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 37fe71d143988f..07ced2096e696a 100644 --- a/x-pack/plugins/watcher/__jest__/client_integration/helpers/index.ts +++ b/x-pack/plugins/watcher/__jest__/client_integration/helpers/index.ts @@ -11,8 +11,8 @@ 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 type { TestBed } from '@kbn/test/jest'; -export { getRandomString, findTestSubject } from '@kbn/test/jest'; +export type { TestBed } from '@kbn/test-jest-helpers'; +export { getRandomString, findTestSubject } from '@kbn/test-jest-helpers'; 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 a276b717bc544b..16e4930510efa4 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test/jest'; +import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test-jest-helpers'; 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 320f88eef2651b..cbfdac67597e1d 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test/jest'; +import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test-jest-helpers'; 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 15489fa0a864d2..9f01750d43593e 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 @@ -5,7 +5,7 @@ * 2.0. */ -import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test/jest'; +import { registerTestBed, TestBed, AsyncTestBedConfig } from '@kbn/test-jest-helpers'; 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 d048a55422f6e9..914eaca62465d0 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 @@ -7,7 +7,12 @@ import { act } from 'react-dom/test-utils'; -import { registerTestBed, findTestSubject, TestBed, AsyncTestBedConfig } from '@kbn/test/jest'; +import { + registerTestBed, + findTestSubject, + TestBed, + AsyncTestBedConfig, +} from '@kbn/test-jest-helpers'; 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 0578f9f1092a17..63892961d8b570 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 @@ -7,7 +7,12 @@ import { act } from 'react-dom/test-utils'; -import { registerTestBed, findTestSubject, TestBed, AsyncTestBedConfig } from '@kbn/test/jest'; +import { + registerTestBed, + findTestSubject, + TestBed, + AsyncTestBedConfig, +} from '@kbn/test-jest-helpers'; import { WatchStatus } from '../../../public/application/sections/watch_status/components/watch_status'; import { ROUTES } from '../../../common/constants'; import { WATCH_ID } from './jest_constants'; 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 b5fb2aa9d915a5..37f9838f176afd 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 @@ -8,7 +8,7 @@ import { act } from 'react-dom/test-utils'; import axiosXhrAdapter from 'axios/lib/adapters/xhr'; import axios from 'axios'; -import { getRandomString } from '@kbn/test/jest'; +import { getRandomString } from '@kbn/test-jest-helpers'; import { getWatch } from '../../__fixtures__'; import { defaultWatch } from '../../public/application/models/watch'; diff --git a/x-pack/test/api_integration/apis/telemetry/telemetry.ts b/x-pack/test/api_integration/apis/telemetry/telemetry.ts index fb0d56f7d7532a..088678a74813b6 100644 --- a/x-pack/test/api_integration/apis/telemetry/telemetry.ts +++ b/x-pack/test/api_integration/apis/telemetry/telemetry.ts @@ -185,40 +185,37 @@ export default function ({ getService }: FtrProviderContext) { const archive = 'x-pack/test/functional/es_archives/monitoring/basic_6.3.x'; const fromTimestamp = '2018-07-23T22:54:59.087Z'; const toTimestamp = '2018-07-23T22:55:05.933Z'; - let cacheLastUpdated: string[] = []; before(async () => { await esArchiver.load(archive); await updateMonitoringDates(esSupertest, fromTimestamp, toTimestamp, timestamp); - // hit the endpoint to cache results - const { body }: { body: UnencryptedTelemetryPayload } = await supertest + await supertest .post('/api/telemetry/v2/clusters/_stats') .set('kbn-xsrf', 'xxx') .send({ unencrypted: true, refreshCache: true }) .expect(200); - - cacheLastUpdated = getCacheDetails(body).map(({ updatedAt }) => updatedAt); }); after(() => esArchiver.unload(archive)); + }); - it('returns cached results by default', async () => { - const now = Date.now(); - const { body }: { body: UnencryptedTelemetryPayload } = await supertest - .post('/api/telemetry/v2/clusters/_stats') - .set('kbn-xsrf', 'xxx') - .send({ unencrypted: true }) - .expect(200); + it('returns non-cached results when unencrypted', async () => { + const now = Date.now(); + const { body }: { body: UnencryptedTelemetryPayload } = await supertest + .post('/api/telemetry/v2/clusters/_stats') + .set('kbn-xsrf', 'xxx') + .send({ unencrypted: true }) + .expect(200); - expect(body).length(2); + expect(body).length(1); - const cacheDetails = getCacheDetails(body); - // Check that the fetched payload is actually cached by comparing cache and updatedAt timestamps - expect(cacheDetails.map(({ updatedAt }) => updatedAt)).to.eql(cacheLastUpdated); - // Check that the fetchedAt timestamp is updated when the data is fethed - cacheDetails.forEach(({ fetchedAt }) => { - expect(new Date(fetchedAt).getTime()).to.be.greaterThan(now); - }); + const cacheDetails = getCacheDetails(body); + cacheDetails.forEach(({ fetchedAt, updatedAt }) => { + // Check that the cache is fresh by comparing updatedAt timestamp with + // the timestamp the data was fetched. + expect(new Date(updatedAt).getTime()).to.be.greaterThan(now); + // Check that the fetchedAt timestamp is updated when the data is fetched + expect(new Date(fetchedAt).getTime()).to.be.greaterThan(now); }); }); @@ -235,7 +232,7 @@ export default function ({ getService }: FtrProviderContext) { // Check that the cache is fresh by comparing updatedAt timestamp with // the timestamp the data was fetched. expect(new Date(updatedAt).getTime()).to.be.greaterThan(now); - // Check that the fetchedAt timestamp is updated when the data is fethed + // Check that the fetchedAt timestamp is updated when the data is fetched expect(new Date(fetchedAt).getTime()).to.be.greaterThan(now); }); }); diff --git a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts index de65fe6deb9856..e9aa339f62e14b 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts @@ -14,8 +14,7 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); const es = getService('es'); - // FAILING ES PROMOTION: https://github.com/elastic/kibana/issues/111240 - describe.skip('telemetry collectors heartbeat', () => { + describe('telemetry collectors heartbeat', () => { before('generating data', async () => { await getService('esArchiver').load('x-pack/test/functional/es_archives/uptime/blank'); @@ -69,7 +68,7 @@ export default function ({ getService }: FtrProviderContext) { 'downMonitorId', 1, 1, - 1, + 10 * 1000, { observer, monitor: { @@ -79,7 +78,15 @@ export default function ({ getService }: FtrProviderContext) { 'down' ); - await makeChecksWithStatus(es, 'mixMonitorId', 1, 1, 1, { observer: observer2 }, 'down'); + await makeChecksWithStatus( + es, + 'mixMonitorId', + 1, + 1, + 30 * 1000, + { observer: observer2 }, + 'down' + ); await es.indices.refresh(); }); @@ -103,6 +110,7 @@ export default function ({ getService }: FtrProviderContext) { dateEnd: 'now/d', autoRefreshEnabled: true, refreshTelemetryHistory: true, + refreshEsData: true, }) .expect(200); @@ -111,7 +119,7 @@ export default function ({ getService }: FtrProviderContext) { monitor_page: 1, no_of_unique_monitors: 4, settings_page: 0, - monitor_frequency: [120, 0.001, 60, 60], + monitor_frequency: [10, 30, 60, 60], monitor_name_stats: { min_length: 7, max_length: 22, avg_length: 12 }, no_of_unique_observer_locations: 3, observer_location_name_stats: { min_length: 2, max_length: 7, avg_length: 4.8 }, diff --git a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors_fleet.ts b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors_fleet.ts index daf70c3fbb7248..84d6d71a4ab6d1 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors_fleet.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors_fleet.ts @@ -175,6 +175,7 @@ export default function ({ getService }: FtrProviderContext) { dateEnd: 'now/d', autoRefreshEnabled: true, refreshTelemetryHistory: true, + refreshEsData: true, }) .expect(200); diff --git a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/metrics/get_case_metrics_alerts.ts b/x-pack/test/cases_api_integration/security_and_spaces/tests/common/metrics/get_case_metrics_alerts.ts index c711dff7b55a07..1f58d4b72cea87 100644 --- a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/metrics/get_case_metrics_alerts.ts +++ b/x-pack/test/cases_api_integration/security_and_spaces/tests/common/metrics/get_case_metrics_alerts.ts @@ -100,6 +100,56 @@ export default ({ getService }: FtrProviderContext): void => { }); }); + describe('alert details invalid alerts', () => { + let caseId: string; + + before(async () => { + caseId = await createCaseWithAlerts(); + await esArchiver.load('x-pack/test/functional/es_archives/cases/signals/hosts_users'); + }); + + after(async () => { + await esArchiver.unload('x-pack/test/functional/es_archives/cases/signals/hosts_users'); + await deleteAllCaseItems(es); + }); + + it('ignores failures from alerts that the index does not exist', async () => { + const theCase = await createCase(supertest, getPostCaseRequest()); + + // add an alert that has an index and id do not exist + await createComment({ supertest, caseId: theCase.id, params: postCommentAlertReq }); + + const metrics = await getCaseMetrics({ + supertest, + caseId: theCase.id, + features: ['alerts.users', 'alerts.hosts'], + }); + + expect(metrics.alerts?.hosts).to.eql({ + total: 0, + values: [], + }); + expect(metrics.alerts?.users).to.eql({ + total: 0, + values: [], + }); + }); + + it('returns the accurate metrics for the alerts that have valid indices', async () => { + await createComment({ supertest, caseId, params: postCommentAlertReq }); + + const metrics = await getCaseMetrics({ + supertest, + caseId, + features: ['alerts.users', 'alerts.hosts', 'alerts.count'], + }); + + expect(metrics.alerts?.hosts?.total).to.be(3); + expect(metrics.alerts?.users?.total).to.be(4); + expect(metrics.alerts?.count).to.be(7); + }); + }); + describe('alert count', () => { afterEach(async () => { await deleteAllCaseItems(es); diff --git a/x-pack/test/functional/apps/maps/file_upload/shapefile.js b/x-pack/test/functional/apps/maps/file_upload/shapefile.js index 2c79db3ceb0685..30d3aa1ae3b02d 100644 --- a/x-pack/test/functional/apps/maps/file_upload/shapefile.js +++ b/x-pack/test/functional/apps/maps/file_upload/shapefile.js @@ -14,7 +14,8 @@ export default function ({ getPageObjects, getService }) { const security = getService('security'); const retry = getService('retry'); - describe('shapefile upload', () => { + // FLAKY: https://github.com/elastic/kibana/issues/124334 + describe.skip('shapefile upload', () => { let indexName = ''; before(async () => { await security.testUser.setRoles([ diff --git a/x-pack/test/functional/services/ml/common_ui.ts b/x-pack/test/functional/services/ml/common_ui.ts index 65621c4959d372..cb9ef179f06269 100644 --- a/x-pack/test/functional/services/ml/common_ui.ts +++ b/x-pack/test/functional/services/ml/common_ui.ts @@ -8,12 +8,15 @@ import expect from '@kbn/expect'; import { ProvidedType } from '@kbn/test'; +import { WebElementWrapper } from 'test/functional/services/lib/web_element_wrapper'; + import { FtrProviderContext } from '../../ftr_provider_context'; import type { CanvasElementColorStats } from '../canvas_element'; export interface SetValueOptions { clearWithKeyboard?: boolean; + enforceDataTestSubj?: boolean; typeCharByChar?: boolean; } @@ -39,24 +42,46 @@ export function MachineLearningCommonUIProvider({ options: SetValueOptions = {} ): Promise { return await retry.try(async () => { - const { clearWithKeyboard = false, typeCharByChar = false } = options; + const { + clearWithKeyboard = false, + enforceDataTestSubj = false, + typeCharByChar = false, + } = options; log.debug(`TestSubjects.setValueWithChecks(${selector}, ${text})`); await testSubjects.click(selector); + // in case the input element is actually a child of the testSubject, we // call clearValue() and type() on the element that is focused after // clicking on the testSubject - const input = await find.activeElement(); + let input: WebElementWrapper; + if (enforceDataTestSubj) { + await retry.tryForTime(5000, async () => { + await testSubjects.click(selector); + input = await find.activeElement(); + const currentDataTestSubj = await input.getAttribute('data-test-subj'); + if (currentDataTestSubj === selector) { + return true; + } else { + throw new Error( + `Expected input data-test-subj to be ${selector}, but got value '${currentDataTestSubj}'` + ); + } + }); + } else { + await testSubjects.click(selector); + input = await find.activeElement(); + } // make sure that clearing the element's value works await retry.tryForTime(5000, async () => { - let currentValue = await input.getAttribute('value'); + let currentValue = await testSubjects.getAttribute(selector, 'value'); if (currentValue !== '') { if (clearWithKeyboard === true) { await input.clearValueWithKeyboard(); } else { await input.clearValue(); } - currentValue = await input.getAttribute('value'); + currentValue = await testSubjects.getAttribute(selector, 'value'); } if (currentValue === '') { @@ -69,11 +94,11 @@ export function MachineLearningCommonUIProvider({ // make sure that typing a character really adds that character to the input value for (const chr of text) { await retry.tryForTime(5000, async () => { - const oldValue = await input.getAttribute('value'); + const oldValue = await testSubjects.getAttribute(selector, 'value'); await input.type(chr, { charByChar: typeCharByChar }); await retry.tryForTime(1000, async () => { - const newValue = await input.getAttribute('value'); + const newValue = await testSubjects.getAttribute(selector, 'value'); if (newValue === `${oldValue}${chr}`) { return true; } else { @@ -88,7 +113,7 @@ export function MachineLearningCommonUIProvider({ // make sure that finally the complete text is entered // this is needed because sometimes the field value is reset while typing // and the above character checking might not catch it due to bad timing - const currentValue = await input.getAttribute('value'); + const currentValue = await testSubjects.getAttribute(selector, 'value'); if (currentValue !== text) { throw new Error( `Expected input '${selector}' to have the value '${text}' (got ${currentValue})` diff --git a/x-pack/test/functional/services/transform/wizard.ts b/x-pack/test/functional/services/transform/wizard.ts index 428a56707b49a4..d96b77ef4998a4 100644 --- a/x-pack/test/functional/services/transform/wizard.ts +++ b/x-pack/test/functional/services/transform/wizard.ts @@ -682,6 +682,7 @@ export function TransformWizardProvider({ getService, getPageObjects }: FtrProvi async setTransformId(transformId: string) { await ml.commonUI.setValueWithChecks('transformIdInput', transformId, { clearWithKeyboard: true, + enforceDataTestSubj: true, }); await this.assertTransformIdValue(transformId); }, diff --git a/x-pack/test/osquery_cypress/agent.ts b/x-pack/test/osquery_cypress/agent.ts index 1838d9df8b3e28..c0e5b2374889d6 100644 --- a/x-pack/test/osquery_cypress/agent.ts +++ b/x-pack/test/osquery_cypress/agent.ts @@ -11,11 +11,12 @@ import { ChildProcess, spawn } from 'child_process'; import { getLatestVersion } from './artifact_manager'; import { Manager } from './resource_manager'; -interface AgentManagerParams { +export interface AgentManagerParams { user: string; password: string; kibanaUrl: string; esHost: string; + esPort: string; } export class AgentManager extends Manager { @@ -23,19 +24,11 @@ export class AgentManager extends Manager { private log: ToolingLog; private agentProcess?: ChildProcess; private requestOptions: AxiosRequestConfig; - constructor(params: AgentManagerParams, log: ToolingLog) { + constructor(params: AgentManagerParams, log: ToolingLog, requestOptions: AxiosRequestConfig) { super(); this.log = log; this.params = params; - this.requestOptions = { - headers: { - 'kbn-xsrf': 'kibana', - }, - auth: { - username: this.params.user, - password: this.params.password, - }, - }; + this.requestOptions = requestOptions; } public async setup() { diff --git a/x-pack/test/osquery_cypress/artifact_manager.ts b/x-pack/test/osquery_cypress/artifact_manager.ts index 17ba9b0a5517d6..498d8737471854 100644 --- a/x-pack/test/osquery_cypress/artifact_manager.ts +++ b/x-pack/test/osquery_cypress/artifact_manager.ts @@ -5,10 +5,11 @@ * 2.0. */ -import axios from 'axios'; -import { last } from 'lodash'; +// import axios from 'axios'; +// import { last } from 'lodash'; export async function getLatestVersion(): Promise { - const response: any = await axios('https://artifacts-api.elastic.co/v1/versions'); - return last(response.data.versions as string[]) || '8.1.0-SNAPSHOT'; + return '8.0.0-SNAPSHOT'; + // const response: any = await axios('https://artifacts-api.elastic.co/v1/versions'); + // return last(response.data.versions as string[]) || '8.1.0-SNAPSHOT'; } diff --git a/x-pack/test/osquery_cypress/fleet_server.ts b/x-pack/test/osquery_cypress/fleet_server.ts index fe2b8c74592292..b64b1871637bc0 100644 --- a/x-pack/test/osquery_cypress/fleet_server.ts +++ b/x-pack/test/osquery_cypress/fleet_server.ts @@ -7,34 +7,49 @@ import { ChildProcess, spawn } from 'child_process'; import { ToolingLog } from '@kbn/dev-utils'; -import axios from 'axios'; +import axios, { AxiosRequestConfig } from 'axios'; import { Manager } from './resource_manager'; import { getLatestVersion } from './artifact_manager'; - -export interface ElasticsearchConfig { - esHost: string; - user: string; - password: string; - port: string; -} +import { AgentManagerParams } from './agent'; export class FleetManager extends Manager { private fleetProcess?: ChildProcess; - private esConfig: ElasticsearchConfig; + private config: AgentManagerParams; private log: ToolingLog; - constructor(esConfig: ElasticsearchConfig, log: ToolingLog) { + private requestOptions: AxiosRequestConfig; + constructor(config: AgentManagerParams, log: ToolingLog, requestOptions: AxiosRequestConfig) { super(); - this.esConfig = esConfig; + this.config = config; this.log = log; + this.requestOptions = requestOptions; } public async setup(): Promise { this.log.info('Setting fleet up'); return new Promise(async (res, rej) => { try { + // default fleet server policy no longer created by default + const { + data: { + item: { id: policyId }, + }, + } = await axios.post( + `${this.config.kibanaUrl}/api/fleet/agent_policies`, + { + name: 'Default Fleet Server policy', + description: '', + namespace: 'default', + monitoring_enabled: ['logs', 'metrics'], + has_fleet_server: true, + }, + this.requestOptions + ); + const response = await axios.post( - `${this.esConfig.esHost}/_security/service/elastic/fleet-server/credential/token` + `${this.config.kibanaUrl}/api/fleet/service_tokens`, + {}, + this.requestOptions ); - const serviceToken = response.data.token.value; + const serviceToken = response.data.value; const artifact = `docker.elastic.co/beats/elastic-agent:${await getLatestVersion()}`; this.log.info(artifact); @@ -49,12 +64,15 @@ export class FleetManager extends Manager { '--env', 'FLEET_SERVER_ENABLE=true', '--env', - `FLEET_SERVER_ELASTICSEARCH_HOST=http://${host}:${this.esConfig.port}`, + `FLEET_SERVER_ELASTICSEARCH_HOST=http://${host}:${this.config.esPort}`, '--env', `FLEET_SERVER_SERVICE_TOKEN=${serviceToken}`, + '--env', + `FLEET_SERVER_POLICY=${policyId}`, '--rm', artifact, ]; + this.log.info('docker ' + args.join(' ')); this.fleetProcess = spawn('docker', args, { stdio: 'inherit', }); diff --git a/x-pack/test/osquery_cypress/runner.ts b/x-pack/test/osquery_cypress/runner.ts index a72eed0bb8c935..3f4855217de374 100644 --- a/x-pack/test/osquery_cypress/runner.ts +++ b/x-pack/test/osquery_cypress/runner.ts @@ -12,7 +12,10 @@ import { withProcRunner } from '@kbn/dev-utils'; import { FtrProviderContext } from './ftr_provider_context'; -import { AgentManager } from './agent'; +import { + // AgentManager, + AgentManagerParams, +} from './agent'; import { FleetManager } from './fleet_server'; async function withFleetAgent( @@ -23,25 +26,29 @@ async function withFleetAgent( const config = getService('config'); const esHost = Url.format(config.get('servers.elasticsearch')); - const esConfig = { + const params: AgentManagerParams = { user: config.get('servers.elasticsearch.username'), password: config.get('servers.elasticsearch.password'), esHost, - port: config.get('servers.elasticsearch.port'), + esPort: config.get('servers.elasticsearch.port'), + kibanaUrl: Url.format({ + protocol: config.get('servers.kibana.protocol'), + hostname: config.get('servers.kibana.hostname'), + port: config.get('servers.kibana.port'), + }), }; - const fleetManager = new FleetManager(esConfig, log); - - const agentManager = new AgentManager( - { - ...esConfig, - kibanaUrl: Url.format({ - protocol: config.get('servers.kibana.protocol'), - hostname: config.get('servers.kibana.hostname'), - port: config.get('servers.kibana.port'), - }), + const requestOptions = { + headers: { + 'kbn-xsrf': 'kibana', }, - log - ); + auth: { + username: params.user, + password: params.password, + }, + }; + const fleetManager = new FleetManager(params, log, requestOptions); + + // const agentManager = new AgentManager(params, log, requestOptions); // Since the managers will create uncaughtException event handlers we need to exit manually process.on('uncaughtException', (err) => { @@ -50,13 +57,13 @@ async function withFleetAgent( process.exit(1); }); - await agentManager.setup(); + // await agentManager.setup(); await fleetManager.setup(); try { await runner({}); } finally { fleetManager.cleanup(); - agentManager.cleanup(); + // agentManager.cleanup(); } } diff --git a/x-pack/test/osquery_cypress/users.ts b/x-pack/test/osquery_cypress/users.ts index bfe8abfd8452fe..cdeea3ddde1224 100644 --- a/x-pack/test/osquery_cypress/users.ts +++ b/x-pack/test/osquery_cypress/users.ts @@ -5,7 +5,7 @@ * 2.0. */ import axios from 'axios'; -import { ElasticsearchConfig } from './fleet_server'; +import { AgentManagerParams } from './agent'; interface Roles { [roleName: string]: { @@ -83,7 +83,7 @@ export const USERS: Users = { }, }; -export const setupUsers = async (config: ElasticsearchConfig) => { +export const setupUsers = async (config: AgentManagerParams) => { const { esHost, user: username, password } = config; const params = { auth: { username, password }, diff --git a/x-pack/test/reporting_api_integration/reporting_and_security/__snapshots__/event_log.snap b/x-pack/test/reporting_api_integration/reporting_and_security/__snapshots__/event_log.snap new file mode 100644 index 00000000000000..603ab78db8c132 --- /dev/null +++ b/x-pack/test/reporting_api_integration/reporting_and_security/__snapshots__/event_log.snap @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Reporting APIs Report generation event logging creates a completed action for a PDF report 1`] = ` +"\\"_id\\",\\"_index\\",\\"_score\\",category,\\"category.keyword\\",currency,\\"customer_first_name\\",\\"customer_first_name.keyword\\",\\"customer_full_name\\",\\"customer_full_name.keyword\\",\\"customer_gender\\",\\"customer_id\\",\\"customer_last_name\\",\\"customer_last_name.keyword\\",\\"customer_phone\\",\\"day_of_week\\",\\"day_of_week_i\\",email,\\"geoip.city_name\\",\\"geoip.continent_name\\",\\"geoip.country_iso_code\\",\\"geoip.location\\",\\"geoip.region_name\\",manufacturer,\\"manufacturer.keyword\\",\\"order_date\\",\\"order_id\\",\\"products._id\\",\\"products._id.keyword\\",\\"products.base_price\\",\\"products.base_unit_price\\",\\"products.category\\",\\"products.category.keyword\\",\\"products.created_on\\",\\"products.discount_amount\\",\\"products.discount_percentage\\",\\"products.manufacturer\\",\\"products.manufacturer.keyword\\",\\"products.min_price\\",\\"products.price\\",\\"products.product_id\\",\\"products.product_name\\",\\"products.product_name.keyword\\",\\"products.quantity\\",\\"products.sku\\",\\"products.tax_amount\\",\\"products.taxful_price\\",\\"products.taxless_price\\",\\"products.unit_discount_amount\\",sku,\\"taxful_total_price\\",\\"taxless_total_price\\",\\"total_quantity\\",\\"total_unique_products\\",type,user +zQMtOW0BH63Xcmy432DJ,ecommerce,1,\\"Men's Clothing\\",\\"Men's Clothing\\",EUR,Eddie,Eddie,\\"Eddie Underwood\\",\\"Eddie Underwood\\",MALE,38,Underwood,Underwood,\\"(empty)\\",Monday,0,\\"eddie@underwood-family.zzz\\",Cairo,Africa,EG,\\"POINT (31.3 30.1)\\",\\"Cairo Governorate\\",\\"Elitelligence, Oceanavigations\\",\\"Elitelligence, Oceanavigations\\",\\"Jul 7, 2019 @ 00:00:00.000\\",584677,\\"sold_product_584677_6283, sold_product_584677_19400\\",\\"sold_product_584677_6283, sold_product_584677_19400\\",\\"11.992, 24.984\\",\\"11.992, 24.984\\",\\"Men's Clothing, Men's Clothing\\",\\"Men's Clothing, Men's Clothing\\",\\"Dec 26, 2016 @ 00:00:00.000, Dec 26, 2016 @ 00:00:00.000\\",\\"0, 0\\",\\"0, 0\\",\\"Elitelligence, Oceanavigations\\",\\"Elitelligence, Oceanavigations\\",\\"6.352, 11.75\\",\\"11.992, 24.984\\",\\"6,283, 19,400\\",\\"Basic T-shirt - dark blue/white, Sweatshirt - grey multicolor\\",\\"Basic T-shirt - dark blue/white, Sweatshirt - grey multicolor\\",\\"1, 1\\",\\"ZO0549605496, ZO0299602996\\",\\"0, 0\\",\\"11.992, 24.984\\",\\"11.992, 24.984\\",\\"0, 0\\",\\"ZO0549605496, ZO0299602996\\",\\"36.969\\",\\"36.969\\",2,2,order,eddie +zgMtOW0BH63Xcmy432DJ,ecommerce,1,\\"Women's Clothing\\",\\"Women's Clothing\\",EUR,Mary,Mary,\\"Mary Bailey\\",\\"Mary Bailey\\",FEMALE,20,Bailey,Bailey,\\"(empty)\\",Sunday,6,\\"mary@bailey-family.zzz\\",Dubai,Asia,AE,\\"POINT (55.3 25.3)\\",Dubai,\\"Champion Arts, Pyramidustries\\",\\"Champion Arts, Pyramidustries\\",\\"Jul 6, 2019 @ 00:00:00.000\\",584021,\\"sold_product_584021_11238, sold_product_584021_20149\\",\\"sold_product_584021_11238, sold_product_584021_20149\\",\\"24.984, 28.984\\",\\"24.984, 28.984\\",\\"Women's Clothing, Women's Clothing\\",\\"Women's Clothing, Women's Clothing\\",\\"Dec 25, 2016 @ 00:00:00.000, Dec 25, 2016 @ 00:00:00.000\\",\\"0, 0\\",\\"0, 0\\",\\"Champion Arts, Pyramidustries\\",\\"Champion Arts, Pyramidustries\\",\\"11.75, 15.648\\",\\"24.984, 28.984\\",\\"11,238, 20,149\\",\\"Denim dress - black denim, Shorts - black\\",\\"Denim dress - black denim, Shorts - black\\",\\"1, 1\\",\\"ZO0489604896, ZO0185501855\\",\\"0, 0\\",\\"24.984, 28.984\\",\\"24.984, 28.984\\",\\"0, 0\\",\\"ZO0489604896, ZO0185501855\\",\\"53.969\\",\\"53.969\\",2,2,order,mary +zwMtOW0BH63Xcmy432DJ,ecommerce,1,\\"Women's Shoes, Women's Clothing\\",\\"Women's Shoes, Women's Clothing\\",EUR,Gwen,Gwen,\\"Gwen Butler\\",\\"Gwen Butler\\",FEMALE,26,Butler,Butler,\\"(empty)\\",Sunday,6,\\"gwen@butler-family.zzz\\",\\"Los Angeles\\",\\"North America\\",US,\\"POINT (-118.2 34.1)\\",California,\\"Low Tide Media, Oceanavigations\\",\\"Low Tide Media, Oceanavigations\\",\\"Jul 6, 2019 @ 00:00:00.000\\",584058,\\"sold_product_584058_22794, sold_product_584058_23386\\",\\"sold_product_584058_22794, sold_product_584058_23386\\",\\"100, 100\\",\\"100, 100\\",\\"Women's Shoes, Women's Clothing\\",\\"Women's Shoes, Women's Clothing\\",\\"Dec 25, 2016 @ 00:00:00.000, Dec 25, 2016 @ 00:00:00.000\\",\\"0, 0\\",\\"0, 0\\",\\"Low Tide Media, Oceanavigations\\",\\"Low Tide Media, Oceanavigations\\",\\"46, 54\\",\\"100, 100\\",\\"22,794, 23,386\\",\\"Boots - Midnight Blue, Short coat - white/black\\",\\"Boots - Midnight Blue, Short coat - white/black\\",\\"1, 1\\",\\"ZO0374603746, ZO0272202722\\",\\"0, 0\\",\\"100, 100\\",\\"100, 100\\",\\"0, 0\\",\\"ZO0374603746, ZO0272202722\\",200,200,2,2,order,gwen +0AMtOW0BH63Xcmy432DJ,ecommerce,1,\\"Women's Shoes, Women's Clothing\\",\\"Women's Shoes, Women's Clothing\\",EUR,Diane,Diane,\\"Diane Chandler\\",\\"Diane Chandler\\",FEMALE,22,Chandler,Chandler,\\"(empty)\\",Sunday,6,\\"diane@chandler-family.zzz\\",\\"-\\",Europe,GB,\\"POINT (-0.1 51.5)\\",\\"-\\",\\"Primemaster, Oceanavigations\\",\\"Primemaster, Oceanavigations\\",\\"Jul 6, 2019 @ 00:00:00.000\\",584093,\\"sold_product_584093_12304, sold_product_584093_19587\\",\\"sold_product_584093_12304, sold_product_584093_19587\\",\\"75, 100\\",\\"75, 100\\",\\"Women's Shoes, Women's Clothing\\",\\"Women's Shoes, Women's Clothing\\",\\"Dec 25, 2016 @ 00:00:00.000, Dec 25, 2016 @ 00:00:00.000\\",\\"0, 0\\",\\"0, 0\\",\\"Primemaster, Oceanavigations\\",\\"Primemaster, Oceanavigations\\",\\"34.5, 47\\",\\"75, 100\\",\\"12,304, 19,587\\",\\"High heeled sandals - argento, Classic coat - black\\",\\"High heeled sandals - argento, Classic coat - black\\",\\"1, 1\\",\\"ZO0360303603, ZO0272002720\\",\\"0, 0\\",\\"75, 100\\",\\"75, 100\\",\\"0, 0\\",\\"ZO0360303603, ZO0272002720\\",175,175,2,2,order,diane +0QMtOW0BH63Xcmy432DJ,ecommerce,1,\\"Men's Clothing, Men's Accessories\\",\\"Men's Clothing, Men's Accessories\\",EUR,Eddie,Eddie,\\"Eddie Weber\\",\\"Eddie Weber\\",MALE,38,Weber,Weber,\\"(empty)\\",Monday,0,\\"eddie@weber-family.zzz\\",Cairo,Africa,EG,\\"POINT (31.3 30.1)\\",\\"Cairo Governorate\\",Elitelligence,Elitelligence,\\"Jun 30, 2019 @ 00:00:00.000\\",574916,\\"sold_product_574916_11262, sold_product_574916_15713\\",\\"sold_product_574916_11262, sold_product_574916_15713\\",\\"60, 20.984\\",\\"60, 20.984\\",\\"Men's Clothing, Men's Accessories\\",\\"Men's Clothing, Men's Accessories\\",\\"Dec 19, 2016 @ 00:00:00.000, Dec 19, 2016 @ 00:00:00.000\\",\\"0, 0\\",\\"0, 0\\",\\"Elitelligence, Elitelligence\\",\\"Elitelligence, Elitelligence\\",\\"28.203, 10.703\\",\\"60, 20.984\\",\\"11,262, 15,713\\",\\"Winter jacket - black, Watch - green\\",\\"Winter jacket - black, Watch - green\\",\\"1, 1\\",\\"ZO0542505425, ZO0601306013\\",\\"0, 0\\",\\"60, 20.984\\",\\"60, 20.984\\",\\"0, 0\\",\\"ZO0542505425, ZO0601306013\\",81,81,2,2,order,eddie +" +`; diff --git a/x-pack/test/reporting_api_integration/reporting_and_security/event_log.ts b/x-pack/test/reporting_api_integration/reporting_and_security/event_log.ts new file mode 100644 index 00000000000000..d063655180e754 --- /dev/null +++ b/x-pack/test/reporting_api_integration/reporting_and_security/event_log.ts @@ -0,0 +1,87 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { omit } from 'lodash'; +import expect from '@kbn/expect'; +import { FtrProviderContext } from '../ftr_provider_context'; + +// eslint-disable-next-line import/no-default-export +export default function ({ getService }: FtrProviderContext) { + const reportingAPI = getService('reportingAPI'); + const es = getService('es'); + + describe('Report generation event logging', () => { + before(async () => { + await reportingAPI.initEcommerce(); + }); + + after(async () => { + await reportingAPI.teardownEcommerce(); + }); + + it('creates a completed action for a PDF report', async () => { + const res = await reportingAPI.generateCsv({ + browserTimezone: 'UTC', + title: 'Test-PDF', + objectType: 'search', + searchSource: { + version: true, + fields: [{ field: '*', include_unmapped: 'true' }], + index: '5193f870-d861-11e9-a311-0fa548c5f953', + }, + columns: [], + version: '7.16.0', + }); + expect(res.status).to.eql(200); + expect(res.body.path).to.match(/download/); + + const { path } = res.body; + + // wait for the the pending job to complete + await reportingAPI.waitForJobToFinish(path); + + const csvFile = await reportingAPI.getCompletedJobOutput(path); + expectSnapshot(csvFile).toMatch(); + + // search for the raw event log data + const events = await es.search<{ event: any; kibana: { reporting: any } }>({ + index: '.kibana-event-log*', + filter_path: 'hits.hits._source.event,hits.hits._source.kibana', + query: { + bool: { + filter: [ + { + bool: { + must: [ + { term: { 'event.provider': 'reporting' } }, + { term: { 'event.action': 'execute-complete' } }, + ], + }, + }, + ], + }, + }, + sort: [{ '@timestamp': { order: 'desc' } }] as unknown as string[], + size: 1, + }); + + // validate the log has the expected fields with expected values + const logSource = events.hits.hits[0]._source; + expect(omit(logSource?.kibana.reporting, 'id')).to.eql({ + byteSize: 5943, + jobType: 'csv_searchsource', + }); + expect(omit(logSource?.event, ['duration', 'start', 'end'])).to.eql({ + action: 'execute-complete', + kind: 'metrics', + outcome: 'success', + provider: 'reporting', + timezone: 'UTC', + }); + }); + }); +} diff --git a/x-pack/test/reporting_api_integration/reporting_and_security/index.ts b/x-pack/test/reporting_api_integration/reporting_and_security/index.ts index 02a2915fffd604..e2f70eed3a508d 100644 --- a/x-pack/test/reporting_api_integration/reporting_and_security/index.ts +++ b/x-pack/test/reporting_api_integration/reporting_and_security/index.ts @@ -24,6 +24,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./bwc_existing_indexes')); loadTestFile(require.resolve('./security_roles_privileges')); loadTestFile(require.resolve('./download_csv_dashboard')); + loadTestFile(require.resolve('./event_log')); loadTestFile(require.resolve('./generate_csv_discover')); loadTestFile(require.resolve('./network_policy')); loadTestFile(require.resolve('./spaces')); diff --git a/x-pack/test/security_solution_endpoint/services/endpoint_artifacts.ts b/x-pack/test/security_solution_endpoint/services/endpoint_artifacts.ts index d8500ecc3e53bc..f36c59722de771 100644 --- a/x-pack/test/security_solution_endpoint/services/endpoint_artifacts.ts +++ b/x-pack/test/security_solution_endpoint/services/endpoint_artifacts.ts @@ -16,7 +16,7 @@ import { FtrService } from '../../functional/ftr_provider_context'; import { ExceptionsListItemGenerator } from '../../../plugins/security_solution/common/endpoint/data_generators/exceptions_list_item_generator'; import { TRUSTED_APPS_EXCEPTION_LIST_DEFINITION } from '../../../plugins/security_solution/public/management/pages/trusted_apps/constants'; import { EndpointError } from '../../../plugins/security_solution/common/endpoint/errors'; -import { EVENT_FILTER_LIST } from '../../../plugins/security_solution/public/management/pages/event_filters/constants'; +import { EVENT_FILTER_LIST_DEFINITION } from '../../../plugins/security_solution/public/management/pages/event_filters/constants'; import { HOST_ISOLATION_EXCEPTIONS_LIST_DEFINITION } from '../../../plugins/security_solution/public/management/pages/host_isolation_exceptions/constants'; export interface ArtifactTestData { @@ -94,7 +94,7 @@ export class EndpointArtifactsTestResources extends FtrService { async createEventFilter( overrides: Partial = {} ): Promise { - await this.ensureListExists(EVENT_FILTER_LIST); + await this.ensureListExists(EVENT_FILTER_LIST_DEFINITION); const eventFilter = this.exceptionsGenerator.generateEventFilterForCreate(overrides); return this.createExceptionItem(eventFilter); diff --git a/x-pack/test/security_solution_endpoint_api_int/apis/endpoint_artifacts/event_filters.ts b/x-pack/test/security_solution_endpoint_api_int/apis/endpoint_artifacts/event_filters.ts index 019d278481bcf5..8ef3aaf9509ddc 100644 --- a/x-pack/test/security_solution_endpoint_api_int/apis/endpoint_artifacts/event_filters.ts +++ b/x-pack/test/security_solution_endpoint_api_int/apis/endpoint_artifacts/event_filters.ts @@ -71,7 +71,10 @@ export default function ({ getService }: FtrProviderContext) { type UnknownBodyGetter = () => unknown; type PutPostBodyGetter = ( overrides?: Partial - ) => Pick; + ) => Pick< + ExceptionListItemSchema, + 'item_id' | 'namespace_type' | 'os_types' | 'tags' | 'entries' + >; type EventFilterApiCallsInterface = Array<{ method: keyof Pick; @@ -182,6 +185,9 @@ export default function ({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'true') .send(body) .expect(200); + + const deleteUrl = `${EXCEPTION_LIST_ITEM_URL}?item_id=${body.item_id}&namespace_type=${body.namespace_type}`; + await supertest.delete(deleteUrl).set('kbn-xsrf', 'true'); }); } }); diff --git a/x-pack/test/security_solution_endpoint_api_int/apis/endpoint_artifacts/host_isolation_exceptions.ts b/x-pack/test/security_solution_endpoint_api_int/apis/endpoint_artifacts/host_isolation_exceptions.ts index 83235826e4f953..ffa7473e954164 100644 --- a/x-pack/test/security_solution_endpoint_api_int/apis/endpoint_artifacts/host_isolation_exceptions.ts +++ b/x-pack/test/security_solution_endpoint_api_int/apis/endpoint_artifacts/host_isolation_exceptions.ts @@ -62,7 +62,7 @@ export default function ({ getService }: FtrProviderContext) { }; const apiCalls: ApiCallsInterface< - Pick + Pick > = [ { method: 'post', @@ -216,17 +216,9 @@ export default function ({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'true') .send(body) .expect(200); - }); - - it(`[${apiCall.method}] and accept all OSs for os_types`, async () => { - const body = apiCall.getBody(); - - body.os_types = ['linux', 'windows', 'macos']; - await supertest[apiCall.method](apiCall.path) - .set('kbn-xsrf', 'true') - .send(body) - .expect(200); + const deleteUrl = `${EXCEPTION_LIST_ITEM_URL}?item_id=${body.item_id}&namespace_type=${body.namespace_type}`; + await supertest.delete(deleteUrl).set('kbn-xsrf', 'true'); }); } }); @@ -277,23 +269,6 @@ export default function ({ getService }: FtrProviderContext) { }, getBody: () => undefined, }, - { - method: 'post', - info: 'create item', - path: EXCEPTION_LIST_ITEM_URL, - getBody: () => exceptionsGenerator.generateHostIsolationExceptionForCreate(), - }, - { - method: 'put', - info: 'update item', - path: EXCEPTION_LIST_ITEM_URL, - getBody: () => - exceptionsGenerator.generateHostIsolationExceptionForUpdate({ - id: existingExceptionData.artifact.id, - item_id: existingExceptionData.artifact.item_id, - _version: existingExceptionData.artifact._version, - }), - }, ]; for (const apiCall of allApiCalls) { diff --git a/yarn.lock b/yarn.lock index 6e0e20d55a1b19..6595fa5871aa74 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3942,6 +3942,10 @@ version "0.0.0" uid "" +"@kbn/test-jest-helpers@link:bazel-bin/packages/kbn-test-jest-helpers": + version "0.0.0" + uid "" + "@kbn/test-subj-selector@link:bazel-bin/packages/kbn-test-subj-selector": version "0.0.0" uid "" @@ -6898,6 +6902,14 @@ version "0.0.0" uid "" +"@types/kbn__test-jest-helpers@link:bazel-bin/packages/kbn-test-jest-helpers/npm_module_types": + version "0.0.0" + uid "" + +"@types/kbn__test@link:bazel-bin/packages/kbn-test/npm_module_types": + version "0.0.0" + uid "" + "@types/kbn__ui-shared-deps-npm@link:bazel-bin/packages/kbn-ui-shared-deps-npm/npm_module_types": version "0.0.0" uid ""