From e6c12f000df1d746a67d7bcf84511329d6823222 Mon Sep 17 00:00:00 2001 From: FrankHassanabad Date: Thu, 25 Feb 2021 00:32:30 -0700 Subject: [PATCH] Fixes Cypress flake by adding pipe, click, and should --- .../cypress/tasks/alerts_detection_rules.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 529ef4afdfa63..10644e046a68b 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 @@ -116,9 +116,19 @@ export const reloadDeletedRules = () => { cy.get(RELOAD_PREBUILT_RULES_BTN).click({ force: true }); }; +/** + * Selects the number of rules. Since there can be missing click handlers + * when the page loads at first, we use a pipe and a trigger of click + * on it and then check to ensure that it is checked before continuing + * with the tests. + * @param numberOfRules The number of rules to click/check + */ export const selectNumberOfRules = (numberOfRules: number) => { for (let i = 0; i < numberOfRules; i++) { - cy.get(RULE_CHECKBOX).eq(i).click({ force: true }); + cy.get(RULE_CHECKBOX) + .eq(i) + .pipe(($el) => $el.trigger('click')) + .should('be.checked'); } };