From 559ae534a1222c0152a433a368a945bf028a25f0 Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Thu, 14 Sep 2023 23:49:57 +0000 Subject: [PATCH] Buffer `waitForLoader` before checking for icon Some async calls occur after navigating and sometimes navigating too quickly prevents the calls from having correct data and therefore the homeIcon is in a bad state. This adds the ability to buffer before checking for the homeIcon. Defaulted to 0 ms, but for `yarn cypress:run-with-security` configures WAIT_FOR_LOADER_BUFFER_MS to be 500 ms Issue resolved: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/5028 Signed-off-by: Kawika Avilla --- cypress.json | 3 ++- cypress/utils/dashboards/commands.js | 2 +- package.json | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cypress.json b/cypress.json index f048c8e2f..f79ebf340 100644 --- a/cypress.json +++ b/cypress.json @@ -19,6 +19,7 @@ "MANAGED_SERVICE_ENDPOINT": false, "VISBUILDER_ENABLED": true, "DATASOURCE_MANAGEMENT_ENABLED": false, - "ML_COMMONS_DASHBOARDS_ENABLED": true + "ML_COMMONS_DASHBOARDS_ENABLED": true, + "WAIT_FOR_LOADER_BUFFER_MS": 0 } } diff --git a/cypress/utils/dashboards/commands.js b/cypress/utils/dashboards/commands.js index 1d2188c4f..dd1f5d024 100644 --- a/cypress/utils/dashboards/commands.js +++ b/cypress/utils/dashboards/commands.js @@ -15,7 +15,7 @@ Cypress.Commands.add('waitForLoader', () => { displayName: 'wait', message: 'page load', }); - + cy.wait(Cypress.env('WAIT_FOR_LOADER_BUFFER_MS')); cy.getElementByTestId('homeIcon', opts); // Update to `homeLoader` once useExpandedHeader is enabled }); diff --git a/package.json b/package.json index bd3626e53..5608b16c3 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,8 @@ "test": "echo \"Error: no test specified\" && exit 1", "cypress:open": "cypress open", "cypress:run-without-security": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --headless --env SECURITY_ENABLED=false", - "cypress:run-with-security": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --headless --env SECURITY_ENABLED=true,openSearchUrl=https://localhost:9200", - "cypress:run-with-security-and-aggregation-view": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --headless --env SECURITY_ENABLED=true,openSearchUrl=https://localhost:9200,AGGREGATION_VIEW=true", + "cypress:run-with-security": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --headless --env SECURITY_ENABLED=true,openSearchUrl=https://localhost:9200,WAIT_FOR_LOADER_BUFFER_MS=500", + "cypress:run-with-security-and-aggregation-view": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --headless --env SECURITY_ENABLED=true,openSearchUrl=https://localhost:9200,AGGREGATION_VIEW=true,WAIT_FOR_LOADER_BUFFER_MS=500", "cypress:run-plugin-tests-without-security": "yarn cypress:run-without-security --spec 'cypress/integration/plugins/*/*.js'", "cypress:run-plugin-tests-with-security": "yarn cypress:run-with-security --spec 'cypress/integration/plugins/*/*.js'", "cypress:release-chrome": "yarn cypress:run-with-security --browser chrome --spec 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/*.js,cypress/integration/plugins/*/*'",