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.

<img width="891" alt="Screenshot 2023-12-26 at 4 05 53 PM"
src="e776dc76-22be-443d-8a4e-41740ea6e7c6">


### 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>
This commit is contained in:
Jared Burgett 2023-12-27 11:28:33 -06:00 committed by GitHub
parent 460ef862dc
commit 66777f14a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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');