From 0c626ade60a44266d88f7b22e6eceb4b4aa1af03 Mon Sep 17 00:00:00 2001 From: gaobinlong Date: Fri, 2 Feb 2024 17:54:30 +0800 Subject: [PATCH] Only run some test cases Signed-off-by: gaobinlong --- .../apps/data_explorer/aaa_before.spec.js | 18 - .../data_source_selector.spec.js | 90 -- .../apps/data_explorer/date_nanos.spec.js | 54 -- .../data_explorer/date_nanos_mixed.spec.js | 64 -- .../apps/data_explorer/discover.spec.js | 285 ------- .../data_explorer/discover_histogram.spec.js | 92 -- .../apps/data_explorer/doc_navigation.spec.js | 111 --- .../apps/data_explorer/doc_table.spec.js | 71 -- .../apps/data_explorer/errors.spec.js | 55 -- .../apps/data_explorer/field_data.spec.js | 92 -- .../data_explorer/field_visualize.spec.js | 104 --- .../apps/data_explorer/filter_editor.spec.js | 83 -- .../index_pattern_with_encoded_id.spec.js | 62 -- .../index_pattern_without_field.spec.js | 61 -- .../apps/data_explorer/inspector.spec.js | 76 -- .../apps/data_explorer/large_string.spec.js | 74 -- .../apps/data_explorer/saved_queries.spec.js | 195 ----- .../apps/data_explorer/shared_links.spec.js | 157 ---- .../apps/data_explorer/sidebar.spec.js | 61 -- .../apps/data_explorer/source_filter.spec.js | 47 - .../apps/data_explorer/zzz_after.spec.js | 27 - .../apps/vis-augmenter/dashboard_spec.js | 129 --- .../apps/vis_builder/basic.spec.js | 160 ---- .../apps/vis_builder/dashboard.spec.js | 152 ---- .../apps/vis_builder/experimental.spec.js | 89 -- .../apps/vis_builder/vis_types/area.spec.js | 63 -- .../apps/vis_builder/vis_types/bar.spec.js | 63 -- .../apps/vis_builder/vis_types/line.spec.js | 63 -- .../apps/vis_builder/vis_types/metric.spec.js | 52 -- .../apps/vis_builder/vis_types/table.spec.js | 96 --- .../apps/vis_type_table/basic.spec.js | 112 --- .../apps/vis_type_table/data.spec.js | 290 ------- .../apps/vis_type_table/embed.spec.js | 175 ---- .../apps/vis_type_table/options.spec.js | 271 ------ .../apps/vis_type_table/split.spec.js | 394 --------- .../1_create_datasource.spec.js | 405 --------- .../2_datasource_table.spec.js | 475 ----------- .../3_update_datasource.spec.js | 803 ------------------ 38 files changed, 5671 deletions(-) delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/aaa_before.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/data_source_selector.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/date_nanos.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/date_nanos_mixed.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover_histogram.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/doc_navigation.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/doc_table.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/errors.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/field_data.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/field_visualize.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/filter_editor.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/index_pattern_with_encoded_id.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/index_pattern_without_field.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/inspector.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/large_string.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/saved_queries.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/shared_links.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/sidebar.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/source_filter.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/zzz_after.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis-augmenter/dashboard_spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/basic.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/dashboard.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/experimental.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/area.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/bar.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/line.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/metric.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/table.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/basic.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/data.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/embed.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/options.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/split.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/2_datasource_table.spec.js delete mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/3_update_datasource.spec.js diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/aaa_before.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/aaa_before.spec.js deleted file mode 100644 index e7e5af5c2..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/aaa_before.spec.js +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { CURRENT_TENANT } from '../../../../../utils/commands'; - -/// - -describe('Before', () => { - before(() => { - CURRENT_TENANT.newTenant = 'global'; - cy.deleteAllIndices(); - cy.deleteSavedObjectByType('index-pattern'); - }); - - it('setup completed', () => {}); -}); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/data_source_selector.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/data_source_selector.spec.js deleted file mode 100644 index 3b5916d0f..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/data_source_selector.spec.js +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - MiscUtils, - TestFixtureHandler, -} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { CURRENT_TENANT } from '../../../../../utils/commands'; - -const miscUtils = new MiscUtils(cy); -const testFixtureHandler = new TestFixtureHandler( - cy, - Cypress.env('openSearchUrl') -); - -describe('Data source selector', () => { - before(() => { - CURRENT_TENANT.newTenant = 'global'; - testFixtureHandler.importJSONMapping( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/index_pattern_without_timefield/mappings.json.txt' - ); - testFixtureHandler.importJSONDoc( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/index_pattern_without_timefield/data.json.txt' - ); - - miscUtils.visitPage('app/data-explorer/discover#/'); - cy.waitForLoader(); - }); - - after(() => { - testFixtureHandler.clearJSONMapping( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/index_pattern_without_timefield/mappings.json.txt' - ); - cy.deleteSavedObjectByType('index-pattern'); - }); - - it('displays all data sources by default', () => { - cy.get('[data-test-subj="dataExplorerDSSelect"]').click(); - cy.get('.euiComboBoxOptionsList').should('exist'); - cy.get('.euiComboBoxOption__content').should('have.length', 2); - }); - - it('filters options based on user input', () => { - cy.get('[data-test-subj="dataExplorerDSSelect"] input').type('without', { - force: true, - }); - cy.get('.euiComboBoxOption__content').should('have.length', 1); - cy.get('.euiComboBoxOption__content') - .first() - .should('contain', 'without-timefield'); - }); - - it('updates the visual length of the dropdown based on filtered results', () => { - cy.get('[data-test-subj="dataExplorerDSSelect"] input').clear({ - force: true, - }); - cy.get('[data-test-subj="dataExplorerDSSelect"] input').type( - 'without-timefield', - { - force: true, - } - ); - cy.get('.euiComboBoxOptionsList').then(($listAfterFilter) => { - const heightAfterFilter = $listAfterFilter.height(); - cy.get('[data-test-subj="dataExplorerDSSelect"] input').clear({ - force: true, - }); - cy.get('.euiComboBoxOptionsList').should(($listAll) => { - expect($listAll.height()).to.be.greaterThan(heightAfterFilter); - }); - }); - }); - - it('selects the correct option when clicked', () => { - cy.get('[data-test-subj="dataExplorerDSSelect"] input').type( - 'with-timefield', - { - force: true, - } - ); - - cy.contains('.euiComboBoxOption__content', 'with-timefield').click(); - cy.get('[data-test-subj="dataExplorerDSSelect"] .euiComboBoxPill').should( - 'contain', - 'with-timefield' - ); - }); -}); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/date_nanos.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/date_nanos.spec.js deleted file mode 100644 index b17c78124..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/date_nanos.spec.js +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - TestFixtureHandler, - MiscUtils, -} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { CURRENT_TENANT } from '../../../../../utils/commands'; - -const testFixtureHandler = new TestFixtureHandler( - cy, - Cypress.env('openSearchUrl') -); - -const miscUtils = new MiscUtils(cy); - -describe('date_nanos', () => { - const fromTime = 'Sep 21, 2019 @ 20:31:44.000'; - const toTime = 'Sep 23, 2019 @ 03:31:44.000'; - before(() => { - CURRENT_TENANT.newTenant = 'global'; - // import date nanos - testFixtureHandler.importJSONMapping( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/date_nanos/mappings.json.txt' - ); - - testFixtureHandler.importJSONDoc( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/date_nanos/data.json.txt' - ); - cy.setAdvancedSetting({ - defaultIndex: 'date-nanos', - }); - miscUtils.visitPage('app/data-explorer/discover#/'); - cy.waitForLoader(); - - cy.setTopNavDate(fromTime, toTime); - cy.waitForSearch(); - }); - - after(() => { - testFixtureHandler.clearJSONMapping( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/date_nanos/mappings.json.txt' - ); - }); - - it('should show a timestamp with nanoseconds in the first result row', function () { - cy.verifyTimeConfig(fromTime, toTime); - cy.get(`[data-test-subj="dataGridRowCell"]`) - .eq(1) - .contains('Sep 22, 2019 @ 16:50:13.253123345'); - }); -}); 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 deleted file mode 100644 index 07e48047f..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/date_nanos_mixed.spec.js +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - TestFixtureHandler, - MiscUtils, -} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { CURRENT_TENANT } from '../../../../../utils/commands'; - -const miscUtils = new MiscUtils(cy); -const testFixtureHandler = new TestFixtureHandler( - cy, - Cypress.env('openSearchUrl') -); - -describe('date_nanos_mixed', () => { - before(() => { - CURRENT_TENANT.newTenant = 'global'; - //import date nanos - testFixtureHandler.importJSONMapping( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/date_nanos_mix/mappings.json.txt' - ); - - testFixtureHandler.importJSONDoc( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/date_nanos_mix/data.json.txt' - ); - cy.setAdvancedSetting({ - defaultIndex: 'timestamp-*', - }); - miscUtils.visitPage('app/data-explorer/discover#/'); - cy.waitForLoader(); - - const fromTime = 'Jan 1, 2019 @ 00:00:00.000'; - const toTime = 'Jan 1, 2019 @ 23:59:59.999'; - cy.setTopNavDate(fromTime, toTime); - 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) - .contains('Jan 1, 2019 @ 04:10:30.124000000'); - - cy.get(`[data-test-subj="dataGridRowCell"]`) - .eq(4) - .contains('Jan 1, 2019 @ 04:10:30.123498765'); - - cy.get(`[data-test-subj="dataGridRowCell"]`) - .eq(7) - .contains('Jan 1, 2019 @ 04:10:30.123456789'); - - cy.get(`[data-test-subj="dataGridRowCell"]`) - .eq(10) - .contains('Jan 1, 2019 @ 04:10:30.123000000'); - }); -}); 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 deleted file mode 100644 index 760ad48b3..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover.spec.js +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - TestFixtureHandler, - MiscUtils, -} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { - DE_DEFAULT_END_TIME, - DE_DEFAULT_START_TIME, -} from '../../../../../utils/constants'; -import { CURRENT_TENANT } from '../../../../../utils/commands'; - -const miscUtils = new MiscUtils(cy); -const testFixtureHandler = new TestFixtureHandler( - cy, - Cypress.env('openSearchUrl') -); -const indexSet = [ - 'logstash-2015.09.22', - 'logstash-2015.09.21', - 'logstash-2015.09.20', -]; - -describe('discover app', { scrollBehavior: false }, () => { - before(() => { - CURRENT_TENANT.newTenant = 'global'; - // import logstash functional - testFixtureHandler.importJSONDocIfNeeded( - indexSet, - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.mappings.json.txt', - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.json.txt' - ); - - 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' - ); - - cy.setAdvancedSetting({ - defaultIndex: 'logstash-*', - }); - - // Go to the Discover page - miscUtils.visitPage( - `app/data-explorer/discover#/?_g=(filters:!(),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))` - ); - cy.waitForLoader(); - cy.waitForSearch(); - }); - - after(() => {}); - - describe('save search', () => { - const saveSearch1 = 'Save Search # 1'; - const saveSearch2 = 'Modified Save Search # 1'; - - it('should show correct time range string by timepicker', function () { - cy.verifyTimeConfig(DE_DEFAULT_START_TIME, DE_DEFAULT_END_TIME); - cy.waitForLoader(); - }); - - it('save search should display save search name in breadcrumb', function () { - cy.log('save search should display save search name in breadcrumb'); - cy.saveSearch(saveSearch1); - cy.getElementByTestId('breadcrumb last') - .should('be.visible') - .should('have.text', saveSearch1); - }); - - it('load save search should show save search name in breadcrumb', function () { - cy.loadSaveSearch(saveSearch1); - - cy.getElementByTestId('breadcrumb last') - .should('be.visible') - .should('have.text', saveSearch1); - }); - - it('renaming a save search should modify name in breadcrumb', function () { - cy.loadSaveSearch(saveSearch1); - cy.saveSearch(saveSearch2); - - cy.getElementByTestId('breadcrumb last') - .should('be.visible') - .should('have.text', saveSearch2); - }); - - it('should show the correct hit count', function () { - cy.loadSaveSearch(saveSearch2); - cy.setTopNavDate(DE_DEFAULT_START_TIME, DE_DEFAULT_END_TIME); - const expectedHitCount = '14,004'; - cy.verifyHitCount(expectedHitCount); - }); - - it('should show correct time range string in chart', function () { - cy.getElementByTestId('discoverIntervalDateRange').should( - 'have.text', - `${DE_DEFAULT_START_TIME} - ${DE_DEFAULT_END_TIME} per` - ); - }); - - it('should show correct initial chart interval of Auto', function () { - cy.getElementByTestId('discoverIntervalSelect') - .get('option') - .first() - .should('have.text', 'Auto'); - }); - - it('should not show "no results"', () => { - cy.getElementByTestId('discoverNoResults').should('not.exist'); - }); - - it('should reload the saved search with persisted query to show the initial hit count', function () { - // apply query some changes - cy.setTopNavQuery('test'); - cy.verifyHitCount('22'); - - // reset to persisted state - cy.getElementByTestId('resetSavedSearch').click(); - const expectedHitCount = '14,004'; - cy.verifyHitCount(expectedHitCount); - }); - }); - - describe( - 'save search #2 which has an empty time range', - { scrollBehavior: false }, - () => { - const fromTime = 'Jun 11, 1999 @ 09:22:11.000'; - const toTime = 'Jun 12, 1999 @ 11:21:04.000'; - - before(() => { - cy.setTopNavDate(fromTime, toTime); - }); - - it('should show "no results"', () => { - cy.getElementByTestId('discoverNoResults').should('be.exist'); - }); - - it('should suggest a new time range is picked', () => { - cy.getElementByTestId('discoverNoResultsTimefilter').should('be.exist'); - }); - } - ); - - // https://github.com/opensearch-project/OpenSearch-Dashboards/issues/5495 - describe.skip('nested query', () => { - before(() => { - cy.setTopNavDate(DE_DEFAULT_START_TIME, DE_DEFAULT_END_TIME); - cy.waitForSearch(); - }); - - it('should support querying on nested fields', function () { - cy.setTopNavQuery('nestedField:{{}child:nestedValue{}}'); - cy.verifyHitCount('1'); - }); - }); - - // https://github.com/opensearch-project/OpenSearch-Dashboards/issues/5495 - describe.skip('data-shared-item', function () { - it('should have correct data-shared-item title and description', () => { - const expected = { - title: 'A Saved Search', - description: 'A Saved Search Description', - }; - - cy.loadSaveSearch(expected.title); - cy.setTopNavDate(DE_DEFAULT_START_TIME, DE_DEFAULT_END_TIME); - cy.waitForSearch(); - cy.waitForLoader(); - cy.getElementByTestId('discoverTable').should( - 'have.attr', - 'data-shared-item' - ); - cy.getElementByTestId('discoverTable').should( - 'have.attr', - 'data-title', - expected.title - ); - cy.getElementByTestId('discoverTable').should( - 'have.attr', - 'data-description', - expected.description - ); - }); - }); - - describe('usage of discover:searchOnPageLoad', () => { - it('should fetch data from OpenSearch initially when discover:searchOnPageLoad is false', function () { - cy.setAdvancedSetting({ - 'discover:searchOnPageLoad': false, - }); - miscUtils.visitPage(`app/data-explorer/discover#/`); - cy.waitForLoader(); - cy.getElementByTestId('discoverTable').should('not.exist'); - }); - - it('should not fetch data from OpenSearch initially when discover:searchOnPageLoad is true', function () { - cy.setAdvancedSetting({ - 'discover:searchOnPageLoad': true, - }); - miscUtils.visitPage(`app/data-explorer/discover#/`); - cy.setTopNavDate(DE_DEFAULT_START_TIME, DE_DEFAULT_END_TIME); - cy.waitForSearch(); - cy.waitForLoader(); - cy.getElementByTestId('discoverTable').should('be.visible'); - }); - }); - - // detached from dom issue - describe.skip('managing fields', function () { - it('should add a field, sort by it, remove it and also sorting by it', function () { - // Go to the Discover page - miscUtils.visitPage( - `app/data-explorer/discover#/?_g=(filters:!(),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))` - ); - cy.waitForLoader(); - cy.waitForSearch(); - - cy.getElementByTestId('fieldFilterSearchInput').type('ip'); - - cy.getElementByTestId('fieldToggle-ip').click({ force: true }); - - cy.getElementByTestId('dataGridHeaderCell-ip').should('be.visible'); - cy.getElementByTestId('dataGridHeaderCell-ip') - .getElementByTestId('dataGridHeaderCellActionButton-ip') - .click({ force: true }); - - // Sort from A-Z - cy.contains('button', 'A-Z').click(); - - // Move the column to the left - cy.getElementByTestId('dataGridHeaderCell-ip') - .getElementByTestId('dataGridHeaderCellActionButton-ip') - .click({ force: true }); - - cy.contains('button', 'Move left').click(); - - cy.getElementByTestId('fieldToggle-ip').click({ force: true }); - - cy.getElementByTestId('dataGridHeaderCell-ip').should('not.be.exist'); - }); - }); - - describe('refresh interval', function () { - it('should refetch when autofresh is enabled', () => { - cy.getElementByTestId('openInspectorButton').click(); - cy.getElementByTestId('inspectorPanel') - .get('.euiTable tr:nth-child(6) td:nth-child(2) span') - .invoke('text') - .then((timestamp) => { - // Get the time stamp of the previous request - cy.log('Time stamp is', timestamp); - - cy.getElementByTestId('euiFlyoutCloseButton').click(); - - // Turn on auto refresh - cy.getElementByTestId('superDatePickerToggleQuickMenuButton').click(); - cy.getElementByTestId('superDatePickerRefreshIntervalInput') - .should('be.visible') - .clear() - .type('2'); - cy.getElementByTestId('superDatePickerToggleRefreshButton').click(); - - // Let auto refresh run - cy.wait(100); - - // Close the auto refresh - cy.getElementByTestId('superDatePickerToggleRefreshButton').click(); - - // Check the timestamp of the last request, it should be different than the first timestamp - cy.getElementByTestId('openInspectorButton').click(); - cy.getElementByTestId('inspectorPanel') - .get('.euiTable tr:nth-child(6) td:nth-child(2) span') - .invoke('text') - .should('not.equal', timestamp); - }); - }); - }); -}); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover_histogram.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover_histogram.spec.js deleted file mode 100644 index 3003b5e8b..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover_histogram.spec.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - TestFixtureHandler, - MiscUtils, -} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { CURRENT_TENANT } from '../../../../../utils/commands'; - -const miscUtils = new MiscUtils(cy); -const testFixtureHandler = new TestFixtureHandler( - cy, - Cypress.env('openSearchUrl') -); -const indexSet = [ - 'logstash-2015.09.22', - 'logstash-2015.09.21', - 'logstash-2015.09.20', -]; - -describe('discover histogram', { scrollBehavior: false }, () => { - before(() => { - CURRENT_TENANT.newTenant = 'global'; - cy.log('load opensearch-dashboards index with default index pattern'); - - // import long window logstash index pattern - testFixtureHandler.importJSONDoc( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/long_window_logstash_index_pattern/data.json.txt' - ); - - // import logstash functional - testFixtureHandler.importJSONDocIfNeeded( - indexSet, - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.mappings.json.txt', - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.json.txt' - ); - - // import long window logstash - testFixtureHandler.importJSONMapping( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/long_window_logstash/mappings.json.txt' - ); - - testFixtureHandler.importJSONDoc( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/long_window_logstash/data.json.txt' - ); - - cy.setAdvancedSetting({ - defaultIndex: 'long-window-logstash-*', - 'dateFormat:tz': 'Europe/Berlin', - }); - - // Go to the Discover page - miscUtils.visitPage('app/data-explorer/discover#/'); - cy.waitForLoader(); - }); - - after(() => { - miscUtils.visitPage('app/management/opensearch-dashboards/settings'); - cy.waitForLoader(); - cy.getElementByTestId('advancedSetting-resetField-dateFormat:tz').click({ - force: true, - }); - cy.getElementByTestId('advancedSetting-saveButton').click({ force: true }); - testFixtureHandler.clearJSONMapping( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/long_window_logstash/mappings.json.txt' - ); - cy.deleteIndex('long-window-logstash-0'); - cy.deleteSavedObjectByType('index-pattern'); - }); - - it('should visualize monthly data with different day intervals', () => { - const fromTime = 'Nov 01, 2017 @ 00:00:00.000'; - const toTime = 'Mar 21, 2018 @ 00:00:00.000'; - cy.prepareTest(fromTime, toTime, 'Month'); - cy.get('.echChart canvas:last-of-type').should('be.visible'); - }); - it('should visualize weekly data with within DST changes', () => { - const fromTime = 'Mar 01, 2018 @ 00:00:00.000'; - const toTime = 'May 01, 2018 @ 00:00:00.000'; - cy.prepareTest(fromTime, toTime, 'Week'); - cy.get('.echChart canvas:last-of-type').should('be.visible'); - }); - it('should visualize monthly data with different years scaled to 30 days', () => { - const fromTime = 'Jan 01, 2010 @ 00:00:00.000'; - const toTime = 'Mar 21, 2019 @ 00:00:00.000'; - cy.prepareTest(fromTime, toTime, 'Day'); - cy.get('.echChart canvas:last-of-type').should('be.visible'); - cy.get('.euiToolTipAnchor').should('be.visible'); - }); -}); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/doc_navigation.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/doc_navigation.spec.js deleted file mode 100644 index 40ad4c7d9..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/doc_navigation.spec.js +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - MiscUtils, - TestFixtureHandler, -} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { CURRENT_TENANT } from '../../../../../utils/commands'; - -const miscUtils = new MiscUtils(cy); -const testFixtureHandler = new TestFixtureHandler( - cy, - Cypress.env('openSearchUrl') -); -const indexSet = [ - 'logstash-2015.09.22', - 'logstash-2015.09.21', - 'logstash-2015.09.20', -]; - -describe('doc link in discover', () => { - beforeEach(() => { - CURRENT_TENANT.newTenant = 'global'; - // import logstash functional - testFixtureHandler.importJSONDocIfNeeded( - indexSet, - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.mappings.json.txt', - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.json.txt' - ); - - 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' - ); - - cy.setAdvancedSetting({ - defaultIndex: 'logstash-*', - }); - - miscUtils.visitPage( - `app/data-explorer/discover#/?_g=(filters:!(),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))` - ); - cy.waitForLoader(); - cy.waitForSearch(); - }); - - after(() => {}); - - it('should open the doc view of the selected document', function () { - cy.getElementByTestId(`docTableExpandToggleColumn-0`) - .should('be.visible') - .click(); - cy.getElementByTestId(`documentDetailFlyOut`).should('be.visible'); - - // Both actions will take to the new tab - cy.getElementByTestId('docTableRowAction-0').should( - 'have.text', - 'View surrounding documents(opens in a new tab or window)' - ); - - cy.getElementByTestId('docTableRowAction-1').should( - 'have.text', - 'View single document(opens in a new tab or window)' - ); - }); - - it('if value is null, add filter should create a non-exist filter', function () { - // Filter out special document - cy.getElementByTestId('addFilter').click(); - cy.getElementByTestId('filterFieldSuggestionList') - .should('be.visible') - .click() - .type(`agent{downArrow}{enter}`) - .trigger('blur', { force: true }); - - cy.getElementByTestId('filterOperatorList') - .should('be.visible') - .click() - .type(`is{downArrow}{enter}`) - .trigger('blur', { force: true }); - - cy.getElementByTestId('filterParams').type('Missing/Fields'); - - cy.getElementByTestId('saveFilter').click({ force: true }); - cy.waitForLoader(); - - cy.waitForSearch(); - - cy.wait(500); - - cy.getElementByTestId(`docTableExpandToggleColumn-0`) - .should('be.visible') - .click(); - cy.getElementByTestId(`documentDetailFlyOut`).should('be.visible'); - - cy.getElementByTestId('tableDocViewRow-referer') - .find(`[data-test-subj="addInclusiveFilterButton"]`) - .click(); - - cy.wait(100); - - // Since the value of referer is null, the filter for value option will add a non-existing filter - cy.get('[data-test-subj~="filter-key-referer"]').should('be.visible'); - cy.get('[data-test-subj~="filter-negated"]').should('be.visible'); - }); -}); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/doc_table.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/doc_table.spec.js deleted file mode 100644 index e79c33fb3..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/doc_table.spec.js +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - MiscUtils, - TestFixtureHandler, -} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { CURRENT_TENANT } from '../../../../../utils/commands'; - -const miscUtils = new MiscUtils(cy); -const testFixtureHandler = new TestFixtureHandler( - cy, - Cypress.env('openSearchUrl') -); -const indexSet = [ - 'logstash-2015.09.22', - 'logstash-2015.09.21', - 'logstash-2015.09.20', -]; - -describe('discover doc table', () => { - before(() => { - CURRENT_TENANT.newTenant = 'global'; - // import logstash functional - testFixtureHandler.importJSONDocIfNeeded( - indexSet, - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.mappings.json.txt', - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.json.txt' - ); - - 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' - ); - - cy.setAdvancedSetting({ - defaultIndex: 'logstash-*', - }); - - miscUtils.visitPage( - `app/data-explorer/discover#/?_g=(filters:!(),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))` - ); - cy.waitForLoader(); - cy.waitForSearch(); - }); - - after(() => {}); - - describe('add and remove columns', function () { - it('should add more columns to the table', function () { - cy.getElementByTestId('fieldFilterSearchInput').type('phpmemory'); - - cy.getElementByTestId('fieldToggle-phpmemory').click({ force: true }); - - cy.getElementByTestId('dataGridHeaderCell-phpmemory').should( - 'be.visible' - ); - }); - - it('should remove columns from the table', function () { - cy.getElementByTestId('fieldToggle-phpmemory').click({ force: true }); - - cy.getElementByTestId('dataGridHeaderCell-phpmemory').should('not.exist'); - }); - }); -}); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/errors.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/errors.spec.js deleted file mode 100644 index 8f2fb99f9..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/errors.spec.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - TestFixtureHandler, - MiscUtils, -} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { - DE_DEFAULT_END_TIME, - DE_DEFAULT_START_TIME, -} from '../../../../../utils/constants'; -import { CURRENT_TENANT } from '../../../../../utils/commands'; - -const miscUtils = new MiscUtils(cy); -const testFixtureHandler = new TestFixtureHandler( - cy, - Cypress.env('openSearchUrl') -); - -describe('errors', () => { - before(() => { - CURRENT_TENANT.newTenant = 'global'; - // import invalid_scripted_field - testFixtureHandler.importJSONMapping( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/invalid_scripted_field/mappings.json.txt' - ); - - testFixtureHandler.importJSONDoc( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/invalid_scripted_field/data.json.txt' - ); - - cy.setAdvancedSetting({ - defaultIndex: '18ea0c30-2d77-11e8-93f2-6f8a391f33ef', - }); - - miscUtils.visitPage('app/data-explorer/discover#/'); - cy.waitForLoader(); - - cy.setTopNavDate(DE_DEFAULT_START_TIME, DE_DEFAULT_END_TIME); - }); - - // after(() => { - // testFixtureHandler.clearJSONMapping( - // 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/invalid_scripted_field/mappings.json.txt' - // ); - // }); - - describe('invalid scripted field error', function () { - it('is rendered', function () { - cy.getElementByTestId('painlessStackTrace').should('be.visible'); - }); - }); -}); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/field_data.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/field_data.spec.js deleted file mode 100644 index 2cbf475ae..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/field_data.spec.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - TestFixtureHandler, - MiscUtils, -} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { CURRENT_TENANT } from '../../../../../utils/commands'; - -const miscUtils = new MiscUtils(cy); -const testFixtureHandler = new TestFixtureHandler( - cy, - Cypress.env('openSearchUrl') -); -const indexSet = [ - 'logstash-2015.09.22', - 'logstash-2015.09.21', - 'logstash-2015.09.20', -]; - -describe('discover tab', () => { - before(() => { - CURRENT_TENANT.newTenant = 'global'; - // import logstash functional - testFixtureHandler.importJSONDocIfNeeded( - indexSet, - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.mappings.json.txt', - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.json.txt' - ); - - 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' - ); - - cy.setAdvancedSetting({ - defaultIndex: 'logstash-*', - }); - - miscUtils.visitPage( - `app/data-explorer/discover#/?_g=(filters:!(),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))` - ); - cy.waitForLoader(); - cy.waitForSearch(); - }); - - after(() => {}); - - describe('field data', function () { - it('search php should show the correct hit count', function () { - const expectedHitCount = '445'; - cy.setTopNavQuery('php'); - cy.verifyHitCount(expectedHitCount); - }); - - it('the search term should be highlighted in the field data', function () { - cy.getElementByTestId('dataGridWrapper') - .get('mark') - .should('have.length', 100); - }); - - it('search type:apache should show the correct hit count', () => { - const expectedHitCount = '11,156'; - cy.setTopNavQuery('type:apache'); - cy.verifyHitCount(expectedHitCount); - }); - - it('doc view should show Time and _source columns', function () { - cy.getElementByTestId('dataGridHeaderCell-@timestamp').should( - 'be.visible' - ); - cy.getElementByTestId('dataGridHeaderCell-_source').should('be.visible'); - }); - - it('doc view should sort ascending', function () { - cy.getElementByTestId( - 'dataGridHeaderCellActionButton-@timestamp' - ).click(); - }); - - it('a bad syntax query should show an error message', function () { - cy.getElementByTestId('queryInput').clear(); - cy.setTopNavQuery('xxx(yyy))'); - cy.getElementByTestId('errorToastMessage').should('be.visible'); - }); - }); -}); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/field_visualize.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/field_visualize.spec.js deleted file mode 100644 index 5b9083bfe..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/field_visualize.spec.js +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - MiscUtils, - TestFixtureHandler, -} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { CURRENT_TENANT } from '../../../../../utils/commands'; - -const miscUtils = new MiscUtils(cy); -const testFixtureHandler = new TestFixtureHandler( - cy, - Cypress.env('openSearchUrl') -); -const indexSet = [ - 'logstash-2015.09.22', - 'logstash-2015.09.21', - 'logstash-2015.09.20', -]; - -describe('discover field visualize button', () => { - before(() => { - CURRENT_TENANT.newTenant = 'global'; - 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' - ); - - // import logstash functional - testFixtureHandler.importJSONDocIfNeeded( - indexSet, - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.mappings.json.txt', - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.json.txt' - ); - - cy.setAdvancedSetting({ - defaultIndex: 'logstash-*', - }); - }); - - after(() => {}); - - beforeEach(() => { - miscUtils.visitPage( - `app/data-explorer/discover#/?_g=(filters:!(),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))` - ); - cy.waitForLoader(); - cy.waitForSearch(); - }); - - it('should be able to visualize a field and save the visualization', () => { - cy.getElementByTestId('fieldFilterSearchInput').type('type'); - cy.log('visualize a type field'); - cy.getElementByTestId('field-type-showDetails').click({ force: true }); - cy.getElementByTestId('fieldVisualize-type').click(); - }); - - it('should visualize a field in area chart', () => { - cy.getElementByTestId('fieldFilterSearchInput').type('phpmemory'); - cy.log('visualize a phpmemory field'); - cy.getElementByTestId('field-phpmemory-showDetails').click({ force: true }); - cy.getElementByTestId('fieldVisualize-phpmemory').click(); - cy.waitForLoader(); - cy.get('.visEditor__canvas').should('be.visible'); - }); - - it('should not show the "Visualize" button for geo field', () => { - cy.getElementByTestId('fieldFilterSearchInput').type('geo.coordinates'); - cy.log('visualize a geo field'); - cy.getElementByTestId('field-geo.coordinates-showDetails').click({ - force: true, - }); - cy.getElementByTestId('fieldVisualize-geo.coordinates').should('not.exist'); - }); - - it('should preserve app filters in visualize', () => { - cy.submitFilterFromDropDown('bytes', 'exists'); - cy.getElementByTestId('fieldFilterSearchInput').type('geo.src'); - cy.log('visualize a geo.src field with filter applied'); - cy.getElementByTestId('field-geo.src-showDetails').click({ force: true }); - cy.getElementByTestId('fieldVisualize-geo.src').click(); - cy.waitForLoader(); - cy.get('.visEditor__canvas').should('be.visible'); - cy.get('[data-test-subj~=filter-key-bytes]').should('be.visible'); - }); - - it('should preserve query in visualize', () => { - const query = 'machine.os : ios'; - cy.setTopNavQuery(query); - cy.getElementByTestId('fieldFilterSearchInput').type('geo.dest'); - cy.log('visualize a geo.dest field with query applied'); - cy.getElementByTestId('field-geo.dest-showDetails').click({ force: true }); - cy.getElementByTestId('fieldVisualize-geo.dest').click(); - cy.waitForLoader(); - cy.get('.visEditor__canvas').should('be.visible'); - - cy.getElementByTestId('queryInput').should('have.text', query); - }); -}); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/filter_editor.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/filter_editor.spec.js deleted file mode 100644 index 18c3c5c3c..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/filter_editor.spec.js +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - MiscUtils, - TestFixtureHandler, -} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { CURRENT_TENANT } from '../../../../../utils/commands'; - -const miscUtils = new MiscUtils(cy); -const testFixtureHandler = new TestFixtureHandler( - cy, - Cypress.env('openSearchUrl') -); -const indexSet = [ - 'logstash-2015.09.22', - 'logstash-2015.09.21', - 'logstash-2015.09.20', -]; - -describe('discover filter editor', () => { - before(() => { - CURRENT_TENANT.newTenant = 'global'; - 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' - ); - - // import logstash functional - testFixtureHandler.importJSONDocIfNeeded( - indexSet, - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.mappings.json.txt', - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.json.txt' - ); - - cy.setAdvancedSetting({ - defaultIndex: 'logstash-*', - }); - - miscUtils.visitPage( - `app/data-explorer/discover#/?_g=(filters:!(),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))` - ); - cy.waitForLoader(); - cy.waitForSearch(); - }); - - describe('filter editor', function () { - it('should add a phrases filter', function () { - cy.submitFilterFromDropDown('extension.raw', 'is one of', 'jpg'); - cy.get('[data-test-subj~="filter-key-extension.raw"]').should( - 'be.visible' - ); - }); - - it('should show the phrases if you re-open a phrases filter', function () { - cy.get('[data-test-subj~="filter-key-extension.raw"]').click(); - cy.getElementByTestId('editFilter').click(); - cy.getElementByTestId('filterFieldSuggestionList').should( - 'have.text', - 'extension.raw' - ); - cy.get('[data-test-subj~="filterParamsComboBox"]').should( - 'have.text', - 'jpg' - ); - cy.getElementByTestId('cancelSaveFilter').click(); - }); - - it('should support filtering on nested fields', () => { - cy.submitFilterFromDropDown('nestedField.child', 'is', 'nestedValue'); - - cy.get('[data-test-subj~="filter-key-nestedField.child"]').should( - 'be.visible' - ); - cy.verifyHitCount('1'); - }); - }); -}); 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 deleted file mode 100644 index 6d99eecc5..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/index_pattern_with_encoded_id.spec.js +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - TestFixtureHandler, - MiscUtils, -} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { - DE_DEFAULT_END_TIME, - DE_DEFAULT_START_TIME, -} from '../../../../../utils/constants'; -import { CURRENT_TENANT } from '../../../../../utils/commands'; - -const miscUtils = new MiscUtils(cy); -const testFixtureHandler = new TestFixtureHandler( - cy, - Cypress.env('openSearchUrl') -); - -describe('index pattern with encoded id', () => { - before(() => { - CURRENT_TENANT.newTenant = 'global'; - testFixtureHandler.importJSONMapping( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/index_pattern_with_encoded_id/mappings.json.txt' - ); - - testFixtureHandler.importJSONDoc( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/index_pattern_with_encoded_id/data.json.txt' - ); - - cy.setAdvancedSetting({ - defaultIndex: 'with-encoded-id', - }); - - // Go to the Discover page - miscUtils.visitPage('app/data-explorer/discover#/'); - cy.setTopNavDate(DE_DEFAULT_START_TIME, DE_DEFAULT_END_TIME); - cy.waitForLoader(); - }); - - after(() => { - testFixtureHandler.clearJSONMapping( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/index_pattern_with_encoded_id/mappings.json.txt' - ); - }); - - describe('expand a document row', function () { - const rowToInspect = 1; - it('should expand the detail flyout when the toggle icon is clicked', function () { - cy.getElementByTestId(`docTableExpandToggleColumn-${rowToInspect - 1}`) - .should('be.visible') - .click(); - cy.getElementByTestId(`documentDetailFlyOut`).should('be.visible'); - }); - - it('should show the detail panel actions', function () { - cy.get('[data-test-subj^="docTableRowAction"]').should(`have.length`, 2); - }); - }); -}); 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 deleted file mode 100644 index bc09964e2..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/index_pattern_without_field.spec.js +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - TestFixtureHandler, - MiscUtils, -} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { CURRENT_TENANT } from '../../../../../utils/commands'; - -const miscUtils = new MiscUtils(cy); -const testFixtureHandler = new TestFixtureHandler( - cy, - Cypress.env('openSearchUrl') -); - -describe('index pattern without field spec', () => { - before(() => { - CURRENT_TENANT.newTenant = 'global'; - testFixtureHandler.importJSONMapping( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/index_pattern_without_timefield/mappings.json.txt' - ); - - testFixtureHandler.importJSONDoc( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/index_pattern_without_timefield/data.json.txt' - ); - - cy.setAdvancedSetting({ - defaultIndex: 'without-timefield', - }); - - // Go to the Discover page - miscUtils.visitPage('app/data-explorer/discover#/'); - cy.waitForLoader(); - }); - - after(() => { - testFixtureHandler.clearJSONMapping( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/index_pattern_without_timefield/mappings.json.txt' - ); - }); - - it('should not display a timepicker', () => { - cy.getElementByTestId('superDatePickerToggleQuickMenuButton').should( - 'not.exist' - ); - }); - - it('should display a timepicker after switching to an index pattern with timefield', () => { - const indexName = 'with-timefield'; - cy.getElementByTestId('comboBoxToggleListButton') - .should('be.visible') - .click(); - cy.contains('button', indexName).click(); - cy.waitForLoader(); - cy.getElementByTestId('superDatePickerToggleQuickMenuButton').should( - 'be.visible' - ); - }); -}); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/inspector.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/inspector.spec.js deleted file mode 100644 index afc9b6c55..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/inspector.spec.js +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - MiscUtils, - TestFixtureHandler, -} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { - DE_DEFAULT_END_TIME, - DE_DEFAULT_START_TIME, -} from '../../../../../utils/constants'; -import { CURRENT_TENANT } from '../../../../../utils/commands'; - -const miscUtils = new MiscUtils(cy); -const testFixtureHandler = new TestFixtureHandler( - cy, - Cypress.env('openSearchUrl') -); -const indexSet = [ - 'logstash-2015.09.22', - 'logstash-2015.09.21', - 'logstash-2015.09.20', -]; - -describe('inspector', () => { - before(() => { - CURRENT_TENANT.newTenant = 'global'; - // import logstash functional - testFixtureHandler.importJSONDocIfNeeded( - indexSet, - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.mappings.json.txt', - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.json.txt' - ); - - 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' - ); - - cy.setAdvancedSetting({ - defaultIndex: 'logstash-*', - }); - }); - - beforeEach(() => { - miscUtils.visitPage('app/data-explorer/discover#/'); - cy.waitForLoader(); - }); - - after(() => {}); - - it('should display request stats with no results', () => { - cy.getElementByTestId('openInspectorButton').click(); - cy.wait(1000); - cy.getElementByTestId('inspectorPanel') - .get('.euiTable tr:nth-child(2) td:nth-child(2) span') - .invoke('text') - .should('eq', '0'); - }); - - it('should display request stats with results', () => { - cy.setTopNavDate(DE_DEFAULT_START_TIME, DE_DEFAULT_END_TIME); - cy.waitForSearch(); - cy.getElementByTestId('openInspectorButton').click(); - cy.wait(1000); - cy.getElementByTestId('inspectorPanel') - .get('.euiTable tr:nth-child(2) td:nth-child(2) span') - .invoke('text') - .should('eq', '14004'); - }); -}); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/large_string.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/large_string.spec.js deleted file mode 100644 index 825bcbd60..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/large_string.spec.js +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - TestFixtureHandler, - MiscUtils, -} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { CURRENT_TENANT } from '../../../../../utils/commands'; - -const miscUtils = new MiscUtils(cy); -const testFixtureHandler = new TestFixtureHandler( - cy, - Cypress.env('openSearchUrl') -); - -describe('test large strings', () => { - before(() => { - CURRENT_TENANT.newTenant = 'global'; - testFixtureHandler.importJSONMapping( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/empty_opensearch_dashboards/mappings.json.txt' - ); - - testFixtureHandler.importJSONDoc( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/empty_opensearch_dashboards/data.json.txt' - ); - - testFixtureHandler.importJSONMapping( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/hamlet/mappings.json.txt' - ); - - testFixtureHandler.importJSONDoc( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/hamlet/data.json.txt' - ); - - //Error: could not locate the index pattern 'testlargestring' - cy.setAdvancedSetting({ - defaultIndex: 'fe302d30-62df-11e9-ab97-9ded634d922e', - }); - }); - - it('verify the large string book present', function () { - // Go to the Discover page - miscUtils.visitPage('app/data-explorer/discover#/'); - cy.waitForLoader(); - - const ExpectedDoc = 'Project Gutenberg EBook of Hamlet'; - - cy.get('[data-test-subj="dataGridRowCell"]:nth-child(3) span') - .invoke('text') - .then((text) => { - const hasTheText = text.includes(ExpectedDoc); - expect(hasTheText).to.be.true; - }); - }); - - describe('test large data', function () { - it('search Newsletter should show the correct hit count', function () { - cy.log('test Newsletter keyword is searched'); - const expectedHitCount = '1'; - const query = 'Newsletter'; - cy.setTopNavQuery(query); - cy.verifyHitCount(expectedHitCount); - }); - - // flaky when looking for the highlighted mark - it.skip('the search term Newsletter should be highlighted in the field data', function () { - cy.log('Newsletter appears only once'); - const expectedMarkCount = '1'; - cy.verifyMarkCount(expectedMarkCount); - }); - }); -}); 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 deleted file mode 100644 index 8173db2cb..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/saved_queries.spec.js +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - TestFixtureHandler, - MiscUtils, -} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { - DE_DEFAULT_END_TIME, - DE_DEFAULT_START_TIME, -} from '../../../../../utils/constants'; -import { CURRENT_TENANT } from '../../../../../utils/commands'; - -const miscUtils = new MiscUtils(cy); -const testFixtureHandler = new TestFixtureHandler( - cy, - Cypress.env('openSearchUrl') -); -const indexSet = [ - 'logstash-2015.09.22', - 'logstash-2015.09.21', - 'logstash-2015.09.20', -]; - -describe('saved queries saved objects', () => { - const fromTime = 'Sep 20, 2015 @ 08:00:00.000'; - const toTime = 'Sep 21, 2015 @ 08:00:00.000'; - before(() => { - CURRENT_TENANT.newTenant = 'global'; - 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' - ); - - // import logstash functional - testFixtureHandler.importJSONDocIfNeeded( - indexSet, - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.mappings.json.txt', - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.json.txt' - ); - - cy.setAdvancedSetting({ - defaultIndex: 'logstash-*', - }); - - // Go to the Discover page - miscUtils.visitPage('app/data-explorer/discover#/'); - - // Set time filter - cy.setTopNavDate(fromTime, toTime); - - // Set up query and filter - cy.setTopNavQuery('response:200'); - cy.submitFilterFromDropDown('extension.raw', 'is one of', 'jpg'); - - cy.waitForLoader(); - }); - - describe('saved query management component functionality', function () { - it('should show the saved query management component when there are no saved queries', () => { - cy.getElementByTestId('saved-query-management-popover-button').click(); - cy.getElementByTestId('saved-query-management-popover') - .should('be.visible') - .get('[id="savedQueryManagementPopoverTitle"]') - .should('have.text', 'Saved Queries'); - - cy.get('[class~="osdSavedQueryManagement__text"]').should( - 'have.text', - 'There are no saved queries. Save query text and filters that you want to use again.' - ); - }); - - it('should allow a query to be saved via the saved objects management component', () => { - cy.saveQuery('OkResponse', '200 responses for .jpg over 24 hours'); - cy.getElementByTestId('saveQueryFormIncludeTimeFilterOption').click(); - cy.getElementByTestId('savedQueryFormSaveButton').click(); - - cy.whenTestIdNotFound('saved-query-management-popover', () => { - cy.getElementByTestId('saved-query-management-popover-button').click(); - }); - cy.get(`[data-test-subj~="load-saved-query-OkResponse-button"]`).should( - 'be.visible' - ); - cy.getElementByTestId(`queryInput`).should('have.text', 'response:200'); - }); - - it('reinstates filters and the time filter when a saved query has filters and a time filter included', () => { - cy.setTopNavDate(DE_DEFAULT_START_TIME, DE_DEFAULT_END_TIME); - cy.getElementByTestId('queryInput').clear(); - cy.loadSaveQuery('OkResponse'); - - cy.getElementByTestId(`queryInput`).should('have.text', 'response:200'); - cy.verifyTimeConfig(fromTime, toTime); - }); - - // https://github.com/opensearch-project/OpenSearch-Dashboards/issues/5071 - it.skip('preserves the currently loaded query when the page is reloaded', () => { - // await browser.refresh(); - // const timePickerValues = await PageObjects.timePicker.getTimeConfigAsAbsoluteTimes(); - // expect(await filterBar.hasFilter('extension.raw', 'jpg')).to.be(true); - // expect(timePickerValues.start).to.not.eql(PageObjects.timePicker.defaultStartTime); - // expect(timePickerValues.end).to.not.eql(PageObjects.timePicker.defaultEndTime); - // await retry.waitFor( - // 'the right hit count', - // async () => (await PageObjects.discover.getHitCount()) === '2,792' - // ); - // expect(await savedQueryManagementComponent.getCurrentlyLoadedQueryID()).to.be('OkResponse'); - }); - - it('allows saving changes to a currently loaded query via the saved query management component', () => { - cy.loadSaveQuery('OkResponse'); - cy.setTopNavQuery(`response:404`); - cy.whenTestIdNotFound('saved-query-management-popover', () => { - cy.getElementByTestId('saved-query-management-popover-button').click(); - }); - cy.getElementByTestId( - 'saved-query-management-save-changes-button' - ).click(); - cy.getElementByTestId('savedQueryFormSaveButton').click(); - - cy.clearSaveQuery(); - - cy.getElementByTestId(`queryInput`).should('have.text', ''); - - cy.get(`[data-test-subj~="load-saved-query-OkResponse-button"]`) - .should('be.visible') - .click(); - - cy.getElementByTestId(`queryInput`).should('have.text', 'response:404'); - }); - - it('allows saving the currently loaded query as a new query', () => { - 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(); - }); - - it('allows deleting the currently loaded saved query in the saved query management component and clears the query', () => { - cy.deleteSaveQuery('OkResponseCopy'); - cy.getElementByTestId('saved-query-management-popover-button').click(); - cy.get( - `[data-test-subj~="load-saved-query-OkResponseCopy-button"]` - ).should('not.exist'); - cy.getElementByTestId(`queryInput`).should('have.text', ''); - }); - - it('does not allow saving a query with a non-unique name', () => { - cy.whenTestIdNotFound('saved-query-management-popover', () => { - cy.getElementByTestId('saved-query-management-popover-button').click(); - }); - cy.getElementByTestId('saved-query-management-save-button').click(); - - cy.getElementByTestId('saveQueryFormTitle').type('OkResponse'); - cy.getElementByTestId('savedQueryFormSaveButton').click(); - 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', () => { - cy.loadSaveQuery('OkResponse'); - cy.setTopNavQuery('response:503'); - cy.loadSaveQuery('OkResponse'); - cy.getElementByTestId(`queryInput`).should('have.text', 'response:404'); - }); - - it('allows clearing the currently loaded saved query', () => { - 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.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/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/shared_links.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/shared_links.spec.js deleted file mode 100644 index 61b9ae7f9..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/shared_links.spec.js +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - MiscUtils, - TestFixtureHandler, -} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { - DE_DEFAULT_END_TIME, - DE_DEFAULT_START_TIME, -} from '../../../../../utils/constants'; -import { CURRENT_TENANT } from '../../../../../utils/commands'; - -const miscUtils = new MiscUtils(cy); -const testFixtureHandler = new TestFixtureHandler( - cy, - Cypress.env('openSearchUrl') -); -const indexSet = [ - 'logstash-2015.09.22', - 'logstash-2015.09.21', - 'logstash-2015.09.20', -]; - -describe('shared links', () => { - before(() => { - CURRENT_TENANT.newTenant = 'global'; - 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' - ); - - // import logstash functional - testFixtureHandler.importJSONDocIfNeeded( - indexSet, - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.mappings.json.txt', - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.json.txt' - ); - - cy.setAdvancedSetting({ - defaultIndex: 'logstash-*', - }); - - miscUtils.visitPage('app/data-explorer/discover#/'); - cy.waitForLoader(); - cy.setTopNavDate(DE_DEFAULT_START_TIME, DE_DEFAULT_END_TIME); - cy.waitForSearch(); - }); - - describe('shared links with state in query', () => { - it('should allow for copying the snapshot URL', function () { - const url = `http://localhost:5601/app/data-explorer/discover#/?_a=(discover:(columns:!(_source),isDirty:!f,sort:!()),metadata:(indexPattern:'logstash-*',view:discover))&_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))&_q=(filters:!(),query:(language:kuery,query:''))`; - cy.getElementByTestId('shareTopNavButton').should('be.visible').click(); - cy.getElementByTestId('copyShareUrlButton') - .invoke('attr', 'data-share-url') - .should('eq', url) - .then((url) => { - cy.log(url); - cy.request(url).its('status').should('eq', 200); - }); - }); - - it('should allow for copying the snapshot URL as a short URL', function () { - cy.getElementByTestId('useShortUrl') - .should('be.visible') - .invoke('attr', 'aria-checked', 'true'); - cy.wait(1000); - // For some reasons, after making the toggle true, the data-share-url do not get updated in the cypress test - // Thus only testing if the button is clickable, instead of comparing the actual URL - cy.getElementByTestId('copyShareUrlButton').should('be.visible').click(); - }); - - it('should allow for copying the saved object URL', function () { - const url = - 'http://localhost:5601/app/data-explorer/discover/#/view/ab12e3c0-f231-11e6-9486-733b1ac9221a?_g=%28filters%3A%21%28%29%2CrefreshInterval%3A%28pause%3A%21t%2Cvalue%3A0%29%2Ctime%3A%28from%3A%272015-09-19T13%3A31%3A44.000Z%27%2Cto%3A%272015-09-24T01%3A31%3A44.000Z%27%29%29'; - - cy.getElementByTestId('exportAsSavedObject') - .get('.euiRadio__input') - .should('be.disabled'); - - // Load a save search - cy.loadSaveSearch('A Saved Search'); - - cy.getElementByTestId('shareTopNavButton').should('be.visible').click(); - cy.getElementByTestId('exportAsSavedObject').should('be.visible').click(); - cy.getElementByTestId('copyShareUrlButton') - .invoke('attr', 'data-share-url') - .should('eq', url) - .then((url) => { - cy.log(url); - cy.request(url).its('status').should('eq', 200); - }); - }); - }); - - describe('shared links with state in sessionStorage', () => { - before(() => { - cy.setAdvancedSetting({ - 'state:storeInSessionStorage': true, - }); - - miscUtils.visitPage('app/data-explorer/discover#/'); - cy.waitForLoader(); - cy.setTopNavDate(DE_DEFAULT_START_TIME, DE_DEFAULT_END_TIME); - cy.waitForSearch(); - }); - - after(() => { - cy.setAdvancedSetting({ - 'state:storeStateInSessionStorage': false, - }); - }); - - it('should allow for copying the snapshot URL', function () { - cy.getElementByTestId('shareTopNavButton').should('be.visible').click(); - cy.getElementByTestId('copyShareUrlButton') - .invoke('attr', 'data-share-url') - .then((url) => { - cy.log(url); - cy.request(url).its('status').should('eq', 200); - }); - }); - - it('should allow for copying the snapshot URL as a short URL', function () { - cy.getElementByTestId('useShortUrl').should('be.visible').click(); - cy.getElementByTestId('copyShareUrlButton') - .invoke('attr', 'data-share-url') - .then((url) => { - cy.log(url); - cy.request(url).its('status').should('eq', 200); - }); - }); - - it('should allow for copying the saved object URL', function () { - cy.getElementByTestId('exportAsSavedObject') - .get('.euiRadio__input') - .should('be.disabled'); - - // Load a save search - cy.loadSaveSearch('A Saved Search'); - - cy.getElementByTestId('shareTopNavButton').should('be.visible').click(); - cy.getElementByTestId('exportAsSavedObject').should('be.visible').click(); - cy.getElementByTestId('copyShareUrlButton') - .invoke('attr', 'data-share-url') - .then((url) => { - cy.log(url); - cy.request(url).its('status').should('eq', 200); - }); - }); - }); -}); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/sidebar.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/sidebar.spec.js deleted file mode 100644 index 4cf36e93c..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/sidebar.spec.js +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - MiscUtils, - TestFixtureHandler, -} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { CURRENT_TENANT } from '../../../../../utils/commands'; - -const miscUtils = new MiscUtils(cy); -const testFixtureHandler = new TestFixtureHandler( - cy, - Cypress.env('openSearchUrl') -); -const indexSet = [ - 'logstash-2015.09.22', - 'logstash-2015.09.21', - 'logstash-2015.09.20', -]; - -describe('discover sidebar', () => { - before(() => { - CURRENT_TENANT.newTenant = 'global'; - 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' - ); - - // import logstash functional - testFixtureHandler.importJSONDocIfNeeded( - indexSet, - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.mappings.json.txt', - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.json.txt' - ); - - cy.setAdvancedSetting({ - defaultIndex: 'logstash-*', - }); - - miscUtils.visitPage('app/data-explorer/discover#/'); - cy.waitForLoader(); - }); - - describe('field filtering', function () { - it('should reveal and hide the filter form when the toggle is clicked', function () { - cy.getElementByTestId('toggleFieldFilterButton').click(); - cy.getElementByTestId('filterSelectionPanel').should('be.visible'); - - cy.getElementByTestId('toggleFieldFilterButton').click(); - cy.getElementByTestId('filterSelectionPanel').should('not.exist'); - }); - }); - - // Add a test to test the expanding and collapsing behavior of the sidebar once it is implemented - // According to issue https://github.com/opensearch-project/OpenSearch-Dashboards/issues/4780 -}); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/source_filter.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/source_filter.spec.js deleted file mode 100644 index b5e2d39a5..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/source_filter.spec.js +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - TestFixtureHandler, - MiscUtils, -} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { CURRENT_TENANT } from '../../../../../utils/commands'; - -const miscUtils = new MiscUtils(cy); -const testFixtureHandler = new TestFixtureHandler( - cy, - Cypress.env('openSearchUrl') -); - -describe('source filters', () => { - before(() => { - CURRENT_TENANT.newTenant = 'global'; - testFixtureHandler.importJSONMapping( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/visualize_source-filters/mappings.json.txt' - ); - - testFixtureHandler.importJSONDoc( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/visualize_source-filters/data.json.txt' - ); - - // Go to the Discover page - miscUtils.visitPage( - `app/data-explorer/discover#/?_g=(filters:!(),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))` - ); - cy.waitForLoader(); - }); - - after(() => { - testFixtureHandler.clearJSONMapping( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/visualize_source-filters/mappings.json.txt' - ); - }); - - it('should not get the field referer', function () { - cy.getElementByTestId('fieldFilterSearchInput').type('referer'); - - cy.getElementByTestId('fieldToggle-referer').should('not.exist'); - }); -}); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/zzz_after.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/zzz_after.spec.js deleted file mode 100644 index 12d7407d2..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/zzz_after.spec.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -/// - -import { TestFixtureHandler } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { CURRENT_TENANT } from '../../../../../utils/commands'; - -const testFixtureHandler = new TestFixtureHandler( - cy, - Cypress.env('openSearchUrl') -); - -describe('After', () => { - before(() => { - CURRENT_TENANT.newTenant = 'global'; - //cy.deleteAllIndices(); - testFixtureHandler.clearJSONMapping( - 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.mappings.json.txt' - ); - cy.deleteSavedObjectByType('index-pattern'); - }); - - it('clean up complete', () => {}); -}); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis-augmenter/dashboard_spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis-augmenter/dashboard_spec.js deleted file mode 100644 index d97647c55..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis-augmenter/dashboard_spec.js +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - INDEX_PATTERN_FILEPATH_SIMPLE, - INDEX_SETTINGS_FILEPATH_SIMPLE, - SAMPLE_DATA_FILEPATH_SIMPLE, -} from '../../../../../utils/constants'; -import { - deleteVisAugmenterData, - bootstrapDashboard, -} from '../../../../../utils/dashboards/vis-augmenter/helpers'; - -describe('Vis augmenter - existing dashboards work as expected', () => { - describe('dashboard with ineligible, eligible, and vega visualizations', () => { - const indexName = 'vis-augmenter-sample-index'; - const indexPatternName = 'vis-augmenter-sample-*'; - const dashboardName = 'Vis Augmenter Dashboard'; - const visualizationSpecs = [ - { - name: 'count-agg-vis', - type: 'line', - indexPattern: indexPatternName, - metrics: [], - }, - { - name: 'single-metric-vis', - type: 'line', - indexPattern: indexPatternName, - metrics: [ - { - aggregation: 'Average', - field: 'value1', - }, - ], - }, - { - name: 'multi-metric-vis', - type: 'line', - indexPattern: indexPatternName, - metrics: [ - { - aggregation: 'Average', - field: 'value1', - }, - { - aggregation: 'Average', - field: 'value2', - }, - { - aggregation: 'Max', - field: 'value3', - }, - ], - }, - { - name: 'area-vis', - type: 'area', - indexPattern: indexPatternName, - metrics: [ - { - aggregation: 'Max', - field: 'value2', - }, - ], - }, - { - name: 'vega-vis', - type: 'vega', - indexPattern: indexPatternName, - metrics: [], - }, - ]; - - const visualizationNames = visualizationSpecs.map( - (visualizationSpec) => visualizationSpec.name - ); - - before(() => { - // Create a dashboard and add some visualizations - bootstrapDashboard( - INDEX_SETTINGS_FILEPATH_SIMPLE, - INDEX_PATTERN_FILEPATH_SIMPLE, - SAMPLE_DATA_FILEPATH_SIMPLE, - indexName, - indexPatternName, - dashboardName, - visualizationSpecs - ); - }); - - beforeEach(() => { - cy.visitDashboard(dashboardName); - }); - - after(() => { - deleteVisAugmenterData( - indexName, - indexPatternName, - visualizationNames, - dashboardName - ); - }); - - it('View events option does not exist for any visualization', () => { - visualizationNames.forEach((visualizationName) => { - cy.getVisPanelByTitle(visualizationName) - .openVisContextMenu() - .getMenuItems() - .contains('View Events') - .should('not.exist'); - }); - }); - - it('Validate non-vega visualizations are not rendered with vega under the hood', () => { - visualizationSpecs.forEach((visualizationSpec) => { - cy.getVisPanelByTitle(visualizationSpec.name).within(() => { - if (visualizationSpec.type === 'vega') { - cy.get('.vgaVis__view').should('exist'); - } else { - cy.get('.vgaVis__view').should('not.exist'); - } - }); - }); - }); - }); -}); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/basic.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/basic.spec.js deleted file mode 100644 index 35a03eed6..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/basic.spec.js +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ -import { - BASE_PATH, - toTestId, - VB_APP_PATH, - VB_APP_URL, - VB_INDEX_DOC_COUNT, - VB_INDEX_END_TIME, - VB_INDEX_ID, - VB_INDEX_PATTERN, - VB_INDEX_START_TIME, - VB_METRIC_VIS_TITLE, - VB_PATH_INDEX_DATA, - VB_PATH_SO_DATA, - VB_SO_TYPE, -} from '../../../../../utils/constants'; - -if (Cypress.env('VISBUILDER_ENABLED')) { - describe('Visualization Builder Base Tests', () => { - before(() => { - cy.deleteIndex(VB_INDEX_ID); - cy.bulkUploadDocs(VB_PATH_INDEX_DATA); - cy.importSavedObjects(VB_PATH_SO_DATA); - }); - - it('Show existing visualizations in Visualize and navigate to it', () => { - cy.visit(`${BASE_PATH}/app/visualize`); - cy.get('input[type="search"]').type(`${VB_METRIC_VIS_TITLE}{enter}`); - cy.get('.euiBasicTable-loading').should('not.exist'); // wait for the loading to stop - cy.getElementByTestId( - `visListingTitleLink-${toTestId(VB_METRIC_VIS_TITLE)}` - ) - .should('exist') - .click(); - cy.location('pathname').should('contain', VB_APP_PATH); - }); - - it('Navigate to Visualization Builder from Create Visualization', () => { - cy.visit(`${BASE_PATH}/app/visualize`); - cy.getElementByTestId('newItemButton').click(); - cy.getElementByTestId('visType-vis-builder').click(); - cy.location('pathname').should('eq', VB_APP_PATH); - }); - - it('Create new basic metric visualization', () => { - cy.visit(VB_APP_URL); - - // Wait for page to load - cy.waitForLoader(); - cy.vbSelectDataSource(VB_INDEX_PATTERN); - - // Set Top nav - cy.setTopNavDate(VB_INDEX_START_TIME, VB_INDEX_END_TIME); - - cy.vbSelectVisType('Metric'); - cy.getElementByTestId('field-undefined-showDetails').drag( - '[data-test-subj=dropBoxAddField-metric]' - ); - cy.getElementByTestId('visualizationLoader') - .find('.mtrVis__value') - .should('contain.text', VB_INDEX_DOC_COUNT); - - // Update Topnav - cy.setTopNavQuery('salary < 15000'); - - // See if the value updated - cy.getElementByTestId('visualizationLoader') - .find('.mtrVis__value') - .should('contain.text', `5,000`); - }); - - it('Be able to add/ edit and remove a field', () => { - cy.visit(VB_APP_URL); - - // Wait for page to load - cy.waitForLoader(); - cy.vbSelectDataSource(VB_INDEX_PATTERN); - cy.vbSelectVisType('Metric'); - - // Set Top nav - cy.setTopNavDate(VB_INDEX_START_TIME, VB_INDEX_END_TIME); - - cy.getElementByTestId('dropBoxAddField-metric') - .find('[data-test-subj="dropBoxAddBtn"]') - .click(); - cy.vbEditAgg([ - { - testSubj: 'defaultEditorAggSelect', - type: 'select', - value: 'Min', - }, - { - testSubj: 'visDefaultEditorField', - type: 'select', - value: 'age', - }, - ]); - - // Check if add worked - cy.getElementByTestId('visualizationLoader') - .find('.mtrVis__value') - .should('contain.text', '10'); - - cy.getElementByTestId('dropBoxField-metric-0').click(); - cy.vbEditAgg([ - { - testSubj: 'defaultEditorAggSelect', - type: 'select', - value: 'Max', - }, - ]); - - // Check if edit worked - cy.getElementByTestId('visualizationLoader') - .find('.mtrVis__value') - .should('contain.text', '100'); - - cy.getElementByTestId('dropBoxField-metric-0') - .find('[data-test-subj="dropBoxRemoveBtn"]') - .click(); - - // Check id remove worked - cy.getElementByTestId('emptyWorkspace').should('exist'); - }); - - it('Be able to save a visualization', () => { - cy.visit(VB_APP_URL); - - // Wait for page to load - cy.waitForLoader(); - cy.vbSelectDataSource(VB_INDEX_PATTERN); - - // Create basic vis - cy.getElementByTestId('field-undefined-showDetails').drag( - '[data-test-subj=dropBoxAddField-metric]' - ); - - // Save - const cleanupKey = Date.now(); - const title = `VB: vb${cleanupKey}`; - cy.getElementByTestId('visBuilderSaveButton') - .should('not.be.disabled') - .click(); - cy.getElementByTestId('savedObjectTitle').type(title + '{enter}'); - - // Verify save - cy.location('pathname').should('contain', VB_APP_PATH + '/edit'); - - // Cleanup - cy.deleteSavedObjectByType(VB_SO_TYPE, `vb${cleanupKey}`); - }); - - after(() => { - cy.deleteIndex(VB_INDEX_ID); - }); - }); -} diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/dashboard.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/dashboard.spec.js deleted file mode 100644 index 234d4138a..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/dashboard.spec.js +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ -import { - BASE_PATH, - VB_INDEX_PATTERN, - VB_INDEX_ID, - VB_DASHBOARD_ID, - toTestId, - VB_INDEX_DOC_COUNT, - VB_INDEX_START_TIME, - VB_INDEX_END_TIME, - VB_PATH_INDEX_DATA, - VB_PATH_SO_DATA, - VB_LINE_VIS_TITLE, - VB_SO_TYPE, - VB_METRIC_VIS_TITLE, - VB_BAR_VIS_TITLE, -} from '../../../../../utils/constants'; - -if (Cypress.env('VISBUILDER_ENABLED')) { - describe('Visualization Builder Dashboard Tests', () => { - before(() => { - cy.deleteIndex(VB_INDEX_ID); - cy.bulkUploadDocs(VB_PATH_INDEX_DATA); - - cy.importSavedObjects(VB_PATH_SO_DATA); - - cy.visit(`${BASE_PATH}/app/dashboards#/view/${VB_DASHBOARD_ID}`); - - // Wait for page to load - cy.waitForLoader(); - - cy.setTopNavDate(VB_INDEX_START_TIME, VB_INDEX_END_TIME); - }); - - it('Should have valid visualizations', () => { - cy.getElementByTestId( - `embeddablePanelHeading-${toTestId(VB_METRIC_VIS_TITLE, '')}` - ) - .should('contain.text', VB_METRIC_VIS_TITLE) - .siblings('.embPanel__content') - .find('.mtrVis__value') - .should('contain.text', VB_INDEX_DOC_COUNT); // Total no of record in the sample daa - cy.getElementByTestId( - `embeddablePanelHeading-${toTestId(VB_BAR_VIS_TITLE, '')}` - ) - .should('contain.text', VB_BAR_VIS_TITLE) - .siblings('.embPanel__content') - .find('.visLegend__valueTitle') - .should('contain.text', `Median`); - }); - - it('Should be able to add a visualization', () => { - // Add Vis Builder Visualisation to dashboard - cy.getElementByTestId('dashboardEditMode').click(); - cy.getElementByTestId('dashboardAddPanelButton').click(); - cy.getElementByTestId('savedObjectFinderFilterButton').click(); - cy.getElementByTestId( - 'savedObjectFinderFilter-visualization-visbuilder' - ).click(); - cy.getElementByTestId( - `savedObjectTitle${toTestId(VB_LINE_VIS_TITLE)}` - ).click(); - cy.getElementByTestId('euiFlyoutCloseButton').click(); - cy.getElementByTestId( - `embeddablePanelHeading-${toTestId(VB_LINE_VIS_TITLE, '')}` - ).should('exist'); - - // Cleanup - cy.getElementByTestId('dashboardViewOnlyMode').click(); - cy.getElementByTestId('confirmModalConfirmButton').click(); - }); - - it('Should be able to create a visualization', () => { - // Create new Vis Builder Visualisation - cy.getElementByTestId('dashboardEditMode').click(); - cy.getElementByTestId('dashboardAddNewPanelButton').click(); - cy.getElementByTestId('visType-vis-builder').click(); - - // Create a metric visualisation - cy.vbSelectDataSource(VB_INDEX_PATTERN); - cy.vbSelectVisType('Metric'); - cy.getElementByTestId('field-age-showDetails').drag( - '[data-test-subj=dropBoxAddField-metric]' - ); - - // Save and return - const cleanupKey = Date.now(); - const visTitle = `VB: New Dashboard Visualization - vb${cleanupKey}`; - cy.getElementByTestId('visBuilderSaveButton') - .should('not.be.disabled') - .click(); - cy.getElementByTestId('savedObjectTitle').type(visTitle); - cy.getElementByTestId('confirmSaveSavedObjectButton').click(); - - // Wait for page to load - cy.waitForLoader(); - // Check to see if the new vis is present in the dashboard - cy.getElementByTestId( - `embeddablePanelHeading-${toTestId(visTitle, '')}` - ).should('exist'); - - // Cleanup - cy.getElementByTestId('dashboardViewOnlyMode').click(); - cy.getElementByTestId('confirmModalConfirmButton').click(); - cy.deleteSavedObjectByType(VB_SO_TYPE, `vb${cleanupKey}`); - }); - - it( - 'Should be able to edit a visualization', - { retries: { runMode: 2 } }, - () => { - // Navigate to vis builder - cy.getElementByTestId('dashboardEditMode').click(); - cy.getElementByTestId( - `embeddablePanelHeading-${toTestId(VB_METRIC_VIS_TITLE, '')}` - ) - .find('[data-test-subj="embeddablePanelToggleMenuIcon"]') - .click(); - cy.getElementByTestId('embeddablePanelAction-editPanel').click(); - cy.getElementByTestId('visualizationLoader') - .find('.mtrVis__value') - .should('contain.text', VB_INDEX_DOC_COUNT); - - // Edit visualization - const newLabel = 'Editied Label'; - cy.getElementByTestId('dropBoxField-metric-0').click(); - cy.vbEditAgg([ - { - testSubj: 'visEditorStringInput1customLabel', - type: 'input', - value: newLabel, - }, - ]); - - // Save and return - cy.getElementByTestId('visBuilderSaveAndReturnButton').click(); - - cy.getElementByTestId('visBuilderLoader').should( - 'contain.text', - newLabel - ); - } - ); - - after(() => { - cy.deleteIndex(VB_INDEX_ID); - }); - }); -} diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/experimental.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/experimental.spec.js deleted file mode 100644 index e2d13b89f..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/experimental.spec.js +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - BASE_PATH, - toTestId, - VB_APP_URL, - VB_DASHBOARD_ID, - VB_METRIC_VIS_TITLE, - VB_PATH_SO_DATA, -} from '../../../../../utils/constants'; - -if (Cypress.env('VISBUILDER_ENABLED')) { - describe('Visualization Builder Experimental settings', () => { - before(() => { - cy.importSavedObjects(VB_PATH_SO_DATA); - }); - - it('Sould show experimental banner', () => { - cy.setAdvancedSetting({ 'visualize:enableLabs': true }); - cy.visit(VB_APP_URL); - - // Check experimental banner - cy.getElementByTestId('experimentalVisInfo').should('exist'); - }); - - it('Sould show experimental icons', () => { - cy.setAdvancedSetting({ 'visualize:enableLabs': true }); - - // Check experimental icon in visualize list - cy.visit(`${BASE_PATH}/app/visualize`); - cy.get('input[type="search"]').type(`${VB_METRIC_VIS_TITLE}{enter}`); - cy.getElementByTestId('itemsInMemTable') - .find('.visListingTable__experimentalIcon') - .should('exist'); - - // Check Create visualization modal - cy.getElementByTestId('newItemButton').click(); - cy.getElementByTestId(['visType-vis-builder']) - .find('.euiKeyPadMenuItem__betaBadge') - .should('exist'); - }); - - it('Sould handle experimental setting turned on', () => { - cy.setAdvancedSetting({ 'visualize:enableLabs': true }); - - // Check visualize listing - cy.visit(`${BASE_PATH}/app/visualize`); - cy.get('input[type="search"]').type(`${VB_METRIC_VIS_TITLE}{enter}`); - cy.getElementByTestId( - `visListingTitleLink-${toTestId(VB_METRIC_VIS_TITLE)}` - ).should('exist'); - - // Check Create visualization modal - cy.getElementByTestId('newItemButton').click(); - cy.getElementByTestId(['visType-vis-builder']).should('exist'); - - // Check Dashboard - cy.visit(`${BASE_PATH}/app/dashboards#/view/${VB_DASHBOARD_ID}`); - cy.getElementByTestId('visBuilderLoader').should('exist'); - }); - - it('Sould handle experimental setting turned off', () => { - cy.setAdvancedSetting({ 'visualize:enableLabs': false }); - - // Check visualize listing - cy.visit(`${BASE_PATH}/app/visualize`); - cy.get('input[type="search"]').type(`${VB_METRIC_VIS_TITLE}{enter}`); - cy.getElementByTestId( - `visListingTitleLink-${toTestId(VB_METRIC_VIS_TITLE)}` - ).should('not.exist'); - - // Check Create visualization modal - cy.getElementByTestId('newItemButton').click(); - cy.getElementByTestId(['visType-vis-builder']).should('not.exist'); - - // Check Dashboard - cy.visit(`${BASE_PATH}/app/dashboards#/view/${VB_DASHBOARD_ID}`); - cy.getElementByTestId('disabledVisBuilderVis').should('exist'); - }); - - after(() => { - // Reset the value - cy.setAdvancedSetting({ 'visualize:enableLabs': null }); - }); - }); -} diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/area.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/area.spec.js deleted file mode 100644 index 8bf522d3c..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/area.spec.js +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - VB_APP_URL, - VB_INDEX_END_TIME, - VB_INDEX_ID, - VB_INDEX_PATTERN, - VB_INDEX_START_TIME, - VB_PATH_INDEX_DATA, - VB_PATH_SO_DATA, -} from '../../../../../../utils/constants'; - -if (Cypress.env('VISBUILDER_ENABLED')) { - describe('Vis Builder: Area Chart', () => { - before(() => { - cy.deleteIndex(VB_INDEX_ID); - cy.bulkUploadDocs(VB_PATH_INDEX_DATA); - cy.importSavedObjects(VB_PATH_SO_DATA); - - cy.visit(VB_APP_URL); - - // Wait for page to load - cy.waitForLoader(); - cy.vbSelectDataSource(VB_INDEX_PATTERN); - - // Set Top nav - cy.setTopNavDate(VB_INDEX_START_TIME, VB_INDEX_END_TIME); - - cy.vbSelectVisType('Area'); - }); - - it('Basic test', () => { - cy.getElementByTestId('field-salary-showDetails').drag( - '[data-test-subj="dropBoxAddField-metric"]' - ); - cy.getElementByTestId('field-categories.keyword-showDetails').drag( - '[data-test-subj="dropBoxAddField-segment"]' - ); - testAreaValues([11250, 13750, 18750, 16250]); - }); - - after(() => { - cy.deleteIndex(VB_INDEX_ID); - }); - }); -} - -export const testAreaValues = (values, delta = 10) => { - cy.getElementByTestId('visualizationLoader') - .find('.points.area circle') - .should('have.length', values.length) - .and(($rect) => { - values.forEach((value, index) => { - expect(Math.round($rect.get(index).__data__.y)).to.be.closeTo( - value, - delta - ); - }); - }); -}; diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/bar.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/bar.spec.js deleted file mode 100644 index a85e45603..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/bar.spec.js +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - VB_APP_URL, - VB_INDEX_END_TIME, - VB_INDEX_ID, - VB_INDEX_PATTERN, - VB_INDEX_START_TIME, - VB_PATH_INDEX_DATA, - VB_PATH_SO_DATA, -} from '../../../../../../utils/constants'; - -if (Cypress.env('VISBUILDER_ENABLED')) { - describe('Vis Builder: Bar Chart', () => { - before(() => { - cy.deleteIndex(VB_INDEX_ID); - cy.bulkUploadDocs(VB_PATH_INDEX_DATA); - cy.importSavedObjects(VB_PATH_SO_DATA); - - cy.visit(VB_APP_URL); - - // Wait for page to load - cy.waitForLoader(); - cy.vbSelectDataSource(VB_INDEX_PATTERN); - - // Set Top nav - cy.setTopNavDate(VB_INDEX_START_TIME, VB_INDEX_END_TIME); - - cy.vbSelectVisType('Bar'); - }); - - it('Basic test', () => { - cy.getElementByTestId('field-salary-showDetails').drag( - '[data-test-subj="dropBoxAddField-metric"]' - ); - cy.getElementByTestId('field-categories.keyword-showDetails').drag( - '[data-test-subj="dropBoxAddField-segment"]' - ); - testBarValues([11250, 13750, 18750, 16250]); - }); - - after(() => { - cy.deleteIndex(VB_INDEX_ID); - }); - }); -} - -export const testBarValues = (values, delta = 10) => { - cy.getElementByTestId('visualizationLoader') - .find('.histogram rect') - .should('have.length', values.length) - .and(($rect) => { - values.forEach((value, index) => { - expect(Math.round($rect.get(index).__data__.y)).to.be.closeTo( - value, - delta - ); - }); - }); -}; diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/line.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/line.spec.js deleted file mode 100644 index 08cd6a509..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/line.spec.js +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - VB_APP_URL, - VB_INDEX_END_TIME, - VB_INDEX_ID, - VB_INDEX_PATTERN, - VB_INDEX_START_TIME, - VB_PATH_INDEX_DATA, - VB_PATH_SO_DATA, -} from '../../../../../../utils/constants'; - -if (Cypress.env('VISBUILDER_ENABLED')) { - describe('Vis Builder: Line Chart', () => { - before(() => { - cy.deleteIndex(VB_INDEX_ID); - cy.bulkUploadDocs(VB_PATH_INDEX_DATA); - cy.importSavedObjects(VB_PATH_SO_DATA); - - cy.visit(VB_APP_URL); - - // Wait for page to load - cy.waitForLoader(); - cy.vbSelectDataSource(VB_INDEX_PATTERN); - - // Set Top nav - cy.setTopNavDate(VB_INDEX_START_TIME, VB_INDEX_END_TIME); - - cy.vbSelectVisType('Line'); - }); - - it('Basic test', () => { - cy.getElementByTestId('field-salary-showDetails').drag( - '[data-test-subj="dropBoxAddField-metric"]' - ); - cy.getElementByTestId('field-categories.keyword-showDetails').drag( - '[data-test-subj="dropBoxAddField-segment"]' - ); - testLineValues([11250, 13750, 18750, 16250]); - }); - - after(() => { - cy.deleteIndex(VB_INDEX_ID); - }); - }); -} - -export const testLineValues = (values, delta = 10) => { - cy.getElementByTestId('visualizationLoader') - .find('.points.line circle.circle') - .should('have.length', values.length) - .and(($rect) => { - values.forEach((value, index) => { - expect(Math.round($rect.get(index).__data__.y)).to.be.closeTo( - value, - delta - ); - }); - }); -}; diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/metric.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/metric.spec.js deleted file mode 100644 index 52ef8676a..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/metric.spec.js +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - VB_APP_URL, - VB_INDEX_END_TIME, - VB_INDEX_ID, - VB_INDEX_PATTERN, - VB_INDEX_START_TIME, - VB_PATH_INDEX_DATA, - VB_PATH_SO_DATA, -} from '../../../../../../utils/constants'; - -if (Cypress.env('VISBUILDER_ENABLED')) { - describe('Vis Builder: Metric Chart', () => { - before(() => { - cy.deleteIndex(VB_INDEX_ID); - cy.bulkUploadDocs(VB_PATH_INDEX_DATA); - cy.importSavedObjects(VB_PATH_SO_DATA); - - cy.visit(VB_APP_URL); - - // Wait for page to load - cy.waitForLoader(); - cy.vbSelectDataSource(VB_INDEX_PATTERN); - - // Set Top nav - cy.setTopNavDate(VB_INDEX_START_TIME, VB_INDEX_END_TIME); - - cy.vbSelectVisType('Metric'); - }); - - it('Basic test', () => { - cy.getElementByTestId('field-undefined-showDetails').drag( - '[data-test-subj="dropBoxAddField-metric"]' - ); - testMetric('10,000'); - }); - - after(() => { - cy.deleteIndex(VB_INDEX_ID); - }); - }); -} - -export const testMetric = (value) => { - cy.getElementByTestId('visualizationLoader') - .find('.mtrVis__value') - .should('contain.text', value); -}; diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/table.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/table.spec.js deleted file mode 100644 index 4abc9d100..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/table.spec.js +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - VB_APP_URL, - VB_INDEX_END_TIME, - VB_INDEX_ID, - VB_INDEX_PATTERN, - VB_INDEX_START_TIME, - VB_PATH_INDEX_DATA, - VB_PATH_SO_DATA, -} from '../../../../../../utils/constants'; - -if (Cypress.env('VISBUILDER_ENABLED')) { - describe('Vis Builder: Table Chart', () => { - before(() => { - cy.deleteIndex(VB_INDEX_ID); - cy.bulkUploadDocs(VB_PATH_INDEX_DATA); - cy.importSavedObjects(VB_PATH_SO_DATA); - - cy.visit(VB_APP_URL); - - // Wait for page to load - cy.waitForLoader(); - cy.vbSelectDataSource(VB_INDEX_PATTERN); - - // Set Top nav - cy.setTopNavDate(VB_INDEX_START_TIME, VB_INDEX_END_TIME); - - cy.vbSelectVisType('Table'); - }); - - it('Basic test', () => { - // vis builder should render a basic table vis - cy.getElementByTestId('field-undefined-showDetails').drag( - '[data-test-subj="dropBoxAddField-metric"]' - ); - testMetric('10,000'); - - // vis builder should render a table vis with multiple rows - cy.getElementByTestId('field-categories.keyword-showDetails').drag( - '[data-test-subj="dropBoxAddField-bucket"]' - ); - testSplitRows(['Cat', 'Dog', 'Hawk', 'Rabbit']); - removeBucket('dropBoxField-bucket-0'); - - // vis builder should render splitted tables in rows - cy.getElementByTestId('field-categories.keyword-showDetails').drag( - '[data-test-subj="dropBoxAddField-split_row"]' - ); - testSplitTables(4); - removeBucket('dropBoxField-split_row-0'); - - // vis builder should render splitted tables in columns - cy.getElementByTestId('field-categories.keyword-showDetails').drag( - '[data-test-subj="dropBoxAddField-split_column"]' - ); - testSplitTables(4); - }); - - after(() => { - cy.deleteIndex(VB_INDEX_ID); - }); - }); -} - -export const testMetric = (value) => { - cy.getElementByTestId('dataGridRowCell') - .find('[class="euiDataGridRowCell__truncate"]') - .should('contain.text', value); -}; - -export const testSplitRows = (valueArray) => { - for (var value of valueArray) { - testMetric(value); - } -}; - -// remove a bucket metric -export const removeBucket = (bucket) => { - cy.getElementByTestId(bucket).within((item) => { - item.find('[data-test-subj="dropBoxRemoveBtn"]').click(); - }); -}; - -export const testSplitTables = (num) => { - cy.getElementByTestId('visTable') - .should('have.class', 'visTable') - .find('.visTable__group') - .should(($tables) => { - // should have found specified number of tables - expect($tables).to.have.length(num); - }); -}; diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/basic.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/basic.spec.js deleted file mode 100644 index f2d822d23..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/basic.spec.js +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - TABLE_INDEX_ID, - TABLE_INDEX_PATTERN, - TABLE_PATH_INDEX_DATA, - TABLE_INDEX_START_TIME, - TABLE_INDEX_END_TIME, - TABLE_CREATE_URL, - TABLE_VIS_APP_PATH, - TABLE_VIS_TYPE, -} from '../../../../../utils/constants'; - -/** - * Basic test suite description: - * Create a new table visualization from index pattern. - * Set the time range and Histogram Aggregation. - * Test that global header and side bar function correctly. - * Test that table visualization can be saved. - * Test inspector is enabled and contains correct data. - */ - -describe('table visualization basic functions', () => { - before(() => { - cy.deleteIndex(TABLE_INDEX_ID); - cy.deleteIndexPattern(TABLE_INDEX_PATTERN); - cy.bulkUploadDocs(TABLE_PATH_INDEX_DATA); - cy.createIndexPattern(TABLE_INDEX_PATTERN, { - title: TABLE_INDEX_ID, - timeFieldName: 'timestamp', - }); - - cy.log('create a new table visualization: ', TABLE_CREATE_URL); - cy.visit(TABLE_CREATE_URL); - cy.url().should('contain', TABLE_VIS_APP_PATH); - // Select index pattern and load table visualization - cy.setTopNavDate(TABLE_INDEX_START_TIME, TABLE_INDEX_END_TIME); - // Wait for page to load - cy.waitForLoader(); - }); - - it('Should apply changed params and allow to reset', () => { - // Set a Histogram Aggregation - cy.tbAddBucketsAggregation(); - cy.tbSplitRows(); - cy.tbSetupHistogramAggregation('age', '20', 2); - // Update Historgram interval - cy.tbSetHistogramInterval('201', 2); - cy.tbIsUpdateAggregationSettingsEnabled(); - // Discard the updated interval - cy.tbDiscardAggregationSettings(); - cy.tbIsHistogramIntervalSet('20', 2); - }); - - it('Should be able to save and load', () => { - const cleanupKey = Date.now(); - const title = `table${cleanupKey}`; - // Save - cy.log('Save this table visualization with title ', title); - cy.getElementByTestId('visualizeSaveButton') - .should('not.be.disabled') - .click(); - cy.getElementByTestId('savedObjectTitle').type(title); - cy.getElementByTestId('confirmSaveSavedObjectButton').click(); - // Verify save - cy.getElementByTestId('breadcrumb last') - .invoke('attr', 'title') - .should('equal', title); - // Cleanup - cy.log('Remove saved table visualization with title ', title); - cy.deleteSavedObjectByType(TABLE_VIS_TYPE, title); - }); - - it('Should have inspector enabled', () => { - cy.getElementByTestId('openInspectorButton') - .invoke('attr', 'class') - .should( - 'equal', - 'euiButtonEmpty euiButtonEmpty--primary euiButtonEmpty--xSmall euiHeaderLink' - ); - }); - - it('Should show correct data in inspector', () => { - const expectedData = [ - '0', - '1,059', - '20', - '2,236', - '40', - '2,200', - '60', - '2,211', - '80', - '2,179', - '100', - '115', - ]; - cy.tbOpenInspector(); - cy.tbGetTableDataFromInspectPanel().then((data) => { - expect(data).to.deep.eq(expectedData); - }); - cy.tbCloseInspector(); - }); - - after(() => { - cy.deleteIndex(TABLE_INDEX_ID); - cy.deleteIndexPattern(TABLE_INDEX_PATTERN); - }); -}); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/data.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/data.spec.js deleted file mode 100644 index 7f3f8aa54..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/data.spec.js +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { CommonUI } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { - BASE_PATH, - TABLE_INDEX_ID, - TABLE_PATH_INDEX_DATA, - TABLE_INDEX_PATTERN, - TABLE_PATH_SO_DATA, - TABLE_BASIC_VIS_TITLE, - TABLE_VIS_APP_PATH, - TABLE_INDEX_START_TIME, - TABLE_INDEX_END_TIME, - toTestId, -} from '../../../../../utils/constants'; - -const commonUI = new CommonUI(cy); - -// TODO: Remove cy.wait(500) -// https://github.com/opensearch-project/OpenSearch-Dashboards/issues/4157 - -describe('table visualization data', () => { - before(() => { - cy.deleteIndex(TABLE_INDEX_ID); - cy.deleteIndexPattern(TABLE_INDEX_PATTERN); - cy.bulkUploadDocs(TABLE_PATH_INDEX_DATA); - cy.importSavedObjects(TABLE_PATH_SO_DATA); - // Load table visualization - cy.visit(`${BASE_PATH}/app/visualize`); - cy.get('input[type="search"]').type(`${TABLE_BASIC_VIS_TITLE}{enter}`); - cy.get('.euiBasicTable-loading').should('not.exist'); // wait for the loading to stop - cy.getElementByTestId( - `visListingTitleLink-${toTestId(TABLE_BASIC_VIS_TITLE)}` - ) - .should('exist') - .click(); - cy.url().should('contain', TABLE_VIS_APP_PATH); - cy.setTopNavDate(TABLE_INDEX_START_TIME, TABLE_INDEX_END_TIME); - cy.waitForLoader(); - }); - - after(() => { - cy.deleteIndex(TABLE_INDEX_ID); - cy.deleteIndexPattern(TABLE_INDEX_PATTERN); - }); - - describe('Check Range aggregation and Percentage Col functions', () => { - const expectedData = ['≥ 0 and < 20', '1,059', '≥ 20 and < 40', '2,236']; - const expectedAverageData = [ - '≥ 0 and < 20', - '1,059', - '14.469', - '≥ 20 and < 40', - '2,236', - '29.53', - ]; - - it('Should show correct range', () => { - cy.tbAddBucketsAggregation(); - cy.tbSplitRows(); - cy.tbSetupRangeAggregation( - 'age', - [ - ['0', '20'], - ['20', '40'], - ], - 2 - ); - cy.waitForLoader(); - cy.wait(500); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectedData); - }); - }); - - it('Should show correct average metrics', () => { - cy.tbOpenDataPanel(); - cy.tbAddMetricsAggregation(); - cy.tbSelectAggregationType('Average', 3); - cy.tbSelectAggregationField('age', 3); - cy.tbUpdateAggregationSettings(); - cy.waitForLoader(); - cy.wait(500); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectedAverageData); - }); - }); - - after(() => { - cy.log('clean out all metrics and buckets aggregations'); - cy.tbRemoveAllAggregations(3); - cy.tbUpdateAggregationSettings(); - cy.waitForLoader(); - }); - }); - - describe('Check Average Pipeline aggregation', () => { - it('Should show correct data when using average pipeline aggregation', () => { - const expectedData = ['10,000', '128.2']; - cy.tbAddMetricsAggregation(); - cy.tbSelectAggregationType('Average Bucket', 2); - cy.tbSelectSubAggregationType('Terms', 2, 'buckets'); - cy.tbSelectSubAggregationField('age', 2, 'buckets'); - cy.tbSelectSubAggregationType('Count', 2, 'metrics'); - cy.tbUpdateAggregationSettings(); - cy.waitForLoader(); - cy.wait(500); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectedData); - }); - }); - - after(() => { - cy.log('clean out all metrics and buckets aggregations'); - cy.tbRemoveAllAggregations(2); - cy.tbUpdateAggregationSettings(); - cy.waitForLoader(); - }); - }); - - describe('Check Date Histogram aggregation and filter functons', () => { - it('Should show correct data for a data table with date histogram', () => { - const expectedData = ['2021', '13', '2022', '9,987']; - cy.tbAddBucketsAggregation(); - cy.tbSplitRows(); - cy.tbSetupDateHistogramAggregation('timestamp', 'Year', 2); - cy.waitForLoader(); - cy.wait(500); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectedData); - }); - }); - - it('Should correctly filter for applied time filter on the main timefield', () => { - commonUI.addFilterRetrySelection('timestamp', 'is', '2022-05-30'); - cy.waitForLoader(); - cy.wait(500); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(['2022', '37']); - }); - commonUI.removeFilter('timestamp'); - cy.waitForLoader(); - commonUI.addFilterRangeRetrySelection( - 'timestamp', - 'is between', - '2022-05-30', - '2022-08-30' - ); - cy.waitForLoader(); - cy.wait(500); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(['2022', '3,370']); - }); - }); - - it('Should correctly filter for pinned filters', () => { - commonUI.pinFilter('timestamp'); - cy.waitForLoader(); - cy.wait(500); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(['2022', '3,370']); - }); - commonUI.removeFilter('timestamp'); - cy.waitForLoader(); - cy.wait(500); - }); - - after(() => { - cy.log('clean out all metrics and buckets aggregations'); - cy.tbRemoveAllAggregations(2); - cy.tbUpdateAggregationSettings(); - cy.waitForLoader(); - }); - }); - - describe('Check Terms aggregation and missing values', () => { - it('Should show correct data before and after adding doc', () => { - cy.waitForLoader(); - cy.wait(500); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(['10,000']); - }); - // add a doc with missing values - cy.insertDocumentToIndex('vis-table', 10000, { - timestamp: '2022-08-30T23:20:41.280Z', - username: 'missing', - }); - cy.reload(); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(['10,001']); - }); - }); - - it('Should group data in other', () => { - const expectDataBeforeGroupInOther = [ - '79', - '132', - '54', - '129', - '33', - '128', - '31', - '126', - '57', - '126', - ]; - const expectDataAfterGroupInOther = [ - '79', - '132', - '54', - '129', - '33', - '128', - '31', - '126', - '57', - '126', - '9,359', - ]; - cy.tbAddBucketsAggregation(); - cy.tbSplitRows(); - cy.tbSetupTermsAggregation('age', 'Descending', '5', 2); - cy.waitForLoader(); - cy.wait(500); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectDataBeforeGroupInOther); - }); - cy.tbToggleOtherBucket('true'); - cy.tbUpdateAggregationSettings(); - cy.waitForLoader(); - cy.wait(500); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectDataAfterGroupInOther); - }); - }); - - it('Should include missing data', () => { - const expectDataBeforeMissing = [ - 'Bryce88@gmail.com', - '2', - 'Isaiah22@yahoo.com', - '2', - 'Jake54@gmail.com', - '2', - 'Linnea4@yahoo.com', - '2', - 'Sherwood92@gmail.com', - '2', - '9,990', - ]; - const expectDataAfterMissing = [ - 'Bryce88@gmail.com', - '2', - 'Isaiah22@yahoo.com', - '2', - 'Jake54@gmail.com', - '2', - 'Linnea4@yahoo.com', - '2', - 'Sherwood92@gmail.com', - '2', - '9,991', - ]; - cy.tbSelectAggregationField('email.keyword', 2); - cy.tbUpdateAggregationSettings(); - cy.waitForLoader(); - cy.wait(500); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectDataBeforeMissing); - }); - cy.tbToggleMissingBucket('true'); - cy.tbUpdateAggregationSettings(); - cy.waitForLoader(); - cy.wait(500); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectDataAfterMissing); - }); - }); - - after(() => { - cy.log('clean out all metrics and buckets aggregations'); - cy.tbRemoveAllAggregations(2); - cy.tbUpdateAggregationSettings(); - cy.waitForLoader(); - }); - }); -}); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/embed.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/embed.spec.js deleted file mode 100644 index 071a5b67f..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/embed.spec.js +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { CommonUI } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { - BASE_PATH, - TABLE_INDEX_ID, - TABLE_PATH_INDEX_DATA, - TABLE_INDEX_PATTERN, - TABLE_PATH_SO_DATA, - TABLE_BASIC_VIS_TITLE, - TABLE_VIS_APP_PATH, - TABLE_INDEX_START_TIME, - TABLE_INDEX_END_TIME, - toTestId, -} from '../../../../../utils/constants'; - -const commonUI = new CommonUI(cy); - -/** - * Embed test suite description: - * Sometimes, we might want to embed a visualization in an iframe. - * This suite is to test how an embedded table visualization works. - * In this test suite, we have the following tests: - * Test that a table visualization is loaded properly in embedded mode. - * Test that table visualization can be filtered in embedded mode. - * Test that table visualization can filter for value. There are two ways - * to filter for value. First is to click the filter for button. Second is - * to click the expand button then choose fiter for option. We test both ways. - * Test that table visualization can filter out value. Same as filter for value. - */ - -describe('table visualization in embedded mode', () => { - const expectedData = [ - '0', - '1,059', - '20', - '2,236', - '40', - '2,200', - '60', - '2,211', - '80', - '2,179', - '100', - '115', - ]; - - const suppressResizeObserverIssue = () => { - // exception is thrown on loading EuiDataGrid in cypress only, ignore for now - cy.on('uncaught:exception', (err) => { - if (err.message.includes('ResizeObserver loop')) return false; - }); - }; - - before(() => { - cy.deleteIndex(TABLE_INDEX_ID); - cy.deleteIndexPattern(TABLE_INDEX_PATTERN); - cy.bulkUploadDocs(TABLE_PATH_INDEX_DATA); - cy.importSavedObjects(TABLE_PATH_SO_DATA); - // Load table visualization - cy.visit(`${BASE_PATH}/app/visualize`); - cy.get('input[type="search"]').type(`${TABLE_BASIC_VIS_TITLE}{enter}`); - cy.get('.euiBasicTable-loading').should('not.exist'); // wait for the loading to stop - cy.getElementByTestId( - `visListingTitleLink-${toTestId(TABLE_BASIC_VIS_TITLE)}` - ) - .should('exist') - .click(); - cy.url().should('contain', TABLE_VIS_APP_PATH); - cy.setTopNavDate(TABLE_INDEX_START_TIME, TABLE_INDEX_END_TIME); - cy.waitForLoader(); - // Set a Histogram Aggregation - // We will use this aggregation for all test case - cy.tbAddBucketsAggregation(); - cy.tbSplitRows(); - cy.tbSetupHistogramAggregation('age', '20', 2); - cy.url().then((url) => { - let embedUrl = url + '&embed=true'; - cy.wrap(embedUrl).as('embedUrl'); - }); - cy.get('@embedUrl').then((url) => { - expect(url).to.contain('&embed=true'); - cy.visit(url); - cy.reload(); - }); - }); - - // after(() => { - // cy.deleteIndex(TABLE_INDEX_ID); - // cy.deleteIndexPattern(TABLE_INDEX_PATTERN); - // }); - - it('Should open table vis in embedded mode', () => { - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectedData); - }); - }); - - it('Should allow to filter in embedded mode', () => { - commonUI.addFilterRangeRetrySelection('age', 'is between', '10', '30'); - cy.reload(); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(['0', '1,059', '20', '1,114']); - }); - commonUI.removeFilter('age'); - cy.reload(); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectedData); - }); - }); - - it('Should filter for value in embedded mode', () => { - cy.tbClickTableCellAction(2, 0, 0, 'filter for', 0, true); - cy.reload(); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(['0', '1,059']); - }); - commonUI.removeFilter('age'); - cy.reload(); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectedData); - }); - cy.tbClickTableCellAction(2, 0, 0, 'expand', 0, true); - cy.tbClickFilterFromExpand('filter for'); - cy.reload(); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(['0', '1,059']); - }); - commonUI.removeFilter('age'); - cy.reload(); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectedData); - }); - }); - - it('Should filter out value in embedded mode', () => { - const expectedFilterOutData = [ - '20', - '2,236', - '40', - '2,200', - '60', - '2,211', - '80', - '2,179', - '100', - '115', - ]; - cy.tbClickTableCellAction(2, 0, 0, 'filter out', 0, true); - cy.reload(); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectedFilterOutData); - }); - commonUI.removeFilter('age'); - cy.reload(); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectedData); - }); - cy.tbClickTableCellAction(2, 0, 0, 'expand', 0, true); - suppressResizeObserverIssue(); - cy.tbClickFilterFromExpand('filter out'); - cy.reload(); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectedFilterOutData); - }); - commonUI.removeFilter('age'); - cy.reload(); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectedData); - }); - }); -}); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/options.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/options.spec.js deleted file mode 100644 index e7b9575e6..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/options.spec.js +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - BASE_PATH, - TABLE_INDEX_ID, - TABLE_PATH_INDEX_DATA, - TABLE_INDEX_PATTERN, - TABLE_PATH_SO_DATA, - TABLE_BASIC_VIS_TITLE, - TABLE_VIS_APP_PATH, - TABLE_INDEX_START_TIME, - TABLE_INDEX_END_TIME, - toTestId, -} from '../../../../../utils/constants'; - -describe('Table visualization options', () => { - before(() => { - cy.deleteIndex(TABLE_INDEX_ID); - cy.deleteIndexPattern(TABLE_INDEX_PATTERN); - cy.bulkUploadDocs(TABLE_PATH_INDEX_DATA); - cy.importSavedObjects(TABLE_PATH_SO_DATA); - // Load table visualization - cy.visit(`${BASE_PATH}/app/visualize`); - cy.get('input[type="search"]').type(`${TABLE_BASIC_VIS_TITLE}{enter}`); - cy.get('.euiBasicTable-loading').should('not.exist'); // wait for the loading to stop - cy.getElementByTestId( - `visListingTitleLink-${toTestId(TABLE_BASIC_VIS_TITLE)}` - ) - .should('exist') - .click(); - cy.url().should('contain', TABLE_VIS_APP_PATH); - cy.setTopNavDate(TABLE_INDEX_START_TIME, TABLE_INDEX_END_TIME); - cy.waitForLoader(); - }); - - after(() => { - cy.deleteIndex(TABLE_INDEX_ID); - cy.deleteIndexPattern(TABLE_INDEX_PATTERN); - }); - - describe('Show percentage column', () => { - const expectedData = ['≥ 0 and < 20', '1,059', '≥ 20 and < 40', '2,236']; - const expectedDataWithPercentage = [ - '≥ 0 and < 20', - '1,059', - '32.14%', - '≥ 20 and < 40', - '2,236', - '67.86%', - ]; - - it('Should show correct range', () => { - cy.tbAddBucketsAggregation(); - cy.tbSplitRows(); - cy.tbSetupRangeAggregation( - 'age', - [ - ['0', '20'], - ['20', '40'], - ], - 2 - ); - cy.waitForLoader(); - cy.wait(500); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectedData); - }); - }); - - it('Should show percentage columns', () => { - cy.tbOpenOptionsPanel(); - cy.tbSelectPercentageColumn('Count'); - cy.tbUpdateAggregationSettings(); - cy.waitForLoader(); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectedDataWithPercentage); - }); - }); - - it('Should remove percentage columns', () => { - cy.tbSelectPercentageColumn('Don’t show'); - cy.tbUpdateAggregationSettings(); - cy.waitForLoader(); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectedData); - }); - }); - - after(() => { - cy.log('clean out all metrics and buckets aggregations'); - cy.tbOpenDataPanel(); - cy.tbRemoveAllAggregations(2); - cy.tbUpdateAggregationSettings(); - cy.waitForLoader(); - }); - }); - - describe('Show metrics for every bucket/level and partial', () => { - const expectData = [ - 'Cat', - '79', - '41', - 'Cat', - '28', - '40', - 'Dog', - '31', - '40', - 'Dog', - '10', - '39', - ]; - const expectShowAllData = [ - 'Cat', - '2,500', - '79', - '41', - 'Cat', - '2,500', - '28', - '40', - 'Dog', - '2,500', - '31', - '40', - 'Dog', - '2,500', - '10', - '39', - ]; - const expectAverageData = [ - 'Cat', - '2,500', - '54.986', - '79', - '41', - '79', - 'Cat', - '2,500', - '54.986', - '28', - '40', - '28', - 'Dog', - '2,500', - '54.799', - '31', - '40', - '31', - 'Dog', - '2,500', - '54.799', - '10', - '39', - '10', - ]; - - before(() => { - cy.tbAddBucketsAggregation(); - cy.tbSplitRows(); - cy.tbSetupTermsAggregation('categories.keyword', 'Ascending', '2', 2); - cy.waitForLoader(); - cy.tbAddBucketsAggregation(); - cy.tbSplitRows(); - cy.tbSetupTermsAggregation('age', 'Descending', '2', 3); - cy.waitForLoader(); - }); - - it('Should show correct data without showMetricsAtAllLevels', () => { - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectData); - }); - }); - - it('Should show correct data without showMetricsAtAllLevels even if showPartialRows is selected', () => { - cy.tbOpenOptionsPanel(); - cy.tbToggleOptionByName('showPartialRows', 'true'); - cy.tbUpdateAggregationSettings(); - cy.waitForLoader(); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectData); - }); - }); - - it('Should show metrics on each level', () => { - cy.tbOpenOptionsPanel(); - cy.tbToggleOptionByName('showMetricsAtAllLevels', 'true'); - cy.tbUpdateAggregationSettings(); - cy.waitForLoader(); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectShowAllData); - }); - }); - - it('Should show metrics other than count on each level', () => { - cy.tbOpenDataPanel(); - cy.tbAddMetricsAggregation(); - cy.tbSelectAggregationType('Average', 4); - cy.tbSelectAggregationField('age', 4); - cy.tbUpdateAggregationSettings(); - cy.waitForLoader(); - cy.tbGetTableDataFromVisualization().then((data) => { - expect(data).to.deep.eq(expectAverageData); - }); - }); - - after(() => { - cy.log('clean out all metrics and buckets aggregations'); - cy.tbRemoveAllAggregations(4); - cy.tbUpdateAggregationSettings(); - cy.waitForLoader(); - }); - }); - - describe('Show Total', () => { - before(() => { - cy.tbAddBucketsAggregation(); - cy.tbSplitRows(); - cy.tbSetupTermsAggregation('categories.keyword', 'Descending', '3', 2); - cy.waitForLoader(); - }); - - it('Should not show total function if not enabled', () => { - cy.tbOpenOptionsPanel(); - cy.getElementByTestId('showTotal') - .invoke('attr', 'aria-checked') - .should('eq', 'false'); - }); - - it('Should show total function if enabled', () => { - cy.tbOpenOptionsPanel(); - cy.tbToggleOptionByName('showTotal', 'true'); - cy.getElementByTestId('showTotal') - .invoke('attr', 'aria-checked') - .should('eq', 'true'); - cy.tbUpdateAggregationSettings(); - cy.waitForLoader(); - }); - - it('Should show correct data if Count is selected', () => { - const expectData = ['3', '3']; - cy.tbSelectTotalFunctionByName('Count'); - cy.tbUpdateAggregationSettings(); - cy.waitForLoader(); - cy.tbGetTotalValueFromTable().then((data) => { - expect(data).to.deep.eq(expectData); - }); - }); - - it('Should show correct data if Average is selected', () => { - const expectData = ['', '2,500']; - cy.tbSelectTotalFunctionByName('Average'); - cy.tbUpdateAggregationSettings(); - cy.waitForLoader(); - cy.tbGetTotalValueFromTable().then((data) => { - expect(data).to.deep.eq(expectData); - }); - }); - - after(() => { - cy.log('clean out all metrics and buckets aggregations'); - cy.tbOpenDataPanel(); - cy.tbRemoveAllAggregations(2); - cy.tbUpdateAggregationSettings(); - cy.waitForLoader(); - }); - }); -}); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/split.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/split.spec.js deleted file mode 100644 index ec4c10dc8..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_type_table/split.spec.js +++ /dev/null @@ -1,394 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - BASE_PATH, - TABLE_INDEX_ID, - TABLE_PATH_INDEX_DATA, - TABLE_INDEX_PATTERN, - TABLE_PATH_SO_DATA, - TABLE_BASIC_VIS_TITLE, - TABLE_VIS_APP_PATH, - TABLE_INDEX_START_TIME, - TABLE_INDEX_END_TIME, - toTestId, -} from '../../../../../utils/constants'; - -// TODO: https://github.com/opensearch-project/opensearch-dashboards-functional-test/issues/699 -describe.skip('Split table', () => { - const expectDataInitial = [ - [ - 'Cat', - '10,045', - '1', - 'Cat', - '10,096', - '1', - 'Hawk', - '17,505', - '1', - 'Hawk', - '17,644', - '1', - ], - [ - 'Dog', - '12,518', - '1', - 'Dog', - '12,520', - '1', - 'Cat', - '10,195', - '1', - 'Cat', - '10,217', - '1', - ], - [ - 'Hawk', - '17,529', - '1', - 'Hawk', - '17,597', - '1', - 'Rabbit', - '15,015', - '1', - 'Rabbit', - '15,194', - '1', - ], - ]; - - before(() => { - cy.deleteIndex(TABLE_INDEX_ID); - cy.deleteIndexPattern(TABLE_INDEX_PATTERN); - cy.bulkUploadDocs(TABLE_PATH_INDEX_DATA); - cy.importSavedObjects(TABLE_PATH_SO_DATA); - // Load table visualization - cy.visit(`${BASE_PATH}/app/visualize`); - cy.get('input[type="search"]').type(`${TABLE_BASIC_VIS_TITLE}{enter}`); - cy.get('.euiBasicTable-loading').should('not.exist'); // wait for the loading to stop - cy.getElementByTestId( - `visListingTitleLink-${toTestId(TABLE_BASIC_VIS_TITLE)}` - ) - .should('exist') - .click(); - cy.url().should('contain', TABLE_VIS_APP_PATH); - cy.setTopNavDate(TABLE_INDEX_START_TIME, TABLE_INDEX_END_TIME); - cy.waitForLoader(); - }); - - it('Should have a splitted table in rows', () => { - cy.tbAddBucketsAggregation(); - cy.tbSplitTables(); - cy.tbSplitTablesInRows(); - cy.tbSetupTermsAggregation('age', 'Descending', '3', 2); - cy.waitForLoader(); - cy.tbToggleOpenEditor(2, 'false'); - cy.tbAddBucketsAggregation(); - cy.tbSplitRows(); - cy.tbSetupTermsAggregation('categories.keyword', 'Descending', '2', 3); - cy.waitForLoader(); - cy.tbToggleOpenEditor(3, 'false'); - cy.tbAddBucketsAggregation(); - cy.tbSplitRows(); - cy.tbSetupTermsAggregation('salary', 'Descending', '2', 4); - cy.tbToggleOpenEditor(4, 'false'); - cy.waitForLoader(); - cy.tbGetAllTableDataFromVisualization(3).then((data) => { - expect(data).to.deep.eq(expectDataInitial); - }); - }); - - it('Should filter for value in all tables', () => { - const expectDataAfterFilter = [ - ['Hawk', '17,591', '1', 'Hawk', '17,602', '1'], - ['Hawk', '17,544', '1', 'Hawk', '17,648', '1'], - ['Hawk', '17,503', '1', 'Hawk', '17,515', '1'], - ]; - cy.tbClickTableCellAction(3, 2, 0, 'filter for'); - cy.waitForLoader(); - cy.tbGetAllTableDataFromVisualization(3).then((data) => { - expect(data).to.deep.eq(expectDataAfterFilter); - }); - cy.get('[aria-label="Delete"]').click(); - cy.waitForLoader(); - cy.tbGetAllTableDataFromVisualization(3).then((data) => { - expect(data).to.deep.eq(expectDataInitial); - }); - cy.tbClickTableCellAction(3, 2, 0, 'expand'); - cy.tbClickFilterFromExpand('filter for'); - cy.waitForLoader(); - cy.tbGetAllTableDataFromVisualization(3).then((data) => { - expect(data).to.deep.eq(expectDataAfterFilter); - }); - cy.get('[aria-label="Delete"]').click(); - cy.waitForLoader(); - cy.tbGetAllTableDataFromVisualization(3).then((data) => { - expect(data).to.deep.eq(expectDataInitial); - }); - }); - - it('Should filter out value in all tables', () => { - const expectDataAfterFilter = [ - [ - 'Dog', - '12,518', - '1', - 'Dog', - '12,520', - '1', - 'Cat', - '10,195', - '1', - 'Cat', - '10,217', - '1', - ], - [ - 'Rabbit', - '15,032', - '1', - 'Rabbit', - '15,044', - '1', - 'Cat', - '10,007', - '1', - 'Cat', - '10,085', - '1', - ], - [ - 'Cat', - '10,045', - '1', - 'Cat', - '10,096', - '1', - 'Rabbit', - '15,007', - '1', - 'Rabbit', - '15,140', - '1', - ], - ]; - cy.tbClickTableCellAction(3, 2, 0, 'filter out'); - cy.waitForLoader(); - cy.tbGetAllTableDataFromVisualization(3).then((data) => { - expect(data).to.deep.eq(expectDataAfterFilter); - }); - cy.get('[aria-label="Delete"]').click(); - cy.waitForLoader(); - cy.tbGetAllTableDataFromVisualization(3).then((data) => { - expect(data).to.deep.eq(expectDataInitial); - }); - cy.tbClickTableCellAction(3, 2, 0, 'expand'); - cy.tbClickFilterFromExpand('filter out'); - cy.waitForLoader(); - cy.tbGetAllTableDataFromVisualization(3).then((data) => { - expect(data).to.deep.eq(expectDataAfterFilter); - }); - cy.get('[aria-label="Delete"]').click(); - cy.waitForLoader(); - cy.tbGetAllTableDataFromVisualization(3).then((data) => { - expect(data).to.deep.eq(expectDataInitial); - }); - }); - - it('Should show metrics for split bucket when using showMetricsAtAllLevels', () => { - const expectData = [ - [ - 'Cat', - '41', - '10,045', - '1', - 'Cat', - '41', - '10,096', - '1', - 'Hawk', - '34', - '17,505', - '1', - 'Hawk', - '34', - '17,644', - '1', - ], - [ - 'Dog', - '37', - '12,518', - '1', - 'Dog', - '37', - '12,520', - '1', - 'Cat', - '32', - '10,195', - '1', - 'Cat', - '32', - '10,217', - '1', - ], - [ - 'Hawk', - '35', - '17,529', - '1', - 'Hawk', - '35', - '17,597', - '1', - 'Rabbit', - '35', - '15,015', - '1', - 'Rabbit', - '35', - '15,194', - '1', - ], - ]; - cy.tbOpenOptionsPanel(); - cy.tbToggleOptionByName('showMetricsAtAllLevels', 'true'); - cy.tbUpdateAggregationSettings(); - cy.waitForLoader(); - cy.tbGetAllTableDataFromVisualization(3).then((data) => { - expect(data).to.deep.eq(expectData); - }); - }); - - it('Should update a splitted table in columns', () => { - const expectData = [ - [ - 'Cat', - '41', - '10,045', - '1', - 'Cat', - '41', - '10,096', - '1', - 'Hawk', - '34', - '17,505', - '1', - 'Hawk', - '34', - '17,644', - '1', - ], - [ - 'Dog', - '37', - '12,518', - '1', - 'Dog', - '37', - '12,520', - '1', - 'Cat', - '32', - '10,195', - '1', - 'Cat', - '32', - '10,217', - '1', - ], - ]; - cy.tbOpenDataPanel(); - cy.tbToggleOpenEditor(2, 'true'); - cy.tbSplitTablesInColumns(); - cy.tbSetupTermsAggregation('age', 'Descending', '2', 2); - cy.waitForLoader(); - cy.get('[class="visTable"]').should('exist'); - cy.tbGetAllTableDataFromVisualization(2).then((data) => { - expect(data).to.deep.eq(expectData); - }); - }); - - it('Should sort column in all tables', () => { - const expectData = [ - [ - 'Cat', - '41', - '10,045', - '1', - 'Cat', - '41', - '10,096', - '1', - 'Hawk', - '34', - '17,505', - '1', - 'Hawk', - '34', - '17,644', - '1', - ], - [ - 'Cat', - '32', - '10,195', - '1', - 'Cat', - '32', - '10,217', - '1', - 'Dog', - '37', - '12,518', - '1', - 'Dog', - '37', - '12,520', - '1', - ], - ]; - cy.tbSelectSortColumn(1, 0, 'asc'); - cy.waitForLoader(); - cy.tbGetAllTableDataFromVisualization(2).then((data) => { - expect(data).to.deep.eq(expectData); - }); - }); - - it('Should adjust column width in all tables', () => { - cy.tbGetColumnWidth(0, 1, 't0col0WidthBefore').then((first) => { - cy.tbGetColumnWidth(1, 1, 't1col0WidthBefore').then((second) => { - expect(second).to.eq(first); - }); - }); - cy.tbAdjustColumnWidth(4, 1, 1, -50); - cy.tbGetColumnWidth(0, 1, 't0col0WidthAfter').then((first) => { - cy.tbGetColumnWidth(1, 1, 't1col0WidthAfter').then((second) => { - expect(second).to.eq(first); - }); - }); - cy.get('@t0col0WidthAfter').then((after) => { - cy.get('@t0col0WidthBefore').then((before) => { - expect(before).equal(after + 50); - }); - }); - cy.get('@t1col0WidthAfter').then((after) => { - cy.get('@t1col0WidthBefore').then((before) => { - expect(before).equal(after + 50); - }); - }); - }); - - after(() => { - cy.deleteIndex(TABLE_INDEX_ID); - cy.deleteIndexPattern(TABLE_INDEX_PATTERN); - }); -}); diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js deleted file mode 100644 index 16340acb8..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js +++ /dev/null @@ -1,405 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; -import { - OSD_TEST_DOMAIN_ENDPOINT_URL, - OSD_INVALID_ENDPOINT_URL, -} from '../../../../utils/dashboards/datasource-management-dashboards-plugin/constants'; - -const miscUtils = new MiscUtils(cy); -// Get environment variables -const username = Cypress.env('username'); -const password = Cypress.env('password'); -const REGION = 'us-east-1'; -const ACCESS_KEY = 'accessKey'; -const SECRET_KEY = 'secretKey'; - -if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) { - describe('Create datasources', () => { - before(() => { - // Clean up before creating new data sources for testing - cy.deleteAllDataSources(); - }); - beforeEach(() => { - // Visit OSD create page - miscUtils.visitPage( - 'app/management/opensearch-dashboards/dataSources/create' - ); - - cy.intercept('POST', '/api/saved_objects/data-source').as( - 'createDataSourceRequest' - ); - }); - - after(() => { - // Clean up after all test are run - cy.deleteAllDataSources(); - }); - - it('should successfully load the page', () => { - cy.contains( - 'Create a new data source connection to help you retrieve data from an external OpenSearch compatible source.', - { timeout: 60000 } - ); - }); - - describe('Datasource can be created successfully', () => { - it('with no auth and all required inputs', () => { - cy.get('[data-test-subj="createDataSourceButton"]').should( - 'be.disabled' - ); - cy.get('[name="dataSourceTitle"]').type('test_noauth'); - cy.get('[name="endpoint"]').type(OSD_TEST_DOMAIN_ENDPOINT_URL); - cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select( - 'no_auth' - ); - cy.get('[data-test-subj="createDataSourceButton"]').should( - 'be.enabled' - ); - cy.get('[name="dataSourceDescription"]').type( - 'cypress test no auth data source' - ); - - cy.get('[data-test-subj="createDataSourceButton"]').click(); - cy.wait('@createDataSourceRequest').then((interception) => { - expect(interception.response.statusCode).to.equal(200); - }); - cy.location('pathname', { timeout: 6000 }).should( - 'include', - 'app/management/opensearch-dashboards/dataSources' - ); - }); - - it('with basic auth and all required inputs', () => { - cy.get('[data-test-subj="createDataSourceButton"]').should( - 'be.disabled' - ); - cy.get('[name="dataSourceTitle"]').type('test_auth'); - cy.get('[name="endpoint"]').type(OSD_TEST_DOMAIN_ENDPOINT_URL); - cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select( - 'username_password' - ); - cy.get('[data-test-subj="createDataSourceFormUsernameField"]').type( - username - ); - cy.get('[data-test-subj="createDataSourceFormPasswordField"]').type( - password - ); - cy.get('[data-test-subj="createDataSourceButton"]').should( - 'be.enabled' - ); - cy.get('[name="dataSourceDescription"]').type( - 'cypress test basic auth data source' - ); - cy.get('[data-test-subj="createDataSourceButton"]').click(); - cy.wait('@createDataSourceRequest').then((interception) => { - expect(interception.response.statusCode).to.equal(200); - }); - cy.location('pathname', { timeout: 6000 }).should( - 'include', - 'app/management/opensearch-dashboards/dataSources' - ); - }); - - it('with sigV4 and all required inputs to connect to OpenSearch Service', () => { - cy.get('[data-test-subj="createDataSourceButton"]').should( - 'be.disabled' - ); - cy.get('[name="dataSourceTitle"]').type('test_sigv4_es'); - cy.get('[name="endpoint"]').type(OSD_TEST_DOMAIN_ENDPOINT_URL); - cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select( - 'sigv4' - ); - cy.get('[data-test-subj="createDataSourceFormRegionField"]').type( - REGION - ); - cy.get( - '[data-test-subj="createDataSourceFormSigV4ServiceTypeSelect"]' - ).select('es'); - cy.get('[data-test-subj="createDataSourceFormAccessKeyField"]').type( - ACCESS_KEY - ); - cy.get('[data-test-subj="createDataSourceFormSecretKeyField"]').type( - SECRET_KEY - ); - cy.get('[data-test-subj="createDataSourceButton"]').should( - 'be.enabled' - ); - cy.get('[name="dataSourceDescription"]').type( - 'cypress test sigV4 data source' - ); - - cy.get('[data-test-subj="createDataSourceButton"]').click(); - cy.wait('@createDataSourceRequest').then((interception) => { - expect(interception.response.statusCode).to.equal(200); - }); - - cy.location('pathname', { timeout: 6000 }).should( - 'include', - 'app/management/opensearch-dashboards/dataSources' - ); - }); - - it('with sigV4 and all required inputs to connect to OpenSearch Serverless Service', () => { - cy.get('[data-test-subj="createDataSourceButton"]').should( - 'be.disabled' - ); - cy.get('[name="dataSourceTitle"]').type('test_sigv4_aoss'); - cy.get('[name="endpoint"]').type(OSD_TEST_DOMAIN_ENDPOINT_URL); - cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select( - 'sigv4' - ); - cy.get('[data-test-subj="createDataSourceFormRegionField"]').type( - REGION - ); - cy.get( - '[data-test-subj="createDataSourceFormSigV4ServiceTypeSelect"]' - ).select('aoss'); - cy.get('[data-test-subj="createDataSourceFormAccessKeyField"]').type( - ACCESS_KEY - ); - cy.get('[data-test-subj="createDataSourceFormSecretKeyField"]').type( - SECRET_KEY - ); - cy.get('[data-test-subj="createDataSourceButton"]').should( - 'be.enabled' - ); - cy.get('[name="dataSourceDescription"]').type( - 'cypress test sigV4 data source (Serverless)' - ); - - cy.get('[data-test-subj="createDataSourceButton"]').click(); - cy.wait('@createDataSourceRequest').then((interception) => { - expect(interception.response.statusCode).to.equal(200); - }); - - cy.location('pathname', { timeout: 6000 }).should( - 'include', - 'app/management/opensearch-dashboards/dataSources' - ); - }); - }); - - describe('Title validation', () => { - it('validate that title is a required field', () => { - cy.get('[name="dataSourceTitle"]').focus().blur(); - cy.get('input[name="dataSourceTitle"]:invalid').should( - 'have.length', - 1 - ); - }); - - it('validate that title cannot use existing datasource name', () => { - cy.get('[name="dataSourceTitle"]').type('test_auth').blur(); - cy.get('input[name="dataSourceTitle"]:invalid').should( - 'have.length', - 1 - ); - cy.contains('This title is already in use').should('exist'); - }); - - it('validate that title field does not show any error if title is valid and unique', () => { - cy.get('[name="dataSourceTitle"]').type('test_unique_title').blur(); - cy.get('input[name="dataSourceTitle"]:valid').should('have.length', 1); - }); - }); - - describe('Description validation', () => { - it('validate that description field does not show any error if the field is empty', () => { - cy.get('[name="dataSourceDescription"]').focus().blur(); - cy.get('input[name="dataSourceDescription"]:valid').should( - 'have.length', - 1 - ); - }); - - it('validate that description field does not show any error if there is a description', () => { - cy.get('[name="dataSourceDescription"]') - .type('test description field') - .blur(); - cy.get('input[name="dataSourceDescription"]:valid').should( - 'have.length', - 1 - ); - }); - }); - - describe('Endpoint validation', () => { - it('validate that endpoint is a required field', () => { - cy.get('[name="endpoint"]').focus().blur(); - cy.get('input[name="endpoint"]:invalid').should('have.length', 1); - }); - - it('validate that endpoint field cannot use invalid format of URL', () => { - cy.get('[name="endpoint"]').type(OSD_INVALID_ENDPOINT_URL).blur(); - cy.get('input[name="endpoint"]:invalid').should('have.length', 1); - }); - - it('validate that endpoint field does not show any error if URL is valid', () => { - cy.get('[name="endpoint"]').type(OSD_TEST_DOMAIN_ENDPOINT_URL).blur(); - cy.get('input[name="endpoint"]:valid').should('have.length', 1); - }); - }); - - describe('Username validation', () => { - it('validate that username field does not show when auth type is no auth', () => { - cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select( - 'no_auth' - ); - cy.get('[data-test-subj="createDataSourceFormUsernameField"]').should( - 'not.exist' - ); - }); - - it('validate that username is a required field when auth type is username & password', () => { - cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select( - 'username_password' - ); - cy.get('[data-test-subj="createDataSourceFormUsernameField"]') - .focus() - .blur(); - cy.get( - 'input[data-test-subj="createDataSourceFormUsernameField"]:invalid' - ).should('have.length', 1); - }); - - it('validate that username field does not show any error when auth type is username & password and field is not empty', () => { - cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select( - 'username_password' - ); - cy.get('[data-test-subj="createDataSourceFormUsernameField"]') - .type(username) - .blur(); - cy.get( - 'input[data-test-subj="createDataSourceFormUsernameField"]:valid' - ).should('have.length', 1); - }); - }); - - describe('Password validation', () => { - it('validate that password field does not show when auth type is no auth', () => { - cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select( - 'no_auth' - ); - cy.get('[data-test-subj="createDataSourceFormPasswordField"]').should( - 'not.exist' - ); - }); - - it('validate that password is a required field when auth type is username & password', () => { - cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select( - 'username_password' - ); - cy.get('[data-test-subj="createDataSourceFormPasswordField"]') - .focus() - .blur(); - cy.get( - 'input[data-test-subj="createDataSourceFormPasswordField"]:invalid' - ).should('have.length', 1); - }); - - it('validate that password field does not show any error when auth type is username & password and field is not empty', () => { - cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select( - 'username_password' - ); - cy.get('[data-test-subj="createDataSourceFormPasswordField"]') - .type(password) - .blur(); - cy.get( - 'input[data-test-subj="createDataSourceFormPasswordField"]:valid' - ).should('have.length', 1); - }); - }); - - describe('SigV4 AuthType: fields validation', () => { - it('validate that region is a required field', () => { - cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select( - 'sigv4' - ); - cy.get('[data-test-subj="createDataSourceFormRegionField"]') - .focus() - .blur(); - cy.get( - 'input[data-test-subj="createDataSourceFormRegionField"]:invalid' - ).should('have.length', 1); - }); - - it('validate that accessKey is a required field', () => { - cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select( - 'sigv4' - ); - cy.get('[data-test-subj="createDataSourceFormAccessKeyField"]') - .focus() - .blur(); - cy.get( - 'input[data-test-subj="createDataSourceFormAccessKeyField"]:invalid' - ).should('have.length', 1); - }); - - it('validate that secretKey is a required field', () => { - cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select( - 'sigv4' - ); - cy.get('[data-test-subj="createDataSourceFormSecretKeyField"]') - .focus() - .blur(); - cy.get( - 'input[data-test-subj="createDataSourceFormSecretKeyField"]:invalid' - ).should('have.length', 1); - }); - - it('validate that serviceName is a required field, and with default option rendered', () => { - cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select( - 'sigv4' - ); - cy.get( - '[data-test-subj="createDataSourceFormSigV4ServiceTypeSelect"]' - ).should('have.value', 'es'); - }); - }); - - describe('Cancel button and create data source button', () => { - it('validate if create data source button is disabled when first visit this page', () => { - miscUtils.visitPage( - 'app/management/opensearch-dashboards/dataSources/create' - ); - cy.get('[data-test-subj="createDataSourceButton"]').should( - 'be.disabled' - ); - }); - - it('validate if create data source button is disabled when there is any field error', () => { - cy.get('[name="dataSourceTitle"]').focus().blur(); - cy.get('input[name="dataSourceTitle"]:invalid').should( - 'have.length', - 1 - ); - cy.get('[data-test-subj="createDataSourceButton"]').should( - 'be.disabled' - ); - }); - - it('validate if create data source button is not disabled only if there is no any field error', () => { - cy.get('[name="dataSourceTitle"]').type('test_create_button'); - cy.get('[name="endpoint"]').type(OSD_TEST_DOMAIN_ENDPOINT_URL); - cy.get('[data-test-subj="createDataSourceFormAuthTypeSelect"]').select( - 'no_auth' - ); - cy.get('[data-test-subj="createDataSourceButton"]').should( - 'not.be.disabled' - ); - }); - - it('cancel button should redirect to datasource listing page', () => { - cy.get('[data-test-subj="cancelCreateDataSourceButton"]').click(); - cy.location('pathname', { timeout: 6000 }).should( - 'include', - 'app/management/opensearch-dashboards/dataSources' - ); - }); - }); - }); -} diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/2_datasource_table.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/2_datasource_table.spec.js deleted file mode 100644 index 1ad8ecdcd..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/2_datasource_table.spec.js +++ /dev/null @@ -1,475 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - TIMEOUT_OPTS, - OSD_TEST_DOMAIN_ENDPOINT_URL, -} from '../../../../utils/dashboards/datasource-management-dashboards-plugin/constants'; - -const searchFieldIdentifier = 'input[type="search"]'; -const tableHeadIdentifier = 'thead > tr > th'; - -if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) { - describe('Datasource Management: Table', () => { - before(() => { - // Visit Data Sources OSD - cy.visitDataSourcesListingPage(); - }); - - after(() => { - // Clean up after all test are run - cy.deleteAllDataSources(); - }); - - it('should successfully load the page', () => { - cy.contains( - 'Create and manage data source connections to help you retrieve data from multiple OpenSearch compatible sources.', - TIMEOUT_OPTS - ); - }); - - describe('Empty State', () => { - before(() => { - // Clean up table before other tests run - cy.deleteAllDataSources(); - cy.visitDataSourcesListingPage(); - }); - it('should show empty table state when no data sources are created yet', () => { - cy.contains('No Data Source Connections have been created yet.').should( - 'exist' - ); - }); - }); - - describe('Sorting', () => { - before(() => { - // Create 25+ data sources that can be sorted alphabetically by using letters a-z - for (let i = 97; i < 123; i++) { - const char = String.fromCharCode(i); - const dataSourceJSON = { - attributes: { - title: `ds_${char}`, - description: `test ds_description_${char}`, - endpoint: `${OSD_TEST_DOMAIN_ENDPOINT_URL}/${char}`, - auth: { - type: i % 2 ? 'username_password' : 'no_auth', - }, - }, - }; - if (dataSourceJSON.attributes.auth.type === 'username_password') { - dataSourceJSON.attributes.auth.credentials = { - username: char, - password: char, - }; - } - cy.createDataSource(dataSourceJSON); - } - cy.visitDataSourcesListingPage(); - }); - - // Sort by title - by default - it('should be sorted in ascending order on Datasource title column by default', () => { - // Confirm we have ds_a in view and not ds_z - cy.get('tbody > tr').should(($tr) => { - expect($tr).to.have.length(10); - }); - cy.contains('ds_a').should('exist'); - cy.contains('ds_z').should('not.exist'); - }); - - // sort by description - it('should be sorted in ascending/descending order on description column', () => { - // case 1: Ascending order - // Get the datasource table header and click it to sort ascending first - cy.getColumnHeaderByNameAndClickForSorting( - tableHeadIdentifier, - 'Description' - ); - // Confirm we have "test ds_description_a" in view and not "test ds_description_z" - cy.contains('test ds_description_a').should('exist'); - cy.contains('test ds_description_z').should('not.exist'); - - // case 2: Descending order - // Get the datasource table header and click it to sort descending - cy.getColumnHeaderByNameAndClickForSorting( - tableHeadIdentifier, - 'Description' - ); - - // Confirm we have "test ds_description_a" in view and not "test ds_description_z" - cy.contains('test ds_description_a').should('not.exist'); - cy.contains('test ds_description_z').should('exist'); - }); - - // sort Ascending by data source title - it('should be sorted in ascending order by Datasource title', () => { - // Get the datasource table header and click it to sort sscending first - cy.getColumnHeaderByNameAndClickForSorting( - tableHeadIdentifier, - 'Title' - ); - - // Confirm we have ds_a in view and not ds_z - cy.contains('ds_a'); - cy.contains('ds_z').should('not.exist'); - }); - - // sort descending by data source title - it('should be sorted in descending order by Datasource title', () => { - // Get the datasource table header and click it to sort descending first - cy.getColumnHeaderByNameAndClickForSorting( - tableHeadIdentifier, - 'Title' - ); - - // Confirm we have ds_z in view and not ds_a - cy.contains('ds_z'); - cy.contains('ds_a').should('not.exist'); - - // sort to ascending order for next steps - cy.getColumnHeaderByNameAndClickForSorting( - tableHeadIdentifier, - 'Title' - ); - }); - }); - - describe('Search', () => { - // case 1: single match - it('should be able to search for single match', () => { - // Clear & Type in ds_z in search input - cy.get(searchFieldIdentifier).focus().clear().type('ds_z'); - - // Confirm we only see ds_z in table - cy.get('tbody > tr').should(($tr) => { - expect($tr, '1 row').to.have.length(1); - expect($tr, 'item').to.contain('ds_z'); - }); - }); - // case 2: multiple match - it('should be able to search for multiple matches', () => { - // Type 'test' in search input - cy.get(searchFieldIdentifier).focus().clear().type('test'); - - // Confirm we only see one row table - cy.get('tbody > tr').should(($tr) => { - expect($tr, '1 row').to.have.length.above(1); - }); - }); - // case 2.1: multiple match with different letter casing - it('should be able to search even when letter casing is different', () => { - // Clear & Type in test in search input - cy.get(searchFieldIdentifier).focus().clear().type('TeSt'); - - // Confirm we more than 1 rows - cy.get('tbody > tr').should(($tr) => { - expect($tr, '1 row').to.have.length.above(1); - }); - }); - // case 3: No match - it('should not display any rows when search finds NO MATCH', () => { - // clear & Type in testNoMaTCH in search input - cy.get(searchFieldIdentifier).focus().clear().type('testNoMaTCH'); - - // Confirm we don't see any results - cy.contains('No items found'); - // confirm pagination is not shown - cy.contains('Rows Per Page').should('not.exist'); - - cy.get(searchFieldIdentifier).focus().clear(); - }); - it('should show all rows when search is cleared', () => { - cy.get(searchFieldIdentifier).focus().clear(); - // Confirm that only 10 rows are shown - cy.get('tbody > tr').should(($tr) => { - expect($tr).to.have.length(10); - }); - }); - }); - - describe('Pagination', () => { - it('should successfully change rows per page & update no of pages', () => { - // select 5 rows - cy.getElementByTestId('tablePaginationPopoverButton').click(); - cy.get('.euiContextMenuItem__text').contains('5 rows').click(); - - // Confirm that only 5 rows are shown - cy.get('tbody > tr').should(($tr) => { - expect($tr).to.have.length(5); - }); - cy.get('li.euiPagination__item').should(($li) => { - expect($li).to.have.length(6); // 6 pages - }); - cy.getElementByTestId('pagination-button-next').should( - 'not.be.disabled' - ); - cy.getElementByTestId('pagination-button-previous').should( - 'be.disabled' - ); - - // select 50 rows - cy.getElementByTestId('tablePaginationPopoverButton').click(); - cy.get('.euiContextMenuItem__text').contains('50 rows').click(); - - // Confirm that only 26 rows are shown - cy.get('tbody > tr').should(($tr) => { - expect($tr).to.have.length(26); // only 26 data sources created - }); - cy.get('li.euiPagination__item').should(($li) => { - expect($li).to.have.length(1); // 1 pages - }); - cy.getElementByTestId('pagination-button-next').should('be.disabled'); - cy.getElementByTestId('pagination-button-previous').should( - 'be.disabled' - ); - - // select 25 rows - cy.getElementByTestId('tablePaginationPopoverButton').click(); - cy.get('.euiContextMenuItem__text').contains('25 rows').click(); - - // Confirm that only 25 rows are shown - cy.get('tbody > tr').should(($tr) => { - expect($tr).to.have.length(25); - }); - cy.get('li.euiPagination__item').should(($li) => { - expect($li).to.have.length(2); // 2 pages - }); - - // select 10 rows - cy.getElementByTestId('tablePaginationPopoverButton').click(); - cy.get('.euiContextMenuItem__text').contains('10 rows').click(); - - // Confirm that only 10 rows are shown - cy.get('tbody > tr').should(($tr) => { - expect($tr).to.have.length(10); - }); - cy.get('li.euiPagination__item').should(($li) => { - expect($li).to.have.length(3); // 3 pages - }); - }); - - it('should go navigate between pages using numbered buttons, next & previous arrows button on pagination', () => { - cy.contains('ds_a').should('exist'); - cy.contains('ds_m').should('not.exist'); - - // Next page - cy.getElementByTestId('pagination-button-next').click(); - cy.contains('ds_a').should('not.exist'); - cy.contains('ds_m').should('exist'); - - // Previous page - cy.getElementByTestId('pagination-button-previous').click(); - cy.contains('ds_a').should('exist'); - cy.contains('ds_m').should('not.exist'); - - // click on page numbers to navigate - last page - cy.get('li.euiPagination__item').last().click(); - cy.contains('ds_a').should('not.exist'); - cy.contains('ds_z').should('exist'); - - // click on page numbers to navigate - second page - cy.get('li.euiPagination__item').eq(1).click(); - cy.contains('ds_m').should('exist'); - cy.contains('ds_a').should('not.exist'); - cy.contains('ds_z').should('not.exist'); - - // click on page numbers to navigate - first page - cy.get('li.euiPagination__item').first().click(); - cy.contains('ds_a').should('exist'); - cy.contains('ds_z').should('not.exist'); - }); - }); - describe('Selection & Deletion', () => { - it('should not select any rows by default & delete button should be disabled', () => { - cy.getElementByTestId('deleteDataSourceConnections').should( - 'be.disabled' - ); - cy.getElementByTestId('deleteDataSourceConnections').should( - 'contain.text', - 'Delete ' - ); - }); - - it('should verify simple selection & un-selection of rows', () => { - // Verify that delete button is disabled - cy.getElementByTestId('deleteDataSourceConnections').should( - 'be.disabled' - ); - // Select first 2 rows - cy.get('tbody > tr > td.euiTableRowCellCheckbox [type="checkbox"]') - .eq(0) - .check(); - cy.get('tbody > tr > td.euiTableRowCellCheckbox [type="checkbox"]') - .eq(1) - .check(); - - // Verify tha delete button is not disabled & displays expected text - cy.getElementByTestId('deleteDataSourceConnections').should( - 'not.be.disabled' - ); - cy.getElementByTestId('deleteDataSourceConnections').should( - 'contain.text', - 'Delete 2 connections' - ); - - // Un-select first two rows & Verify that delete button is disabled - cy.get('tbody > tr > td.euiTableRowCellCheckbox [type="checkbox"]') - .eq(0) - .uncheck(); - cy.get('tbody > tr > td.euiTableRowCellCheckbox [type="checkbox"]') - .eq(1) - .uncheck(); - cy.getElementByTestId('deleteDataSourceConnections').should( - 'be.disabled' - ); - }); - - it('should select single row & perform delete', () => { - cy.getElementByTestId('deleteDataSourceConnections').should( - 'be.disabled' - ); - cy.contains('ds_a').should('exist'); - - cy.get('tbody > tr > td.euiTableRowCellCheckbox [type="checkbox"]') - .first() - .check(); - - cy.getElementByTestId('deleteDataSourceConnections').should( - 'contain.text', - 'Delete 1 connection' - ); - - // delete - cy.getElementByTestId('deleteDataSourceConnections').click(); - cy.getElementByTestId('confirmModalConfirmButton').click(); - cy.contains('ds_a').should('not.exist'); - cy.getElementByTestId('deleteDataSourceConnections').should( - 'contain.text', - 'Delete ' - ); - }); - - it('should select multiple rows & perform delete', () => { - cy.getElementByTestId('deleteDataSourceConnections').should( - 'be.disabled' - ); - cy.contains('ds_b').should('exist'); - - // select first 5 rows - cy.get('tbody > tr > td.euiTableRowCellCheckbox [type="checkbox"]') - .eq(0) - .check(); - cy.get('tbody > tr > td.euiTableRowCellCheckbox [type="checkbox"]') - .eq(1) - .check(); - cy.get('tbody > tr > td.euiTableRowCellCheckbox [type="checkbox"]') - .eq(2) - .check(); - cy.get('tbody > tr > td.euiTableRowCellCheckbox [type="checkbox"]') - .eq(3) - .check(); - cy.get('tbody > tr > td.euiTableRowCellCheckbox [type="checkbox"]') - .eq(4) - .check(); - - cy.getElementByTestId('deleteDataSourceConnections').should( - 'contain.text', - 'Delete 5 connections' - ); - - // delete - cy.getElementByTestId('deleteDataSourceConnections').click(); - cy.getElementByTestId('confirmModalConfirmButton').click(); - cy.contains('ds_b').should('not.exist'); - cy.getElementByTestId('deleteDataSourceConnections').should( - 'contain.text', - 'Delete ' - ); - cy.get('li.euiPagination__item').should(($li) => { - expect($li).to.have.length(2); // 2 pages - }); - }); - - it('Select all rows should select only current page rows', () => { - cy.getElementByTestId('checkboxSelectAll').check(); - cy.getElementByTestId('deleteDataSourceConnections').should( - 'contain.text', - 'Delete 10 connections' - ); - }); - - it('should lose selection when selection is made and sort happens', () => { - // Select all rows - cy.getElementByTestId('checkboxSelectAll').check(); - cy.getElementByTestId('deleteDataSourceConnections').should( - 'contain.text', - 'Delete 10 connections' - ); - cy.getElementByTestId('deleteDataSourceConnections').should( - 'not.be.disabled' - ); - - // sort by description column - cy.getColumnHeaderByNameAndClickForSorting( - tableHeadIdentifier, - 'Description' - ); - - cy.getElementByTestId('deleteDataSourceConnections').should( - 'be.disabled' - ); - }); - - it('should lose selection when selection is made and pagination changes happens', () => { - // Select all rows - cy.getElementByTestId('checkboxSelectAll').check(); - cy.getElementByTestId('deleteDataSourceConnections').should( - 'contain.text', - 'Delete 10 connections' - ); - cy.getElementByTestId('deleteDataSourceConnections').should( - 'not.be.disabled' - ); - - // Next page - cy.getElementByTestId('pagination-button-next').click(); - - cy.getElementByTestId('deleteDataSourceConnections').should( - 'be.disabled' - ); - }); - - it('should lose selection when selection is made and search happens', () => { - // Select all rows - cy.getElementByTestId('checkboxSelectAll').check(); - cy.getElementByTestId('deleteDataSourceConnections').should( - 'contain.text', - 'Delete 10 connections' - ); - cy.getElementByTestId('deleteDataSourceConnections').should( - 'not.be.disabled' - ); - - // Clear & Type in ds_z in search input - cy.get(searchFieldIdentifier).focus().clear().type('ds_z'); - - cy.getElementByTestId('deleteDataSourceConnections').should( - 'be.disabled' - ); - }); - }); - - /* Create button*/ - describe('create button', () => { - it('should navigate to create data source on button click', () => { - cy.getElementByTestId('createDataSourceButton').first().click(); - cy.location('pathname').should( - 'eq', - '/app/management/opensearch-dashboards/dataSources/create' - ); - }); - }); - }); -} diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/3_update_datasource.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/3_update_datasource.spec.js deleted file mode 100644 index ba5a84d34..000000000 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/3_update_datasource.spec.js +++ /dev/null @@ -1,803 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { - DS_JSON, - DS_JSON_2, - DS_JSON_UNIQUE_VALUES, - FORCE_CLICK_OPTS, - TIMEOUT_OPTS, -} from '../../../../utils/dashboards/datasource-management-dashboards-plugin/constants'; - -const passwordFieldIdentifier = - 'input[type="password"][data-test-subj="updateDataSourceFormPasswordField"]'; -const updatedPasswordIdentifier = - 'input[type="password"][data-test-subj="updateStoredPasswordUpdatedPasswordField"]'; -const confirmUpdatedPasswordIdentifier = - 'input[type="password"][data-test-subj="updateStoredPasswordConfirmUpdatedPasswordField"]'; - -const typeInInputFieldAndBlur = (name, updatedText, identifier) => { - const locator = identifier || `[name="${name}"]`; - if (updatedText && updatedText.length) { - cy.get(locator).clear().focus().type(updatedText).blur(); - } else { - cy.get(locator).clear().focus().blur(); - } -}; - -const checkIfTableIsLoaded = () => { - cy.contains('Rows per page', TIMEOUT_OPTS).should('exist'); -}; - -const clickOnTableRowTitleColumnByValue = (value) => { - cy.get('tbody > tr > td').contains(value).click(FORCE_CLICK_OPTS); -}; - -if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) { - describe('Datasource Management: Update', () => { - before(() => { - // Clean up before creating new data sources for testing - cy.deleteAllDataSources(); - // Create - cy.createDataSource(DS_JSON); - cy.createDataSource(DS_JSON_2); - cy.visitDataSourcesListingPage(); - }); - after(() => { - // Clean up after all test are run - cy.deleteAllDataSources(); - }); - - it('should successfully load the listing page & have 2 records in table', () => { - cy.contains( - 'Create and manage data source connections to help you retrieve data from multiple OpenSearch compatible sources.' - ); - // Confirm we have 2 rows in the table - cy.get('tbody > tr').should(($tr) => { - expect($tr).to.have.length(2); - }); - }); - - describe('navigate to details page using various ways', () => { - let detailsPageURL = ''; - it("should navigate to details page on table row datasource 'title' click", () => { - clickOnTableRowTitleColumnByValue(DS_JSON_2.attributes.title); - cy.get('[name="dataSourceTitle"]').should( - 'have.value', - DS_JSON_2.attributes.title - ); - cy.location('pathname').then((pathname) => { - detailsPageURL = pathname; - }); - }); - it('should navigate to details page by URL successfully', () => { - cy.visitDataSourcesListingPage(); - cy.visit(detailsPageURL); - cy.get('[name="dataSourceTitle"]').should( - 'have.value', - DS_JSON_2.attributes.title - ); - }); - it('should navigate to details page by URL and show error when id is invalid', () => { - cy.visitDataSourcesListingPage(); - cy.visit(`${detailsPageURL}64fa3`); - cy.get('[name="dataSourceTitle"]').should('not.exist'); - }); - }); - - describe('validation: Originally datasource credential type is "No Authentication"', () => { - before(() => { - cy.visitDataSourcesListingPage(); - checkIfTableIsLoaded(); - clickOnTableRowTitleColumnByValue(DS_JSON.attributes.title); - cy.get('[name="dataSourceTitle"]').should('exist'); - }); - it('should make sure that title field is required & does not accept duplicates', () => { - /* Required */ - typeInInputFieldAndBlur('dataSourceTitle', '', ''); - cy.get('input[name="dataSourceTitle"]:invalid').should( - 'have.length', - 1 - ); - cy.getElementByTestId('datasource-edit-saveButton').should( - 'be.disabled' - ); - - /* No error - on original title */ - typeInInputFieldAndBlur( - 'dataSourceTitle', - DS_JSON.attributes.title, - '' - ); - cy.get('input[name="dataSourceTitle"]:valid').should('have.length', 1); - cy.getElementByTestId('datasource-edit-saveButton').should('not.exist'); - - /* Duplicate */ - typeInInputFieldAndBlur( - 'dataSourceTitle', - DS_JSON_2.attributes.title, - '' - ); - cy.get('input[name="dataSourceTitle"]:invalid').should( - 'have.length', - 1 - ); - cy.contains('This title is already in use').should('exist'); - cy.getElementByTestId('datasource-edit-saveButton').should( - 'be.disabled' - ); - - /* No error - unique value */ - typeInInputFieldAndBlur( - 'dataSourceTitle', - DS_JSON_UNIQUE_VALUES.attributes.title, - '' - ); - cy.get('input[name="dataSourceTitle"]:valid').should('have.length', 1); - cy.getElementByTestId('datasource-edit-saveButton').should( - 'be.enabled' - ); - }); - it('should make sure that description field is optional', () => { - typeInInputFieldAndBlur('dataSourceDescription', '', ''); - cy.get('input[name="dataSourceDescription"]:valid').should( - 'have.length', - 1 - ); - cy.getElementByTestId('datasource-edit-saveButton').should( - 'be.enabled' - ); - }); - it('should make sure that endpoint field is disabled in all scenarios', () => { - // credential: Username & password - cy.get('[data-test-subj="editDataSourceSelectAuthType"]').select( - 'username_password' - ); - cy.get('input[name="endpoint"]').should('be.disabled'); - cy.get('input[name="endpoint"]').should( - 'have.value', - DS_JSON.attributes.endpoint - ); - - // credential: No Authentication - cy.get('[data-test-subj="editDataSourceSelectAuthType"]').select( - 'no_auth' - ); - cy.get('input[name="endpoint"]').should('be.disabled'); - cy.get('input[name="endpoint"]').should( - 'have.value', - DS_JSON.attributes.endpoint - ); - - // credential: sigv4 - cy.get('[data-test-subj="editDataSourceSelectAuthType"]').select( - 'sigv4' - ); - cy.get('input[name="endpoint"]').should('be.disabled'); - cy.get('input[name="endpoint"]').should( - 'have.value', - DS_JSON.attributes.endpoint - ); - }); - it('should make sure that username field is required for credential: Username & password & hidden when credential: No Authentication', () => { - // credential: Username & password - cy.get('[data-test-subj="editDataSourceSelectAuthType"]').select( - 'username_password' - ); - cy.get('input[name="datasourceUsername"]').should('exist'); - cy.get('input[name="datasourceUsername"]').should('be.empty'); - - /* Required */ - typeInInputFieldAndBlur('datasourceUsername', '', ''); - cy.get('input[name="datasourceUsername"]:invalid').should( - 'have.length', - 1 - ); - - /* Valid */ - typeInInputFieldAndBlur( - 'datasourceUsername', - DS_JSON_UNIQUE_VALUES.attributes.auth.credentials.username, - '' - ); - cy.get('input[name="datasourceUsername"]:valid').should( - 'have.length', - 1 - ); - - // credential: No Authentication - cy.get('[data-test-subj="editDataSourceSelectAuthType"]').select( - 'no_auth' - ); - cy.get('input[name="datasourceUsername"]').should('not.exist'); - }); - it('should make sure that password field is required', () => { - // credential: Username & password - cy.get('[data-test-subj="editDataSourceSelectAuthType"]').select( - 'username_password' - ); - cy.getElementByTestId('editDatasourceUpdatePasswordBtn').should( - 'not.exist' - ); - cy.get(passwordFieldIdentifier).should('exist'); - cy.get(passwordFieldIdentifier).should('have.value', ''); - - /* Required */ - typeInInputFieldAndBlur('', '', passwordFieldIdentifier); - cy.get('input[type="password"]:invalid').should('have.length', 1); - - /* Valid */ - typeInInputFieldAndBlur( - '', - DS_JSON_UNIQUE_VALUES.attributes.auth.credentials.password, - passwordFieldIdentifier - ); - cy.get('input[type="password"]:valid').should('have.length', 1); - - // credential: No Authentication - cy.get('[data-test-subj="editDataSourceSelectAuthType"]').select( - 'no_auth' - ); - cy.get(passwordFieldIdentifier).should('not.exist'); - }); - }); - describe('bottom bar: Cancel & Save Changes', () => { - it('should clear all changes by clicking on cancel changes button', () => { - cy.get('[name="dataSourceTitle"]').should( - 'have.value', - DS_JSON_UNIQUE_VALUES.attributes.title - ); - cy.get('[name="dataSourceDescription"]').should( - 'have.value', - DS_JSON_UNIQUE_VALUES.attributes.description - ); - cy.getElementByTestId('datasource-edit-cancelButton').should('exist'); - cy.getElementByTestId('datasource-edit-cancelButton').should( - 'be.enabled' - ); - cy.getElementByTestId('datasource-edit-cancelButton').click(); - cy.get('[name="dataSourceTitle"]').should( - 'have.value', - DS_JSON.attributes.title // original value - ); - cy.get('[name="dataSourceDescription"]').should( - 'have.value', - DS_JSON.attributes.description // original value - ); - }); - it('should change credential to "Username & Password" & save changes with valid form', () => { - // credential: Username & password - cy.get('[data-test-subj="editDataSourceSelectAuthType"]').select( - 'username_password' - ); - // set username - typeInInputFieldAndBlur( - 'datasourceUsername', - DS_JSON_UNIQUE_VALUES.attributes.auth.credentials.username, - '' - ); - // set password - typeInInputFieldAndBlur( - '', - DS_JSON_UNIQUE_VALUES.attributes.auth.credentials.password, - passwordFieldIdentifier - ); - cy.getElementByTestId('datasource-edit-saveButton') - .should('be.enabled') - .click(); - cy.getElementByTestId( - 'datasource-edit-saveButton', - TIMEOUT_OPTS - ).should('not.exist'); - }); - it('should verify that changes were updated successfully', () => { - // credential: Username & password - cy.get('[data-test-subj="editDataSourceSelectAuthType"]').should( - 'have.value', - 'username_password' - ); - cy.get('[name="datasourceUsername"]').should( - 'have.value', - DS_JSON_UNIQUE_VALUES.attributes.auth.credentials.username - ); - cy.get(passwordFieldIdentifier).should('be.disabled'); - cy.getElementByTestId('editDatasourceUpdatePasswordBtn').should( - 'exist' // "Update Stored Password Button" - ); - }); - }); - - describe('validation: Originally datasource credential type is "Username & Password"', () => { - it('should again make sure that title field is required & does not accept duplicates', () => { - /* Required */ - typeInInputFieldAndBlur('dataSourceTitle', '', ''); - cy.get('input[name="dataSourceTitle"]:invalid').should( - 'have.length', - 1 - ); - cy.getElementByTestId('datasource-edit-saveButton').should( - 'be.disabled' - ); - - /* No error - on original title */ - typeInInputFieldAndBlur( - 'dataSourceTitle', - DS_JSON.attributes.title, - '' - ); - cy.get('input[name="dataSourceTitle"]:valid').should('have.length', 1); - cy.getElementByTestId('datasource-edit-saveButton').should('not.exist'); - - /* Duplicate */ - typeInInputFieldAndBlur( - 'dataSourceTitle', - DS_JSON_2.attributes.title, - '' - ); - cy.get('input[name="dataSourceTitle"]:invalid').should( - 'have.length', - 1 - ); - cy.contains('This title is already in use').should('exist'); - cy.getElementByTestId('datasource-edit-saveButton').should( - 'be.disabled' - ); - - /* No error - unique value */ - typeInInputFieldAndBlur( - 'dataSourceTitle', - DS_JSON_UNIQUE_VALUES.attributes.title, - '' - ); - cy.get('input[name="dataSourceTitle"]:valid').should('have.length', 1); - cy.getElementByTestId('datasource-edit-saveButton').should( - 'be.enabled' - ); - }); - it('should again make sure that description field is optional', () => { - typeInInputFieldAndBlur('dataSourceDescription', '', ''); - cy.get('input[name="dataSourceDescription"]:valid').should( - 'have.length', - 1 - ); - cy.getElementByTestId('datasource-edit-saveButton').should( - 'be.enabled' - ); - }); - it('should make sure that endpoint field is disabled in all scenarios', () => { - // credential: No Authentication - cy.get('[data-test-subj="editDataSourceSelectAuthType"]').select( - 'no_auth' - ); - cy.get('input[name="endpoint"]').should('be.disabled'); - cy.get('input[name="endpoint"]').should( - 'have.value', - DS_JSON.attributes.endpoint - ); - - // credential: Username & password - cy.get('[data-test-subj="editDataSourceSelectAuthType"]').select( - 'username_password' - ); - cy.get('input[name="endpoint"]').should('be.disabled'); - cy.get('input[name="endpoint"]').should( - 'have.value', - DS_JSON.attributes.endpoint - ); - }); - - it('should make sure that username field is hidden when credential: No Authentication & required for credential: Username & password', () => { - // credential: No Authentication - cy.get('[data-test-subj="editDataSourceSelectAuthType"]').select( - 'no_auth' - ); - cy.get('input[name="datasourceUsername"]').should('not.exist'); - - // credential: Username & password - cy.get('[data-test-subj="editDataSourceSelectAuthType"]').select( - 'username_password' - ); - cy.get('input[name="datasourceUsername"]').should('exist'); - cy.get('input[name="datasourceUsername"]').should( - 'have.value', - DS_JSON_UNIQUE_VALUES.attributes.auth.credentials.username - ); - - /* Required */ - typeInInputFieldAndBlur('datasourceUsername', '', ''); - cy.get('input[name="datasourceUsername"]:invalid').should( - 'have.length', - 1 - ); - - /* Valid */ - typeInInputFieldAndBlur( - 'datasourceUsername', - DS_JSON_UNIQUE_VALUES.attributes.auth.credentials.username, - '' - ); - cy.get('input[name="datasourceUsername"]:valid').should( - 'have.length', - 1 - ); - }); - it('should make sure that password field is disabled & Update stored password button is present', () => { - // credential: No Authentication - cy.get('[data-test-subj="editDataSourceSelectAuthType"]').select( - 'no_auth' - ); - cy.get(passwordFieldIdentifier).should('not.exist'); - cy.getElementByTestId('editDatasourceUpdatePasswordBtn').should( - 'not.exist' // Update stored password button - ); - - // credential: Username & password - cy.get('[data-test-subj="editDataSourceSelectAuthType"]').select( - 'username_password' - ); - cy.getElementByTestId('editDatasourceUpdatePasswordBtn').should( - 'exist' // Update stored password button - ); - cy.get(passwordFieldIdentifier).should('exist'); - cy.get(passwordFieldIdentifier).should('be.disabled'); - }); - }); - describe('validation: Update stores password modal', () => { - it('should display update password modal', () => { - cy.getElementByTestId('editDatasourceUpdatePasswordBtn').click({ - force: true, - }); - cy.get('.euiModal').should('exist'); - cy.getElementByTestId('updateStoredPasswordConfirmBtn').should( - 'be.disabled' - ); - cy.contains( - 'Update credential password to reflect accurate password to gain access to the endpoint.' - ).should('exist'); - }); - it('should make sure "Updated Password" filed is required', () => { - cy.get(updatedPasswordIdentifier).should('have.value', ''); - typeInInputFieldAndBlur('', '', updatedPasswordIdentifier); - - cy.get(`${updatedPasswordIdentifier}:invalid`).should('have.length', 1); - typeInInputFieldAndBlur( - '', - DS_JSON_UNIQUE_VALUES.attributes.auth.credentials.password, - updatedPasswordIdentifier - ); - - cy.get(`${updatedPasswordIdentifier}:valid`).should('have.length', 1); - }); - it('should make sure that "Confirm Updated Password" filed is required & matches with Updated Password field', () => { - cy.get(confirmUpdatedPasswordIdentifier).should('have.value', ''); - - /* Required */ - typeInInputFieldAndBlur('', '', confirmUpdatedPasswordIdentifier); - - cy.get(`${confirmUpdatedPasswordIdentifier}:invalid`).should( - 'have.length', - 1 - ); - - /* Passwords do not match */ - - typeInInputFieldAndBlur('', 'test', confirmUpdatedPasswordIdentifier); - cy.get(`${confirmUpdatedPasswordIdentifier}:invalid`).should( - 'have.length', - 1 - ); - cy.contains('Passwords do not match').should('exist'); - - /* Matching passwords */ - typeInInputFieldAndBlur( - '', - DS_JSON_UNIQUE_VALUES.attributes.auth.credentials.password, - confirmUpdatedPasswordIdentifier - ); - cy.get(`${confirmUpdatedPasswordIdentifier}:valid`).should( - 'have.length', - 1 - ); - cy.get(`${confirmUpdatedPasswordIdentifier}:valid`).should( - 'have.length', - 1 - ); - cy.get(`${confirmUpdatedPasswordIdentifier}`) - .invoke('val') - .then((confirmPwd) => { - cy.get(`${updatedPasswordIdentifier}`).should( - 'have.value', - confirmPwd - ); - }); - cy.contains('Passwords do not match').should('not.exist'); - - cy.getElementByTestId('updateStoredPasswordConfirmBtn').should( - 'be.enabled' - ); - }); - }); - describe('Cancel & update password from modal', () => { - it('should close the update stored password modal', () => { - cy.getElementByTestId('updateStoredPasswordCancelBtn').click({ - force: true, - }); - cy.get('.euiModal').should('not.exist'); - }); - it('should not remember previous input for updated & confirm updated password fields', () => { - cy.getElementByTestId('editDatasourceUpdatePasswordBtn').click({ - force: true, - }); - cy.get(updatedPasswordIdentifier).should( - 'not.have.value', - DS_JSON_UNIQUE_VALUES.attributes.auth.credentials.password - ); - cy.get(confirmUpdatedPasswordIdentifier).should( - 'not.have.value', - DS_JSON_UNIQUE_VALUES.attributes.auth.credentials.password - ); - }); - it('should save valid updated stored password', () => { - typeInInputFieldAndBlur( - '', - DS_JSON_UNIQUE_VALUES.attributes.auth.credentials.password, - updatedPasswordIdentifier - ); - typeInInputFieldAndBlur( - '', - DS_JSON_UNIQUE_VALUES.attributes.auth.credentials.password, - confirmUpdatedPasswordIdentifier - ); - cy.getElementByTestId('updateStoredPasswordConfirmBtn').should( - 'be.enabled' - ); - cy.getElementByTestId('updateStoredPasswordConfirmBtn').click({ - force: true, - }); - cy.get('.euiModal', TIMEOUT_OPTS).should('not.exist'); - cy.contains('Password updated successfully.', TIMEOUT_OPTS).should( - 'exist' - ); - }); - }); - describe('bottom bar: Save Changes -> "Change Credential Type & few fields"', () => { - it('should change credential to "No Authentication" & save changes with valid form', () => { - // credential: No Authentication - cy.get('[data-test-subj="editDataSourceSelectAuthType"]').select( - 'no_auth' - ); - typeInInputFieldAndBlur( - 'dataSourceTitle', - DS_JSON_UNIQUE_VALUES.attributes.title, - '' - ); - cy.getElementByTestId('datasource-edit-saveButton') - .should('be.enabled') - .click(); - cy.getElementByTestId( - 'datasource-edit-saveButton', - TIMEOUT_OPTS - ).should('not.exist'); - }); - it('should verify that changes were updated successfully', () => { - cy.get('[name="dataSourceTitle"]').should( - 'have.value', - DS_JSON_UNIQUE_VALUES.attributes.title - ); - // credential: No Authentication - cy.get('[data-test-subj="editDataSourceSelectAuthType"]').should( - 'have.value', - 'no_auth' - ); - cy.get('[name="datasourceUsername"]').should('not.exist'); - cy.get(passwordFieldIdentifier).should('not.exist'); - cy.getElementByTestId('editDatasourceUpdatePasswordBtn').should( - 'not.exist' // "Update Stored Password Button" - ); - }); - }); - - describe(`Updating current datasource auth type from "no auth" to "SigV4"`, () => { - it('should change credential to "SigV4" & render only related fields', () => { - // verify current auth type is "no auth" - cy.get('[data-test-subj="editDataSourceSelectAuthType"]').should( - 'have.value', - 'no_auth' - ); - cy.get('[data-test-subj="editDataSourceSelectAuthType"]').select( - 'sigv4' - ); - - // username & password fields should be hidden - cy.get('input[name="datasourceUsername"]').should('not.exist'); - cy.get(passwordFieldIdentifier).should('not.exist'); - cy.getElementByTestId('editDatasourceUpdatePasswordBtn').should( - 'not.exist' - ); - - // SigV4 related fields should be visible - cy.getElementByTestId('editDataSourceFormRegionField').should('exist'); - cy.getElementByTestId( - 'editDataSourceFormSigV4ServiceTypeSelect' - ).should('have.value', 'es'); - cy.getElementByTestId('editDataSourceFormAccessKeyField').should( - 'exist' - ); - cy.getElementByTestId('editDataSourceFormSecretKeyField').should( - 'exist' - ); - }); - - it('should make sure that region field is required', () => { - cy.getElementByTestId('editDataSourceFormRegionField').should( - 'not.have.value' - ); - typeInInputFieldAndBlur( - '', - '', - '[data-test-subj="editDataSourceFormRegionField"]' - ); - cy.get( - 'input[data-test-subj="editDataSourceFormRegionField"]:invalid' - ).should('have.length', 1); - cy.getElementByTestId('datasource-edit-saveButton').should( - 'be.disabled' - ); - }); - it('should make sure that access key field is required', () => { - cy.getElementByTestId('editDataSourceFormAccessKeyField').should( - 'not.have.value' - ); - /* Required */ - typeInInputFieldAndBlur( - '', - '', - '[data-test-subj="editDataSourceFormAccessKeyField"]' - ); - cy.get( - 'input[data-test-subj="editDataSourceFormAccessKeyField"]:invalid' - ).should('have.length', 1); - cy.getElementByTestId('datasource-edit-saveButton').should( - 'be.disabled' - ); - }); - it('should make sure that secret key field is required', () => { - cy.getElementByTestId('editDataSourceFormSecretKeyField').should( - 'not.have.value' - ); - /* Required */ - typeInInputFieldAndBlur( - '', - '', - '[data-test-subj="editDataSourceFormSecretKeyField"]' - ); - cy.get( - 'input[data-test-subj="editDataSourceFormSecretKeyField"]:invalid' - ).should('have.length', 1); - cy.getElementByTestId('datasource-edit-saveButton').should( - 'be.disabled' - ); - }); - }); - - describe('bottom bar: Save Changes -> "Change Credential Type to sigv4"', () => { - it('should change credential to "SigV4" & save changes with valid form', () => { - // credential: SigV4 - cy.get('[data-test-subj="editDataSourceSelectAuthType"]').select( - 'sigv4' - ); - // set region - typeInInputFieldAndBlur( - '', - DS_JSON_UNIQUE_VALUES.attributes.auth.credentials.region, - '[data-test-subj="editDataSourceFormRegionField"]' - ); - // set access key - typeInInputFieldAndBlur( - '', - DS_JSON_UNIQUE_VALUES.attributes.auth.credentials.accessKey, - '[data-test-subj="editDataSourceFormAccessKeyField"]' - ); - - // set secret key - typeInInputFieldAndBlur( - '', - DS_JSON_UNIQUE_VALUES.attributes.auth.credentials.secretKey, - '[data-test-subj="editDataSourceFormSecretKeyField"]' - ); - - // set service type - cy.getElementByTestId( - 'editDataSourceFormSigV4ServiceTypeSelect' - ).select(DS_JSON_UNIQUE_VALUES.attributes.auth.credentials.service); - - cy.getElementByTestId('datasource-edit-saveButton') - .should('be.enabled') - .click(); - cy.getElementByTestId( - 'datasource-edit-saveButton', - TIMEOUT_OPTS - ).should('not.exist'); - }); - it('should verify that changes were updated successfully', () => { - cy.get('[data-test-subj="editDataSourceSelectAuthType"]').should( - 'have.value', - 'sigv4' - ); - cy.getElementByTestId('editDataSourceFormRegionField').should( - 'have.value', - DS_JSON_UNIQUE_VALUES.attributes.auth.credentials.region - ); - cy.getElementByTestId( - 'editDataSourceFormSigV4ServiceTypeSelect' - ).should( - 'have.value', - DS_JSON_UNIQUE_VALUES.attributes.auth.credentials.service - ); - cy.getElementByTestId('editDataSourceFormAccessKeyField').should( - 'be.disabled' - ); - cy.getElementByTestId('editDataSourceFormSecretKeyField').should( - 'be.disabled' - ); - cy.getElementByTestId('editDatasourceUpdateAwsCredentialBtn').should( - 'exist' - ); - }); - }); - - describe('delete datasource', () => { - it('should open delete confirmation modal on click of trash icon', () => { - cy.getElementByTestId('editDatasourceDeleteIcon') - .should('exist') - .click(FORCE_CLICK_OPTS); - - cy.getElementByTestId( - 'editDatasourceDeleteConfirmModal', - TIMEOUT_OPTS - ).should('exist'); - cy.getElementByTestId('confirmModalCancelButton').should('exist'); - cy.getElementByTestId('confirmModalConfirmButton').should('exist'); - cy.contains( - 'Any objects created using data from these sources, including Index Patterns, Visualizations, and Observability Panels, will be impacted.' - ).should('exist'); - cy.contains('This action cannot be undone.').should('exist'); - }); - it('should close delete confirmation modal on cancel button click without deleting the datasource', () => { - cy.getElementByTestId('confirmModalCancelButton') - .should('exist') - .click(FORCE_CLICK_OPTS); - cy.getElementByTestId('editDatasourceDeleteConfirmModal').should( - 'not.exist' - ); - cy.get('[name="dataSourceTitle"]').should( - 'have.value', - DS_JSON_UNIQUE_VALUES.attributes.title - ); - }); - it('should delete the datasource & navigate back to listing screen on click delete button on modal', () => { - cy.getElementByTestId('editDatasourceDeleteIcon') - .should('exist') - .click(FORCE_CLICK_OPTS); - - cy.getElementByTestId('editDatasourceDeleteConfirmModal').should( - 'exist' - ); - - cy.getElementByTestId('confirmModalConfirmButton') - .should('exist') - .click(FORCE_CLICK_OPTS); - cy.location('pathname', TIMEOUT_OPTS).should( - 'equal', - '/app/management/opensearch-dashboards/dataSources' - ); - checkIfTableIsLoaded(); - cy.get('tbody > tr').should(($tr) => { - expect($tr).to.have.length(1); - }); - }); - }); - }); -}