From 92e6842cff139126dbb9aad3a64a64a28ca211d9 Mon Sep 17 00:00:00 2001 From: "Qingyang(Abby) Hu" Date: Mon, 18 Sep 2023 10:44:49 -0700 Subject: [PATCH] more tests #3 Signed-off-by: Qingyang(Abby) Hu --- .../apps/data_explorer/doc_navigation.spec.js | 60 +++++++++++++++++++ .../apps/data_explorer/doc_table.spec.js | 45 ++++++++++++++ .../data_explorer/field_visualize.spec.js | 49 +++++++-------- .../apps/data_explorer/filter_editor.spec.js | 15 +++-- .../dashboards/data_explorer/commands.js | 26 +++++--- 5 files changed, 155 insertions(+), 40 deletions(-) diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/doc_navigation.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/doc_navigation.spec.js index e69de29bb..405fe0427 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/doc_navigation.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/doc_navigation.spec.js @@ -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') + + }); +}) \ No newline at end of file diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/doc_table.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/doc_table.spec.js index e69de29bb..2899135e1 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/doc_table.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/doc_table.spec.js @@ -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') + }); + }); +}) \ No newline at end of file diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/field_visualize.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/field_visualize.spec.js index 4464dd875..79efa01fd 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/field_visualize.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/field_visualize.spec.js @@ -18,26 +18,26 @@ 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-*', @@ -45,14 +45,12 @@ describe('discover field visualize button', () => { }); 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'); @@ -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'); @@ -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'); @@ -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') diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/filter_editor.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/filter_editor.spec.js index 34f139d23..9085def73 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/filter_editor.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/filter_editor.spec.js @@ -15,19 +15,20 @@ 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() @@ -35,12 +36,14 @@ describe('discover filter editor', () => { .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') }); diff --git a/cypress/utils/dashboards/data_explorer/commands.js b/cypress/utils/dashboards/data_explorer/commands.js index 80e3fc2af..22b0d3b08 100644 --- a/cypress/utils/dashboards/data_explorer/commands.js +++ b/cypress/utils/dashboards/data_explorer/commands.js @@ -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() }) @@ -124,3 +130,7 @@ Cypress.Commands.add('saveQuery', (name, description) => { cy.getElementByTestId('saveQueryFormDescription') .type(description) }) + +Cypress.Commands.add(`importJSONDoc`, (index, filePath) => { + +})