Audit and fix 52 test correctness issues across 22 files

Systematic audit of 1,191 tests found tests written to pass rather than
verify correctness. Key fixes:

Infrastructure:
- TestClock: fixed timezone from .current to America/New_York (deterministic)
- TestFixtures: added 1.3x road routing factor to match production
- ItineraryTestHelpers: real per-city coordinates instead of hardcoded (40,-80)

Planning tests:
- Added missing Scenario E factory dispatch tests
- Tightened 12 loose assertions (>= 1 → == 8.0, > 0 → range checks)
- Fixed 4 no-op tests that accepted both success and failure
- Fixed wrong repeat-city invariant (was checking same-day, not different-day)
- Fixed tautological assertion in missing-stadium edge case

Services/Domain/Export tests:
- Replaced 4 placeholder tests (#expect(true)) with real assertions
- Fixed tautological assertions in POISearchServiceTests
- Fixed Chicago coordinate in RegionMapSelectorTests (-89 → -87.6553)
- Added sort order verification to ItineraryRowFlatteningTests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Trey T
2026-04-04 23:00:46 -05:00
parent 9b622f8bbb
commit a6f538dfed
23 changed files with 265 additions and 109 deletions

View File

@@ -703,12 +703,23 @@ struct Bug15_DateArithmeticTests {
let planner = ScenarioBPlanner()
let result = planner.plan(request: request)
// Should not crash verify we get a valid result (success or failure, not a crash)
// Bug #15 was a force-unwrap crash in date arithmetic. The fix ensures safe
// optional unwrapping. Both outcomes are acceptable here because:
// - .success: date arithmetic worked and a route was found
// - .failure(.noValidRoutes): date arithmetic worked but driving constraints
// or game spacing prevented a valid route (BostonNYC in the available window)
// The critical assertion is that this code path does NOT crash (no force-unwrap trap).
switch result {
case .success(let options):
#expect(!options.isEmpty, "If success, should have at least one option")
case .failure:
break // Failure is acceptable the point is it didn't crash
case .failure(let failure):
// Any planning-related failure is acceptable the critical assertion is
// that the code path does NOT crash (no force-unwrap trap).
let acceptableReasons: [PlanningFailure.FailureReason] = [
.noValidRoutes, .noGamesInRange, .constraintsUnsatisfiable, .missingDateRange
]
#expect(acceptableReasons.contains { $0 == failure.reason },
"Expected a planning-related failure, got \(failure.reason)")
}
}
}