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

@@ -20,48 +20,6 @@ struct TripPlanningEngineTests {
private let chicagoCoord = CLLocationCoordinate2D(latitude: 41.8827, longitude: -87.6233)
private let laCoord = CLLocationCoordinate2D(latitude: 34.0430, longitude: -118.2673)
// MARK: - Specification Tests: Planning Mode Selection
@Test("planningMode: dateRange is valid mode")
func planningMode_dateRange() {
let prefs = TripPreferences(
planningMode: .dateRange,
sports: [.mlb]
)
#expect(prefs.planningMode == .dateRange)
}
@Test("planningMode: gameFirst is valid mode")
func planningMode_gameFirst() {
let prefs = TripPreferences(
planningMode: .gameFirst,
sports: [.mlb],
mustSeeGameIds: ["game1"]
)
#expect(prefs.planningMode == .gameFirst)
}
@Test("planningMode: followTeam is valid mode")
func planningMode_followTeam() {
let prefs = TripPreferences(
planningMode: .followTeam,
sports: [.mlb],
followTeamId: "yankees"
)
#expect(prefs.planningMode == .followTeam)
}
@Test("planningMode: locations is valid mode")
func planningMode_locations() {
let prefs = TripPreferences(
planningMode: .locations,
startLocation: LocationInput(name: "Chicago", coordinate: chicagoCoord),
endLocation: LocationInput(name: "New York", coordinate: nycCoord),
sports: [.mlb]
)
#expect(prefs.planningMode == .locations)
}
// MARK: - Specification Tests: Driving Constraints
@Test("DrivingConstraints: calculates maxDailyDrivingHours correctly")
@@ -177,12 +135,11 @@ struct TripPlanningEngineTests {
let engine = TripPlanningEngine()
let result = engine.planItineraries(request: request)
if case .success(let options) = result {
for option in options {
#expect(option.isValid, "Every returned option must be valid (segments = stops - 1)")
if option.stops.count > 1 {
#expect(option.travelSegments.count == option.stops.count - 1)
}
guard case .success(let options) = result else { Issue.record("Expected .success, got \(result)"); return }
for option in options {
#expect(option.isValid, "Every returned option must be valid (segments = stops - 1)")
if option.stops.count > 1 {
#expect(option.travelSegments.count == option.stops.count - 1)
}
}
}
@@ -219,16 +176,15 @@ struct TripPlanningEngineTests {
let engine = TripPlanningEngine()
let result = engine.planItineraries(request: request)
if case .success(let options) = result {
#expect(!options.isEmpty, "Should produce at least one option")
for option in options {
if option.stops.count > 1 {
#expect(option.travelSegments.count == option.stops.count - 1,
"Option with \(option.stops.count) stops must have exactly \(option.stops.count - 1) segments, got \(option.travelSegments.count)")
} else {
#expect(option.travelSegments.isEmpty,
"Single-stop option must have 0 segments")
}
guard case .success(let options) = result else { Issue.record("Expected .success, got \(result)"); return }
#expect(!options.isEmpty, "Should produce at least one option")
for option in options {
if option.stops.count > 1 {
#expect(option.travelSegments.count == option.stops.count - 1,
"Option with \(option.stops.count) stops must have exactly \(option.stops.count - 1) segments, got \(option.travelSegments.count)")
} else {
#expect(option.travelSegments.isEmpty,
"Single-stop option must have 0 segments")
}
}
}