Harden planning test suite with realistic fixtures and output sanity checks

Adds messy/realistic data factories to TestFixtures, new PlannerOutputSanityTests,
and updates all scenario planner tests with improved coverage and assertions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Trey T
2026-04-04 13:38:41 -05:00
parent 188076717b
commit 9b622f8bbb
13 changed files with 2174 additions and 446 deletions

View File

@@ -278,15 +278,14 @@ struct TravelIntegrity_EngineGateTests {
let engine = TripPlanningEngine()
let result = engine.planItineraries(request: request)
if case .success(let options) = result {
for (i, option) in options.enumerated() {
#expect(option.isValid,
"Option \(i) has \(option.stops.count) stops but \(option.travelSegments.count) segments — INVALID")
// Double-check the math
if option.stops.count > 1 {
#expect(option.travelSegments.count == option.stops.count - 1,
"Option \(i): \(option.stops.count) stops must have \(option.stops.count - 1) segments, got \(option.travelSegments.count)")
}
guard case .success(let options) = result else { Issue.record("Expected .success, got \(result)"); return }
for (i, option) in options.enumerated() {
#expect(option.isValid,
"Option \(i) has \(option.stops.count) stops but \(option.travelSegments.count) segments — INVALID")
// Double-check the math
if option.stops.count > 1 {
#expect(option.travelSegments.count == option.stops.count - 1,
"Option \(i): \(option.stops.count) stops must have \(option.stops.count - 1) segments, got \(option.travelSegments.count)")
}
}
}
@@ -624,19 +623,18 @@ struct TravelIntegrity_EdgeCaseTests {
let engine = TripPlanningEngine()
let result = engine.planItineraries(request: request)
if case .success(let options) = result {
for option in options {
for i in 0..<option.travelSegments.count {
let segment = option.travelSegments[i]
let fromStop = option.stops[i]
let toStop = option.stops[i + 1]
guard case .success(let options) = result else { Issue.record("Expected .success, got \(result)"); return }
for option in options {
for i in 0..<option.travelSegments.count {
let segment = option.travelSegments[i]
let fromStop = option.stops[i]
let toStop = option.stops[i + 1]
// Segment endpoints should match stop cities
#expect(segment.fromLocation.name == fromStop.city,
"Segment \(i) from '\(segment.fromLocation.name)' should match stop '\(fromStop.city)'")
#expect(segment.toLocation.name == toStop.city,
"Segment \(i) to '\(segment.toLocation.name)' should match stop '\(toStop.city)'")
}
// Segment endpoints should match stop cities
#expect(segment.fromLocation.name == fromStop.city,
"Segment \(i) from '\(segment.fromLocation.name)' should match stop '\(fromStop.city)'")
#expect(segment.toLocation.name == toStop.city,
"Segment \(i) to '\(segment.toLocation.name)' should match stop '\(toStop.city)'")
}
}
}