Bugzilla – Attachment 188813 Details for
Bug 40245
Support option to display firstname in patron search results when different than preferred_name
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40245: Update cypress test to handle ShowPatronFirstnameIfDifferentThanPreferredname
Bug-40245-Update-cypress-test-to-handle-ShowPatron.patch (text/plain), 10.19 KB, created by
Nick Clemens (kidclamp)
on 2025-10-31 11:31:47 UTC
(
hide
)
Description:
Bug 40245: Update cypress test to handle ShowPatronFirstnameIfDifferentThanPreferredname
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2025-10-31 11:31:47 UTC
Size:
10.19 KB
patch
obsolete
>From 56969c5699247e2a890235ec94e533c6ecb80d9f Mon Sep 17 00:00:00 2001 >From: CJ Lynce <cj.lynce@westlakelibrary.org> >Date: Wed, 15 Oct 2025 18:45:26 +0000 >Subject: [PATCH] Bug 40245: Update cypress test to handle > ShowPatronFirstnameIfDifferentThanPreferredname > >Updates patron format cypress tests to allow for ShowPatronFirstnameIfDifferentThanPreferredname > >Test Plan: >-Install Patch >-On command line, in koha root directory, run `cypress run --spec t/cypress/integration/Patron/Format.ts` >-Check to make all tests pass > >Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com> >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/cypress/integration/Patron/Format.ts | 209 +++++++++++++++++++++++++ > 1 file changed, 209 insertions(+) > >diff --git a/t/cypress/integration/Patron/Format.ts b/t/cypress/integration/Patron/Format.ts >index 9b82a2869f4..13147546380 100644 >--- a/t/cypress/integration/Patron/Format.ts >+++ b/t/cypress/integration/Patron/Format.ts >@@ -2,6 +2,21 @@ describe("Display patron - search", () => { > beforeEach(() => { > cy.login(); > cy.title().should("eq", "Koha staff interface"); >+ cy.task("query", { >+ sql: "SELECT value FROM systempreferences WHERE variable='ShowPatronFirstnameIfDifferentThanPreferredname'", >+ }).then(rows => { >+ cy.wrap(rows[0].value).as( >+ "syspref_ShowPatronFirstnameIfDifferentThanPreferredname" >+ ); >+ }); >+ cy.set_syspref("ShowPatronFirstnameIfDifferentThanPreferredname", 0); >+ }); >+ >+ afterEach(function () { >+ cy.set_syspref( >+ "ShowPatronFirstnameIfDifferentThanPreferredname", >+ this.syspref_ShowPatronFirstnameIfDifferentThanPreferredname >+ ); > }); > > const table_id = "memberresultst"; >@@ -93,12 +108,130 @@ describe("Display patron - search", () => { > }); > }); > }); >+ >+ it("should display patron firstname and preferred name when different and ShowPatronFirstnameIfDifferentThanPreferredname is enabled", 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.set_syspref( >+ "ShowPatronFirstnameIfDifferentThanPreferredname", >+ 1 >+ ).then(() => { >+ 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}\\) \\[${patron.firstname}\\]` >+ ); >+ const displayedText = $el.text().replace(/ /g, " ").trim(); >+ expect(displayedText).to.match(re); >+ re = new RegExp(patron.cardnumber); >+ expect(displayedText).to.not.match(re); >+ }); >+ }); >+ }); >+ }); >+ >+ it("should not display patron firstname when same as preferred_name and ShowPatronFirstnameIfDifferentThanPreferredname is enabled", function () { >+ cy.task("buildSampleObjects", { >+ object: "patron", >+ count: 2, >+ values: { >+ firstname: "SameFirstnameAndPreferredname", >+ preferred_name: "SameFirstnameAndPreferredname", >+ }, >+ }).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.set_syspref( >+ "ShowPatronFirstnameIfDifferentThanPreferredname", >+ 1 >+ ).then(() => { >+ 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); >+ re = new RegExp(`\\[${patron.firstname}\\]`); >+ expect(displayedText).to.not.match(re); >+ }); >+ }); >+ }); >+ }); > }); > > describe("Display patron - autocomplete", () => { > beforeEach(() => { > cy.login(); > cy.title().should("eq", "Koha staff interface"); >+ cy.task("query", { >+ sql: "SELECT value FROM systempreferences WHERE variable='ShowPatronFirstnameIfDifferentThanPreferredname'", >+ }).then(rows => { >+ cy.wrap(rows[0].value).as( >+ "syspref_ShowPatronFirstnameIfDifferentThanPreferredname" >+ ); >+ }); >+ cy.set_syspref("ShowPatronFirstnameIfDifferentThanPreferredname", 0); >+ }); >+ >+ afterEach(function () { >+ cy.set_syspref( >+ "ShowPatronFirstnameIfDifferentThanPreferredname", >+ this.syspref_ShowPatronFirstnameIfDifferentThanPreferredname >+ ); > }); > > it("should display all patron info", function () { >@@ -162,6 +295,82 @@ describe("Display patron - autocomplete", () => { > }); > }); > }); >+ >+ it("should display patron firstname and preferred name when different and ShowPatronFirstnameIfDifferentThanPreferredname is enabled", 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.set_syspref( >+ "ShowPatronFirstnameIfDifferentThanPreferredname", >+ 1 >+ ).then(() => { >+ 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.firstname}\\] \\(${patron.cardnumber}\\)` >+ ); >+ const displayedText = $el.text().replace(/ /g, " ").trim(); >+ expect(displayedText).to.match(re); >+ }); >+ }); >+ }); >+ }); >+ >+ it("should not display patron firstname when same as preferred_name and ShowPatronFirstnameIfDifferentThanPreferredname is enabled", function () { >+ cy.task("buildSampleObjects", { >+ object: "patron", >+ count: 1, >+ values: { >+ firstname: "SameFirstnameAndPreferredname", >+ preferred_name: "SameFirstnameAndPreferredname", >+ }, >+ }).then(patrons => { >+ cy.intercept("GET", "/api/v1/patrons*", { >+ statusCode: 200, >+ body: patrons, >+ headers: { >+ "X-Base-Total-Count": "1", >+ "X-Total-Count": "1", >+ }, >+ }); >+ >+ cy.set_syspref( >+ "ShowPatronFirstnameIfDifferentThanPreferredname", >+ 1 >+ ).then(() => { >+ 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); >+ re = new RegExp(`\\[${patron.firstname}\\]`); >+ expect(displayedText).to.not.match(re); >+ }); >+ }); >+ }); >+ }); > }); > > describe("Display patron - no search", () => { >-- >2.39.5
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 40245
:
184501
|
184502
|
184637
|
184638
|
184639
|
185601
|
185602
|
185603
|
186732
|
186733
|
187891
|
187892
|
187893
|
187943
|
188112
|
188113
|
188114
|
188811
|
188812
| 188813