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 c3b3be129..97f5a2623 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 @@ -37,6 +37,12 @@ describe('date_nanos_mixed', () => { cy.waitForSearch(); }); + after(() => { + testFixtureHandler.clearJSONMapping( + 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/date_nanos_mix/mappings.json.txt' + ); + }); + it('shows a list of records of indices with date & date_nanos fields in the right order', function () { cy.get(`[data-test-subj="dataGridRowCell"]`) .eq(1) 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 981e980c0..93992b256 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 @@ -20,7 +20,6 @@ const testFixtureHandler = new TestFixtureHandler( describe('discover app', () => { before(() => { - cy.log('load opensearch-dashboards index with default index pattern'); testFixtureHandler.importJSONMapping( 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/discover/discover.mappings.json.txt' ); 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 c49f93eee..a12446187 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 @@ -3,18 +3,41 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; +import { + TestFixtureHandler, + MiscUtils, +} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; import { DX_DEFAULT_END_TIME, DX_DEFAULT_START_TIME, } from '../../../../../utils/constants'; const miscUtils = new MiscUtils(cy); +const testFixtureHandler = new TestFixtureHandler( + cy, + Cypress.env('openSearchUrl') +); describe('saved queries saved objects', () => { const fromTime = 'Sep 20, 2015 @ 08:00:00.000'; const toTime = 'Sep 21, 2015 @ 08:00:00.000'; before(() => { + testFixtureHandler.importJSONMapping( + 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/discover/discover.mappings.json.txt' + ); + + testFixtureHandler.importJSONDoc( + 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/discover/discover.json.txt' + ); + + testFixtureHandler.importJSONMapping( + 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.mappings.json.txt' + ); + + testFixtureHandler.importJSONDoc( + 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.json.txt' + ); + cy.setAdvancedSetting({ defaultIndex: 'logstash-*', }); @@ -98,26 +121,22 @@ describe('saved queries saved objects', () => { cy.getElementByTestId(`queryInput`).should('have.text', ''); - cy.loadSaveQuery('OkResponse'); - - cy.getElementByTestId(`queryInput`).should( - 'have.text', + cy.get(`[data-test-subj~="load-saved-query-OkResponse-button"]`) + .should('be.visible') + .click(); - 'response:404' - ); + cy.getElementByTestId(`queryInput`).should('have.text', 'response:404'); }); it('allows saving the currently loaded query as a new query', () => { - cy.whenTestIdNotFound('saved-query-management-popover', () => { - cy.getElementByTestId('saved-query-management-popover-button').click(); - }); + cy.getElementByTestId('saved-query-management-popover-button').click(); + //save as new query cy.getElementByTestId( 'saved-query-management-save-as-new-button' ).click(); cy.getElementByTestId('saveQueryFormTitle').type('OkResponseCopy'); cy.getElementByTestId('savedQueryFormSaveButton').click(); - cy.loadSaveQuery('OkResponseCopy'); }); it('allows deleting the currently loaded saved query in the saved query management component and clears the query', () => { @@ -140,6 +159,7 @@ describe('saved queries saved objects', () => { cy.getElementByTestId('saveQueryForm') .get('.euiForm__error') .should('have.text', 'Name conflicts with an existing saved query'); + cy.getElementByTestId('savedQueryFormCancelButton').click(); }); it('resets any changes to a loaded query on reloading the same saved query', () => { @@ -150,13 +170,17 @@ describe('saved queries saved objects', () => { }); it('allows clearing the currently loaded saved query', () => { - cy.loadSaveQuery('OkResponse'); - cy.clearSaveQuery(); + cy.getElementByTestId('saved-query-management-popover-button').click({ + force: true, + }); + cy.getElementByTestId('saved-query-management-clear-button').click(); cy.getElementByTestId(`queryInput`).should('have.text', ''); }); it('changing language removes saved query', () => { - cy.loadSaveQuery('OkResponse'); + cy.get(`[data-test-subj~="load-saved-query-OkResponse-button"]`) + .should('be.visible') + .click(); cy.getElementByTestId('switchQueryLanguageButton').click(); cy.getElementByTestId('languageToggle').click(); cy.getElementByTestId(`queryInput`).should('have.text', ''); diff --git a/cypress/utils/dashboards/data_explorer/commands.js b/cypress/utils/dashboards/data_explorer/commands.js index 867dc8224..83574d317 100644 --- a/cypress/utils/dashboards/data_explorer/commands.js +++ b/cypress/utils/dashboards/data_explorer/commands.js @@ -115,9 +115,10 @@ Cypress.Commands.add('saveQuery', (name, description) => { }); Cypress.Commands.add('loadSaveQuery', (name) => { - cy.whenTestIdNotFound('saved-query-management-popover', () => { - cy.getElementByTestId('saved-query-management-popover-button').click(); + cy.getElementByTestId('saved-query-management-popover-button').click({ + force: true, }); + cy.get(`[data-test-subj~="load-saved-query-${name}-button"]`) .should('be.visible') .click(); @@ -134,8 +135,8 @@ Cypress.Commands.add('clearSaveQuery', () => { Cypress.Commands.add('deleteSaveQuery', (name) => { cy.getElementByTestId('saved-query-management-popover-button').click(); - cy.get(`[data-test-subj~="delete-saved-query-${name}-button"]`) - .should('be.visible') - .click(); + cy.get(`[data-test-subj~="delete-saved-query-${name}-button"]`).click({ + force: true, + }); cy.getElementByTestId('confirmModalConfirmButton').click(); });