Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"reporterOptions": {
"configFile": "reporter-config.json"
},
"experimentalStudio": true,
"viewportWidth": 2000,
"viewportHeight": 1320,
"env": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
/*
* 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';
import { cloneDeep } from 'lodash';

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#/');
});

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', () => {
// Needs validation
cy.get('[data-test-subj="datasetSelectorButton"]').click({ force: true });
cy.get('.euiSelectableListItem__text').should('have.length', 2);
});

it('filters options based on user input', () => {
cy.get('input[aria-label="Filter options"]').click().type('without', {
force: true,
});
cy.get('.euiSelectableListItem__text').should('have.length', 1);
cy.get('.euiSelectableListItem__text')
.first()
.should('contain', 'without-timefield');
});

it('updates the visual length of the dropdown based on filtered results', () => {
// cy.get('[data-test-subj="datasetSelectorButton"]').click({ force: true });
cy.get('input[aria-label="Filter options"]').click().clear({
force: true,
});
cy.get('input[aria-label="Filter options"]')
.click()
.type('without-timefield', {
force: true,
});
cy.get('.euiSelectableList').then(($listAfterFilter) => {
const heightAfterFilter = $listAfterFilter.height();
cy.get('input[aria-label="Filter options"]').click().clear({
force: true,
});
cy.get('.euiSelectableList').should(($listAll) => {
expect($listAll.height()).to.be.greaterThan(heightAfterFilter);
});
});
});

it('selects the correct option when clicked', () => {
// cy.get('[data-test-subj="datasetSelectorButton"]').click({ force: true });
cy.get('input[aria-label="Filter options"]')
.click()
.type('with-timefield', {
force: true,
});

cy.contains('.euiSelectableListItem__text', 'with-timefield').click();
cy.get(
'[data-test-subj="datasetSelectorButton"] .euiButton__content'
).should('contain', 'with-timefield');
});
});

describe('data source selector', () => {
before(() => {
// Creating additional index patterns
// logstash index pattern

cy.createIndexPattern(
'logstash-sample-1',
{
title: 'logstash-sample-1*',
timeFieldName: 'timestamp',
},
{
securitytenant: ['global'],
}
);
cy.createIndexPattern(
'logstash-sample-2',
{
title: 'logstash-sample-2*',
timeFieldName: 'timestamp',
},
{
securitytenant: ['global'],
}
);
cy.wait(5000); // Intentional Wait
cy.reload();
});
it('check data source selector options are ordered', function () {
const indexPatterns = [];
cy.get('[data-test-subj="datasetSelectorButton"]').click({ force: true });
cy.get('input[aria-label="Filter options"]')
.click()
.type('l')
.then(() => {
cy.get('[role="option"]')
.each((res) => {
indexPatterns.push(res.text());
})
.then(() => {
const sortedIndexPatterns = cloneDeep(indexPatterns);
sortedIndexPatterns.sort();

console.log(sortedIndexPatterns);

cy.wrap(indexPatterns).should('deep.equal', sortedIndexPatterns);
});
});
});

it('check filtering in data source selector ', function () {
cy.get('input[aria-label="Filter options"]')
.click()
.clear()
.type('logstash-sample')
.then(() => {
cy.get('[role="option"]').should('have.length', 2);
});
});

after(() => {
cy.deleteIndexPattern('logstash-sample-1');
cy.deleteIndexPattern('logstash-sample-2');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* 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.waitForLoaderNewHeader();
});

after(() => {
miscUtils.visitPage('app/management/opensearch-dashboards/settings');
cy.waitForLoaderNewHeader();
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');
cy.clearCache();
});

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.setDatasource('long-window-logstash-*');
cy.prepareNewTest(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.setDatasource('long-window-logstash-*');
cy.prepareNewTest(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.setDatasource('long-window-logstash-*');
cy.prepareNewTest(fromTime, toTime, 'Day');
cy.get('.echChart canvas:last-of-type').should('be.visible');
cy.get('.euiToolTipAnchor').should('be.visible');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* 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',
];

// Setting up the page
describe('discover_table', () => {
before(() => {
// import logstash functional
CURRENT_TENANT.newTenant = 'global';
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'
);

testFixtureHandler.importJSONMapping(
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/index_with_nested_field/mappings.json.txt'
);

testFixtureHandler.importJSONDoc(
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/index_with_nested_field/data.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.setDatasource('logstash-*');
cy.waitForSearch();
});

describe('auto line wrapping in legacy table', () => {
it('auto line wrapping in legacy table', function () {
// last element is _scrore if there is wrapping this field won't be present
// So we check for the presence of the _score element in the legacy table

cy.get('.euiDescriptionList__title').should('contain.text', '_score');
});
});

describe('expand multiple documents in legacy table', () => {
it('checks if multiple documents can be expanded in legacy table', function () {
// expanding a document in the table
cy.get('[data-test-subj="docTableExpandToggleColumn"]')
.find('[type="button"]')
.eq(2)
.click();

// expanding a document in the table
cy.get('[data-test-subj="docTableExpandToggleColumn"]')
.find('[type="button"]')
.eq(3)
.click();

// checking the number of exapnded documents visible on screen
cy.get('[data-test-subj="tableDocViewRow-_index"]').should(
'have.length',
2
);
});
});
});
Loading
Loading