Skip to content

Commit

Permalink
Fixes Cypress flake by adding pipe, click, and should
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankHassanabad committed Feb 25, 2021
1 parent ebb0435 commit e6c12f0
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
};

Expand Down

0 comments on commit e6c12f0

Please sign in to comment.