From 5f33d1051dce85884903233c409ae38da7fde6a9 Mon Sep 17 00:00:00 2001 From: Angela Chuang <6295984+angorayc@users.noreply.github.com> Date: Thu, 4 Mar 2021 00:27:29 +0000 Subject: [PATCH] [Security Solution] fix data provider cypress test (#93465) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 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. --- .../integration/timelines/data_providers.spec.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/security_solution/cypress/integration/timelines/data_providers.spec.ts b/x-pack/plugins/security_solution/cypress/integration/timelines/data_providers.spec.ts index 1955e320556a8..9f0d64a77c8a1 100644 --- a/x-pack/plugins/security_solution/cypress/integration/timelines/data_providers.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/timelines/data_providers.spec.ts @@ -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'; @@ -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'); });