From cdbb3a1501732e01971c7855f82d8adf3eb86f4b Mon Sep 17 00:00:00 2001 From: Kaituo Li Date: Thu, 2 May 2024 14:06:32 -0700 Subject: [PATCH] Reintroduce 2-second delay to fix Cypress test failures (#1261) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [PR 1038](https://github.com/opensearch-project/opensearch-dashboards-functional-test/pull/1038/files) removed a 2-second delay in `cypress/utils/dashboards/vis-augmenter/commands.js`, which was intended to allow UI elements to render fully before interactions in Cypress tests. This removal led to test failures due to timing issues when typing in the dashboard name during the test execution. Specifically, the error encountered was a `TypeError` related to the `KeyboardEvent`, indicating that the expected input element was not ready at the time of interaction. Example error trace: ``` 1) Anomaly detection integration with vis augmenter Associate existing detector - creation flow: TypeError: Cannot read properties of undefined (reading 'KeyboardEvent') at Keyboard.fireSimulatedEvent (http://localhost:5601/__cypress/runner/cypress_runner.js:165273:28) at Keyboard.simulatedKeydown (http://localhost:5601/__cypress/runner/cypress_runner.js:165418:58) at Keyboard.typeSimulatedKey (http://localhost:5601/__cypress/runner/cypress_runner.js:165458:10) at http://localhost:5601/__cypress/runner/cypress_runner.js:165128:14 at tryCatcher (http://localhost:5601/__cypress/runner/cypress_runner.js:13022:23) at Function.Promise.attempt.Promise.try (http://localhost:5601/__cypress/runner/cypress_runner.js:10296:29) at http://localhost:5601/__cypress/runner/cypress_runner.js:165138:67 at tryCatcher (http://localhost:5601/__cypress/runner/cypress_runner.js:13022:23) at Object.gotValue (http://localhost:5601/__cypress/runner/cypress_runner.js:12164:18) at Object.gotAccum (http://localhost:5601/__cypress/runner/cypress_runner.js:12153:25) at Object.tryCatcher (http://localhost:5601/__cypress/runner/cypress_runner.js:13022:23) at Promise._settlePromiseFromHandler (http://localhost:5601/__cypress/runner/cypress_runner.js:10957:31) at Promise._settlePromise (http://localhost:5601/__cypress/runner/cypress_runner.js:11014:18) at Promise._settlePromise0 (http://localhost:5601/__cypress/runner/cypress_runner.js:11059:10) at Promise._settlePromises (http://localhost:5601/__cypress/runner/cypress_runner.js:11139:18) at Promise._fulfill (http://localhost:5601/__cypress/runner/cypress_runner.js:11083:18) ``` The test failures were observed in the ad anywhere related tests. CI Failure Details: https://github.com/opensearch-project/anomaly-detection-dashboards-plugin/actions/runs/8916683824/job/24488529476 This PR reinstates the 2-second wait, resolving the timing issue and ensuring that the necessary DOM elements are fully loaded before proceeding with the tests. **Testing Done:** 1. Confirmed that all related tests, including those in `ad anywhere`, now pass with the reintroduction of the delay. ``` (Run Finished) Spec Tests Passing Failing Pending Skipped ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ │ ✔ plugins/anomaly-detection-dashboard 05:23 5 5 - - - │ │ s-plugin/vis_augmenter/associate_de │ │ tector_spec.js │ ├────────────────────────────────────────────────────────────────────────────────────────────────┤ │ ✔ plugins/anomaly-detection-dashboard 02:00 3 3 - - - │ │ s-plugin/vis_augmenter/augment_vis_ │ │ saved_object_spec.js │ ├────────────────────────────────────────────────────────────────────────────────────────────────┤ │ ✔ plugins/anomaly-detection-dashboard 02:12 4 4 - - - │ │ s-plugin/vis_augmenter/view_anomaly │ │ _events_spec.js │ └────────────────────────────────────────────────────────────────────────────────────────────────┘ ✔ All specs passed! 09:35 12 12 - - - ``` Signed-off-by: Kaituo Li --- cypress/utils/dashboards/vis-augmenter/commands.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cypress/utils/dashboards/vis-augmenter/commands.js b/cypress/utils/dashboards/vis-augmenter/commands.js index 28d3b57e0..a476fdfc3 100644 --- a/cypress/utils/dashboards/vis-augmenter/commands.js +++ b/cypress/utils/dashboards/vis-augmenter/commands.js @@ -35,6 +35,7 @@ Cypress.Commands.add('visitDashboard', (dashboardName) => { cy.intercept('/api/saved_objects/_find*').as('loadDashboards'); cy.visit(`${BASE_PATH}/app/dashboards`); cy.wait('@loadDashboards', { timeout: 300000 }); + cy.wait(2000); cy.get('.euiFieldSearch').type(dashboardName); cy.wait(2000); cy.get('[data-test-subj="itemsInMemTable"]').contains(dashboardName).click({