From ad4239a7136ee49645edad4a391483635fa316bd Mon Sep 17 00:00:00 2001 From: Junqiu Lei Date: Fri, 2 Feb 2024 01:50:25 -0800 Subject: [PATCH] Enable run maps tests when security enabled (#1044) * Enable run maps tests when security enabled Signed-off-by: Junqiu Lei * Fix test order by adding files name with number Signed-off-by: Junqiu Lei * Update maps-dashboards CI workflow Signed-off-by: Junqiu Lei --------- Signed-off-by: Junqiu Lei --- ...rt-map-dashboards-release-e2e-workflow.yml | 4 +- ...pec.js => 1_import_vector_map_tab.spec.js} | 0 .../2_opensearchMapLayer.spec.js | 53 +++++++++++ .../3_add_saved_object.spec.js | 39 +++++++++ .../4_documentsLayer.spec.js | 83 ++++++++++++++++++ .../add_saved_object.spec.js | 41 --------- .../documentsLayer.spec.js | 87 ------------------- .../opensearchMapLayer.spec.js | 55 ------------ 8 files changed, 177 insertions(+), 185 deletions(-) rename cypress/integration/plugins/custom-import-map-dashboards/{import_vector_map_tab.spec.js => 1_import_vector_map_tab.spec.js} (100%) create mode 100644 cypress/integration/plugins/custom-import-map-dashboards/2_opensearchMapLayer.spec.js create mode 100644 cypress/integration/plugins/custom-import-map-dashboards/3_add_saved_object.spec.js create mode 100644 cypress/integration/plugins/custom-import-map-dashboards/4_documentsLayer.spec.js delete mode 100644 cypress/integration/plugins/custom-import-map-dashboards/add_saved_object.spec.js delete mode 100644 cypress/integration/plugins/custom-import-map-dashboards/documentsLayer.spec.js delete mode 100644 cypress/integration/plugins/custom-import-map-dashboards/opensearchMapLayer.spec.js diff --git a/.github/workflows/custom-import-map-dashboards-release-e2e-workflow.yml b/.github/workflows/custom-import-map-dashboards-release-e2e-workflow.yml index 0bf7fa279..df00b9c2e 100644 --- a/.github/workflows/custom-import-map-dashboards-release-e2e-workflow.yml +++ b/.github/workflows/custom-import-map-dashboards-release-e2e-workflow.yml @@ -20,5 +20,5 @@ jobs: if: ${{ needs.changes.outputs.tests == 'true' }} uses: ./.github/workflows/release-e2e-workflow-template.yml with: - test-name: Observability - test-command: yarn cypress:run-with-security --browser chromium --spec 'cypress/integration/plugins/custom-import-map-dashboards/*' + test-name: Maps Dashboards + test-command: yarn cypress:run-with-security --browser electron --spec 'cypress/integration/plugins/custom-import-map-dashboards/*' diff --git a/cypress/integration/plugins/custom-import-map-dashboards/import_vector_map_tab.spec.js b/cypress/integration/plugins/custom-import-map-dashboards/1_import_vector_map_tab.spec.js similarity index 100% rename from cypress/integration/plugins/custom-import-map-dashboards/import_vector_map_tab.spec.js rename to cypress/integration/plugins/custom-import-map-dashboards/1_import_vector_map_tab.spec.js diff --git a/cypress/integration/plugins/custom-import-map-dashboards/2_opensearchMapLayer.spec.js b/cypress/integration/plugins/custom-import-map-dashboards/2_opensearchMapLayer.spec.js new file mode 100644 index 000000000..2435691aa --- /dev/null +++ b/cypress/integration/plugins/custom-import-map-dashboards/2_opensearchMapLayer.spec.js @@ -0,0 +1,53 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { BASE_PATH } from '../../../utils/constants'; + +describe('Default OpenSearch base map layer', () => { + before(() => { + cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`, { + retryOnStatusCodeFailure: true, + timeout: 60000, + }); + cy.get('div[data-test-subj="sampleDataSetCardflights"]', { + timeout: 60000, + }) + .contains(/(Add|View) data/) + .click(); + cy.wait(60000); + }); + + it('check if default OpenSearch map layer can be open', () => { + cy.visit(`${BASE_PATH}/app/maps-dashboards`); + cy.contains('Create map').click(); + cy.get('[data-test-subj="layerControlPanel"]').should( + 'contain', + 'Default map' + ); + cy.get('canvas.maplibregl-canvas').trigger('mousemove', { + x: 100, + y: 100, + force: true, + }); + cy.get('canvas.maplibregl-canvas').trigger('mousemove', { + x: 200, + y: 200, + force: true, + }); + for (let i = 0; i < 21; i++) { + cy.wait(1000) + .get('canvas.maplibregl-canvas') + .trigger('dblclick', { force: true }); + } + cy.get('[data-test-subj="mapStatusBar"]').should('contain', 'zoom: 22'); + }); + + after(() => { + cy.visit(`${BASE_PATH}/app/home#/tutorial_directory`); + cy.get('button[data-test-subj="removeSampleDataSetflights"]') + .should('be.visible') + .click(); + }); +}); diff --git a/cypress/integration/plugins/custom-import-map-dashboards/3_add_saved_object.spec.js b/cypress/integration/plugins/custom-import-map-dashboards/3_add_saved_object.spec.js new file mode 100644 index 000000000..fc448a292 --- /dev/null +++ b/cypress/integration/plugins/custom-import-map-dashboards/3_add_saved_object.spec.js @@ -0,0 +1,39 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { BASE_PATH } from '../../../utils/constants'; + +describe('Add flights dataset saved object', () => { + before(() => { + cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`, { + retryOnStatusCodeFailure: true, + timeout: 60000, + }); + cy.get('div[data-test-subj="sampleDataSetCardflights"]', { + timeout: 60000, + }) + .contains(/Add data/) + .click(); + cy.wait(60000); + }); + + after(() => { + cy.visit(`${BASE_PATH}/app/home#/tutorial_directory`); + cy.get('button[data-test-subj="removeSampleDataSetflights"]') + .should('be.visible') + .click(); + }); + + it('check if maps saved object of flights dataset can be found and open', () => { + cy.visit(`${BASE_PATH}/app/maps-dashboards`); + cy.contains( + '[Flights] Flights Status on Maps Destination Location' + ).click(); + cy.get('[data-test-subj="layerControlPanel"]').should( + 'contain', + 'Flights On Time' + ); + }); +}); diff --git a/cypress/integration/plugins/custom-import-map-dashboards/4_documentsLayer.spec.js b/cypress/integration/plugins/custom-import-map-dashboards/4_documentsLayer.spec.js new file mode 100644 index 000000000..ce677b147 --- /dev/null +++ b/cypress/integration/plugins/custom-import-map-dashboards/4_documentsLayer.spec.js @@ -0,0 +1,83 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { BASE_PATH } from '../../../utils/constants'; + +describe('Documents layer', () => { + before(() => { + cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`, { + retryOnStatusCodeFailure: true, + timeout: 60000, + }); + cy.get('div[data-test-subj="sampleDataSetCardflights"]', { + timeout: 60000, + }) + .contains(/(Add|View) data/) + .click(); + cy.wait(60000); + }); + + const uniqueName = 'saved-map-' + Date.now().toString(); + + it('Add new documents layer with configuration', () => { + cy.visit(`${BASE_PATH}/app/maps-dashboards`); + cy.contains('Create map').click(); + cy.get("button[data-test-subj='addLayerButton']").click(); + cy.contains('Documents').click(); + cy.contains('Select data source', { timeout: 60000 }).click({ + force: true, + }); + cy.wait(5000).contains('opensearch_dashboards_sample_data_flights').click(); + cy.contains('Select data field', { timeout: 60000 }).click({ + force: true, + }); + cy.wait(5000).contains('DestLocation').click(); + cy.get('[data-test-subj="indexPatternSelect"]').should( + 'contain', + 'opensearch_dashboards_sample_data_flights' + ); + cy.get('[data-test-subj="geoFieldSelect"]').should( + 'contain', + 'DestLocation' + ); + cy.get(`button[testSubj="styleTab"]`).click(); + cy.contains('Fill color').click(); + cy.get(`button[aria-label="Select #E7664C as the color"]`).click(); + cy.wait(1000).contains('Border color').click(); + cy.get(`button[aria-label="Select #DA8B45 as the color"]`).click(); + cy.wait(1000).get(`button[testSubj="settingsTab"]`).click(); + cy.get('[name="layerName"]').clear().type('Documents layer 1'); + cy.get(`button[data-test-subj="updateButton"]`).click(); + cy.get('[data-test-subj="layerControlPanel"]').should( + 'contain', + 'Documents layer 1' + ); + cy.wait(5000).get('[data-test-subj="top-nav"]').click(); + cy.wait(5000).get('[data-test-subj="savedObjectTitle"]').type(uniqueName); + cy.wait(5000) + .get('[data-test-subj="confirmSaveSavedObjectButton"]') + .click(); + cy.wait(5000) + .get('[data-test-subj="breadcrumb last"]') + .should('contain', uniqueName); + }); + + it('Open saved map with documents layer', () => { + cy.visit(`${BASE_PATH}/app/maps-dashboards`); + cy.get('[data-test-subj="mapListingPage"]').should('contain', uniqueName); + cy.contains(uniqueName).click(); + cy.get('[data-test-subj="layerControlPanel"]').should( + 'contain', + 'Documents layer 1' + ); + }); + + after(() => { + cy.visit(`${BASE_PATH}/app/home#/tutorial_directory`); + cy.get('button[data-test-subj="removeSampleDataSetflights"]') + .should('be.visible') + .click(); + }); +}); diff --git a/cypress/integration/plugins/custom-import-map-dashboards/add_saved_object.spec.js b/cypress/integration/plugins/custom-import-map-dashboards/add_saved_object.spec.js deleted file mode 100644 index 19eb060db..000000000 --- a/cypress/integration/plugins/custom-import-map-dashboards/add_saved_object.spec.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { BASE_PATH } from '../../../utils/constants'; - -if (!Cypress.env('SECURITY_ENABLED')) { - describe('Add flights dataset saved object', () => { - before(() => { - cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`, { - retryOnStatusCodeFailure: true, - timeout: 60000, - }); - cy.get('div[data-test-subj="sampleDataSetCardflights"]', { - timeout: 60000, - }) - .contains(/Add data/) - .click(); - cy.wait(60000); - }); - - after(() => { - cy.visit(`${BASE_PATH}/app/home#/tutorial_directory`); - cy.get('button[data-test-subj="removeSampleDataSetflights"]') - .should('be.visible') - .click(); - }); - - it('check if maps saved object of flights dataset can be found and open', () => { - cy.visit(`${BASE_PATH}/app/maps-dashboards`); - cy.contains( - '[Flights] Flights Status on Maps Destination Location' - ).click(); - cy.get('[data-test-subj="layerControlPanel"]').should( - 'contain', - 'Flights On Time' - ); - }); - }); -} diff --git a/cypress/integration/plugins/custom-import-map-dashboards/documentsLayer.spec.js b/cypress/integration/plugins/custom-import-map-dashboards/documentsLayer.spec.js deleted file mode 100644 index 34ed57287..000000000 --- a/cypress/integration/plugins/custom-import-map-dashboards/documentsLayer.spec.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { BASE_PATH } from '../../../utils/constants'; - -if (!Cypress.env('SECURITY_ENABLED')) { - describe('Documents layer', () => { - before(() => { - cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`, { - retryOnStatusCodeFailure: true, - timeout: 60000, - }); - cy.get('div[data-test-subj="sampleDataSetCardflights"]', { - timeout: 60000, - }) - .contains(/(Add|View) data/) - .click(); - cy.wait(60000); - }); - - const uniqueName = 'saved-map-' + Date.now().toString(); - - it('Add new documents layer with configuration', () => { - cy.visit(`${BASE_PATH}/app/maps-dashboards`); - cy.contains('Create map').click(); - cy.get("button[data-test-subj='addLayerButton']").click(); - cy.contains('Documents').click(); - cy.contains('Select data source', { timeout: 60000 }).click({ - force: true, - }); - cy.wait(5000) - .contains('opensearch_dashboards_sample_data_flights') - .click(); - cy.contains('Select data field', { timeout: 60000 }).click({ - force: true, - }); - cy.wait(5000).contains('DestLocation').click(); - cy.get('[data-test-subj="indexPatternSelect"]').should( - 'contain', - 'opensearch_dashboards_sample_data_flights' - ); - cy.get('[data-test-subj="geoFieldSelect"]').should( - 'contain', - 'DestLocation' - ); - cy.get(`button[testSubj="styleTab"]`).click(); - cy.contains('Fill color').click(); - cy.get(`button[aria-label="Select #E7664C as the color"]`).click(); - cy.wait(1000).contains('Border color').click(); - cy.get(`button[aria-label="Select #DA8B45 as the color"]`).click(); - cy.wait(1000).get(`button[testSubj="settingsTab"]`).click(); - cy.get('[name="layerName"]').clear().type('Documents layer 1'); - cy.get(`button[data-test-subj="updateButton"]`).click(); - cy.get('[data-test-subj="layerControlPanel"]').should( - 'contain', - 'Documents layer 1' - ); - cy.wait(5000).get('[data-test-subj="top-nav"]').click(); - cy.wait(5000).get('[data-test-subj="savedObjectTitle"]').type(uniqueName); - cy.wait(5000) - .get('[data-test-subj="confirmSaveSavedObjectButton"]') - .click(); - cy.wait(5000) - .get('[data-test-subj="breadcrumb last"]') - .should('contain', uniqueName); - }); - - it('Open saved map with documents layer', () => { - cy.visit(`${BASE_PATH}/app/maps-dashboards`); - cy.get('[data-test-subj="mapListingPage"]').should('contain', uniqueName); - cy.contains(uniqueName).click(); - cy.get('[data-test-subj="layerControlPanel"]').should( - 'contain', - 'Documents layer 1' - ); - }); - - after(() => { - cy.visit(`${BASE_PATH}/app/home#/tutorial_directory`); - cy.get('button[data-test-subj="removeSampleDataSetflights"]') - .should('be.visible') - .click(); - }); - }); -} diff --git a/cypress/integration/plugins/custom-import-map-dashboards/opensearchMapLayer.spec.js b/cypress/integration/plugins/custom-import-map-dashboards/opensearchMapLayer.spec.js deleted file mode 100644 index f27ea1829..000000000 --- a/cypress/integration/plugins/custom-import-map-dashboards/opensearchMapLayer.spec.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { BASE_PATH } from '../../../utils/constants'; - -if (!Cypress.env('SECURITY_ENABLED')) { - describe('Default OpenSearch base map layer', () => { - before(() => { - cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`, { - retryOnStatusCodeFailure: true, - timeout: 60000, - }); - cy.get('div[data-test-subj="sampleDataSetCardflights"]', { - timeout: 60000, - }) - .contains(/(Add|View) data/) - .click(); - cy.wait(60000); - }); - - it('check if default OpenSearch map layer can be open', () => { - cy.visit(`${BASE_PATH}/app/maps-dashboards`); - cy.contains('Create map').click(); - cy.get('[data-test-subj="layerControlPanel"]').should( - 'contain', - 'Default map' - ); - cy.get('canvas.maplibregl-canvas').trigger('mousemove', { - x: 100, - y: 100, - force: true, - }); - cy.get('canvas.maplibregl-canvas').trigger('mousemove', { - x: 200, - y: 200, - force: true, - }); - for (let i = 0; i < 21; i++) { - cy.wait(1000) - .get('canvas.maplibregl-canvas') - .trigger('dblclick', { force: true }); - } - cy.get('[data-test-subj="mapStatusBar"]').should('contain', 'zoom: 22'); - }); - - after(() => { - cy.visit(`${BASE_PATH}/app/home#/tutorial_directory`); - cy.get('button[data-test-subj="removeSampleDataSetflights"]') - .should('be.visible') - .click(); - }); - }); -}