Skip to content

Commit

Permalink
Add tests for data source selector (#965) (#1013)
Browse files Browse the repository at this point in the history
* add tests for data source selector

Signed-off-by: Eric <[email protected]>

* add global tenant

Signed-off-by: Eric <[email protected]>

* add to ciGroup

Signed-off-by: Eric <[email protected]>

---------

Signed-off-by: Eric <[email protected]>
(cherry picked from commit 26ab107)

Co-authored-by: Eric Wei <[email protected]>
  • Loading branch information
1 parent 4add696 commit 9bd0504
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* 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'
);
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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\"",
Expand Down

0 comments on commit 9bd0504

Please sign in to comment.