diff --git a/x-pack/solutions/security/test/security_solution_cypress/cypress/e2e/entity_analytics/entity_analytics_home/entities_table_grouping.cy.ts b/x-pack/solutions/security/test/security_solution_cypress/cypress/e2e/entity_analytics/entity_analytics_home/entities_table_grouping.cy.ts index 40a39381f8237..60c703e3ddfe3 100644 --- a/x-pack/solutions/security/test/security_solution_cypress/cypress/e2e/entity_analytics/entity_analytics_home/entities_table_grouping.cy.ts +++ b/x-pack/solutions/security/test/security_solution_cypress/cypress/e2e/entity_analytics/entity_analytics_home/entities_table_grouping.cy.ts @@ -10,6 +10,7 @@ import { visit } from '../../../tasks/navigation'; import { setGrouping, waitForGroupingTable, + waitForEntityAnalyticsPageReady, interceptEntityStoreSearch, selectGroupingOption, interceptEntityStoreStatus, @@ -63,9 +64,7 @@ describe( visit(ENTITY_ANALYTICS_HOME_PAGE_URL); cy.get(PAGE_TITLE).should('exist'); // Resolution is the default grouping - cy.wait('@entityStoreStatus', { timeout: 20000 }); - cy.wait('@entityStoreSearch'); - waitForGroupingTable(); + waitForEntityAnalyticsPageReady(); }); it('displays resolution groups', () => { @@ -116,9 +115,7 @@ describe( interceptEntityStoreSearch(); visit(ENTITY_ANALYTICS_HOME_PAGE_URL); cy.get(PAGE_TITLE).should('exist'); - cy.wait('@entityStoreStatus', { timeout: 20000 }); - cy.wait('@entityStoreSearch'); - waitForGroupingTable(); + waitForEntityAnalyticsPageReady(); }); it('shows group selector with Entity type selected', () => { @@ -152,9 +149,7 @@ describe( interceptEntityStoreSearch(); visit(ENTITY_ANALYTICS_HOME_PAGE_URL); cy.get(PAGE_TITLE).should('exist'); - cy.wait('@entityStoreStatus', { timeout: 20000 }); - cy.wait('@entityStoreSearch'); - waitForGroupingTable(); + waitForEntityAnalyticsPageReady(); }); it('selecting "None" shows flat data table', () => { diff --git a/x-pack/solutions/security/test/security_solution_cypress/cypress/tasks/entity_analytics/entity_analytics_home.ts b/x-pack/solutions/security/test/security_solution_cypress/cypress/tasks/entity_analytics/entity_analytics_home.ts index 616e0540d6ea5..e0cf3104ccc54 100644 --- a/x-pack/solutions/security/test/security_solution_cypress/cypress/tasks/entity_analytics/entity_analytics_home.ts +++ b/x-pack/solutions/security/test/security_solution_cypress/cypress/tasks/entity_analytics/entity_analytics_home.ts @@ -59,6 +59,23 @@ export const waitForGroupingTable = () => { cy.get(GROUPING_LEVEL_0).should('exist'); }; +/** + * Waits for the entity store status intercept and the initial entity store + * search to both resolve, then confirms the grouping table is ready. + * + * Must be called after `interceptEntityStoreStatus` and + * `interceptEntityStoreSearch` are registered and after `cy.visit`. + * + * The search fires only once the sourcerer / data-view has finished loading, + * which can take well over 5 s in CI — both timeouts are set to 20 s to + * match the patience already applied to `@entityStoreStatus`. + */ +export const waitForEntityAnalyticsPageReady = () => { + cy.wait('@entityStoreStatus', { timeout: 20000 }); + cy.wait('@entityStoreSearch', { timeout: 20000 }); + waitForGroupingTable(); +}; + /** * Intercepts the entity store search API and registers an alias. * Call this before navigation so Cypress captures the request.