From 0e90eb9452efb8fad6b4a917011c6c12c614f0e8 Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 28 Nov 2023 16:41:58 +0000 Subject: [PATCH 1/3] add tests for data source selector Signed-off-by: Eric --- .../data_source_selector.spec.js | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/data_source_selector.spec.js 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 new file mode 100644 index 000000000..6a87966ed --- /dev/null +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/data_source_selector.spec.js @@ -0,0 +1,88 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { + MiscUtils, + TestFixtureHandler, +} from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; + +const miscUtils = new MiscUtils(cy); +const testFixtureHandler = new TestFixtureHandler( + cy, + Cypress.env('openSearchUrl') +); + +describe('Data source selector', () => { + before(() => { + 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' + ); + }); +}); From d01589f80611f447cfb4568cb3f8470a5f72935d Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 28 Nov 2023 18:02:18 +0000 Subject: [PATCH 2/3] add global tenant Signed-off-by: Eric --- .../apps/data_explorer/data_source_selector.spec.js | 2 ++ 1 file changed, 2 insertions(+) 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 index 6a87966ed..3b5916d0f 100644 --- 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 @@ -7,6 +7,7 @@ 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( @@ -16,6 +17,7 @@ const testFixtureHandler = new TestFixtureHandler( 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' ); From 72b8591d2aa3c6671d7cc1b0ef033c16ce99eb8b Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 28 Nov 2023 18:10:52 +0000 Subject: [PATCH 3/3] add to ciGroup Signed-off-by: Eric --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 19b3ea8e9..1a974e4d4 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "osd:ciGroup3": "echo \"apps/vis-augmenter/*.js\"", "osd:ciGroup4": "echo \"dashboard_sample_data_with_datasource_spec.js,dashboard_sanity_test_spec.js\"", "osd:ciGroup5": "echo \"datasource-management-plugin/*.js\"", - "osd:ciGroup6": "echo \"apps/data_explorer/aaa_before.spec.js,apps/data_explorer/date_nanos_mixed.spec.js,apps/data_explorer/date_nanos.spec.js,apps/data_explorer/discover_histogram.spec.js,apps/data_explorer/discover.spec.js,apps/data_explorer/zzz_after.spec.js\"", + "osd:ciGroup6": "echo \"apps/data_explorer/aaa_before.spec.js,apps/data_explorer/data_source_selector.spec.js,apps/data_explorer/date_nanos_mixed.spec.js,apps/data_explorer/date_nanos.spec.js,apps/data_explorer/discover_histogram.spec.js,apps/data_explorer/discover.spec.js,apps/data_explorer/zzz_after.spec.js\"", "osd:ciGroup7": "echo \"apps/data_explorer/aaa_before.spec.js,apps/data_explorer/doc_navigation.spec.js,apps/data_explorer/doc_table.spec.js,apps/data_explorer/errors.spec.js,apps/data_explorer/field_data.spec.js,apps/data_explorer/zzz_after.spec.js\"", "osd:ciGroup8": "echo \"apps/data_explorer/aaa_before.spec.js,apps/data_explorer/field_visualize.spec.js,apps/data_explorer/filter_editor.spec.js,apps/data_explorer/index_pattern_with_encoded_id.spec.js,apps/data_explorer/index_pattern_without_field.spec.js,apps/data_explorer/zzz_after.spec.js\"", "osd:ciGroup9": "echo \"apps/data_explorer/aaa_before.spec.js,apps/data_explorer/inspector.spec.js,apps/data_explorer/large_string.spec.js,apps/data_explorer/saved_queries.spec.js,apps/data_explorer/shared_links.spec.js,apps/data_explorer/sidebar.spec.js,apps/data_explorer/source_filter.spec.js,apps/data_explorer/zzz_after.spec.js\""