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:
@@ -32,7 +32,7 @@ struct TripPlanningEngineTests {
|
||||
func drivingConstraints_clampsNegativeDrivers() {
|
||||
let constraints = DrivingConstraints(numberOfDrivers: -5, maxHoursPerDriverPerDay: 8.0)
|
||||
#expect(constraints.numberOfDrivers == 1)
|
||||
#expect(constraints.maxDailyDrivingHours >= 1.0)
|
||||
#expect(constraints.maxDailyDrivingHours == 8.0)
|
||||
}
|
||||
|
||||
@Test("DrivingConstraints: clamps zero hours to minimum")
|
||||
@@ -89,9 +89,11 @@ struct TripPlanningEngineTests {
|
||||
func invariant_totalDriverHoursPositive() {
|
||||
let prefs1 = TripPreferences(numberOfDrivers: 1)
|
||||
#expect(prefs1.totalDriverHoursPerDay > 0)
|
||||
#expect(prefs1.totalDriverHoursPerDay == 8.0) // 1 driver × 8 hrs
|
||||
|
||||
let prefs2 = TripPreferences(numberOfDrivers: 3, maxDrivingHoursPerDriver: 4)
|
||||
#expect(prefs2.totalDriverHoursPerDay > 0)
|
||||
#expect(prefs2.totalDriverHoursPerDay == 12.0) // 3 drivers × 4 hrs
|
||||
}
|
||||
|
||||
@Test("Invariant: effectiveTripDuration >= 1")
|
||||
@@ -102,6 +104,10 @@ struct TripPlanningEngineTests {
|
||||
let prefs = TripPreferences(tripDuration: duration)
|
||||
#expect(prefs.effectiveTripDuration >= 1)
|
||||
}
|
||||
|
||||
// Verify specific value for nil duration with default dates
|
||||
let prefsNil = TripPreferences(tripDuration: nil)
|
||||
#expect(prefsNil.effectiveTripDuration == 8) // Default 7-day range = 8 days inclusive
|
||||
}
|
||||
|
||||
// MARK: - Travel Segment Validation
|
||||
@@ -189,7 +195,7 @@ struct TripPlanningEngineTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test("planTrip: invalid options are filtered out")
|
||||
@Test("ItineraryOption.isValid: correctly validates segment count")
|
||||
func planTrip_invalidOptions_areFilteredOut() {
|
||||
// Create a valid ItineraryOption manually with wrong segment count
|
||||
let stop1 = ItineraryStop(
|
||||
|
||||
Reference in New Issue
Block a user