This patch adds end-to-end Cypress tests for the booking modal improvements,
including smart window maximization and server-side optimal item selection.
New Tests:
1. "should successfully submit an 'Any item' booking with server-side optimal item selection"
- Tests the complete "any item" booking workflow
- Selects itemtype and "Any item" option (item_id = 0)
- Submits booking form
- Verifies modal closes without errors
- Validates booking created in database
- Confirms item was assigned by server
- Verifies server-side optimal selection completed
- Test status: PASSING
2. "should maximize booking window by dynamically reducing available items during overlaps"
- Creates 4 items with strategic booking patterns
- Tests "never re-add items to pool" algorithm
- Validates 5 scenarios:
a) Full window when all items available
b) Reduced window when Item 1 becomes unavailable
c) Further reduction when Items 1&2 unavailable
d) Minimal window with Items 1,2,3 unavailable
e) No availability when all items booked
- Demonstrates smart window maximization
- Test status: PASSING
3. "should handle edit mode date initialization correctly"
- Tests fix for edit mode race condition
- Verifies dates populate correctly when editing booking
- Ensures itemtype is set before date initialization
- Tests that flatpickr dates are set properly
- Test status: PASSING
Updated Tests:
- "should successfully submit a booking"
* Updated to use day+5 start date (accounts for 3-day lead period)
* Ensures test doesn't fail on past-date constraint
- Updated test comments and log messages to reflect server-side selection
* Changed from "client-side selectOptimalItem()" references
* Updated to "server-side optimal item selection"
* Clarified that server performs the optimal selection
Test Coverage:
- End-to-end "any item" booking submission
- Smart window maximization algorithm
- Edit mode date initialization
- Server-side optimal selection validation
- Database verification of assigned items
- Modal interaction and form submission
Test plan:
1. Start KTD environment
2. Ensure Cypress is installed: yarn install
3. Run: npx cypress run --spec "t/cypress/integration/Circulation/bookingsModalBasic_spec.ts"
4. Verify all 11 tests pass
5. Optionally run in interactive mode: npx cypress open
Signed-off-by: Kristi Krueger <kkrueger@cuyahogalibrary.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 9360ed6157)
Signed-off-by: Chloé Zermatten <chloe.zermatten@openfifth.co.uk>