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:
@@ -531,10 +531,18 @@ struct GameDAGRouterTests {
|
||||
constraints: constraints
|
||||
)
|
||||
|
||||
// May return routes with just game1, or empty
|
||||
#expect(routes.allSatisfy { route in
|
||||
route.allSatisfy { game in stadiums[game.stadiumId] != nil || game.id == game2.id }
|
||||
})
|
||||
// Multi-game routes should not include games with missing stadiums
|
||||
// (the router can't build transitions without stadium coordinates).
|
||||
// Single-game routes may still include them since no transition is needed.
|
||||
for route in routes where route.count > 1 {
|
||||
for game in route {
|
||||
#expect(stadiums[game.stadiumId] != nil,
|
||||
"Multi-game route should not include games with missing stadiums")
|
||||
}
|
||||
}
|
||||
|
||||
// The router should still return routes (at least the valid single-game route)
|
||||
#expect(!routes.isEmpty, "Should return at least the valid game as a single-game route")
|
||||
}
|
||||
|
||||
// MARK: - Route Preference Tests
|
||||
@@ -576,7 +584,7 @@ struct GameDAGRouterTests {
|
||||
let directMiles = totalMiles(for: directFirst, stadiums: stadiums)
|
||||
let scenicMiles = totalMiles(for: scenicFirst, stadiums: stadiums)
|
||||
// Direct should tend toward lower mileage routes being ranked first
|
||||
#expect(directMiles <= scenicMiles + 500, "Direct route should not be significantly longer than scenic")
|
||||
#expect(directMiles <= scenicMiles, "Direct first route (\(Int(directMiles))mi) should be <= scenic first route (\(Int(scenicMiles))mi)")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -606,6 +614,16 @@ struct GameDAGRouterTests {
|
||||
Set(route.compactMap { stadiums[$0.stadiumId]?.city }).count
|
||||
}.max() ?? 0
|
||||
#expect(maxCities >= 2, "Scenic should produce multi-city routes")
|
||||
|
||||
let directRoutes2 = GameDAGRouter.findRoutes(
|
||||
games: games, stadiums: stadiums, constraints: constraints,
|
||||
routePreference: .direct
|
||||
)
|
||||
if let sFirst = scenicRoutes.first, let dFirst = directRoutes2.first {
|
||||
let sCities = Set(sFirst.compactMap { stadiums[$0.stadiumId]?.city }).count
|
||||
let dCities = Set(dFirst.compactMap { stadiums[$0.stadiumId]?.city }).count
|
||||
#expect(sCities >= dCities, "Scenic first route should have >= cities than direct first route")
|
||||
}
|
||||
}
|
||||
|
||||
@Test("routePreference: balanced matches default behavior")
|
||||
@@ -629,6 +647,12 @@ struct GameDAGRouterTests {
|
||||
|
||||
// Both should produce the same routes (balanced is default)
|
||||
#expect(balancedRoutes.count == defaultRoutes.count)
|
||||
|
||||
if let bFirst = balancedRoutes.first, let dFirst = defaultRoutes.first {
|
||||
let bIds = bFirst.map { $0.id }
|
||||
let dIds = dFirst.map { $0.id }
|
||||
#expect(bIds == dIds, "Balanced and default should produce identical first route")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Route Preference Scoring Tests
|
||||
|
||||
Reference in New Issue
Block a user