From f634862fa9bc6dc2e22adbedde2b5c700840b953 Mon Sep 17 00:00:00 2001 From: Anan Zhuang Date: Fri, 25 Oct 2024 00:42:14 -0700 Subject: [PATCH] Clean query to make the test more robust (#1601) Signed-off-by: Anan (cherry picked from commit 0cca77b24165610cc09c5ee32aa68d1221bef3a0) --- .../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 };