Skip to content

Commit

Permalink
more tests #3
Browse files Browse the repository at this point in the history
Signed-off-by: Qingyang(Abby) Hu <[email protected]>
  • Loading branch information
abbyhu2000 committed Sep 18, 2023
1 parent f5b768e commit 92e6842
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import {
MiscUtils,
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library';

const miscUtils = new MiscUtils(cy);

describe('doc link in discover', () => {
beforeEach(() => {
cy.setAdvancedSetting({
defaultIndex: 'logstash-*',
});

miscUtils.visitPage(`app/data-explorer/discover#/?_g=(filters:!(),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))`);
cy.waitForLoader()
cy.waitForSearch()
});

it('should open the doc view of the selected document', function () {
cy.getElementByTestId(`docTableExpandToggleColumn-0`)
.should('be.visible')
.click()
cy.getElementByTestId(`documentDetailFlyOut`)
.should('be.visible')

cy.getElementByTestId('docTableRowAction')
.find('View single document')
.click()

cy.getElementByTestId('doc-hit')
.should('be.visible')
});

it('if value is null, add filter should create a non-exist filter', function () {
// Filter out special document
cy.submitFilterFromDropDown('agent', 'is', 'Missing/Fields');
cy.waitForSearch()

cy.getElementByTestId(`docTableExpandToggleColumn-0`)
.should('be.visible')
.click()
cy.getElementByTestId(`documentDetailFlyOut`)
.should('be.visible')

cy.getElementByTestId('tableDocViewRow-referer')
.find(`[data-test-subj="addInclusiveFilterButton"]`)
.click()

cy.get('[data-test-subj~="filter-key-referer"]')
.should('be.visible')

cy.get('[data-test-subj~="filter-negated"]')
.should('be.visible')

});
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import {
MiscUtils,
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library';

const miscUtils = new MiscUtils(cy);

describe('discover doc table', () => {
beforeEach(() => {
cy.setAdvancedSetting({
defaultIndex: 'logstash-*',
});

miscUtils.visitPage(`app/data-explorer/discover#/?_g=(filters:!(),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))`);
cy.waitForLoader()
cy.waitForSearch()
});

describe('add and remove columns', function () {
it('should add more columns to the table', function () {
cy.getElementByTestId('fieldFilterSearchInput')
.type('phpmemory')

cy.getElementByTestId('fieldToggle-phpmemory')
.should('be.visible')
.click()

cy.getElementByTestId('dataGridHeaderCell-phpmemory')
.should('be.visible')
});

it('should remove columns from the table', function () {
cy.getElementByTestId('fieldToggle-phpmemory')
.should('be.visible')
.click()

cy.getElementByTestId('dataGridHeaderCell-phpmemory')
.should('not.be.visible')
});
});
})
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,39 @@ const testFixtureHandler = new TestFixtureHandler(
describe('discover field visualize button', () => {
before(() => {

testFixtureHandler.importJSONMapping(
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/discover/discover.mappings.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'
);
// import long window logstash index pattern
testFixtureHandler.importJSONDoc(
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/long_window_logstash_index_pattern/data.json.txt'
);
// testFixtureHandler.importJSONDoc(
// 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/discover/discover.json.txt'
// );
// // 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.importJSONMapping(
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.mappings.json.txt'
)
// // import logstash functional
// testFixtureHandler.importJSONMapping(
// 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.mappings.json.txt'
// )

testFixtureHandler.importJSONDoc(
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.json.txt'
)
// testFixtureHandler.importJSONDoc(
// 'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/logstash/logstash.json.txt'
// )

cy.setAdvancedSetting({
defaultIndex: 'logstash-*',
});
});

beforeEach(() => {
miscUtils.visitPage('app/data-explorer/discover#/');
miscUtils.visitPage(`app/data-explorer/discover#/?_g=(filters:!(),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))`);
cy.waitForLoader()
cy.wait(60000)
cy.setTopNavDate(DX_DEFAULT_START_TIME, DX_DEFAULT_END_TIME)
cy.waitForSearch()
})

it.skip('should be able to visualize a field and save the visualization', () => {
it('should be able to visualize a field and save the visualization', () => {
cy.getElementByTestId('fieldFilterSearchInput')
.type('type')
cy.log('visualize a type field');
Expand All @@ -62,7 +60,7 @@ describe('discover field visualize button', () => {
.click()
});

it.skip('should visualize a field in area chart', () => {
it('should visualize a field in area chart', () => {
cy.getElementByTestId('fieldFilterSearchInput')
.type('phpmemory')
cy.log('visualize a phpmemory field');
Expand All @@ -75,7 +73,7 @@ describe('discover field visualize button', () => {
.should('be.visible')
});

it.skip('should not show the "Visualize" button for geo field', () => {
it('should not show the "Visualize" button for geo field', () => {
cy.getElementByTestId('fieldFilterSearchInput')
.type('geo.coordinates')
cy.log('visualize a geo field');
Expand All @@ -97,12 +95,11 @@ describe('discover field visualize button', () => {
cy.waitForLoader()
cy.get('.visEditor__canvas')
.should('be.visible')

cy.getElementByTestId('filter filter-enabled filter-key-bytes filter-value-exists filter-unpinned')
cy.get('[data-test-subj~=filter-key-bytes]')
.should('be.visible')
});

it.skip('should preserve query in visualize', () => {
it('should preserve query in visualize', () => {
const query = 'machine.os : ios'
cy.setTopNavQuery(query)
cy.getElementByTestId('fieldFilterSearchInput')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,35 @@ describe('discover filter editor', () => {
defaultIndex: 'logstash-*',
});

miscUtils.visitPage('app/data-explorer/discover#/');
miscUtils.visitPage(`app/data-explorer/discover#/?_g=(filters:!(),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))`);
cy.waitForLoader()
cy.waitForSearch()
});

describe('filter editor', function () {
it('should add a phrases filter', function () {
it.skip('should add a phrases filter', function () {
cy.submitFilterFromDropDown('extension.raw', 'is one of', 'jpg')
cy.getElementByTestId('filter filter-enabled filter-key-extension.raw filter-value-jpg filter-unpinned')
cy.get('[data-test-subj~="filter-key-extension.raw"]')
.should('be.visible')
});

it('should show the phrases if you re-open a phrases filter', function () {
cy.getElementByTestId('filter filter-enabled filter-key-extension.raw filter-value-jpg filter-unpinned')
it.skip('should show the phrases if you re-open a phrases filter', function () {
cy.get('[data-test-subj~="filter-key-extension.raw"]')
.click()
cy.getElementByTestId('editFilter')
.click()
cy.getElementByTestId('filterFieldSuggestionList')
.should('have.text', 'extension.raw')
cy.get('[data-test-subj~="filterParamsComboBox"]')
.should('have.text', 'jpg')
cy.getElementByTestId('cancelSaveFilter')
.click()
});

it('should support filtering on nested fields', () => {
cy.submitFilterFromDropDown('nestedField.child', 'is', 'nestedValue')

cy.getElementByTestId('filter filter-enabled filter-key-nestedField.child filter-value-nestedValue filter-unpinned')
cy.get('[data-test-subj~="filter-key-nestedField.child"]')
.should('be.visible')
cy.verifyHitCount('1')
});
Expand Down
26 changes: 18 additions & 8 deletions cypress/utils/dashboards/data_explorer/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,29 @@ Cypress.Commands.add('submitFilterFromDropDown', (field, operator, value) => {
cy.getElementByTestId('filterFieldSuggestionList')
.should('be.visible')
.click()
cy.getElementByTestId('comboBoxOptionsList filterFieldSuggestionList-optionsList')
.get('button')
.contains(field)
.type(field)
cy.contains('button', field)
.click()

cy.getElementByTestId('filterOperatorList')
.should('be.visible')
.click()
.type(operator)
cy.contains('button', operator)

cy.get('[data-test-subj~="filterParamsComboBox"]')
.should('be.visible')
.click()
cy.contains('button', value)

if(value){
cy.get('[data-test-subj~="filterParamsComboBox"]')
.should('be.visible')
.click()
.type(value)
cy.contains('button', value)
.click()
}


cy.getElementByTestId('saveFilter')
.click()
.click({force:true})
cy.waitForLoader()
})

Expand All @@ -124,3 +130,7 @@ Cypress.Commands.add('saveQuery', (name, description) => {
cy.getElementByTestId('saveQueryFormDescription')
.type(description)
})

Cypress.Commands.add(`importJSONDoc`, (index, filePath) => {

})

0 comments on commit 92e6842

Please sign in to comment.