From cac703169f14c4807d06fc258e5626acc564bf53 Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Sat, 16 Mar 2024 00:59:02 -0700 Subject: [PATCH] [Discover] toggle for legacy mode Signed-off-by: Kawika Avilla --- .../utils/dashboards/data_explorer/commands.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cypress/utils/dashboards/data_explorer/commands.js b/cypress/utils/dashboards/data_explorer/commands.js index 8170089d6..1e21397dd 100644 --- a/cypress/utils/dashboards/data_explorer/commands.js +++ b/cypress/utils/dashboards/data_explorer/commands.js @@ -135,15 +135,18 @@ Cypress.Commands.add('deleteSaveQuery', (name) => { }); Cypress.Commands.add('switchDiscoverTable', (name) => { - cy.getElementByTestId('datagridTableButton') - .then(($button) => { - const buttonText = $button.text(); + cy.getElementByTestId('discoverOptionsButton') + .then(async ($button) => { + await cy.wrap($button).click(); - if (name === 'new' && buttonText.includes('Try new Discover')) { - cy.wrap($button).click(); + const switchButton = await cy.getElementByTestId('discoverOptionsLegacySwitch'); + const isLegacyChecked = (await cy.wrap(switchButton).getAttribute('aria-checked')) === 'true'; + + if (name === 'new' && isLegacyChecked) { + cy.wrap(switchButton).click(); } - if (name === 'legacy' && buttonText.includes('Use legacy Discover')) { - cy.wrap($button).click(); + if (name === 'legacy' && !isLegacyChecked) { + cy.wrap(switchButton).click(); } cy.waitForLoader(); })