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

Switch to Sonner for toast notifications #9405

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5c0f052
Switch to Sonner for toast notifications #9394
nilay-v3rma Dec 13, 2024
bb44c6a
toaster position and theme updates
nilay-v3rma Dec 19, 2024
a828352
updated cypress tests to check for sonner toast notifications
nilay-v3rma Dec 19, 2024
9434c27
updated closeNotification to close sonner toast notification
nilay-v3rma Dec 19, 2024
0761bc7
Merge branch 'develop' into issues/9394/use-sonner-notifications
nilay-v3rma Dec 19, 2024
c3b3b8d
Update package-lock.json
rithviknishad Dec 19, 2024
cbd8d11
Merge branch 'develop' into issues/9394/use-sonner-notifications
nihal467 Dec 20, 2024
05702ac
Merge remote-tracking branch 'origin' into issues/9394/use-sonner-not…
rithviknishad Dec 23, 2024
63c3a83
fix-verify notification cypress command
nilay-v3rma Dec 24, 2024
fc2efc2
Merge branch 'develop' into issues/9394/use-sonner-notifications
nilay-v3rma Dec 24, 2024
7007e04
fix-close notification cypress command
nilay-v3rma Dec 26, 2024
e1d536f
update lockfile
rithviknishad Dec 28, 2024
0ba432f
fix asset create
rithviknishad Dec 28, 2024
bfbcd97
Fixes #9559:No Notice Available Icon Misaligned in Mobile View (#9562)
pranavchaitu Dec 25, 2024
603b1b8
Bump @yudiel/react-qr-scanner from 2.0.8 to 2.1.0 (#9566)
dependabot[bot] Dec 25, 2024
7754bbd
Bump @sentry/browser from 8.45.1 to 8.47.0 (#9565)
dependabot[bot] Dec 25, 2024
86d171b
fixed flaky test in doctor notes (#9569)
nihal467 Dec 26, 2024
94a1d53
Always show "online" for authenticated user profiles (#9574)
abhimanyurajeesh Dec 26, 2024
7a0874e
Bump @radix-ui/react-popover from 1.1.2 to 1.1.4 (#9576)
dependabot[bot] Dec 27, 2024
809900e
Bump react-i18next from 15.1.3 to 15.2.0 (#9575)
dependabot[bot] Dec 27, 2024
9a085cf
Fix: the selected medicine issue in the placeholder (#9596)
AdityaJ2305 Dec 28, 2024
0177534
Removed unwanted check in the patient discharge test (#9601)
nihal467 Dec 28, 2024
de2ff2e
Merge branch 'develop' into issues/9394/use-sonner-notifications
nilay-v3rma Dec 28, 2024
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
7 changes: 5 additions & 2 deletions cypress/pageobject/Facility/FacilityManage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,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);
Jacobjeevan marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
13 changes: 7 additions & 6 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,12 @@ 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")
.contains(text);
});

Cypress.Commands.add("clearAllFilters", () => {
Expand Down Expand Up @@ -221,11 +225,8 @@ Cypress.Commands.add("preventPrint", () => {
});

Cypress.Commands.add("closeNotification", () => {
cy.get(".pnotify")
.should("exist")
.each(($div) => {
cy.wrap($div).click();
});
cy.wait(5000); //wait for the notification to disappear
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
cy.wait(5000); //wait for the notification to disappear
cy.wait(5000); //wait for the notification to disappear

don't use hardcorded wait, look into another solution

Copy link
Author

Choose a reason for hiding this comment

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

don't use hardcorded wait, look into another solution

I understand this is not the best solution, but I have tried the following methods to drag the notification upwards to close it, unfortunately they did not work

  1. using mousemove
Cypress.Commands.add("closeNotification", () => {
  cy.get("li[data-sonner-toast] div[data-title]")
    .should("exist")
    .trigger('mousedown', { which: 1, force: true }) //start the drag
    .trigger('mousemove', { clientY: -100, force: true }) // drag upward
    .trigger('mouseup', { force: true }); // end the drag
    });

  // ensure the toast is removed from the DOM
  cy.get("li[data-sonner-toast]").should("not.exist");
});
  1. using pointermove

    Cypress.Commands.add("closeNotification", () => {
      cy.get("li[data-sonner-toast]")
        .trigger('pointerdown', { which: 1, force: true }) // start the drag
        .trigger('pointermove', { clientX: 0, clientY: -100, force: true }) // drag upward
        .trigger('pointerup', { force: true }); // end the drag
    
      // ensure the toast is removed from the DOM
      cy.get("li[data-sonner-toast]").should('not.exist');
    });
  2. using toast.dismiss()

    Cypress.Commands.add("closeNotification", () => {
      cy.window().then((win) => {
        if (win.toast) {
          win.toast.dismiss(); // dismiss all toasts programmatically
        } else {
          throw new Error("Sonner `toast` object not found.");
        }
      });
    
      // ensure the toast is removed from the DOM
      cy.get("li[data-sonner-toast]").should("not.exist");
    });

I am continuing to explore better solutions and would greatly appreciate any advice or suggestions you might have!

cy.get("li[data-sonner-toast]").should("not.exist"); // Ensure the toast is removed from the DOM
});

Cypress.Commands.add("verifyContentPresence", (selector, texts) => {
Expand Down
Loading
Loading