|
Lines 25-40
describe("Booking Modal Basic Tests", () => {
Link Here
|
| 25 |
testData = objects; |
25 |
testData = objects; |
| 26 |
|
26 |
|
| 27 |
// Update items to be bookable with different itemtypes |
27 |
// Update items to be bookable with different itemtypes |
| 28 |
return cy.task("query", { |
28 |
return cy |
| 29 |
sql: "UPDATE items SET bookable = 1, itype = 'BK', homebranch = 'CPL', enumchron = 'A', dateaccessioned = '2024-12-03' WHERE itemnumber = ?", |
29 |
.task("query", { |
| 30 |
values: [objects.items[0].item_id], |
30 |
sql: "UPDATE items SET bookable = 1, itype = 'BK', homebranch = 'CPL', enumchron = 'A', dateaccessioned = '2024-12-03' WHERE itemnumber = ?", |
| 31 |
}).then(() => cy.task("query", { |
31 |
values: [objects.items[0].item_id], |
| 32 |
sql: "UPDATE items SET bookable = 1, itype = 'CF', homebranch = 'CPL', enumchron = 'B', dateaccessioned = '2024-12-02' WHERE itemnumber = ?", |
32 |
}) |
| 33 |
values: [objects.items[1].item_id], |
33 |
.then(() => |
| 34 |
})).then(() => cy.task("query", { |
34 |
cy.task("query", { |
| 35 |
sql: "UPDATE items SET bookable = 1, itype = 'BK', homebranch = 'CPL', enumchron = 'C', dateaccessioned = '2024-12-01' WHERE itemnumber = ?", |
35 |
sql: "UPDATE items SET bookable = 1, itype = 'CF', homebranch = 'CPL', enumchron = 'B', dateaccessioned = '2024-12-02' WHERE itemnumber = ?", |
| 36 |
values: [objects.items[2].item_id], |
36 |
values: [objects.items[1].item_id], |
| 37 |
})); |
37 |
}) |
|
|
38 |
) |
| 39 |
.then(() => |
| 40 |
cy.task("query", { |
| 41 |
sql: "UPDATE items SET bookable = 1, itype = 'BK', homebranch = 'CPL', enumchron = 'C', dateaccessioned = '2024-12-01' WHERE itemnumber = ?", |
| 42 |
values: [objects.items[2].item_id], |
| 43 |
}) |
| 44 |
); |
| 38 |
}) |
45 |
}) |
| 39 |
.then(() => { |
46 |
.then(() => { |
| 40 |
// Create a test patron using upstream pattern |
47 |
// Create a test patron using upstream pattern |
|
Lines 92-104
describe("Booking Modal Basic Tests", () => {
Link Here
|
| 92 |
cy.get("#catalog_detail").should("be.visible"); |
99 |
cy.get("#catalog_detail").should("be.visible"); |
| 93 |
|
100 |
|
| 94 |
// The "Place booking" button should appear for bookable items |
101 |
// The "Place booking" button should appear for bookable items |
| 95 |
cy.get("[data-booking-modal]") |
102 |
cy.get("[data-booking-modal]").should("exist").and("be.visible"); |
| 96 |
.should("exist") |
|
|
| 97 |
.and("be.visible"); |
| 98 |
|
103 |
|
| 99 |
// Click to open the booking modal |
104 |
// Click to open the booking modal |
| 100 |
cy.get("booking-modal-island .modal").should("exist"); |
105 |
cy.get("booking-modal-island .modal").should("exist"); |
| 101 |
cy.get("[data-booking-modal]").first().then($btn => $btn[0].click()); |
106 |
cy.get("[data-booking-modal]") |
|
|
107 |
.first() |
| 108 |
.then($btn => $btn[0].click()); |
| 102 |
|
109 |
|
| 103 |
// Wait for modal to appear |
110 |
// Wait for modal to appear |
| 104 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
111 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
|
Lines 122-134
describe("Booking Modal Basic Tests", () => {
Link Here
|
| 122 |
cy.vueSelectShouldBeDisabled("booking_item_id"); |
129 |
cy.vueSelectShouldBeDisabled("booking_item_id"); |
| 123 |
|
130 |
|
| 124 |
// Period should be disabled initially |
131 |
// Period should be disabled initially |
| 125 |
cy.get("#booking_period") |
132 |
cy.get("#booking_period").should("exist").and("be.disabled"); |
| 126 |
.should("exist") |
|
|
| 127 |
.and("be.disabled"); |
| 128 |
|
133 |
|
| 129 |
// Verify form and submit button exist |
134 |
// Verify form and submit button exist |
| 130 |
cy.get('button[form="form-booking"][type="submit"]') |
135 |
cy.get('button[form="form-booking"][type="submit"]').should("exist"); |
| 131 |
.should("exist"); |
|
|
| 132 |
|
136 |
|
| 133 |
cy.get(".btn-close").should("exist"); |
137 |
cy.get(".btn-close").should("exist"); |
| 134 |
}); |
138 |
}); |
|
Lines 149-155
describe("Booking Modal Basic Tests", () => {
Link Here
|
| 149 |
|
153 |
|
| 150 |
// Open the modal |
154 |
// Open the modal |
| 151 |
cy.get("booking-modal-island .modal").should("exist"); |
155 |
cy.get("booking-modal-island .modal").should("exist"); |
| 152 |
cy.get("[data-booking-modal]").first().then($btn => $btn[0].click()); |
156 |
cy.get("[data-booking-modal]") |
|
|
157 |
.first() |
| 158 |
.then($btn => $btn[0].click()); |
| 153 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
159 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
| 154 |
"be.visible" |
160 |
"be.visible" |
| 155 |
); |
161 |
); |
|
Lines 175-207
describe("Booking Modal Basic Tests", () => {
Link Here
|
| 175 |
cy.vueSelectShouldBeEnabled("pickup_library_id"); |
181 |
cy.vueSelectShouldBeEnabled("pickup_library_id"); |
| 176 |
cy.vueSelectShouldBeEnabled("booking_itemtype"); |
182 |
cy.vueSelectShouldBeEnabled("booking_itemtype"); |
| 177 |
cy.vueSelectShouldBeEnabled("booking_item_id"); |
183 |
cy.vueSelectShouldBeEnabled("booking_item_id"); |
| 178 |
cy.get("#booking_period").should("be.disabled"); // Still disabled until itemtype/item selected |
|
|
| 179 |
|
| 180 |
// Step 4: Select pickup location |
| 181 |
cy.vueSelectByIndex("pickup_library_id", 0); |
| 182 |
|
| 183 |
// Step 5: Select item type - this triggers circulation rules API call |
| 184 |
cy.vueSelectByIndex("booking_itemtype", 0); // Select first available itemtype |
| 185 |
|
184 |
|
| 186 |
// Wait for circulation rules API call to complete |
185 |
// Wait for circulation rules API call to complete |
| 187 |
cy.wait("@getCirculationRules"); |
186 |
cy.wait("@getCirculationRules"); |
| 188 |
|
187 |
|
| 189 |
// After itemtype selection and circulation rules load, period should be enabled |
188 |
// "Any item" is a valid default — period enables without requiring |
|
|
189 |
// a specific item type or item selection |
| 190 |
cy.get("#booking_period").should("not.be.disabled"); |
190 |
cy.get("#booking_period").should("not.be.disabled"); |
| 191 |
|
191 |
|
| 192 |
// Step 6: Test clearing item type disables period again (comprehensive workflow) |
192 |
// Step 4: Select pickup location |
| 193 |
cy.vueSelectClear("booking_itemtype"); |
193 |
cy.vueSelectByIndex("pickup_library_id", 0); |
| 194 |
cy.get("#booking_period").should("be.disabled"); |
|
|
| 195 |
|
194 |
|
| 196 |
// Step 7: Select item instead of itemtype - this also triggers circulation rules |
195 |
// Step 5: Select item type |
| 197 |
cy.vueSelectByIndex("booking_item_id", 1); // Skip "Any item" option |
196 |
cy.vueSelectByIndex("booking_itemtype", 0); |
| 198 |
|
197 |
|
| 199 |
// Wait for circulation rules API call (item selection also triggers this) |
198 |
// Period remains enabled after itemtype selection |
| 200 |
cy.wait("@getCirculationRules"); |
199 |
cy.get("#booking_period").should("not.be.disabled"); |
| 201 |
|
200 |
|
| 202 |
// Period should be enabled after item selection and circulation rules load |
201 |
// Step 6: Clearing item type keeps period enabled ("any item" still valid) |
|
|
202 |
cy.vueSelectClear("booking_itemtype"); |
| 203 |
cy.get("#booking_period").should("not.be.disabled"); |
203 |
cy.get("#booking_period").should("not.be.disabled"); |
| 204 |
|
204 |
|
|
|
205 |
// Step 7: Select item instead of itemtype |
| 206 |
cy.vueSelectByIndex("booking_item_id", 1); |
| 207 |
|
| 208 |
// Period stays enabled after item selection |
| 209 |
cy.get("#booking_period").should("not.be.disabled"); |
| 205 |
}); |
210 |
}); |
| 206 |
|
211 |
|
| 207 |
it("should handle item type and item dependencies correctly", () => { |
212 |
it("should handle item type and item dependencies correctly", () => { |
|
Lines 220-226
describe("Booking Modal Basic Tests", () => {
Link Here
|
| 220 |
|
225 |
|
| 221 |
// Open the modal |
226 |
// Open the modal |
| 222 |
cy.get("booking-modal-island .modal").should("exist"); |
227 |
cy.get("booking-modal-island .modal").should("exist"); |
| 223 |
cy.get("[data-booking-modal]").first().then($btn => $btn[0].click()); |
228 |
cy.get("[data-booking-modal]") |
|
|
229 |
.first() |
| 230 |
.then($btn => $btn[0].click()); |
| 224 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
231 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
| 225 |
"be.visible" |
232 |
"be.visible" |
| 226 |
); |
233 |
); |
|
Lines 327-333
describe("Booking Modal Basic Tests", () => {
Link Here
|
| 327 |
|
334 |
|
| 328 |
// Open the modal |
335 |
// Open the modal |
| 329 |
cy.get("booking-modal-island .modal").should("exist"); |
336 |
cy.get("booking-modal-island .modal").should("exist"); |
| 330 |
cy.get("[data-booking-modal]").first().then($btn => $btn[0].click()); |
337 |
cy.get("[data-booking-modal]") |
|
|
338 |
.first() |
| 339 |
.then($btn => $btn[0].click()); |
| 331 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
340 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
| 332 |
"be.visible" |
341 |
"be.visible" |
| 333 |
); |
342 |
); |
|
Lines 348-354
describe("Booking Modal Basic Tests", () => {
Link Here
|
| 348 |
|
357 |
|
| 349 |
// Open the modal |
358 |
// Open the modal |
| 350 |
cy.get("booking-modal-island .modal").should("exist"); |
359 |
cy.get("booking-modal-island .modal").should("exist"); |
| 351 |
cy.get("[data-booking-modal]").first().then($btn => $btn[0].click()); |
360 |
cy.get("[data-booking-modal]") |
|
|
361 |
.first() |
| 362 |
.then($btn => $btn[0].click()); |
| 352 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
363 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
| 353 |
"be.visible" |
364 |
"be.visible" |
| 354 |
); |
365 |
); |
|
Lines 416-422
describe("Booking Modal Basic Tests", () => {
Link Here
|
| 416 |
|
427 |
|
| 417 |
// Open the modal |
428 |
// Open the modal |
| 418 |
cy.get("booking-modal-island .modal").should("exist"); |
429 |
cy.get("booking-modal-island .modal").should("exist"); |
| 419 |
cy.get("[data-booking-modal]").first().then($btn => $btn[0].click()); |
430 |
cy.get("[data-booking-modal]") |
|
|
431 |
.first() |
| 432 |
.then($btn => $btn[0].click()); |
| 420 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
433 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
| 421 |
"be.visible" |
434 |
"be.visible" |
| 422 |
); |
435 |
); |
|
Lines 505-511
describe("Booking Modal Basic Tests", () => {
Link Here
|
| 505 |
|
518 |
|
| 506 |
// Open the modal |
519 |
// Open the modal |
| 507 |
cy.get("booking-modal-island .modal").should("exist"); |
520 |
cy.get("booking-modal-island .modal").should("exist"); |
| 508 |
cy.get("[data-booking-modal]").first().then($btn => $btn[0].click()); |
521 |
cy.get("[data-booking-modal]") |
|
|
522 |
.first() |
| 523 |
.then($btn => $btn[0].click()); |
| 509 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
524 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
| 510 |
"be.visible" |
525 |
"be.visible" |
| 511 |
); |
526 |
); |
|
Lines 562-568
describe("Booking Modal Basic Tests", () => {
Link Here
|
| 562 |
|
577 |
|
| 563 |
// Open booking modal |
578 |
// Open booking modal |
| 564 |
cy.get("booking-modal-island .modal").should("exist"); |
579 |
cy.get("booking-modal-island .modal").should("exist"); |
| 565 |
cy.get("[data-booking-modal]").first().then($btn => $btn[0].click()); |
580 |
cy.get("[data-booking-modal]") |
|
|
581 |
.first() |
| 582 |
.then($btn => $btn[0].click()); |
| 566 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
583 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
| 567 |
"be.visible" |
584 |
"be.visible" |
| 568 |
); |
585 |
); |
|
Lines 596-603
describe("Booking Modal Basic Tests", () => {
Link Here
|
| 596 |
cy.get("#booking_period").should($el => { |
613 |
cy.get("#booking_period").should($el => { |
| 597 |
const fp = $el[0]._flatpickr; |
614 |
const fp = $el[0]._flatpickr; |
| 598 |
expect(fp.selectedDates.length).to.eq(2); |
615 |
expect(fp.selectedDates.length).to.eq(2); |
| 599 |
expect(dayjs(fp.selectedDates[0]).format("YYYY-MM-DD")).to.eq(startDate.format("YYYY-MM-DD")); |
616 |
expect(dayjs(fp.selectedDates[0]).format("YYYY-MM-DD")).to.eq( |
| 600 |
expect(dayjs(fp.selectedDates[1]).format("YYYY-MM-DD")).to.eq(endDate.format("YYYY-MM-DD")); |
617 |
startDate.format("YYYY-MM-DD") |
|
|
618 |
); |
| 619 |
expect(dayjs(fp.selectedDates[1]).format("YYYY-MM-DD")).to.eq( |
| 620 |
endDate.format("YYYY-MM-DD") |
| 621 |
); |
| 601 |
}); |
622 |
}); |
| 602 |
|
623 |
|
| 603 |
// Verify the period field is populated |
624 |
// Verify the period field is populated |
|
Lines 686-695
describe("Booking Modal Basic Tests", () => {
Link Here
|
| 686 |
cy.log("✓ Edit modal opened with pre-populated data"); |
707 |
cy.log("✓ Edit modal opened with pre-populated data"); |
| 687 |
|
708 |
|
| 688 |
// Verify core edit fields are pre-populated |
709 |
// Verify core edit fields are pre-populated |
| 689 |
cy.vueSelectShouldHaveValue( |
710 |
cy.vueSelectShouldHaveValue("booking_patron", testData.patron.surname); |
| 690 |
"booking_patron", |
|
|
| 691 |
testData.patron.surname |
| 692 |
); |
| 693 |
cy.log("✓ Patron field pre-populated correctly"); |
711 |
cy.log("✓ Patron field pre-populated correctly"); |
| 694 |
|
712 |
|
| 695 |
// Test that the booking can be retrieved via the real API |
713 |
// Test that the booking can be retrieved via the real API |
|
Lines 799-805
describe("Booking Modal Basic Tests", () => {
Link Here
|
| 799 |
`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${testData.biblio.biblio_id}` |
817 |
`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${testData.biblio.biblio_id}` |
| 800 |
); |
818 |
); |
| 801 |
cy.get("booking-modal-island .modal").should("exist"); |
819 |
cy.get("booking-modal-island .modal").should("exist"); |
| 802 |
cy.get("[data-booking-modal]").first().then($btn => $btn[0].click()); |
820 |
cy.get("[data-booking-modal]") |
|
|
821 |
.first() |
| 822 |
.then($btn => $btn[0].click()); |
| 803 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
823 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
| 804 |
"be.visible" |
824 |
"be.visible" |
| 805 |
); |
825 |
); |
|
Lines 899-905
describe("Booking Modal Basic Tests", () => {
Link Here
|
| 899 |
); |
919 |
); |
| 900 |
|
920 |
|
| 901 |
cy.get("booking-modal-island .modal").should("exist"); |
921 |
cy.get("booking-modal-island .modal").should("exist"); |
| 902 |
cy.get("[data-booking-modal]").first().then($btn => $btn[0].click()); |
922 |
cy.get("[data-booking-modal]") |
|
|
923 |
.first() |
| 924 |
.then($btn => $btn[0].click()); |
| 903 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
925 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
| 904 |
"be.visible" |
926 |
"be.visible" |
| 905 |
); |
927 |
); |
|
Lines 919-925
describe("Booking Modal Basic Tests", () => {
Link Here
|
| 919 |
cy.get("body").should("not.have.class", "modal-open"); |
941 |
cy.get("body").should("not.have.class", "modal-open"); |
| 920 |
|
942 |
|
| 921 |
// Reopen and verify state is reset |
943 |
// Reopen and verify state is reset |
| 922 |
cy.get("[data-booking-modal]").first().then($btn => $btn[0].click()); |
944 |
cy.get("[data-booking-modal]") |
|
|
945 |
.first() |
| 946 |
.then($btn => $btn[0].click()); |
| 923 |
cy.get("booking-modal-island .modal.show", { timeout: 10000 }).should( |
947 |
cy.get("booking-modal-island .modal.show", { timeout: 10000 }).should( |
| 924 |
"be.visible" |
948 |
"be.visible" |
| 925 |
); |
949 |
); |
|
Lines 960-966
describe("Booking Modal Basic Tests", () => {
Link Here
|
| 960 |
); |
984 |
); |
| 961 |
|
985 |
|
| 962 |
cy.get("booking-modal-island .modal").should("exist"); |
986 |
cy.get("booking-modal-island .modal").should("exist"); |
| 963 |
cy.get("[data-booking-modal]").first().then($btn => $btn[0].click()); |
987 |
cy.get("[data-booking-modal]") |
|
|
988 |
.first() |
| 989 |
.then($btn => $btn[0].click()); |
| 964 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
990 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
| 965 |
"be.visible" |
991 |
"be.visible" |
| 966 |
); |
992 |
); |
|
Lines 1007-1013
describe("Booking Modal Basic Tests", () => {
Link Here
|
| 1007 |
); |
1033 |
); |
| 1008 |
|
1034 |
|
| 1009 |
cy.get("booking-modal-island .modal").should("exist"); |
1035 |
cy.get("booking-modal-island .modal").should("exist"); |
| 1010 |
cy.get("[data-booking-modal]").first().then($btn => $btn[0].click()); |
1036 |
cy.get("[data-booking-modal]") |
|
|
1037 |
.first() |
| 1038 |
.then($btn => $btn[0].click()); |
| 1011 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
1039 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
| 1012 |
"be.visible" |
1040 |
"be.visible" |
| 1013 |
); |
1041 |
); |
|
Lines 1058-1064
describe("Booking Modal Basic Tests", () => {
Link Here
|
| 1058 |
); |
1086 |
); |
| 1059 |
|
1087 |
|
| 1060 |
cy.get("booking-modal-island .modal").should("exist"); |
1088 |
cy.get("booking-modal-island .modal").should("exist"); |
| 1061 |
cy.get("[data-booking-modal]").first().then($btn => $btn[0].click()); |
1089 |
cy.get("[data-booking-modal]") |
|
|
1090 |
.first() |
| 1091 |
.then($btn => $btn[0].click()); |
| 1062 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
1092 |
cy.get("booking-modal-island .modal", { timeout: 10000 }).should( |
| 1063 |
"be.visible" |
1093 |
"be.visible" |
| 1064 |
); |
1094 |
); |
| 1065 |
- |
|
|