From 100e8b65bcfe65143ca58049207aa31f37e7a319 Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Mon, 18 Dec 2023 09:25:54 -0600 Subject: [PATCH 1/8] fix more flakes --- .../e2e/explore/cases/attach_alert_to_case.cy.ts | 14 +++++--------- .../e2e/explore/guided_onboarding/tour.cy.ts | 9 +++------ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts index 6b40e1d336186..28ac90288db5a 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts @@ -6,13 +6,10 @@ */ import { ROLES, SecurityRoleName } from '@kbn/security-solution-plugin/common/test'; -import { getNewRule } from '../../../objects/rule'; - import { expandFirstAlertActions } from '../../../tasks/alerts'; -import { createRule } from '../../../tasks/api_calls/rules'; import { waitForAlertsToPopulate } from '../../../tasks/create_new_rule'; import { login } from '../../../tasks/login'; -import { visit } from '../../../tasks/navigation'; +import { visitWithTimeRange } from '../../../tasks/navigation'; import { ALERTS_URL } from '../../../urls/navigation'; import { ATTACH_ALERT_TO_CASE_BUTTON, TIMELINE_CONTEXT_MENU_BTN } from '../../../screens/alerts'; @@ -20,16 +17,15 @@ import { LOADING_INDICATOR } from '../../../screens/security_header'; const loadDetectionsPage = (role: SecurityRoleName) => { login(role); - visit(ALERTS_URL); + visitWithTimeRange(ALERTS_URL); waitForAlertsToPopulate(); }; -describe('Alerts timeline', { tags: ['@ess'] }, () => { +describe('Alerts timeline', { tags: ['@ess', '@serverless'] }, () => { before(() => { - // First we login as a privileged user to create alerts. + cy.task('esArchiverLoad', { archiveName: 'query_alert', useCreate: true, docsOnly: true }); login(); - createRule(getNewRule()); - visit(ALERTS_URL); + visitWithTimeRange(ALERTS_URL); waitForAlertsToPopulate(); }); diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/explore/guided_onboarding/tour.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/explore/guided_onboarding/tour.cy.ts index fbe1ebf91cbff..35894e517a94e 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/explore/guided_onboarding/tour.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/explore/guided_onboarding/tour.cy.ts @@ -21,24 +21,21 @@ import { goToStep, startTour, } from '../../../tasks/guided_onboarding'; -import { createRule } from '../../../tasks/api_calls/rules'; -import { getNewRule } from '../../../objects/rule'; import { ALERTS_URL, DASHBOARDS_URL } from '../../../urls/navigation'; import { waitForAlertsToPopulate } from '../../../tasks/create_new_rule'; import { login } from '../../../tasks/login'; -import { visit } from '../../../tasks/navigation'; +import { visitWithTimeRange } from '../../../tasks/navigation'; import { startAlertsCasesTour } from '../../../tasks/api_calls/tour'; describe('Guided onboarding tour', { tags: ['@ess'] }, () => { before(() => { - login(); - createRule(getNewRule({ query: 'user.name:*' })); + cy.task('esArchiverLoad', { archiveName: 'query_alert', useCreate: true, docsOnly: true }); }); beforeEach(() => { login(); disableExpandableFlyout(); startAlertsCasesTour(); - visit(ALERTS_URL); + visitWithTimeRange(ALERTS_URL); waitForAlertsToPopulate(); }); From c17cafdd30918b3796cea37f6f4086652ea7659b Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Mon, 18 Dec 2023 10:34:59 -0600 Subject: [PATCH 2/8] Update attach_alert_to_case.cy.ts --- .../cypress/e2e/explore/cases/attach_alert_to_case.cy.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts index 28ac90288db5a..d23de11762048 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts @@ -29,8 +29,9 @@ describe('Alerts timeline', { tags: ['@ess', '@serverless'] }, () => { waitForAlertsToPopulate(); }); - context('Privileges: read only', () => { + context('Privileges: read only', { tags: ['@ess'] }, () => { beforeEach(() => { + // ess only role loadDetectionsPage(ROLES.reader); }); From d57e29c24d7bc821b08c2a456a275e72eb43b159 Mon Sep 17 00:00:00 2001 From: Angela Chuang Date: Mon, 22 Apr 2024 13:01:33 +0100 Subject: [PATCH 3/8] fix js error --- .../public/common/components/event_details/osquery_tab.tsx | 2 +- .../common/components/event_details/response_actions_view.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/security_solution/public/common/components/event_details/osquery_tab.tsx b/x-pack/plugins/security_solution/public/common/components/event_details/osquery_tab.tsx index 274c649ece9dc..b7a3c938fbbf7 100644 --- a/x-pack/plugins/security_solution/public/common/components/event_details/osquery_tab.tsx +++ b/x-pack/plugins/security_solution/public/common/components/event_details/osquery_tab.tsx @@ -47,7 +47,7 @@ export const useOsqueryTab = ({ : undefined; const responseActions = - expandedEventFieldsObject?.kibana?.alert?.rule?.parameters?.[0].response_actions; + expandedEventFieldsObject?.kibana?.alert?.rule?.parameters?.[0]?.response_actions; const shouldEarlyReturn = !rawEventData || diff --git a/x-pack/plugins/security_solution/public/common/components/event_details/response_actions_view.tsx b/x-pack/plugins/security_solution/public/common/components/event_details/response_actions_view.tsx index 58e18114f08f9..619537f9b457f 100644 --- a/x-pack/plugins/security_solution/public/common/components/event_details/response_actions_view.tsx +++ b/x-pack/plugins/security_solution/public/common/components/event_details/response_actions_view.tsx @@ -80,7 +80,7 @@ export const useResponseActionsView = ({ : undefined; const responseActions = - expandedEventFieldsObject?.kibana?.alert?.rule?.parameters?.[0].response_actions; + expandedEventFieldsObject?.kibana?.alert?.rule?.parameters?.[0]?.response_actions; const shouldEarlyReturn = !rawEventData || !responseActionsEnabled; const alertId = rawEventData?._id ?? ''; From 0600ccf5ecd1312331a3c5d5b3e2d9a4cef71459 Mon Sep 17 00:00:00 2001 From: Angela Chuang Date: Wed, 24 Apr 2024 10:00:07 +0100 Subject: [PATCH 4/8] rm duplicate steps --- .../cypress/e2e/explore/cases/attach_alert_to_case.cy.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts index fc1eb69699665..6aaf36a21fdcb 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts @@ -31,10 +31,6 @@ describe('Alerts timeline', { tags: ['@ess', '@serverless'] }, () => { beforeEach(() => { cleanKibana(); cy.task('esArchiverLoad', { archiveName: 'query_alert', useCreate: true, docsOnly: true }); - - login(); - visitWithTimeRange(ALERTS_URL); - waitForAlertsToPopulate(); }); afterEach(() => { From 74dbd5b0a01aa17d7d0f1bfa6390b9e73d6079bf Mon Sep 17 00:00:00 2001 From: Angela Chuang Date: Tue, 30 Apr 2024 14:00:17 +0100 Subject: [PATCH 5/8] create alerts --- .../cypress/e2e/explore/cases/attach_alert_to_case.cy.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts index 6aaf36a21fdcb..387075d65e214 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts @@ -8,7 +8,7 @@ import { ROLES, SecurityRoleName } from '@kbn/security-solution-plugin/common/te import { expandFirstAlertActions } from '../../../tasks/alerts'; import { waitForAlertsToPopulate } from '../../../tasks/create_new_rule'; -import { login } from '../../../tasks/login'; +import { login, logout } from '../../../tasks/login'; import { visitWithTimeRange } from '../../../tasks/navigation'; import { ALERTS_URL } from '../../../urls/navigation'; @@ -16,7 +16,7 @@ import { ATTACH_ALERT_TO_CASE_BUTTON, TIMELINE_CONTEXT_MENU_BTN } from '../../.. import { LOADING_INDICATOR } from '../../../screens/security_header'; import { deleteAlertsAndRules } from '../../../tasks/api_calls/common'; -const loadDetectionsPage = (role: SecurityRoleName) => { +const loadDetectionsPage = (role?: SecurityRoleName) => { login(role); visitWithTimeRange(ALERTS_URL); waitForAlertsToPopulate(); @@ -31,6 +31,7 @@ describe('Alerts timeline', { tags: ['@ess', '@serverless'] }, () => { beforeEach(() => { cleanKibana(); cy.task('esArchiverLoad', { archiveName: 'query_alert', useCreate: true, docsOnly: true }); + loadDetectionsPage(); }); afterEach(() => { From d10f07de3d30f8c8286c692d5915d8aab28cd45c Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:54:44 +0000 Subject: [PATCH 6/8] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- .../cypress/e2e/explore/cases/attach_alert_to_case.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts index 387075d65e214..3e6bde80ea530 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts @@ -8,7 +8,7 @@ import { ROLES, SecurityRoleName } from '@kbn/security-solution-plugin/common/te import { expandFirstAlertActions } from '../../../tasks/alerts'; import { waitForAlertsToPopulate } from '../../../tasks/create_new_rule'; -import { login, logout } from '../../../tasks/login'; +import { login } from '../../../tasks/login'; import { visitWithTimeRange } from '../../../tasks/navigation'; import { ALERTS_URL } from '../../../urls/navigation'; From 9266ed8f718600720ae33032df95b49900fee33c Mon Sep 17 00:00:00 2001 From: Angela Chuang Date: Tue, 30 Apr 2024 18:49:33 +0100 Subject: [PATCH 7/8] run on ess only --- .../cypress/e2e/explore/cases/attach_alert_to_case.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts index 387075d65e214..1ef5f842e6f42 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts @@ -27,7 +27,7 @@ const cleanKibana = () => { deleteAlertsAndRules(); }; -describe('Alerts timeline', { tags: ['@ess', '@serverless'] }, () => { +describe('Alerts timeline', { tags: ['@ess'] }, () => { beforeEach(() => { cleanKibana(); cy.task('esArchiverLoad', { archiveName: 'query_alert', useCreate: true, docsOnly: true }); From 2e45de2b98c7aadcf1ffd3050fc61f821b4ba183 Mon Sep 17 00:00:00 2001 From: Angela Chuang Date: Tue, 30 Apr 2024 18:52:39 +0100 Subject: [PATCH 8/8] comments --- .../cypress/e2e/explore/cases/attach_alert_to_case.cy.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts index 74546e1cc7b46..886d4a1deedf7 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/explore/cases/attach_alert_to_case.cy.ts @@ -30,7 +30,9 @@ const cleanKibana = () => { describe('Alerts timeline', { tags: ['@ess'] }, () => { beforeEach(() => { cleanKibana(); + cy.task('esArchiverLoad', { archiveName: 'query_alert', useCreate: true, docsOnly: true }); + // First we login as a privileged user so data view can be created. loadDetectionsPage(); });