Bug 40995: Add Cypress tests

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2025-10-13 15:56:59 +02:00 committed by Lucas Gass
parent 1f9babb201
commit 6e1ef7ea44
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 31 additions and 0 deletions

View File

@ -131,6 +131,37 @@ describe("Display patron - autocomplete", () => {
});
});
});
it("should have correct punctuation when surname is missing", function () {
cy.task("buildSampleObjects", {
object: "patron",
count: 1,
values: { surname: null },
}).then(patrons => {
cy.intercept("GET", "/api/v1/patrons*", {
statusCode: 200,
body: patrons,
headers: {
"X-Base-Total-Count": "1",
"X-Total-Count": "1",
},
});
cy.visit("/cgi-bin/koha/mainpage.pl");
const patron = patrons[0];
cy.get("#findborrower").type(patron.firstname);
// invert_name is set
cy.get(`ul.ui-autocomplete li a`).should($el => {
let re = new RegExp(
`^${patron.preferred_name} ${patron.middle_name} \\(${patron.other_name}\\) \\(${patron.cardnumber}\\)`
);
const displayedText = $el.text().replace(/ /g, " ").trim();
expect(displayedText).to.match(re);
});
});
});
});
describe("Display patron - no search", () => {