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:
@@ -232,18 +232,16 @@ struct TravelEstimatorTests {
|
||||
|
||||
@Test("calculateTravelDays: all dates are start of day")
|
||||
func calculateTravelDays_allDatesAreStartOfDay() {
|
||||
let calendar = TestClock.calendar
|
||||
// Use a specific time that's not midnight
|
||||
var components = calendar.dateComponents([.year, .month, .day], from: TestClock.now)
|
||||
components.hour = 14
|
||||
components.minute = 30
|
||||
let departure = calendar.date(from: components)!
|
||||
// Production calculateTravelDays uses Calendar.current for startOfDay,
|
||||
// so assert with Calendar.current to match.
|
||||
let departure = TestFixtures.date(year: 2026, month: 6, day: 15, hour: 14, minute: 30)
|
||||
|
||||
let days = TravelEstimator.calculateTravelDays(departure: departure, drivingHours: 20)
|
||||
|
||||
let systemCalendar = Calendar.current
|
||||
for day in days {
|
||||
let hour = calendar.component(.hour, from: day)
|
||||
let minute = calendar.component(.minute, from: day)
|
||||
let hour = systemCalendar.component(.hour, from: day)
|
||||
let minute = systemCalendar.component(.minute, from: day)
|
||||
#expect(hour == 0 && minute == 0, "Expected midnight, got \(hour):\(minute)")
|
||||
}
|
||||
}
|
||||
@@ -411,7 +409,7 @@ struct TravelEstimatorTests {
|
||||
func edge_negativeDrivingHours() {
|
||||
let departure = TestClock.now
|
||||
let days = TravelEstimator.calculateTravelDays(departure: departure, drivingHours: -5)
|
||||
#expect(days.count >= 1, "Negative hours should still return at least 1 day")
|
||||
#expect(days.count == 1, "Negative hours should be treated as zero driving, returning exactly 1 day")
|
||||
}
|
||||
|
||||
// MARK: - Helper Methods
|
||||
|
||||
Reference in New Issue
Block a user