From dd67fabfbb40a9c382038122f07ce0e95f263cb9 Mon Sep 17 00:00:00 2001 From: Anan Zhuang Date: Tue, 2 Nov 2021 06:20:05 +0000 Subject: [PATCH] Add more bwc tests for osd with bundles This PR adds the following bwc tests: 1)verify sample data work properly for bwc 2)verify timeline visualization work properly for bwc add more commands check in check_timeline and rename sample data check minimize the login time and make the tests more robust change query content to make bwc test more robust update license header solve timestamp issue fix comments and eslint Partically Resolved: https://github.com/opensearch-project/opensearch-build/issues/705 Signed-off-by: Anan Zhuang --- .../osd-bundle/check_loaded_data.js | 90 +++++++++++++++++ .../integration/osd-bundle/check_timeline.js | 99 +++++++++++++++++++ 2 files changed, 189 insertions(+) create mode 100644 cypress/integration/osd-bundle/check_loaded_data.js create mode 100644 cypress/integration/osd-bundle/check_timeline.js diff --git a/cypress/integration/osd-bundle/check_loaded_data.js b/cypress/integration/osd-bundle/check_loaded_data.js new file mode 100644 index 000000000000..34f0ac545688 --- /dev/null +++ b/cypress/integration/osd-bundle/check_loaded_data.js @@ -0,0 +1,90 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* eslint-disable */ +import { MiscUtils, CommonUI, LoginPage } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; + +const miscUtils = new MiscUtils(cy); +const commonUI = new CommonUI(cy); +const loginPage = new LoginPage(cy); + +describe('check previously loaded data', () => { + beforeEach(() => { + miscUtils.visitPage('app/dashboards#'); + loginPage.enterUserName('admin'); + loginPage.enterPassword('admin'); + loginPage.submit(); + }); + + afterEach(() => { + cy.clearCookies(); + }); + + it('previous loaded data should exist in dashboards', () => { + let items = cy.get('[data-test-subj="itemsInMemTable"]'); + + items.get('[data-test-subj="dashboardListingTitleLink-[Flights]-Global-Flight-Dashboard"]') + .should('have.text', '[Flights] Global Flight Dashboard'); + + items.get('[data-test-subj="dashboardListingTitleLink-[Logs]-Web-Traffic"]') + .should('have.text', '[Logs] Web Traffic'); + + items.get('[data-test-subj="dashboardListingTitleLink-[eCommerce]-Revenue-Dashboard"]') + .should('have.text', '[eCommerce] Revenue Dashboard'); + }); + + describe('Check Global Flight Dashboard', () => { + beforeEach(() => { + cy.get('[data-test-subj="itemsInMemTable"]') + .get('[data-test-subj="dashboardListingTitleLink-[Flights]-Global-Flight-Dashboard"]') + .click(); + commonUI.removeAllFilters(); + commonUI.setDateRange('Dec 1, 2021 @ 00:00:00.000', 'Nov 1, 2021 @ 00:00:00.000') + }); + + it('Global Flight Dashboard is loaded and funtions correctly', () => { + cy.get('[data-test-subj="breadcrumb last"]').should('have.text', '[Flights] Global Flight Dashboard'); + cy.get('[data-title="[Flights] Total Flights"]').should('exist'); + cy.get('[data-title="[Flights] Average Ticket Price"]').should('exist'); + + commonUI.addFilterRetrySelection('FlightDelayType', 'is not', 'No Delay'); + let types = cy.get('[data-title="[Flights] Delay Type"]') + types.find('[data-label="Weather Delay"]').should('exist'); + types.find('[data-label="No Delay"]').should('not.exist'); ; + commonUI.removeFilter('FlightDelayType'); + + commonUI.addFilterRetrySelection('Carrier', 'is', 'Logstash Airways'); + cy.get('[data-title="[Flights] Airline Carrier"]') + .find('[class="label-text"]') + .should('have.text', 'Logstash Airways (100%)'); + }); + }); + + describe('Check eCommerce Revenue Dashboard', () => { + beforeEach(() => { + cy.get('[data-test-subj="itemsInMemTable"]') + .get('[data-test-subj="dashboardListingTitleLink-[eCommerce]-Revenue-Dashboard"]') + .click(); + commonUI.removeAllFilters(); + commonUI.setDateRange('Nov 1, 2021 @ 00:00:00.000', 'Nov 1, 2016 @ 00:00:00.000') + }); + + it('eCommerce Revenue Dashboard is loaded and functions correctly', () => { + cy.get('[data-test-subj="breadcrumb last"]').should('have.text', '[eCommerce] Revenue Dashboard'); + cy.get('[data-title="[eCommerce] Average Sales Price"]').should('exist'); + cy.get('[data-title="[eCommerce] Average Sold Quantity"]').should('exist'); + + commonUI.addFilterRetrySelection('customer_gender', 'is', 'FEMALE'); + cy.get('[data-title="[eCommerce] Sales by Gender"]') + .find('[class="label-text"]') + .should('have.text', 'FEMALE (100%)'); + + commonUI.addFilterRetrySelection('category', 'is not', "Women's Clothing"); + let category = cy.get('[data-title="[eCommerce] Sales by Category"]') + category.find('[data-label="Men\'s Clothing"]').should('exist'); + category.find('[data-label="Women\'s Clothing"]').should('not.exist'); + }); + }); +}); \ No newline at end of file diff --git a/cypress/integration/osd-bundle/check_timeline.js b/cypress/integration/osd-bundle/check_timeline.js new file mode 100644 index 000000000000..e0639d3b917a --- /dev/null +++ b/cypress/integration/osd-bundle/check_timeline.js @@ -0,0 +1,99 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* eslint-disable */ +import { MiscUtils, LoginPage } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; + +const miscUtils = new MiscUtils(cy); +const loginPage = new LoginPage(cy); + +describe('check timeline visualization', () => { + beforeEach(() => { + miscUtils.visitPage('app/visualize#'); + loginPage.enterUserName('admin'); + loginPage.enterPassword('admin'); + loginPage.submit(); + }); + + afterEach(() => { + cy.clearCookies(); + }); + + it('tenant-switch-modal page should show and be clicked', () => { + cy.get('[data-test-subj="tenant-switch-modal"]'); + cy.get('[data-test-subj="confirm"]').click(); + }); + + it('timeline visualizations should be saved and named correctly', () => { + cy.get('[data-test-subj="visualizationLandingPage"]') + .find('[class="euiFormControlLayout__childrenWrapper"]') + .type('timeline'); + cy.get('[data-test-subj="visListingTitleLink-test-timeline"]').should('have.text', 'test-timeline').click(); + cy.get('[class="view-line"]').contains('.es(*)'); + }); + + describe('timeline visualizations should work properly', () => { + beforeEach(() => { + cy.get('[data-test-subj="visualizationLandingPage"]') + .find('[data-test-subj="newItemButton"]') + .click(); + cy.get('[data-test-subj="visType-timelion"]').click(); + }); + + it('.es(*, kibana1=true) should report search error', () => { + cy.get('[class="view-line"]').type('{selectall}{backspace}, kibana1=true)'); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').contains('Timeline request error: undefined Error: Unknown argument to es: kibana1') + }); + + it('.es(*, kibana=true) should not report search error', () => { + cy.get('[class="view-line"]').type('{selectall}{backspace}, kibana=true)'); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').should('not.exist') + }); + + it('.es(*, opensearchDashboards=true) should not report search error', () => { + cy.get('[class="view-line"]').type('{selectall}{backspace}, opensearchDashboards=true)'); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').should('not.exist') + }); + + it('.elasticsearch(*, kibana1=true) should report search error', () => { + cy.get('[class="view-line"]').type('{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}elasticsearch(*, kibana1=true)'); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').contains('Timeline request error: undefined Error: Unknown argument to es: kibana1') + }); + + it('.elasticsearch(*, kibana=true) should not report search error', () => { + cy.get('[class="view-line"]').type('{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}elasticsearch(*, kibana=true)'); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').should('not.exist') + }); + + it('.elasticsearch(*, opensearchDashboards=true) should not report search error', () => { + cy.get('[class="view-line"]').type('{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}elasticsearch(*, opensearchDashboards=true)'); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').should('not.exist') + }); + + it('.opensearch(*, kibana1=true) should report search error', () => { + cy.get('[class="view-line"]').type('{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}opensearch(*, kibana1=true)'); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').contains('Timeline request error: undefined Error: Unknown argument to es: kibana1') + }); + + it('.opensearch(*, kibana=true) should not report search error', () => { + cy.get('[class="view-line"]').type('{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}opensearch(*, kibana=true)'); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').should('not.exist') + }); + + it('.opensearch(*, opensearchDashboards=true) should not report search error', () => { + cy.get('[class="view-line"]').type('{selectall}{backspace}{backspace}{backspace}{backspace}{backspace}opensearch(*, opensearchDashboards=true)'); + cy.get('[data-test-subj="visualizeEditorRenderButton"]').click(); + cy.get('[data-test-subj="globalToastList"]').find('[data-test-subj="errorToastMessage"]').should('not.exist') + }); + }); +}); \ No newline at end of file