diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/date_nanos_mixed.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/date_nanos_mixed.spec.js index b56b2ab54..6cc468c6a 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/date_nanos_mixed.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/date_nanos_mixed.spec.js @@ -31,12 +31,12 @@ describe('date_nanos_mixed', () => { }); miscUtils.visitPage('app/data-explorer/discover#/'); cy.waitForLoader(); - cy.switchDiscoverTable('new'); const fromTime = 'Jan 1, 2019 @ 00:00:00.000'; const toTime = 'Jan 1, 2019 @ 23:59:59.999'; cy.setTopNavDate(fromTime, toTime); cy.waitForSearch(); + cy.switchDiscoverTable('new'); }); after(() => { diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/index_pattern_with_encoded_id.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/index_pattern_with_encoded_id.spec.js index 8e4d4766f..d101b2897 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/index_pattern_with_encoded_id.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/index_pattern_with_encoded_id.spec.js @@ -36,8 +36,8 @@ describe('index pattern with encoded id', () => { // Go to the Discover page miscUtils.visitPage('app/data-explorer/discover#/'); - cy.switchDiscoverTable('new'); cy.setTopNavDate(DE_DEFAULT_START_TIME, DE_DEFAULT_END_TIME); + cy.switchDiscoverTable('new'); cy.waitForLoader(); }); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/index_pattern_without_field.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/index_pattern_without_field.spec.js index 5eeb2a57e..bc09964e2 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/index_pattern_without_field.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/index_pattern_without_field.spec.js @@ -33,7 +33,6 @@ describe('index pattern without field spec', () => { // Go to the Discover page miscUtils.visitPage('app/data-explorer/discover#/'); cy.waitForLoader(); - cy.switchDiscoverTable('new'); }); after(() => { @@ -50,7 +49,6 @@ describe('index pattern without field spec', () => { it('should display a timepicker after switching to an index pattern with timefield', () => { const indexName = 'with-timefield'; - cy.switchDiscoverTable('new'); cy.getElementByTestId('comboBoxToggleListButton') .should('be.visible') .click(); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/saved_queries.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/saved_queries.spec.js index f6b5bf711..315e10f31 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/saved_queries.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/saved_queries.spec.js @@ -51,10 +51,10 @@ describe.skip('saved queries saved objects', () => { // Go to the Discover page miscUtils.visitPage('app/data-explorer/discover#/'); cy.waitForLoader(); - cy.switchDiscoverTable('new'); // Set time filter cy.setTopNavDate(fromTime, toTime); + cy.switchDiscoverTable('new'); // Set up query and filter cy.setTopNavQuery('response:200'); diff --git a/cypress/utils/dashboards/data_explorer/commands.js b/cypress/utils/dashboards/data_explorer/commands.js index 1e21397dd..5ff2f0141 100644 --- a/cypress/utils/dashboards/data_explorer/commands.js +++ b/cypress/utils/dashboards/data_explorer/commands.js @@ -136,19 +136,21 @@ Cypress.Commands.add('deleteSaveQuery', (name) => { Cypress.Commands.add('switchDiscoverTable', (name) => { cy.getElementByTestId('discoverOptionsButton') - .then(async ($button) => { - await 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' && !isLegacyChecked) { - cy.wrap(switchButton).click(); - } - cy.waitForLoader(); + .then(($button) => { + cy.wrap($button).click(); + + cy.getElementByTestId('discoverOptionsLegacySwitch').then( + ($switchButton) => { + const isLegacyChecked = $switchButton.checked; + if (name === 'new' && isLegacyChecked) { + cy.wrap($switchButton).click(); + } + if (name === 'legacy' && !isLegacyChecked) { + cy.wrap($switchButton).click(); + } + cy.waitForLoader(); + } + ); }) .then(() => { checkForElementVisibility();