From 3fd7f68594ed22dd8e2b6dcc1e0ca6fd3a2ea798 Mon Sep 17 00:00:00 2001 From: Kristen Tian <105667444+kristenTian@users.noreply.github.com> Date: Thu, 13 Jul 2023 10:59:19 -0700 Subject: [PATCH] Test sample data with multiple data source enabled on local cluster (#756) Signed-off-by: Kristen Tian (cherry picked from commit e1bd3243c9e803e0554cfaf3c97f4db56e650ba4) --- ...hboard_sample_data_with_datasource_spec.js | 166 ++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/dashboard_sample_data_with_datasource_spec.js diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/dashboard_sample_data_with_datasource_spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/dashboard_sample_data_with_datasource_spec.js new file mode 100644 index 000000000..0056a537e --- /dev/null +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/dashboard_sample_data_with_datasource_spec.js @@ -0,0 +1,166 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { + CommonUI, + MiscUtils, +} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; + +const commonUI = new CommonUI(cy); +const miscUtils = new MiscUtils(cy); +const baseURL = new URL(Cypress.config().baseUrl); +// remove trailing slash +const path = baseURL.pathname.replace(/\/$/, ''); + +if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) { + describe('dashboard local cluster sample data validation', () => { + before(() => {}); + + after(() => {}); + + describe('checking home page', () => { + before(() => { + // Go to the home page + miscUtils.visitPage('app/home#'); + cy.window().then((win) => + win.localStorage.setItem('home:welcome:show', false) + ); + cy.reload(true); + }); + + after(() => { + cy.window().then((win) => + win.localStorage.removeItem('home:welcome:show') + ); + }); + + it('checking tutorial_directory display', () => { + // Check that tutorial_directory is visible + commonUI.checkElementExists( + `a[href="${path}/app/home#/tutorial_directory"]`, + 2 + ); + }); + }); + + describe('adding sample data', () => { + before(() => { + miscUtils.addSampleData(); + }); + + after(() => { + miscUtils.removeSampleData(); + }); + + it('checking ecommerce dashboards displayed', () => { + miscUtils.viewData('ecommerce'); + commonUI.checkElementContainsValue( + 'span[title="[eCommerce] Revenue Dashboard"]', + 1, + '\\[eCommerce\\] Revenue Dashboard' + ); + commonUI.checkElementContainsValue( + 'div[data-test-subj="markdownBody"] > h3', + 1, + 'Sample eCommerce Data' + ); + }); + + it('checking flights dashboards displayed', () => { + miscUtils.viewData('flights'); + commonUI.checkElementContainsValue( + 'span[title="[Flights] Global Flight Dashboard"]', + 1, + '\\[Flights\\] Global Flight Dashboard' + ); + commonUI.checkElementContainsValue( + 'div[data-test-subj="markdownBody"] > h3', + 1, + 'Sample Flight data' + ); + }); + + it('checking web logs dashboards displayed', () => { + miscUtils.viewData('logs'); + commonUI.checkElementContainsValue( + 'span[title="[Logs] Web Traffic"]', + 1, + '\\[Logs\\] Web Traffic' + ); + commonUI.checkElementContainsValue( + 'div[data-test-subj="markdownBody"] > h3', + 1, + 'Sample Logs Data' + ); + }); + + describe('checking index patterns', () => { + before(() => { + miscUtils.visitPage( + 'app/management/opensearch-dashboards/indexPatterns' + ); + }); + + after(() => {}); + + it('checking ecommerce index patterns are added', () => { + commonUI.checkElementContainsValue( + 'div[data-test-subj="indexPatternTable"]', + 1, + 'opensearch_dashboards_sample_data_ecommerce' + ); + }); + + it('checking flights index patterns are added', () => { + commonUI.checkElementContainsValue( + 'div[data-test-subj="indexPatternTable"]', + 1, + 'opensearch_dashboards_sample_data_flights' + ); + }); + + it('checking web logs index patterns are added', () => { + commonUI.checkElementContainsValue( + 'div[data-test-subj="indexPatternTable"]', + 1, + 'opensearch_dashboards_sample_data_logs' + ); + }); + }); + + describe('checking saved objects', () => { + before(() => { + miscUtils.visitPage('app/management/opensearch-dashboards/objects'); + }); + + after(() => {}); + + it('checking ecommerce object is saved', () => { + commonUI.checkElementContainsValue( + 'div[data-test-subj="savedObjectsTable"]', + 1, + 'opensearch_dashboards_sample_data_ecommerce' + ); + }); + + it('checking flights object is saved', () => { + commonUI.checkElementContainsValue( + 'div[data-test-subj="savedObjectsTable"]', + 1, + 'opensearch_dashboards_sample_data_flights' + ); + }); + + it('checking web logs object is saved', () => { + commonUI.checkElementContainsValue( + 'div[data-test-subj="savedObjectsTable"]', + 1, + 'opensearch_dashboards_sample_data_logs' + ); + }); + }); + }); + }); +}