From 66777f14a73871abe78ad2702107e7ce0ddde94b Mon Sep 17 00:00:00 2001 From: Jared Burgett <147995946+jaredburgettelastic@users.noreply.github.com> Date: Wed, 27 Dec 2023 11:28:33 -0600 Subject: [PATCH] Fixed entity analytics dashboard filtering flaky tests (#173970) ## Summary This PR fixes two flaky tests within the Entity Analytics dashboard pages. Resolves https://github.com/elastic/kibana/issues/173871 Resolves https://github.com/elastic/kibana/issues/173846. I was able to reproduce this issue locally by running the tests 10 times in succession, and found that they fail even locally ~10% of the time. After implementing this fix, I have been unable to reproduce the issue locally again. **Flaky test runner, with x200 iterations, all passing: https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4676#_** ## The Fix Previously, the dashboard tests in question would attempt to click the "User/Host Risk Level" filter button immediately upon opening the page. In some circumstances, that click would fire before that respective user/host panel was fully loaded, even though the component was available. This would prevent the popover from showing up (see screenshot below for what the popover is **supposed** to look like). Therefore, the fix was to simply ensure that the user/host panel has been fully loaded beforehand. We already do this in other tests by checking if the inner table has been loaded, and I followed suit in this case as well. This is also a very appropriate prerequisite for these tests, because the purpose of the test is to check whether we can filter data in that table. Screenshot 2023-12-26 at 4 05 53 PM ### Checklist - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../entity_analytics/dashboards/entity_analytics.cy.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics/dashboards/entity_analytics.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics/dashboards/entity_analytics.cy.ts index d1675897f56cf..f586105483b9c 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics/dashboards/entity_analytics.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics/dashboards/entity_analytics.cy.ts @@ -168,8 +168,10 @@ describe('Entity Analytics Dashboard', { tags: ['@ess', '@serverless'] }, () => it('renders alerts column', () => { cy.get(HOSTS_TABLE_ALERT_CELL).should('have.length', 5); }); - it('filters by risk level', () => { + cy.get(HOSTS_TABLE).should('be.visible'); + cy.get(HOSTS_TABLE_ROWS).should('have.length', 5); + openRiskTableFilterAndSelectTheLowOption(); cy.get(HOSTS_DONUT_CHART).should('include.text', '1Total'); @@ -225,8 +227,7 @@ describe('Entity Analytics Dashboard', { tags: ['@ess', '@serverless'] }, () => }); }); - // FLAKY: https://github.com/elastic/kibana/issues/173846 - describe.skip('With user risk data', () => { + describe('With user risk data', () => { before(() => { cy.task('esArchiverLoad', { archiveName: 'risk_users' }); }); @@ -254,6 +255,9 @@ describe('Entity Analytics Dashboard', { tags: ['@ess', '@serverless'] }, () => }); it('filters by risk level', () => { + cy.get(USERS_TABLE).should('be.visible'); + cy.get(USERS_TABLE_ROWS).should('have.length', 5); + openRiskTableFilterAndSelectTheLowOption(); cy.get(USERS_DONUT_CHART).should('include.text', '2Total');