Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution] Fixes flaky test rules #81040

Merged
merged 6 commits into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these two operations totally independent? I assume so but wanted to call out the discrepancy in ordering.

Copy link
Member Author

@MadameSheema MadameSheema Oct 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this specific case, does not matter the order, but you are right, in general, it should not be like that, good catch! I need to update this 😊

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