Skip to content

Commit

Permalink
updated cypress tests to check for sonner toast notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
nilay-v3rma committed Dec 19, 2024
1 parent bb44c6a commit a828352
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions cypress/pageobject/Facility/FacilityManage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,13 @@ class FacilityManage {
text: string | RegExp,
isRegex = false,
) {
// Selector for the Sonner toast content
const toastSelector = "li[data-sonner-toast] div[data-title]";

if (isRegex) {
cy.get(".pnotify-text").should("be.visible").contains(text);
cy.get(toastSelector).should("be.visible").contains(text);
} else {
cy.get(".pnotify-text").should("be.visible").and("contain.text", text);
cy.get(toastSelector).should("be.visible").and("contain.text", text);
}
}

Expand Down
7 changes: 6 additions & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,13 @@ Cypress.Commands.add(
},
);

//check sonner toast notification
Cypress.Commands.add("verifyNotification", (text) => {
return cy.get(".pnotify-container").should("exist").contains(text);
return cy
.get("li[data-sonner-toast] div[data-title]")
.should("exist")
.and("be.visible")
.contains(text);
});

Cypress.Commands.add("clearAllFilters", () => {
Expand Down

0 comments on commit a828352

Please sign in to comment.