From a81b7eebfc2ed406e0b3e4dbd48d88a2ed635ad7 Mon Sep 17 00:00:00 2001 From: "Qingyang(Abby) Hu" Date: Wed, 18 Dec 2024 21:56:19 -0800 Subject: [PATCH] fix Signed-off-by: Qingyang(Abby) Hu --- .../apps/data_explorer/discover.spec.js | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover.spec.js index 3c30216f6..a935d31ff 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/data_explorer/discover.spec.js @@ -61,7 +61,9 @@ describe('discover app', { scrollBehavior: false }, () => { cy.fleshTenantSettings(); }); - after(() => {}); + after(() => { + cy.deleteSavedObjectByType('save-search'); + }); describe('filters and queries', () => { after(() => { @@ -94,25 +96,40 @@ describe('discover app', { scrollBehavior: false }, () => { const saveSearch1 = 'Save Search # 1'; const saveSearch2 = 'Modified Save Search # 1'; - it('should show correct time range string by timepicker', function () { - cy.verifyTimeConfig(DE_DEFAULT_START_TIME, DE_DEFAULT_END_TIME); - cy.waitForLoader(); - }); - it('save search should display save search name in breadcrumb', function () { cy.log('save search should display save search name in breadcrumb'); + // Set up query and filter + cy.setTopNavQuery('response:200'); + cy.submitFilterFromDropDown('extension.raw', 'is one of', 'jpg'); cy.saveSearch(saveSearch1); cy.getElementByTestId('breadcrumb last') .should('be.visible') .should('have.text', saveSearch1); }); - it('load save search should show save search name in breadcrumb', function () { + it('load save search should show save search name in breadcrumb, and show the correct query and filter', function () { + // Change time filter to something other than default time filter + const fromTime = 'Sep 20, 2015 @ 00:00:00.000'; + const toTime = 'Sep 21, 2015 @ 00:00:00.000'; + cy.setTopNavDate(fromTime, toTime); + + // Click new discover + cy.getElementByTestId('discoverNewButton').click(); cy.loadSaveSearch(saveSearch1); + // Check if breadcrumb is updated cy.getElementByTestId('breadcrumb last') .should('be.visible') .should('have.text', saveSearch1); + + // Check if the correct query and filter are updated + cy.getElementByTestId(`queryInput`).should('have.text', 'response:200'); + cy.get('[data-test-subj~="filter-key-extension.raw"]').should( + 'be.visible' + ); + + // Check that time filter should not be updated with loading saved search; the time filter that we changed before should still be persisted + cy.verifyTimeConfig(fromTime, toTime); }); it('renaming a save search should modify name in breadcrumb', function () { @@ -127,7 +144,7 @@ describe('discover app', { scrollBehavior: false }, () => { it('should show the correct hit count', function () { cy.loadSaveSearch(saveSearch2); cy.setTopNavDate(DE_DEFAULT_START_TIME, DE_DEFAULT_END_TIME); - const expectedHitCount = '14,004'; + const expectedHitCount = '8,366'; cy.verifyHitCount(expectedHitCount); }); @@ -152,11 +169,11 @@ describe('discover app', { scrollBehavior: false }, () => { it('should reload the saved search with persisted query to show the initial hit count', function () { // apply query some changes cy.setTopNavQuery('test'); - cy.verifyHitCount('22'); + cy.verifyHitCount('15'); // reset to persisted state cy.getElementByTestId('resetSavedSearch').click(); - const expectedHitCount = '14,004'; + const expectedHitCount = '8,366'; cy.verifyHitCount(expectedHitCount); }); });