30 lines
1.0 KiB
JavaScript
30 lines
1.0 KiB
JavaScript
describe("Report generation", () => {
|
|
it("Customer report opens without error", () => {
|
|
cy.ayLogin("bizadmin");
|
|
|
|
cy.visit("/cust-customers/1");
|
|
cy.url().should("include", "/cust-customers/1");
|
|
cy.get("[data-cy=generalerror]").should("not.exist");
|
|
cy.get("[data-cy=name]");
|
|
|
|
// Stub window.open AFTER the page has loaded
|
|
cy.window().then(win => {
|
|
cy.stub(win, "open").as("windowOpen");
|
|
});
|
|
|
|
cy.get("[data-cy=contextmenu]").click();
|
|
cy.get("[data-cy='customer-edit:report']").click();
|
|
cy.get(".v-list > :nth-child(1) > .v-list-item__title").click();
|
|
|
|
// The render job is async — give it time to complete and call window.open
|
|
// Adjust timeout if your reports take longer to render
|
|
cy.get("@windowOpen", { timeout: 30000 }).should("have.been.calledOnce");
|
|
|
|
// Verify the URL passed to window.open looks like a PDF download
|
|
cy.get("@windowOpen").should(
|
|
"have.been.calledWithMatch",
|
|
/\/api\/v8\.0\/report\/download\/.+\.pdf/
|
|
);
|
|
});
|
|
});
|