From 039ef54a18028b0245d0b37c01eb8cfa65e8c160 Mon Sep 17 00:00:00 2001 From: Suchit Sahoo Date: Fri, 6 Sep 2024 16:36:15 -0700 Subject: [PATCH] Fix Flaky Discover Tests Signed-off-by: Suchit Sahoo --- .../discover_advanced_settings.spec.js | 138 +++++++++--------- 1 file changed, 72 insertions(+), 66 deletions(-) diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover_advanced_settings.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover_advanced_settings.spec.js index e0c79a420..9af242ce3 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover_advanced_settings.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover_advanced_settings.spec.js @@ -323,6 +323,8 @@ describe('discover_advanced_setting', () => { it('check new table respects doc_table:highlight setting', function () { // check if we have highlighted fields + cy.get('mark').should('exist'); + cy.setAdvancedSetting({ 'doc_table:highlight': false, }); @@ -335,8 +337,6 @@ describe('discover_advanced_setting', () => { 'doc_table:highlight': true, }); cy.reload(); - cy.switchDiscoverTable('new'); - cy.get('mark').should('exist'); }); it('check legacy table respects doc_table:highlight setting', function () { @@ -354,6 +354,12 @@ describe('discover_advanced_setting', () => { 'doc_table:highlight': true, }); cy.reload(); + cy.get('[data-test-subj="fieldToggle-index"]') + .click() + .then(() => { + cy.get('[data-test-subj="field-index-showDetails"]').click(); + cy.get('[data-test-subj="plus-index-logstash-2015.09.22"]').click(); + }); cy.get('mark').should('exist'); }); @@ -435,78 +441,78 @@ describe('discover_advanced_setting', () => { }); }); - describe('modifyColumnsOnSwitch advanced setting', () => { - before(() => { - CURRENT_TENANT.newTenant = 'global'; - cy.fleshTenantSettings(); - cy.setAdvancedSetting({ - 'discover:modifyColumnsOnSwitch': false, - }); - }); - - it.skip('check columns still available after switching data sources in legacy table', function () { - 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(); - cy.get('[data-test-subj="fieldToggle-agent"]').click(); - - // Now switching the data sources - cy.get('[data-test-subj="comboBoxSearchInput"]') - .type('nestedindex') - .then(() => { - cy.get('[title="nestedindex*"]') - .trigger('click') - .then(() => { - cy.wait(300); - cy.get('[data-test-subj="docTableHeader-agent"]').should( - 'be.visible' - ); - cy.get('[data-test-subj="docTableField"]') - .contains('-') - .should('exist'); - }); - }); + after(() => {}); +}); - /* - */ +describe('modifyColumnsOnSwitch advanced setting', () => { + before(() => { + CURRENT_TENANT.newTenant = 'global'; + cy.fleshTenantSettings(); + cy.setAdvancedSetting({ + 'discover:modifyColumnsOnSwitch': false, }); + }); - it('check columns still available after switching data sources in new table', function () { - 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(); - cy.switchDiscoverTable('new'); - - cy.get('[data-test-subj="fieldToggle-agent"]').click(); + it.skip('check columns still available after switching data sources in legacy table', function () { + 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(); + cy.get('[data-test-subj="fieldToggle-agent"]').click(); + + // Now switching the data sources + cy.get('[data-test-subj="comboBoxSearchInput"]') + .type('nestedindex') + .then(() => { + cy.get('[title="nestedindex*"]') + .trigger('click') + .then(() => { + cy.wait(300); + cy.get('[data-test-subj="docTableHeader-agent"]').should( + 'be.visible' + ); + cy.get('[data-test-subj="docTableField"]') + .contains('-') + .should('exist'); + }); + }); - // Now switching the data sources - cy.get('[data-test-subj="comboBoxSearchInput"]') - .type('nestedindex') - .then(() => { - cy.waitForSearch(); - cy.get('[title="nestedindex*"]') - .trigger('click') - .then(() => { - cy.get('[data-test-subj="dataGridHeaderCell-agent"]').should( - 'be.visible' - ); - cy.get('[data-test-subj="dataGridRowCell"]') - .contains('-') - .should('exist'); - }); - }); - }); + /* + */ + }); - after(() => { - cy.setAdvancedSetting({ - 'discover:modifyColumnsOnSwitch': true, + it('check columns still available after switching data sources in new table', function () { + miscUtils.visitPage( + `app/data-explorer/discover#/?_a=(discover:(metadata:(indexPattern:'logstash-*',view:discover))&_g=(filters:!(),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))` + ); + cy.waitForSearch(); + cy.switchDiscoverTable('new'); + + cy.get('[data-test-subj="fieldToggle-agent"]').click(); + + // Now switching the data sources + cy.get('[data-test-subj="comboBoxSearchInput"]') + .type('nestedindex') + .then(() => { + cy.waitForSearch(); + cy.get('[title="nestedindex*"]') + .trigger('click') + .then(() => { + cy.get('[data-test-subj="dataGridHeaderCell-agent"]').should( + 'be.visible' + ); + cy.wait(2000); + cy.get('[data-test-subj="dataGridRowCell"]') + .contains('-') + .should('exist'); + }); }); - }); }); after(() => { - cy.deleteIndexPattern('nestedindex'); + cy.setAdvancedSetting({ + 'discover:modifyColumnsOnSwitch': true, + }); + cy.deleteSavedObjectByType('index-pattern'); }); });