Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for data source selector #965

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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(
mengweieric marked this conversation as resolved.
Show resolved Hide resolved
'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'
);
});
});
Loading