I am trying to test my own wordpress plugin with Cypress.
I've encountered the following issue: if I add items to the cart with the built-in "Add to cart" button and navigate to the cart, it is empty.
If I try the same scenario manually with the cypress chrome browser beside the tests, the same thing happens.
Code:
it("puts in the cart", () => {
cy.getChatbotIframe()
.find("[data-cy=coupon-code]")
.invoke("text")
.then((text) => {
cy.getChatbotIframe().find("[data-cy=go-to-cart-button]").click();
cy.get("[data-cy=coupon-code]").contains(text);
});
});
The getChatbotIframe command:
Cypress.Commands.add("getChatbotIframe", () => {
return cy
.get("[data-cy=alkubot-chat-iframe]", { log: false })
.its("0.contentDocument.body", { log: false })
.should("not.be.empty")
.then((body) => cy.wrap(body, { log: false }));
});
