Skip to content

Commit

Permalink
[Security Solution] Fixes flaky test rules (#81040)
Browse files Browse the repository at this point in the history
* deletes the created rule in the after hook

* fixes failing test

* changes rule deletion order

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
MadameSheema and kibanamachine committed Oct 21, 2020
1 parent d618098 commit 0f2b1c0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import {
import {
changeToThreeHundredRowsPerPage,
deleteFirstRule,
deleteRule,
deleteSelectedRules,
editFirstRule,
filterByCustomRules,
Expand Down Expand Up @@ -119,6 +120,7 @@ describe('Custom detection rules creation', () => {
});

after(() => {
deleteRule();
esArchiverUnload('timeline');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import {
} from '../tasks/alerts';
import {
changeToThreeHundredRowsPerPage,
deleteRule,
filterByCustomRules,
goToCreateNewRule,
goToRuleDetails,
Expand Down Expand Up @@ -93,6 +94,7 @@ describe('Detection rules, EQL', () => {
});

afterEach(() => {
deleteRule();
esArchiverUnload('timeline');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
} from '../tasks/alerts';
import {
changeToThreeHundredRowsPerPage,
deleteRule,
filterByCustomRules,
goToCreateNewRule,
goToRuleDetails,
Expand Down Expand Up @@ -78,6 +79,7 @@ describe('Detection rules, machine learning', () => {
});

after(() => {
deleteRule();
esArchiverUnload('prebuilt_rules_loaded');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {
} from '../tasks/alerts';
import {
changeToThreeHundredRowsPerPage,
deleteRule,
filterByCustomRules,
goToCreateNewRule,
goToRuleDetails,
Expand Down Expand Up @@ -91,6 +92,7 @@ describe('Detection rules, threshold', () => {
});

after(() => {
deleteRule();
esArchiverUnload('timeline');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]';
Expand All @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand All @@ -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();
Expand Down

0 comments on commit 0f2b1c0

Please sign in to comment.