From 904282d2f3cb0c6ffd88a27ec7cde262ad818a31 Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Thu, 14 Sep 2023 17:03:45 -0700 Subject: [PATCH] Buffer `waitForLoader` before checking for icon (#857) 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 (cherry picked from commit e7c7e59abefa8d17b9d5ee22b9d7c933fdf7b1ad) --- 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 4dae0d436..14d84624b 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/*/*'",