From 9351f92d329c3ecfc91675310b256f457fbcdc45 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 18 Jun 2025 14:20:29 +0200 Subject: [PATCH] Bug 40320: (bug 40319 follow-up) Add Cypress tests Test plan: Make sure the display of city, state and zipcode is the same as before the patch Confirm that the new Cypress tests pass --- .../includes/member-display-address-style.inc | 4 +- t/cypress/integration/Patron/Address.ts | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 t/cypress/integration/Patron/Address.ts diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/member-display-address-style.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/member-display-address-style.inc index 3e0bb172e01..2e410506f16 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/member-display-address-style.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/member-display-address-style.inc @@ -31,9 +31,7 @@
  • [%~ patron.city |html ~%] [%~ IF ( patron.state ) %] - [%~ IF ( patron.city ) ~%] - , - [% END ~%] + [%~ IF ( patron.city ) ~%],[% END ~%] [% patron.state |html ~%] [%~ END ~%] [%~ IF ( patron.zipcode ) %][%~ " " _ patron.zipcode |html ~%][% END %] diff --git a/t/cypress/integration/Patron/Address.ts b/t/cypress/integration/Patron/Address.ts new file mode 100644 index 00000000000..1d09a43690c --- /dev/null +++ b/t/cypress/integration/Patron/Address.ts @@ -0,0 +1,44 @@ +describe("Display address", () => { + beforeEach(() => { + cy.login(); + cy.title().should("eq", "Koha staff interface"); + cy.task("buildSampleObject", { + object: "patron", + values: { + street_number: 12, + street_type: "Rd", + address: "Awesome", + address2: "Library", + city: "Portland", + state: "OR", + postal_code: "44240", + country: "USA", + }, + }).then(generatedPatron => { + cy.task("insertObject", { + type: "patron", + object: generatedPatron, + }).then(objects_patron => { + cy.wrap(objects_patron).as("objects_patron"); + }); + }); + }); + + afterEach(function () { + cy.task("deleteSampleObjects", [this.objects_patron]); + }); + + it("should have correct spacing", function () { + cy.visit( + `/cgi-bin/koha/members/moremember.pl?borrowernumber=${this.objects_patron.patron_id}` + ); + const patron = this.objects_patron; + cy.get(".patronbriefinfo").should($el => { + const re = new RegExp( + `${patron.street_number} ${patron.address} ${patron.street_type}\\n\\s*${patron.address2}\\n\\s*${patron.city}, ${patron.state} ${patron.postal_code}\\n\\s*${patron.country}` + ); + const displayedText = $el.text().replace(/ /g, " ").trim(); + expect(displayedText).to.match(re); + }); + }); +}); -- 2.34.1