From 17d6630c54416be970e7a0dfa74d6d8a6d8cd266 Mon Sep 17 00:00:00 2001 From: Anan Date: Wed, 23 Oct 2024 12:20:58 -0700 Subject: [PATCH] Clean query to make the test more robust Signed-off-by: Anan --- .../apps/data_explorer/discover.spec.js | 1 + cypress/utils/dashboards/commands.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover.spec.js index a8b0a349f..3c30216f6 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover.spec.js @@ -86,6 +86,7 @@ describe('discover app', { scrollBehavior: false }, () => { cy.get('[data-test-subj~="filter-key-extension.raw"]').should( 'be.visible' ); + cy.clearTopNavQuery(); }); }); diff --git a/cypress/utils/dashboards/commands.js b/cypress/utils/dashboards/commands.js index 348465b92..bbabd73f1 100644 --- a/cypress/utils/dashboards/commands.js +++ b/cypress/utils/dashboards/commands.js @@ -41,6 +41,22 @@ Cypress.Commands.add('setTopNavQuery', (value, submit = true) => { } }); +Cypress.Commands.add('clearTopNavQuery', (submit = true) => { + const opts = { log: false }; + + Cypress.log({ + name: 'clearTopNavQuery', + displayName: 'clear query', + message: 'clearing query field', + }); + + cy.getElementByTestId('queryInput', opts).clear(opts).blur(opts); + + if (submit) { + cy.updateTopNav(opts); + } +}); + Cypress.Commands.add('setTopNavDate', (start, end, submit = true) => { const opts = { log: false };