Scheduling rule tests
These run now in your browser against fixed dates (week of 7 Oct 2026) and a fixed "now", so results never depend on today's clock. They exercise the exact same rule code used by /book, rescheduling, and the /demo claim step. The same cases run as automated tests in the codebase.
27 of 27 passed
Portland time
- PASSSummer offset is UTC−7 (PDT)
- PASSWinter offset is UTC−8 (PST)
- PASS9:00 AM PT in December = 17:00 UTC
Mon–Fri 9–5
- PASSFirst weekday start is 9:00 AM PT
- PASSLast 30-min start is 4:30 PM PT (ends 5:00)
- PASSLast 45-min start is 4:15 PM PT
- PASSSaturday has no slots
- PASSSunday has no slots
1-hour lead time
- PASSAt 8:30 AM, 9:00 and 9:15 are too soon
- PASSAt 8:30 AM, 9:30 is the first bookable start
- PASSSaving a too-soon start is rejected
Duration + 15-min turnover
- PASS9:15 (ends 9:45, 15 min gap) stays open
- PASS9:30 (ends 10:00, no gap) is blocked
- PASS10:30 (no gap after) is blocked
- PASS10:45 (15 min after) is open
- PASSA 45-min visit at 9:00 (ends 9:45) fits before 10:00
Overlap rejection
- PASSSaving 10:15 over a 10:00 visit is rejected
- PASSRaw overlap detector flags touching visits
- PASSSaving an off-grid 10:07 start is rejected
Reschedule
- PASSMoving X onto Y's 11:00 is rejected
- PASSMoving X to 2:00 PM is allowed
- PASSAfter the move, X's old 10:00 slot is released
- PASS…and X's new 2:00 PM slot is now taken
No availability
- PASSA fully booked Wednesday has no open slots
- PASSNext open time is Thursday 9:00 AM PT
- PASSA full Friday skips the weekend to Monday 9:00 AM
- PASSNothing open for 21 days → null (call the clinic)
What is and isn't protected on the server
- Saving a booking and rescheduling re-run these rules on the server against the live schedule (the old appointment is excluded, so its slot is released on move). A bad or taken time is rejected.
- The check and the save are two steps, not one database transaction — two patients submitting the same slot in the same instant could in theory both succeed. There's no database-level lock yet.
- The /demo page runs these rules in your browser on synthetic data only.