From 2a736eef1859089798135a402d5100b239d469d8 Mon Sep 17 00:00:00 2001 From: Suchit Sahoo Date: Tue, 26 Mar 2024 17:13:10 -0700 Subject: [PATCH] Add Discover Table Tests Signed-off-by: Suchit Sahoo --- .../apps/data_explorer/discover_table.spec.js | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover_table.spec.js diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover_table.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover_table.spec.js new file mode 100644 index 000000000..2a06bc63d --- /dev/null +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover_table.spec.js @@ -0,0 +1,126 @@ +/* + * 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', () => { + beforeEach(() => { + if (Cypress.env('SECURITY_ENABLED')) { + /** + * Security plugin is using private tenant as default. + * So here we'd need to set global tenant as default manually. + */ + cy.changeDefaultTenant({ + multitenancy_enabled: true, + private_tenant_enabled: true, + default_tenant: 'global', + }); + } + CURRENT_TENANT.newTenant = 'global'; + // 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' + ); + + 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' + ); + + 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.waitForSearch(); + }); + + describe('no line wrapping in legacy table', () => { + it('checks that there is no line wrapping by default in the 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('maxHeight With truncation', () => { + before(() => { + cy.setAdvancedSetting({ + 'truncate:maxHeight': 130, + }); + }); + + it('checks if the table respects maxHeight setting of truncation', function () { + cy.get('.truncate-by-height') + .first() + .should('have.css', 'max-height', '130px'); + }); + }); + + describe('maxHeight With No truncation', () => { + before(() => { + cy.setAdvancedSetting({ + 'truncate:maxHeight': 0, + }); + }); + + it('checks if the table respects maxHeight setting of no truncation', function () { + cy.get('.truncate-by-height') + .first() + .should('have.css', 'max-height', 'none'); + }); + }); + + describe('dynamic height of row in new table', () => { + before(() => { + cy.switchDiscoverTable('new'); + cy.waitForLoader(); + }); + + it('checks if height of new table changes with change to line count property ', function () { + cy.get('[data-test-subj="dataGridRowCell"]') + .first() + .invoke('height') // Get Row Height Before update + .then((res) => { + cy.get('.euiButtonEmpty') + .contains('Display') + .click() + .then(() => { + cy.get('[type="number"]').type('{selectall}').type('2'); // Update the line count value + }); + + cy.get('[data-test-subj="dataGridRowCell"]') + .first() + .invoke('height') + .should('be.gt', res); // Check if the new height is greater than previus height + }); + }); + }); +});