|
1 | 1 | import Toast from "../../src/Toast.js";
|
2 | 2 | import List from "../../src/List.js";
|
3 | 3 | import ListItemStandard from "../../src/ListItemStandard.js";
|
| 4 | +import ResponsivePopover from "../../src/ResponsivePopover.js"; |
| 5 | +import Button from "../../src/Button.js"; |
4 | 6 |
|
5 | 7 | describe("Toast - test popover API", () => {
|
6 | 8 | it("Should verify the toast has the popover attribute set to manual", () => {
|
@@ -42,4 +44,56 @@ describe("Toast - test popover API", () => {
|
42 | 44 | });
|
43 | 45 | });
|
44 | 46 | });
|
| 47 | + |
| 48 | + it("Should open toast from popover and only toast should fire close event", () => { |
| 49 | + cy.mount( |
| 50 | + <> |
| 51 | + <Button id="openResponsivePopoverBtn">Open Popover</Button> |
| 52 | + <ResponsivePopover |
| 53 | + id="responsivePopover" |
| 54 | + opener="openResponsivePopoverBtn"> |
| 55 | + <Button id="openToastBtn">Open Toast</Button> |
| 56 | + </ResponsivePopover> |
| 57 | + <Toast open id="toast" duration={-1} placement="BottomCenter">Toast Text</Toast> |
| 58 | + </> |
| 59 | + ); |
| 60 | + |
| 61 | + cy.get("[ui5-responsive-popover]").then(popover => { |
| 62 | + popover[0].addEventListener("close", cy.stub().as("popoverClose")); |
| 63 | + }); |
| 64 | + |
| 65 | + cy.get("#openResponsivePopoverBtn").then($button => { |
| 66 | + $button[0].addEventListener("click", () => { |
| 67 | + cy.get("[ui5-responsive-popover]").then($popover => { |
| 68 | + const popover = $popover[0] as ResponsivePopover; |
| 69 | + popover.setAttribute("open", "true"); |
| 70 | + }); |
| 71 | + }); |
| 72 | + }); |
| 73 | + |
| 74 | + cy.get("#openToastBtn").then($button => { |
| 75 | + $button[0].addEventListener("click", () => { |
| 76 | + cy.get("[ui5-toast]").then($toast => { |
| 77 | + const toast = $toast[0] as Toast; |
| 78 | + toast.setAttribute("open", "true"); |
| 79 | + }); |
| 80 | + }); |
| 81 | + }); |
| 82 | + |
| 83 | + cy.get("[ui5-toast]").should("exist").then(($toast) => { |
| 84 | + $toast[0].addEventListener("close", cy.stub().as("toastClose")); |
| 85 | + }); |
| 86 | + |
| 87 | + cy.get("#openResponsivePopoverBtn") |
| 88 | + .realClick(); |
| 89 | + |
| 90 | + cy.get("#openToastBtn") |
| 91 | + .realClick(); |
| 92 | + |
| 93 | + cy.get("@toastClose") |
| 94 | + .should("be.calledOnce"); |
| 95 | + |
| 96 | + cy.get("@popoverClose") |
| 97 | + .should("not.have.been.called"); |
| 98 | + }); |
45 | 99 | });
|
0 commit comments