Koha-clms/t/cypress/integration
Martin Renvoize 5a04483d45
Bug 40134: Add Cypress tests for booking improvements
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>
2026-03-23 11:44:45 +00:00
..
Acquisitions Bug 41593: (QA follow-up) Move cypress test 2026-01-28 09:59:11 +00:00
Admin Bug 41336: (follow-up) Fix breadcrumb selector in Cypress test 2025-12-03 08:20:03 -07:00
Auth Bug 40170: Replace cypress-mysql with mysql2 - Cypress tests 2025-07-08 15:42:03 -06:00
Circulation Bug 40134: Add Cypress tests for booking improvements 2026-03-23 11:44:45 +00:00
ERM Bug 41001: (QA follow-up): Add 'Confirmation messages with inputs' specific tests 2025-11-07 10:54:22 -07:00
Islands Bug 40170: Replace cypress-mysql with mysql2 - Cypress tests 2025-07-08 15:42:03 -06:00
KohaTable Bug 38311: Fix Selenium and Cypress tests 2025-12-02 10:07:20 -07:00
Patron Bug 40245: Update cypress test to handle ShowPatronFirstnameIfDifferentThanPreferredname 2025-11-07 10:54:11 -07:00
Preservation Bug 38201: Remove DT warnings from Cypress tests 2025-10-02 09:40:34 -06:00
SIP2 Bug 41214: Add cypress test 2026-03-16 13:23:08 +00:00
Tools Bug 41177: Adjust Cypress tests 2025-11-25 10:13:27 -07:00
t Bug 40345: Add insertSamplePatron 2025-07-21 14:01:25 -06:00
AdditionalFields_spec.ts Bug 38446: Add a dedicated route to retrieve ERM-related additional fields 2025-11-17 15:15:38 -07:00
Breadcrumbs_spec.ts Bug 38201: Add VueFramework cypress tests 2025-10-02 09:40:16 -06:00
InfiniteScrollSelect_spec.ts Bug 38475: Skip some tests in InfiniteScrollSelect_spec 2025-11-18 06:56:53 -07:00
PatronSearchDebounce_spec.ts Bug 41039: Add cypress tests 2025-11-18 06:56:54 -07:00
Toolbar_spec.ts Bug 40430: Fix Toolbar_spec.ts 2025-07-21 14:01:28 -06:00
VueFramework_spec.ts Bug 38201: Cypress fixes 2025-10-02 09:40:30 -06:00
flatpickr_spec.ts Revert "Bug 37493: [DONT PUSH] Test only - Force test fail" 2024-09-02 17:21:50 +02:00