Bugzilla – Attachment 188340 Details for
Bug 23415
Notify patron fines when renewing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23415: Add Cypress test coverage for FineNoRenewals
Bug-23415-Add-Cypress-test-coverage-for-FineNoRene.patch (text/plain), 8.36 KB, created by
Martin Renvoize (ashimema)
on 2025-10-23 11:25:40 UTC
(
hide
)
Description:
Bug 23415: Add Cypress test coverage for FineNoRenewals
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-10-23 11:25:40 UTC
Size:
8.36 KB
patch
obsolete
>From 8d0eed1c6a2fbf258173f7e99bbea25a8c1014a8 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Thu, 23 Oct 2025 11:56:27 +0100 >Subject: [PATCH] Bug 23415: Add Cypress test coverage for FineNoRenewals > >This commit adds comprehensive end-to-end tests for the fine-based >renewal blocking functionality using Cypress. > >Test coverage includes: >1. Blocking renewal when patron fines exceed FineNoRenewals limit >2. Displaying override button when AllowFineOverrideRenewing is enabled >3. Hiding override button when AllowFineOverrideRenewing is disabled >4. Successful override when permission is enabled >5. Allowing renewal when fines are below the limit > >The test creates test data including: >- A patron with checkouts >- Account fines that exceed the FineNoRenewals threshold >- Tests both blocking and override scenarios > >Tests verify the UI behavior matches the business logic: >- Error messages are displayed correctly >- Override buttons appear based on preference setting >- Override functionality works as expected >- Security is maintained (no override without permission) > >To run these tests: > npx cypress run --spec "t/cypress/integration/Circulation/FineNoRenewals_spec.ts" >--- > .../Circulation/FineNoRenewals_spec.ts | 180 ++++++++++++++++++ > 1 file changed, 180 insertions(+) > create mode 100644 t/cypress/integration/Circulation/FineNoRenewals_spec.ts > >diff --git a/t/cypress/integration/Circulation/FineNoRenewals_spec.ts b/t/cypress/integration/Circulation/FineNoRenewals_spec.ts >new file mode 100644 >index 00000000000..8f49d3979ab >--- /dev/null >+++ b/t/cypress/integration/Circulation/FineNoRenewals_spec.ts >@@ -0,0 +1,180 @@ >+describe("Circulation - FineNoRenewals and AllowFineOverrideRenewing", () => { >+ beforeEach(() => { >+ cy.login(); >+ cy.title().should("eq", "Koha staff interface"); >+ }); >+ >+ describe("Renewal with fines", () => { >+ let patron, checkout, fine_amount; >+ >+ beforeEach(function () { >+ // Set up test data: patron with checkout and fines >+ cy.task("insertSampleCheckout").then(objects => { >+ patron = objects.patron; >+ checkout = objects.checkout; >+ >+ // Set FineNoRenewals to 5 >+ cy.task("query", { >+ sql: "UPDATE systempreferences SET value = ? WHERE variable = ?", >+ values: ["5", "FineNoRenewals"], >+ }); >+ >+ // Add a fine of 10 to the patron (exceeds limit) >+ fine_amount = 10; >+ cy.task("query", { >+ sql: `INSERT INTO accountlines (borrowernumber, amountoutstanding, debit_type_code, status, interface, itemnumber) >+ VALUES (?, ?, 'OVERDUE', 'UNRETURNED', 'test', ?)`, >+ values: [ >+ patron.patron_id, >+ fine_amount, >+ objects.item.item_id, >+ ], >+ }); >+ >+ cy.wrap(objects).as("testObjects"); >+ }); >+ }); >+ >+ afterEach(function () { >+ // Clean up >+ cy.task("deleteSampleObjects", [this.testObjects]); >+ >+ // Reset system preferences >+ cy.task("query", { >+ sql: "UPDATE systempreferences SET value = '100' WHERE variable = 'FineNoRenewals'", >+ }); >+ cy.task("query", { >+ sql: "UPDATE systempreferences SET value = '0' WHERE variable = 'AllowFineOverrideRenewing'", >+ }); >+ }); >+ >+ it("should block renewal when patron has fines over FineNoRenewals limit", function () { >+ const barcode = this.testObjects.item.barcode; >+ >+ // Visit renewal page >+ cy.visit("/cgi-bin/koha/circ/renew.pl"); >+ >+ // Enter barcode >+ cy.get("#barcode").type(barcode); >+ cy.get("form").submit(); >+ >+ // Should see error message about patron debt >+ cy.get(".dialog.alert").should("be.visible"); >+ cy.get(".dialog.alert li").should( >+ "contain", >+ `The patron has a debt of` >+ ); >+ }); >+ >+ it("should show override button when AllowFineOverrideRenewing is enabled", function () { >+ // Enable AllowFineOverrideRenewing >+ cy.task("query", { >+ sql: "UPDATE systempreferences SET value = '1' WHERE variable = 'AllowFineOverrideRenewing'", >+ }); >+ >+ const barcode = this.testObjects.item.barcode; >+ >+ // Visit renewal page >+ cy.visit("/cgi-bin/koha/circ/renew.pl"); >+ >+ // Enter barcode >+ cy.get("#barcode").type(barcode); >+ cy.get("form").submit(); >+ >+ // Should see error message about patron debt >+ cy.get(".dialog.alert").should("be.visible"); >+ cy.get(".dialog.alert li").should( >+ "contain", >+ `The patron has a debt of` >+ ); >+ >+ // Should see override button >+ cy.get('.dialog.alert form button[type="submit"].approve').should( >+ "be.visible" >+ ); >+ cy.get('.dialog.alert form button[type="submit"].approve').should( >+ "contain", >+ "Renew checkout(s)" >+ ); >+ }); >+ >+ it("should NOT show override button when AllowFineOverrideRenewing is disabled", function () { >+ // Ensure AllowFineOverrideRenewing is disabled >+ cy.task("query", { >+ sql: "UPDATE systempreferences SET value = '0' WHERE variable = 'AllowFineOverrideRenewing'", >+ }); >+ >+ const barcode = this.testObjects.item.barcode; >+ >+ // Visit renewal page >+ cy.visit("/cgi-bin/koha/circ/renew.pl"); >+ >+ // Enter barcode >+ cy.get("#barcode").type(barcode); >+ cy.get("form").submit(); >+ >+ // Should see error message about patron debt >+ cy.get(".dialog.alert").should("be.visible"); >+ cy.get(".dialog.alert li").should( >+ "contain", >+ `The patron has a debt of` >+ ); >+ >+ // Should NOT see override button >+ cy.get('.dialog.alert form button[type="submit"].approve').should( >+ "not.exist" >+ ); >+ }); >+ >+ it("should allow renewal after override when AllowFineOverrideRenewing is enabled", function () { >+ // Enable AllowFineOverrideRenewing >+ cy.task("query", { >+ sql: "UPDATE systempreferences SET value = '1' WHERE variable = 'AllowFineOverrideRenewing'", >+ }); >+ >+ const barcode = this.testObjects.item.barcode; >+ >+ // Visit renewal page >+ cy.visit("/cgi-bin/koha/circ/renew.pl"); >+ >+ // Enter barcode >+ cy.get("#barcode").type(barcode); >+ cy.get("form").submit(); >+ >+ // Click override button >+ cy.get('.dialog.alert form button[type="submit"].approve').click(); >+ >+ // Should see success message >+ cy.get(".dialog.message").should("be.visible"); >+ cy.get(".dialog.message").should("contain", "Item renewed"); >+ }); >+ >+ it("should allow renewal when patron has fines below FineNoRenewals limit", function () { >+ // Delete the existing fine >+ cy.task("query", { >+ sql: "DELETE FROM accountlines WHERE borrowernumber = ?", >+ values: [patron.patron_id], >+ }); >+ >+ // Add a smaller fine (below limit) >+ cy.task("query", { >+ sql: `INSERT INTO accountlines (borrowernumber, amountoutstanding, debit_type_code, status, interface, itemnumber) >+ VALUES (?, 3.00, 'OVERDUE', 'UNRETURNED', 'test', ?)`, >+ values: [patron.patron_id, this.testObjects.item.item_id], >+ }); >+ >+ const barcode = this.testObjects.item.barcode; >+ >+ // Visit renewal page >+ cy.visit("/cgi-bin/koha/circ/renew.pl"); >+ >+ // Enter barcode >+ cy.get("#barcode").type(barcode); >+ cy.get("form").submit(); >+ >+ // Should see success message (no error about fines) >+ cy.get(".dialog.message").should("be.visible"); >+ cy.get(".dialog.message").should("contain", "Item renewed"); >+ }); >+ }); >+}); >-- >2.51.0
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 23415
:
92039
|
92541
|
98442
|
98634
|
98996
|
98997
|
105893
|
105894
|
108392
|
109871
|
109872
|
109876
|
109880
|
116919
|
116920
|
116921
|
116922
|
118175
|
118176
|
118177
|
118178
|
118183
|
119300
|
119301
|
119302
|
119303
|
121472
|
139670
|
139671
|
139672
|
139673
|
139674
|
146415
|
148198
|
148199
|
148200
|
148201
|
148202
|
152776
|
152777
|
152778
|
152779
|
152780
|
152781
|
154595
|
154596
|
154597
|
154598
|
154599
|
154600
|
158302
|
158303
|
158304
|
158305
|
158306
|
158307
|
161964
|
161965
|
161966
|
161967
|
161968
|
161969
|
162171
|
162172
|
162173
|
162174
|
162175
|
162176
|
162177
|
162178
|
162179
|
162180
|
171620
|
171621
|
171622
|
171623
|
171983
|
171984
|
171985
|
171986
|
172906
|
172907
|
172908
|
172909
|
172910
|
185270
|
185271
|
185272
|
185273
|
185274
|
185275
|
186014
|
188331
|
188332
|
188333
|
188334
|
188335
|
188336
|
188337
|
188338
|
188339
| 188340 |
188341
|
188342