Skip to content

Commit

Permalink
[Security Solution] fix data provider cypress test (elastic#93465)
Browse files Browse the repository at this point in the history
## Summary
This PR is to fix data_provider's cypress test: displays the data provider action menu when Enter is pressed.

When I ran it locally, I couldn’t reproduce it every time. There’s a chance that the timeline was opened but the filter we put wasn’t there, this happen when I simulate slow 3G with Chrome or once out of my 10-time-trial with `loop_cypress_tests.js`

[failure 1](https://kibana-ci.elastic.co/job/elastic+kibana+security-cypress/4313/testReport/junit/(root)/displays%20the%20data%20provider%20action%20menu%20when%20Enter%20is%20pressed/timeline_data_providers_displays_the_data_provider_action_menu_when_Enter_is_pressed/)
[failure 2](https://kibana-ci.elastic.co/job/elastic+kibana+security-cypress/4313/testReport/junit/(root)/displays%20the%20data%20provider%20action%20menu%20when%20Enter%20is%20pressed/timeline_data_providers_displays_the_data_provider_action_menu_when_Enter_is_pressed_2/)

How to run this test several times automatically:
1. Go to the file and mark your case with .only
2. Copy the relative path of the file
3. Go to x-pack/plugins/security_solution/package.json Line 13, change —spec to the path you just copied (e.g: ./cypress/integration/timelines/data_providers.spec.ts)
4. Go to Kibana/ and run node x-pack/plugins/security_solution/scripts/loop_cypress_tests.js 1 (1 means run it once, you can put more to check flakiness)
5. After it finishes, it generates you a report under: kibana/target/loop-cypress-tests.txt
6. Search for `displays the data provider action menu when Enter is pressed.` and see if all passes.
  • Loading branch information
angorayc authored and kibanamachine committed Mar 4, 2021
1 parent fb1c983 commit fcdd0f7
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
TIMELINE_DATA_PROVIDERS_EMPTY,
TIMELINE_DROPPED_DATA_PROVIDERS,
TIMELINE_DATA_PROVIDERS_ACTION_MENU,
TIMELINE_FLYOUT_HEADER,
} from '../../screens/timeline';
import { HOSTS_NAMES_DRAGGABLE } from '../../screens/hosts/all_hosts';

Expand Down Expand Up @@ -60,8 +61,13 @@ describe('timeline data providers', () => {
openTimelineUsingToggle();
cy.get(TIMELINE_DATA_PROVIDERS_ACTION_MENU).should('not.exist');

cy.get(TIMELINE_DROPPED_DATA_PROVIDERS).first().focus();
cy.get(TIMELINE_DROPPED_DATA_PROVIDERS).first().parent().type('{enter}');
cy.get(`${TIMELINE_FLYOUT_HEADER} ${TIMELINE_DROPPED_DATA_PROVIDERS}`)
.pipe(($el) => $el.trigger('focus'))
.should('exist');
cy.get(`${TIMELINE_FLYOUT_HEADER} ${TIMELINE_DROPPED_DATA_PROVIDERS}`)
.first()
.parent()
.type('{enter}');

cy.get(TIMELINE_DATA_PROVIDERS_ACTION_MENU).should('exist');
});
Expand Down

0 comments on commit fcdd0f7

Please sign in to comment.