|
Lines 13-24
describe("Circulation - FineNoRenewals and AllowFineOverrideRenewing", () => {
Link Here
|
| 13 |
patron = objects.patron; |
13 |
patron = objects.patron; |
| 14 |
checkout = objects.checkout; |
14 |
checkout = objects.checkout; |
| 15 |
|
15 |
|
| 16 |
// Set FineNoRenewals to 5 |
16 |
// Disable auto_renew on the checkout to get too_much_owing error instead of auto_too_much_owing |
| 17 |
cy.task("query", { |
17 |
cy.task("query", { |
| 18 |
sql: "UPDATE systempreferences SET value = ? WHERE variable = ?", |
18 |
sql: "UPDATE issues SET auto_renew = 0 WHERE issue_id = ?", |
| 19 |
values: ["5", "FineNoRenewals"], |
19 |
values: [checkout.checkout_id], |
| 20 |
}); |
20 |
}); |
| 21 |
|
21 |
|
|
|
22 |
// Set FineNoRenewals to 5 |
| 23 |
cy.set_syspref("FineNoRenewals", "5"); |
| 24 |
|
| 22 |
// Add a fine of 10 to the patron (exceeds limit) |
25 |
// Add a fine of 10 to the patron (exceeds limit) |
| 23 |
fine_amount = 10; |
26 |
fine_amount = 10; |
| 24 |
cy.task("query", { |
27 |
cy.task("query", { |
|
Lines 27-33
describe("Circulation - FineNoRenewals and AllowFineOverrideRenewing", () => {
Link Here
|
| 27 |
values: [ |
30 |
values: [ |
| 28 |
patron.patron_id, |
31 |
patron.patron_id, |
| 29 |
fine_amount, |
32 |
fine_amount, |
| 30 |
objects.item.item_id, |
33 |
objects.items[0].item_id, |
| 31 |
], |
34 |
], |
| 32 |
}); |
35 |
}); |
| 33 |
|
36 |
|
|
Lines 40-62
describe("Circulation - FineNoRenewals and AllowFineOverrideRenewing", () => {
Link Here
|
| 40 |
cy.task("deleteSampleObjects", [this.testObjects]); |
43 |
cy.task("deleteSampleObjects", [this.testObjects]); |
| 41 |
|
44 |
|
| 42 |
// Reset system preferences |
45 |
// Reset system preferences |
| 43 |
cy.task("query", { |
46 |
cy.set_syspref("FineNoRenewals", "100"); |
| 44 |
sql: "UPDATE systempreferences SET value = '100' WHERE variable = 'FineNoRenewals'", |
47 |
cy.set_syspref("AllowFineOverrideRenewing", "0"); |
| 45 |
}); |
|
|
| 46 |
cy.task("query", { |
| 47 |
sql: "UPDATE systempreferences SET value = '0' WHERE variable = 'AllowFineOverrideRenewing'", |
| 48 |
}); |
| 49 |
}); |
48 |
}); |
| 50 |
|
49 |
|
| 51 |
it("should block renewal when patron has fines over FineNoRenewals limit", function () { |
50 |
it("should block renewal when patron has fines over FineNoRenewals limit", function () { |
| 52 |
const barcode = this.testObjects.item.barcode; |
51 |
const barcode = this.testObjects.items[0].external_id; |
| 53 |
|
52 |
|
| 54 |
// Visit renewal page |
53 |
// Visit renewal page |
| 55 |
cy.visit("/cgi-bin/koha/circ/renew.pl"); |
54 |
cy.visit("/cgi-bin/koha/circ/renew.pl"); |
| 56 |
|
55 |
|
| 57 |
// Enter barcode |
56 |
// Enter barcode |
| 58 |
cy.get("#barcode").type(barcode); |
57 |
cy.get("#barcode").type(barcode); |
| 59 |
cy.get("form").submit(); |
58 |
cy.get("#barcode").closest("form").submit(); |
| 60 |
|
59 |
|
| 61 |
// Should see error message about patron debt |
60 |
// Should see error message about patron debt |
| 62 |
cy.get(".dialog.alert").should("be.visible"); |
61 |
cy.get(".dialog.alert").should("be.visible"); |
|
Lines 68-88
describe("Circulation - FineNoRenewals and AllowFineOverrideRenewing", () => {
Link Here
|
| 68 |
|
67 |
|
| 69 |
it("should show override button when AllowFineOverrideRenewing is enabled", function () { |
68 |
it("should show override button when AllowFineOverrideRenewing is enabled", function () { |
| 70 |
// Enable AllowFineOverrideRenewing |
69 |
// Enable AllowFineOverrideRenewing |
| 71 |
cy.task("query", { |
70 |
cy.set_syspref("AllowFineOverrideRenewing", "1"); |
| 72 |
sql: "UPDATE systempreferences SET value = '1' WHERE variable = 'AllowFineOverrideRenewing'", |
|
|
| 73 |
}); |
| 74 |
|
71 |
|
| 75 |
const barcode = this.testObjects.item.barcode; |
72 |
const barcode = this.testObjects.items[0].external_id; |
| 76 |
|
73 |
|
| 77 |
// Visit renewal page |
74 |
// Visit renewal page |
| 78 |
cy.visit("/cgi-bin/koha/circ/renew.pl"); |
75 |
cy.visit("/cgi-bin/koha/circ/renew.pl"); |
| 79 |
|
76 |
|
| 80 |
// Enter barcode |
77 |
// Enter barcode |
| 81 |
cy.get("#barcode").type(barcode); |
78 |
cy.get("#barcode").type(barcode); |
| 82 |
cy.get("form").submit(); |
79 |
cy.get("#barcode").closest("form").submit(); |
| 83 |
|
80 |
|
| 84 |
// Should see error message about patron debt |
81 |
// Should see error message about patron debt |
| 85 |
cy.get(".dialog.alert").should("be.visible"); |
82 |
cy.get(".dialog.alert").should("be.visible"); |
|
|
83 |
|
| 86 |
cy.get(".dialog.alert li").should( |
84 |
cy.get(".dialog.alert li").should( |
| 87 |
"contain", |
85 |
"contain", |
| 88 |
`The patron has a debt of` |
86 |
`The patron has a debt of` |
|
Lines 94-117
describe("Circulation - FineNoRenewals and AllowFineOverrideRenewing", () => {
Link Here
|
| 94 |
); |
92 |
); |
| 95 |
cy.get('.dialog.alert form button[type="submit"].approve').should( |
93 |
cy.get('.dialog.alert form button[type="submit"].approve').should( |
| 96 |
"contain", |
94 |
"contain", |
| 97 |
"Renew checkout(s)" |
95 |
"Override and renew" |
| 98 |
); |
96 |
); |
| 99 |
}); |
97 |
}); |
| 100 |
|
98 |
|
| 101 |
it("should NOT show override button when AllowFineOverrideRenewing is disabled", function () { |
99 |
it("should NOT show override button when AllowFineOverrideRenewing is disabled", function () { |
| 102 |
// Ensure AllowFineOverrideRenewing is disabled |
100 |
// Ensure AllowFineOverrideRenewing is disabled |
| 103 |
cy.task("query", { |
101 |
cy.set_syspref("AllowFineOverrideRenewing", "0"); |
| 104 |
sql: "UPDATE systempreferences SET value = '0' WHERE variable = 'AllowFineOverrideRenewing'", |
|
|
| 105 |
}); |
| 106 |
|
102 |
|
| 107 |
const barcode = this.testObjects.item.barcode; |
103 |
const barcode = this.testObjects.items[0].external_id; |
| 108 |
|
104 |
|
| 109 |
// Visit renewal page |
105 |
// Visit renewal page |
| 110 |
cy.visit("/cgi-bin/koha/circ/renew.pl"); |
106 |
cy.visit("/cgi-bin/koha/circ/renew.pl"); |
| 111 |
|
107 |
|
| 112 |
// Enter barcode |
108 |
// Enter barcode |
| 113 |
cy.get("#barcode").type(barcode); |
109 |
cy.get("#barcode").type(barcode); |
| 114 |
cy.get("form").submit(); |
110 |
cy.get("#barcode").closest("form").submit(); |
| 115 |
|
111 |
|
| 116 |
// Should see error message about patron debt |
112 |
// Should see error message about patron debt |
| 117 |
cy.get(".dialog.alert").should("be.visible"); |
113 |
cy.get(".dialog.alert").should("be.visible"); |
|
Lines 128-145
describe("Circulation - FineNoRenewals and AllowFineOverrideRenewing", () => {
Link Here
|
| 128 |
|
124 |
|
| 129 |
it("should allow renewal after override when AllowFineOverrideRenewing is enabled", function () { |
125 |
it("should allow renewal after override when AllowFineOverrideRenewing is enabled", function () { |
| 130 |
// Enable AllowFineOverrideRenewing |
126 |
// Enable AllowFineOverrideRenewing |
| 131 |
cy.task("query", { |
127 |
cy.set_syspref("AllowFineOverrideRenewing", "1"); |
| 132 |
sql: "UPDATE systempreferences SET value = '1' WHERE variable = 'AllowFineOverrideRenewing'", |
|
|
| 133 |
}); |
| 134 |
|
128 |
|
| 135 |
const barcode = this.testObjects.item.barcode; |
129 |
const barcode = this.testObjects.items[0].external_id; |
| 136 |
|
130 |
|
| 137 |
// Visit renewal page |
131 |
// Visit renewal page |
| 138 |
cy.visit("/cgi-bin/koha/circ/renew.pl"); |
132 |
cy.visit("/cgi-bin/koha/circ/renew.pl"); |
| 139 |
|
133 |
|
| 140 |
// Enter barcode |
134 |
// Enter barcode |
| 141 |
cy.get("#barcode").type(barcode); |
135 |
cy.get("#barcode").type(barcode); |
| 142 |
cy.get("form").submit(); |
136 |
cy.get("#barcode").closest("form").submit(); |
| 143 |
|
137 |
|
| 144 |
// Click override button |
138 |
// Click override button |
| 145 |
cy.get('.dialog.alert form button[type="submit"].approve').click(); |
139 |
cy.get('.dialog.alert form button[type="submit"].approve').click(); |
|
Lines 160-176
describe("Circulation - FineNoRenewals and AllowFineOverrideRenewing", () => {
Link Here
|
| 160 |
cy.task("query", { |
154 |
cy.task("query", { |
| 161 |
sql: `INSERT INTO accountlines (borrowernumber, amountoutstanding, debit_type_code, status, interface, itemnumber) |
155 |
sql: `INSERT INTO accountlines (borrowernumber, amountoutstanding, debit_type_code, status, interface, itemnumber) |
| 162 |
VALUES (?, 3.00, 'OVERDUE', 'UNRETURNED', 'test', ?)`, |
156 |
VALUES (?, 3.00, 'OVERDUE', 'UNRETURNED', 'test', ?)`, |
| 163 |
values: [patron.patron_id, this.testObjects.item.item_id], |
157 |
values: [patron.patron_id, this.testObjects.items[0].item_id], |
| 164 |
}); |
158 |
}); |
| 165 |
|
159 |
|
| 166 |
const barcode = this.testObjects.item.barcode; |
160 |
const barcode = this.testObjects.items[0].external_id; |
| 167 |
|
161 |
|
| 168 |
// Visit renewal page |
162 |
// Visit renewal page |
| 169 |
cy.visit("/cgi-bin/koha/circ/renew.pl"); |
163 |
cy.visit("/cgi-bin/koha/circ/renew.pl"); |
| 170 |
|
164 |
|
| 171 |
// Enter barcode |
165 |
// Enter barcode |
| 172 |
cy.get("#barcode").type(barcode); |
166 |
cy.get("#barcode").type(barcode); |
| 173 |
cy.get("form").submit(); |
167 |
cy.get("#barcode").closest("form").submit(); |
| 174 |
|
168 |
|
| 175 |
// Should see success message (no error about fines) |
169 |
// Should see success message (no error about fines) |
| 176 |
cy.get(".dialog.message").should("be.visible"); |
170 |
cy.get(".dialog.message").should("be.visible"); |
| 177 |
- |
|
|