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

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Amended-by: Jonathan Druart
Added $raw filter to [% ", " %]

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2025-06-18 14:20:29 +02:00 committed by Lucas Gass
parent 15c51ce4b2
commit 67e04b039a
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 45 additions and 3 deletions

View File

@ -31,9 +31,7 @@
<li class="patroncity">
<span class="city">[%~ patron.city |html ~%]</span>
[%~ IF ( patron.state ) %]
[%~ IF ( patron.city ) ~%]
,
[% END ~%]
[%~ IF ( patron.city ) ~%][% ", " | $raw %][% END ~%]
<span class="state">[% patron.state |html ~%]</span>
[%~ END ~%]
[%~ IF ( patron.zipcode ) %]<span class="zipcode">[%~ " " _ patron.zipcode |html ~%]</span>[% END %]

View File

@ -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);
});
});
});