From 00575794c100d359160da48073b7613fa815ffd7 Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Mon, 11 Dec 2023 11:23:43 -0600 Subject: [PATCH 1/5] wip --- .../e2e/explore/network/hover_actions.cy.ts | 6 ++--- .../cypress/tasks/network/flows.ts | 27 +++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/explore/network/hover_actions.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/explore/network/hover_actions.cy.ts index e03e70dcd8535..bdf829d7ba6c0 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/explore/network/hover_actions.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/explore/network/hover_actions.cy.ts @@ -10,7 +10,7 @@ import { GLOBAL_SEARCH_BAR_FILTER_ITEM } from '../../../screens/search_bar'; import { DATA_PROVIDERS } from '../../../screens/timeline'; import { login } from '../../../tasks/login'; -import { visit } from '../../../tasks/navigation'; +import { visitWithTimeRange } from '../../../tasks/navigation'; import { NETWORK_URL } from '../../../urls/navigation'; import { clickOnAddToTimeline, @@ -26,7 +26,7 @@ import { openTimelineUsingToggle } from '../../../tasks/security_main'; const testDomain = 'myTest'; // tracked by https://github.com/elastic/kibana/issues/161874 -describe.skip('Hover actions', { tags: ['@ess', '@serverless'] }, () => { +describe('Hover actions', { tags: ['@ess', '@serverless'] }, () => { const onBeforeLoadCallback = (win: Cypress.AUTWindow) => { // avoid cypress being held by windows prompt and timeout cy.stub(win, 'prompt').returns(true); @@ -42,7 +42,7 @@ describe.skip('Hover actions', { tags: ['@ess', '@serverless'] }, () => { beforeEach(() => { login(); - visit(NETWORK_URL, { visitOptions: { onBeforeLoad: onBeforeLoadCallback } }); + visitWithTimeRange(NETWORK_URL, { visitOptions: { onBeforeLoad: onBeforeLoadCallback } }); openHoverActions(); mouseoverOnToOverflowItem(); }); diff --git a/x-pack/test/security_solution_cypress/cypress/tasks/network/flows.ts b/x-pack/test/security_solution_cypress/cypress/tasks/network/flows.ts index b9febb6a39381..6e8762055943d 100644 --- a/x-pack/test/security_solution_cypress/cypress/tasks/network/flows.ts +++ b/x-pack/test/security_solution_cypress/cypress/tasks/network/flows.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { recurse } from 'cypress-recurse'; import { ADD_TO_TIMELINE, COPY, @@ -50,3 +51,29 @@ export const clickOnCopyValue = () => { cy.get(COPY).first().focus(); cy.focused().click({ force: true }); // eslint-disable-line cypress/unsafe-to-chain-command }; + +export function withHoverActionsReady() { + // NOTE: not sure if this is precise enough, but it seems to work + const actionsButtonInPortal = '[data-euiportal="true"] button[data-test-subj*="cellActions"]'; + recurse( + () => { + openHoverActions(); + mouseoverOnToOverflowItem(); + return cy.root(); + }, + // Check if actions portal element is visible + ($el) => $el.find(actionsButtonInPortal).length > 0 + ); + // cy.get('body').then(($body) => { + // if ($body.find(actionsButtonInPortal).length > 0) { + // cy.get(actionsButtonInPortal).should('be.visible'); + // action(); + // } else if (maxTries <= 0) { + // throw new Error(`Max tries reached. The element ${actionsButtonInPortal} is not visible.`); + // } else { + // openHoverActions(); + // mouseoverOnToOverflowItem(); + // withHoverActionsReady(action, maxTries - 1); + // } + // }); +} From 96b7a0ea8c01b1cb71e874306f7a46ac1cacb5dd Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Mon, 11 Dec 2023 14:14:46 -0600 Subject: [PATCH 2/5] cypress recurse --- .../cypress/e2e/explore/network/hover_actions.cy.ts | 6 ++---- .../cypress/tasks/network/flows.ts | 12 +++++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/explore/network/hover_actions.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/explore/network/hover_actions.cy.ts index bdf829d7ba6c0..0b4250b5777b8 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/explore/network/hover_actions.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/explore/network/hover_actions.cy.ts @@ -18,8 +18,7 @@ import { clickOnFilterIn, clickOnFilterOut, clickOnShowTopN, - mouseoverOnToOverflowItem, - openHoverActions, + withHoverActionsReady, } from '../../../tasks/network/flows'; import { openTimelineUsingToggle } from '../../../tasks/security_main'; @@ -43,8 +42,7 @@ describe('Hover actions', { tags: ['@ess', '@serverless'] }, () => { beforeEach(() => { login(); visitWithTimeRange(NETWORK_URL, { visitOptions: { onBeforeLoad: onBeforeLoadCallback } }); - openHoverActions(); - mouseoverOnToOverflowItem(); + withHoverActionsReady(); }); it('Adds global filter - filter in', () => { diff --git a/x-pack/test/security_solution_cypress/cypress/tasks/network/flows.ts b/x-pack/test/security_solution_cypress/cypress/tasks/network/flows.ts index 6e8762055943d..4d007bc12cc5e 100644 --- a/x-pack/test/security_solution_cypress/cypress/tasks/network/flows.ts +++ b/x-pack/test/security_solution_cypress/cypress/tasks/network/flows.ts @@ -53,16 +53,22 @@ export const clickOnCopyValue = () => { }; export function withHoverActionsReady() { - // NOTE: not sure if this is precise enough, but it seems to work const actionsButtonInPortal = '[data-euiportal="true"] button[data-test-subj*="cellActions"]'; recurse( () => { openHoverActions(); mouseoverOnToOverflowItem(); - return cy.root(); + return cy.get('body').then(($body) => { + return $body.find(actionsButtonInPortal); + }); }, // Check if actions portal element is visible - ($el) => $el.find(actionsButtonInPortal).length > 0 + ($el) => { + return $el.length > 0; + }, + { + delay: 500, + } ); // cy.get('body').then(($body) => { // if ($body.find(actionsButtonInPortal).length > 0) { From 503b7dc34ab9e96bb4fdb34cdccffe753d1769cc Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Mon, 11 Dec 2023 14:16:22 -0600 Subject: [PATCH 3/5] rm comment --- .../cypress/e2e/explore/network/hover_actions.cy.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/explore/network/hover_actions.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/explore/network/hover_actions.cy.ts index 0b4250b5777b8..661ee1850bd85 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/explore/network/hover_actions.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/explore/network/hover_actions.cy.ts @@ -24,7 +24,6 @@ import { openTimelineUsingToggle } from '../../../tasks/security_main'; const testDomain = 'myTest'; -// tracked by https://github.com/elastic/kibana/issues/161874 describe('Hover actions', { tags: ['@ess', '@serverless'] }, () => { const onBeforeLoadCallback = (win: Cypress.AUTWindow) => { // avoid cypress being held by windows prompt and timeout From cb50f28e66022c85f95f66c880eeca6f11c56618 Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Mon, 11 Dec 2023 14:17:19 -0600 Subject: [PATCH 4/5] rm commentss --- .../cypress/tasks/network/flows.ts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/tasks/network/flows.ts b/x-pack/test/security_solution_cypress/cypress/tasks/network/flows.ts index 4d007bc12cc5e..5c335ea553682 100644 --- a/x-pack/test/security_solution_cypress/cypress/tasks/network/flows.ts +++ b/x-pack/test/security_solution_cypress/cypress/tasks/network/flows.ts @@ -70,16 +70,4 @@ export function withHoverActionsReady() { delay: 500, } ); - // cy.get('body').then(($body) => { - // if ($body.find(actionsButtonInPortal).length > 0) { - // cy.get(actionsButtonInPortal).should('be.visible'); - // action(); - // } else if (maxTries <= 0) { - // throw new Error(`Max tries reached. The element ${actionsButtonInPortal} is not visible.`); - // } else { - // openHoverActions(); - // mouseoverOnToOverflowItem(); - // withHoverActionsReady(action, maxTries - 1); - // } - // }); } From 60fb29d3ecd3c468b5bea3e6785540d4f48f979a Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Tue, 12 Dec 2023 09:08:21 -0600 Subject: [PATCH 5/5] apply same fix to overflow items --- .../cypress/e2e/explore/network/overflow_items.cy.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/explore/network/overflow_items.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/explore/network/overflow_items.cy.ts index 22c242f63e887..41df26cf36337 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/explore/network/overflow_items.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/explore/network/overflow_items.cy.ts @@ -16,16 +16,14 @@ import { import { login } from '../../../tasks/login'; import { visitWithTimeRange } from '../../../tasks/navigation'; -import { mouseoverOnToOverflowItem, openHoverActions } from '../../../tasks/network/flows'; +import { withHoverActionsReady } from '../../../tasks/network/flows'; import { NETWORK_URL } from '../../../urls/navigation'; const testDomainOne = 'myTest'; const testDomainTwo = 'myTest2'; -// FLAKY: https://github.com/elastic/kibana/issues/165692 -// Tracked by https://github.com/elastic/security-team/issues/7696 -describe.skip('Overflow items', { tags: ['@ess', '@serverless', '@brokenInServerless'] }, () => { +describe('Overflow items', { tags: ['@ess', '@serverless'] }, () => { context('Network stats and tables', () => { before(() => { cy.task('esArchiverLoad', { archiveName: 'network' }); @@ -41,8 +39,7 @@ describe.skip('Overflow items', { tags: ['@ess', '@serverless', '@brokenInServer cy.get(SHOW_TOP_FIELD).should('not.exist'); cy.get(COPY).should('not.exist'); - openHoverActions(); - mouseoverOnToOverflowItem(); + withHoverActionsReady(); }); after(() => {