From 60c125a3a64606c52edf0e66ed1a3177141398d9 Mon Sep 17 00:00:00 2001 From: Gloria Hornero Date: Mon, 19 Oct 2020 20:27:50 +0200 Subject: [PATCH 1/3] deletes the created rule in the after hook --- .../integration/alerts_detection_rules_custom.spec.ts | 2 ++ .../cypress/integration/alerts_detection_rules_eql.spec.ts | 2 ++ .../cypress/integration/alerts_detection_rules_ml.spec.ts | 2 ++ .../integration/alerts_detection_rules_threshold.spec.ts | 2 ++ .../security_solution/cypress/screens/rule_details.ts | 4 ++++ .../cypress/tasks/alerts_detection_rules.ts | 6 ++++++ 6 files changed, 18 insertions(+) diff --git a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_custom.spec.ts b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_custom.spec.ts index 41665cf6d20a4..532cff1642028 100644 --- a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_custom.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_custom.spec.ts @@ -73,6 +73,7 @@ import { import { changeToThreeHundredRowsPerPage, deleteFirstRule, + deleteRule, deleteSelectedRules, editFirstRule, filterByCustomRules, @@ -120,6 +121,7 @@ describe('Custom detection rules creation', () => { after(() => { esArchiverUnload('timeline'); + deleteRule(); }); it('Creates and activates a new rule', () => { diff --git a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_eql.spec.ts b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_eql.spec.ts index 5502f35d6f0f8..10317a456ddff 100644 --- a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_eql.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_eql.spec.ts @@ -55,6 +55,7 @@ import { } from '../tasks/alerts'; import { changeToThreeHundredRowsPerPage, + deleteRule, filterByCustomRules, goToCreateNewRule, goToRuleDetails, @@ -94,6 +95,7 @@ describe.skip('Detection rules, EQL', () => { }); afterEach(() => { + deleteRule(); esArchiverUnload('timeline'); }); diff --git a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_ml.spec.ts b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_ml.spec.ts index 0f34e7d71e5fa..1ed889c77b49d 100644 --- a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_ml.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_ml.spec.ts @@ -44,6 +44,7 @@ import { } from '../tasks/alerts'; import { changeToThreeHundredRowsPerPage, + deleteRule, filterByCustomRules, goToCreateNewRule, goToRuleDetails, @@ -79,6 +80,7 @@ describe('Detection rules, machine learning', () => { after(() => { esArchiverUnload('prebuilt_rules_loaded'); + deleteRule(); }); it('Creates and activates a new ml rule', () => { diff --git a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_threshold.spec.ts b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_threshold.spec.ts index 5095e856e3f65..01c49b033441b 100644 --- a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_threshold.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_threshold.spec.ts @@ -56,6 +56,7 @@ import { } from '../tasks/alerts'; import { changeToThreeHundredRowsPerPage, + deleteRule, filterByCustomRules, goToCreateNewRule, goToRuleDetails, @@ -91,6 +92,7 @@ describe('Detection rules, threshold', () => { }); after(() => { + deleteRule(); esArchiverUnload('timeline'); }); diff --git a/x-pack/plugins/security_solution/cypress/screens/rule_details.ts b/x-pack/plugins/security_solution/cypress/screens/rule_details.ts index 5a376e95e38dd..e40b81ed0e856 100644 --- a/x-pack/plugins/security_solution/cypress/screens/rule_details.ts +++ b/x-pack/plugins/security_solution/cypress/screens/rule_details.ts @@ -4,6 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ +export const ALL_ACTIONS = '[data-test-subj="rules-details-popover-button-icon"]'; + export const ABOUT_INVESTIGATION_NOTES = '[data-test-subj="stepAboutDetailsNoteContent"]'; export const ABOUT_RULE_DESCRIPTION = '[data-test-subj=stepAboutRuleDetailsToggleDescriptionText]'; @@ -24,6 +26,8 @@ export const DETAILS_DESCRIPTION = '.euiDescriptionList__description'; export const DETAILS_TITLE = '.euiDescriptionList__title'; +export const DELETE_RULE = '[data-test-subj=rules-details-delete-rule]'; + export const FALSE_POSITIVES_DETAILS = 'False positive examples'; export const INDEX_PATTERNS_DETAILS = 'Index patterns'; diff --git a/x-pack/plugins/security_solution/cypress/tasks/alerts_detection_rules.ts b/x-pack/plugins/security_solution/cypress/tasks/alerts_detection_rules.ts index 8b494edaade3a..1c430e12b6b73 100644 --- a/x-pack/plugins/security_solution/cypress/tasks/alerts_detection_rules.ts +++ b/x-pack/plugins/security_solution/cypress/tasks/alerts_detection_rules.ts @@ -27,6 +27,7 @@ import { EDIT_RULE_ACTION_BTN, NEXT_BTN, } from '../screens/alerts_detection_rules'; +import { ALL_ACTIONS, DELETE_RULE } from '../screens/rule_details'; export const activateRule = (rulePosition: number) => { cy.get(RULE_SWITCH).eq(rulePosition).click({ force: true }); @@ -47,6 +48,11 @@ export const deleteFirstRule = () => { cy.get(DELETE_RULE_ACTION_BTN).click(); }; +export const deleteRule = () => { + cy.get(ALL_ACTIONS).click(); + cy.get(DELETE_RULE).click(); +}; + export const deleteSelectedRules = () => { cy.get(BULK_ACTIONS_BTN).click({ force: true }); cy.get(DELETE_RULE_BULK_BTN).click(); From e07b19f8a19eb3ba01e635dcfdfa0b35987b93c9 Mon Sep 17 00:00:00 2001 From: Gloria Hornero Date: Tue, 20 Oct 2020 11:26:56 +0200 Subject: [PATCH 2/3] fixes failing test --- .../security_solution/cypress/screens/create_new_rule.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/security_solution/cypress/screens/create_new_rule.ts b/x-pack/plugins/security_solution/cypress/screens/create_new_rule.ts index e1ab5ff30572f..0e4946405fc4e 100644 --- a/x-pack/plugins/security_solution/cypress/screens/create_new_rule.ts +++ b/x-pack/plugins/security_solution/cypress/screens/create_new_rule.ts @@ -31,7 +31,8 @@ export const COMBO_BOX_INPUT = '[data-test-subj="comboBoxInput"]'; export const CREATE_AND_ACTIVATE_BTN = '[data-test-subj="create-activate"]'; -export const CUSTOM_QUERY_INPUT = '[data-test-subj="queryInput"]'; +export const CUSTOM_QUERY_INPUT = + '[data-test-subj="detectionEngineStepDefineRuleQueryBar"] [data-test-subj="queryInput"]'; export const DEFINE_CONTINUE_BUTTON = '[data-test-subj="define-continue"]'; From 486eb4b50b4825c7bf2813191f523e7eb999760c Mon Sep 17 00:00:00 2001 From: Gloria Hornero Date: Wed, 21 Oct 2020 10:21:49 +0200 Subject: [PATCH 3/3] changes rule deletion order --- .../cypress/integration/alerts_detection_rules_custom.spec.ts | 2 +- .../cypress/integration/alerts_detection_rules_ml.spec.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_custom.spec.ts b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_custom.spec.ts index 79cdc6c72f128..491f4f8952fd9 100644 --- a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_custom.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_custom.spec.ts @@ -120,8 +120,8 @@ describe('Custom detection rules creation', () => { }); after(() => { - esArchiverUnload('timeline'); deleteRule(); + esArchiverUnload('timeline'); }); it('Creates and activates a new rule', () => { diff --git a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_ml.spec.ts b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_ml.spec.ts index 1ed889c77b49d..153c55fae59fe 100644 --- a/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_ml.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/alerts_detection_rules_ml.spec.ts @@ -79,8 +79,8 @@ describe('Detection rules, machine learning', () => { }); after(() => { - esArchiverUnload('prebuilt_rules_loaded'); deleteRule(); + esArchiverUnload('prebuilt_rules_loaded'); }); it('Creates and activates a new ml rule', () => {