Skip to content

Commit

Permalink
fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 committed Dec 14, 2023
1 parent 12b4847 commit 2b7c488
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions cypress/pageobject/Users/UserSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,25 @@ export class UserPage {
cy.url().should("include", `page=${pageNumber}`);
}

verifyMultipleBadgesWithSameId(expectedContents: string[]) {
cy.get("#user-view-name").each((el, index) => {
expect(el.text().trim()).to.equal(expectedContents[index]);
verifyMultipleBadgesWithSameId(alreadylinkedusersviews: string[]) {
cy.get("#user-view-name").then(($elements) => {
const userViews = $elements
.map((_, el) => Cypress.$(el).text().trim())
.get();
let foundMatches = 0;

alreadylinkedusersviews.forEach((expectedContent) => {
const index = userViews.findIndex((actualContent) =>
actualContent.includes(expectedContent)
);
if (index !== -1) {
userViews.splice(index, 1); // Remove the matched element
foundMatches++;
}
if (foundMatches === alreadylinkedusersviews.length) {
return false; // Break the loop if all matches are found
}
});
});
}
}

0 comments on commit 2b7c488

Please sign in to comment.