Skip to content

Commit 26ab107

Browse files
authored
Add tests for data source selector (opensearch-project#965)
* add tests for data source selector Signed-off-by: Eric <menwe@amazon.com> * add global tenant Signed-off-by: Eric <menwe@amazon.com> * add to ciGroup Signed-off-by: Eric <menwe@amazon.com> --------- Signed-off-by: Eric <menwe@amazon.com>
1 parent a1d3ca1 commit 26ab107

File tree

2 files changed

+91
-1
lines changed

2 files changed

+91
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import {
7+
MiscUtils,
8+
TestFixtureHandler,
9+
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
10+
import { CURRENT_TENANT } from '../../../../../utils/commands';
11+
12+
const miscUtils = new MiscUtils(cy);
13+
const testFixtureHandler = new TestFixtureHandler(
14+
cy,
15+
Cypress.env('openSearchUrl')
16+
);
17+
18+
describe('Data source selector', () => {
19+
before(() => {
20+
CURRENT_TENANT.newTenant = 'global';
21+
testFixtureHandler.importJSONMapping(
22+
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/index_pattern_without_timefield/mappings.json.txt'
23+
);
24+
testFixtureHandler.importJSONDoc(
25+
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/index_pattern_without_timefield/data.json.txt'
26+
);
27+
28+
miscUtils.visitPage('app/data-explorer/discover#/');
29+
cy.waitForLoader();
30+
});
31+
32+
after(() => {
33+
testFixtureHandler.clearJSONMapping(
34+
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/index_pattern_without_timefield/mappings.json.txt'
35+
);
36+
cy.deleteSavedObjectByType('index-pattern');
37+
});
38+
39+
it('displays all data sources by default', () => {
40+
cy.get('[data-test-subj="dataExplorerDSSelect"]').click();
41+
cy.get('.euiComboBoxOptionsList').should('exist');
42+
cy.get('.euiComboBoxOption__content').should('have.length', 2);
43+
});
44+
45+
it('filters options based on user input', () => {
46+
cy.get('[data-test-subj="dataExplorerDSSelect"] input').type('without', {
47+
force: true,
48+
});
49+
cy.get('.euiComboBoxOption__content').should('have.length', 1);
50+
cy.get('.euiComboBoxOption__content')
51+
.first()
52+
.should('contain', 'without-timefield');
53+
});
54+
55+
it('updates the visual length of the dropdown based on filtered results', () => {
56+
cy.get('[data-test-subj="dataExplorerDSSelect"] input').clear({
57+
force: true,
58+
});
59+
cy.get('[data-test-subj="dataExplorerDSSelect"] input').type(
60+
'without-timefield',
61+
{
62+
force: true,
63+
}
64+
);
65+
cy.get('.euiComboBoxOptionsList').then(($listAfterFilter) => {
66+
const heightAfterFilter = $listAfterFilter.height();
67+
cy.get('[data-test-subj="dataExplorerDSSelect"] input').clear({
68+
force: true,
69+
});
70+
cy.get('.euiComboBoxOptionsList').should(($listAll) => {
71+
expect($listAll.height()).to.be.greaterThan(heightAfterFilter);
72+
});
73+
});
74+
});
75+
76+
it('selects the correct option when clicked', () => {
77+
cy.get('[data-test-subj="dataExplorerDSSelect"] input').type(
78+
'with-timefield',
79+
{
80+
force: true,
81+
}
82+
);
83+
84+
cy.contains('.euiComboBoxOption__content', 'with-timefield').click();
85+
cy.get('[data-test-subj="dataExplorerDSSelect"] .euiComboBoxPill').should(
86+
'contain',
87+
'with-timefield'
88+
);
89+
});
90+
});

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"osd:ciGroup3": "echo \"apps/vis-augmenter/*.js\"",
3131
"osd:ciGroup4": "echo \"dashboard_sample_data_with_datasource_spec.js,dashboard_sanity_test_spec.js\"",
3232
"osd:ciGroup5": "echo \"datasource-management-plugin/*.js\"",
33-
"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\"",
33+
"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\"",
3434
"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\"",
3535
"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\"",
3636
"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\"",

0 commit comments

Comments
 (0)