From e982dfe9d210b2d06dce55757d95e4bff4598249 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 25 Sep 2025 14:03:36 +0200 Subject: [PATCH] Bug 40865: Add a cypress test --- .../KohaTable/PatronSearch_spec.ts | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/t/cypress/integration/KohaTable/PatronSearch_spec.ts b/t/cypress/integration/KohaTable/PatronSearch_spec.ts index c6bff2545ac..92dd23c852a 100644 --- a/t/cypress/integration/KohaTable/PatronSearch_spec.ts +++ b/t/cypress/integration/KohaTable/PatronSearch_spec.ts @@ -271,3 +271,55 @@ describe("Filters", () => { }); }); }); + +describe("On single result", () => { + const table_id = "memberresultst"; + + beforeEach(() => { + cleanup(); + cy.login(); + cy.title().should("eq", "Koha staff interface"); + cy.window().then(win => { + win.localStorage.clear(); + }); + }); + + it("should redirect", () => { + cy.task("insertSamplePatron").then(patron_objects => { + let patron = patron_objects.patron; + patron.library = patron_objects.library; + cy.intercept("GET", "/api/v1/patrons*", { + statusCode: 200, + body: [patron], + headers: { + "X-Base-Total-Count": baseTotalCount, + "X-Total-Count": "1", + }, + }).as("searchPatrons"); + + cy.visit("/cgi-bin/koha/mainpage.pl"); + + cy.get("#findborrower").type( + `${patron.surname} ${patron.firstname}` + ); + // Wait for auto complete + cy.wait("@searchPatrons"); + + cy.get("#findborrower").type(`{enter}`); + + cy.title().should( + "to.match", + new RegExp(`^Checking out to.* ${patron.surname}`) + ); + + cy.location("pathname").should( + "include", + "/cgi-bin/koha/circ/circulation.pl" + ); + cy.location("search").should( + "include", + `?borrowernumber=${patron.patron_id}` + ); + }); + }); +}); -- 2.34.1