From d75f5742888c82c06a029b059fd9a0c457d404a3 Mon Sep 17 00:00:00 2001 From: Owen Wang Date: Mon, 17 Feb 2025 12:48:34 +0800 Subject: [PATCH] Improve the assertion in recent history test to avoid flakiness (#1717) Signed-off-by: Owen Wang (cherry picked from commit c064e0315cb8474d0526d312aa536ed8dee0d4b8) --- .../left-navigation/left_navigation.spec.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/left-navigation/left_navigation.spec.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/left-navigation/left_navigation.spec.js index 965b53623..f93664f36 100644 --- a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/left-navigation/left_navigation.spec.js +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/left-navigation/left_navigation.spec.js @@ -267,11 +267,13 @@ describe('Left navigation menu', () => { // open recent history dialog cy.get('.headerRecentItemsButton').should('exist').click(); - cy.get('div[role="dialog"]').within(() => { - // dialog displays correct visited content - cy.contains(/Recent assets/).should('exist'); - cy.contains(visualizationName).should('exist'); - }); + cy.get('div[role="dialog"][data-autofocus="true"]') + .should('have.class', 'euiPanel') + .within(() => { + // dialog displays correct visited content + cy.contains(/Recent assets/).should('exist'); + cy.contains(visualizationName).should('exist'); + }); // back to dashboard cy.get('.left-navigation-wrapper').within(() => { @@ -283,10 +285,14 @@ describe('Left navigation menu', () => { // wait for the page to be loaded cy.get('.application').should('exist'); cy.get('.headerRecentItemsButton--loadingIndicator').should('not.exist'); + // wait for the dashboards list loaded, avoid flaky loading icon + cy.getElementByTestId('dashboardLandingPage').within(() => { + cy.get('.euiBasicTable .euiTableRow').should('exist'); + }); // open recent history dialog again cy.get('.headerRecentItemsButton').should('exist').click(); - cy.get('div[role="dialog"]').within(() => { + cy.get('div[role="dialog"][data-autofocus="true"]').within(() => { // click recent visited visualization in the dialog cy.contains(visualizationName).should('exist').click({ force: true }); });