Skip to content

Commit

Permalink
Try to spy on loan request
Browse files Browse the repository at this point in the history
to be able to make an assertion that the loan request has happened after
the renewal.
  • Loading branch information
spaceo committed Oct 8, 2023
1 parent ce380af commit 0659da2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
11 changes: 8 additions & 3 deletions src/apps/dashboard/dashboard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1421,14 +1421,19 @@ describe("Dashboard", () => {
});

it.only("Can go trough renewal flow of soon overdue loans", () => {
// Spy on the loan request.
cy.intercept(
"**/external/agencyid/patrons/patronid/loans/v2**",
cy.spy().as("loan-spy")
);
cy.getBySel("physical-loans-soon-overdue").click();
cy.getBySel("modal-due-date-2023-10-11-close-button").should("exist");
cy.getBySel("loans-group-modal-button").first().click();
cy.getBySel("modal-cta-button").click();
cy.getBySel("modal-due-date-2023-10-11-close-button").should("not.exist");
// Because the loans cache is invalidated we should get precisely 2 requests
// to the loans service: The initial and the one after renewal.
cy.get("@loans.all").should("have.length", 2);
// Because the loans cache is invalidated we should get precisely 1 request
// to the loans service (after the intial request on page load).
cy.get("@loan-spy").its("callCount").should("equal", 1);
});
});

Expand Down
11 changes: 8 additions & 3 deletions src/apps/loan-list/list/loan-list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,11 @@ describe("Loan list", () => {
});

it.only("Can go trough renewal flow of a single loan from the loan list", () => {
// Spy on the loan request.
cy.intercept(
"**/external/agencyid/patrons/patronid/loans/v2**",
cy.spy().as("loan-spy")
);
cy.getBySel("loan-list-items")
.find(".list-reservation")
.eq(1)
Expand All @@ -718,9 +723,9 @@ describe("Loan list", () => {
cy.getBySel("modal-loan-details-956442399-close-button").should(
"not.exist"
);
// Because the loans cache is invalidated we should get precisely 2 requests
// to the loans service: The initial and the one after renewal.
cy.get("@physical_loans.all").should("have.length", 2);
// Because the loans cache is invalidated we should get precisely 1 request
// to the loans service (after the intial request on page load).
cy.get("@loan-spy").its("callCount").should("equal", 1);
});
});

Expand Down

0 comments on commit 0659da2

Please sign in to comment.