Bugzilla – Attachment 187838 Details for
Bug 41003
Missing Cypress tests for patron display
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41003: Add Cypress tests to cover patron formatting
Bug-41003-Add-Cypress-tests-to-cover-patron-format.patch (text/plain), 4.77 KB, created by
Jonathan Druart
on 2025-10-13 13:17:20 UTC
(
hide
)
Description:
Bug 41003: Add Cypress tests to cover patron formatting
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-10-13 13:17:20 UTC
Size:
4.77 KB
patch
obsolete
>From 55e505b2cf01334fed8ba6d196e3ae1a4e7f558b Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 13 Oct 2025 15:16:55 +0200 >Subject: [PATCH] Bug 41003: Add Cypress tests to cover patron formatting > >--- > t/cypress/integration/Patron/Format.ts | 118 +++++++++++++++++++++++++ > 1 file changed, 118 insertions(+) > create mode 100644 t/cypress/integration/Patron/Format.ts > >diff --git a/t/cypress/integration/Patron/Format.ts b/t/cypress/integration/Patron/Format.ts >new file mode 100644 >index 00000000000..4458ae29169 >--- /dev/null >+++ b/t/cypress/integration/Patron/Format.ts >@@ -0,0 +1,118 @@ >+describe("Display patron - search", () => { >+ beforeEach(() => { >+ cy.login(); >+ cy.title().should("eq", "Koha staff interface"); >+ }); >+ >+ const table_id = "memberresultst"; >+ >+ it("should display all patron info", function () { >+ cy.task("buildSampleObjects", { >+ object: "patron", >+ count: 2, >+ values: {}, >+ }).then(patrons => { >+ // Needs more properties to not explode >+ // account_balace: balance_str.escapeHtml(...).format_price is not a function >+ patrons = patrons.map(p => ({ ...p, account_balance: 0 })); >+ >+ cy.intercept("GET", "/api/v1/patrons*", { >+ statusCode: 200, >+ body: patrons, >+ headers: { >+ "X-Base-Total-Count": "2", >+ "X-Total-Count": "2", >+ }, >+ }); >+ >+ cy.visit("/cgi-bin/koha/members/members-home.pl"); >+ >+ cy.window().then(win => { >+ win.categories_map = patrons.reduce((map, p) => { >+ map[p.category_id.toLowerCase()] = p.category_id; >+ return map; >+ }, {}); >+ }); >+ >+ cy.get("form.patron_search_form input[type='submit']").click(); >+ >+ const patron = patrons[0]; >+ // invert_name is set >+ cy.get(`#${table_id} tbody tr:eq(0) td:eq(2)`).should($el => { >+ let re = new RegExp( >+ `${patron.surname}, ${patron.preferred_name} ${patron.middle_name} \\(${patron.other_name}\\)` >+ ); >+ const displayedText = $el.text().replace(/ /g, " ").trim(); >+ expect(displayedText).to.match(re); >+ re = new RegExp(patron.cardnumber); >+ expect(displayedText).to.not.match(re); >+ }); >+ }); >+ }); >+}); >+ >+describe.only("Display patron - autocomplete", () => { >+ beforeEach(() => { >+ cy.login(); >+ cy.title().should("eq", "Koha staff interface"); >+ }); >+ >+ it("should display all patron info", function () { >+ cy.task("buildSampleObjects", { >+ object: "patron", >+ count: 1, >+ values: {}, >+ }).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.surname); >+ >+ // invert_name is set >+ cy.get(`ul.ui-autocomplete li a`).should($el => { >+ let re = new RegExp( >+ `${patron.surname}, ${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", () => { >+ beforeEach(() => { >+ cy.login(); >+ cy.title().should("eq", "Koha staff interface"); >+ cy.task("insertSamplePatron").then(objects_patron => { >+ cy.wrap(objects_patron).as("objects_patron"); >+ }); >+ }); >+ >+ afterEach(function () { >+ cy.task("deleteSampleObjects", this.objects_patron); >+ }); >+ >+ it("should display all patron info", function () { >+ const patron = this.objects_patron.patron; >+ cy.visit( >+ `/cgi-bin/koha/members/moremember.pl?borrowernumber=${patron.patron_id}` >+ ); >+ cy.get(".row .col-sm-12 h1").should($el => { >+ const re = new RegExp( >+ `${patron.title} ${patron.preferred_name} ${patron.middle_name} \\(${patron.other_name}\\) ${patron.surname} \\(${patron.cardnumber}\\)` >+ ); >+ const displayedText = $el.text().replace(/ /g, " ").trim(); >+ expect(displayedText).to.match(re); >+ }); >+ }); >+}); >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 41003
:
187837
|
187838
|
187840