=== Auto-Schedule API Error Handling Test === Cleaning up test data... Creating focused test user... ✓ Created user: ID 28 (focused interface) Test 1: Auto-schedule creation with SUCCESSFUL API call ======================================================== ✓ Study creation SUCCEEDED despite API being available - Study ID: 23 ✓ Schedule was created - Schedule ID: 17 - Status: 1 (1=active, 0=inactive) - Upcoming: 2026-01-28 07:12:25 ✓ Schedule is ACTIVE (correct!) ✓ Upcoming timestamp is SET (API succeeded) Test 2: Auto-schedule creation with API EXCEPTION ================================================== ✓ Study creation SUCCEEDED despite API failure (this is the key behavior!) - Study ID: 24 - This proves study creation is not blocked by API failures ✓ Schedule was created EVEN THOUGH API failed - Schedule ID: 18 - Status: 1 (1=active, 0=inactive) - Upcoming: NULL ✓ Schedule is ACTIVE (correct!) ✓ Upcoming is NULL as expected when API fails - This allows cron to calculate it later Test 3: Auto-schedule creation with API NULL response ====================================================== ✓ Study creation SUCCEEDED despite API returning NULL - Study ID: 25 ✓ Schedule was created despite API NULL response - Schedule ID: 19 - Status: 1 (1=active, 0=inactive) - Upcoming: NULL ✓ Schedule is ACTIVE ✓ Upcoming is NULL as expected Test 4: Standard user (should NOT auto-create schedule) ======================================================== ✓ Created standard user: ID 29 ✓ Study creation succeeded for standard user - Study ID: 26 ✓ Schedule was NOT auto-created for standard user (correct behavior) - Only focused users (interface=1) get auto-schedules === Test Summary === Key behaviors validated: ✓ Study creation succeeds even when API fails ✓ Schedule created with active=true regardless of API success/failure ✓ Upcoming = timestamp if API succeeds ✓ Upcoming = NULL if API fails ✓ Only focused users get auto-schedules ✓ No exceptions propagate to block study creation === Cron Handling Test === Found 4 active schedules with NULL upcoming ✓ These can be processed by cron using (upcoming IS NULL OR upcoming <= NOW()) query Cleaning up test data... === Test Complete ===