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:
@@ -105,6 +105,18 @@ final class ItineraryRowFlatteningTests: XCTestCase {
|
||||
// Then: Items should appear in sortOrder: First (1.0), Second (2.0), Third (3.0)
|
||||
let rowCount = controller.tableView(controller.tableView, numberOfRowsInSection: 0)
|
||||
XCTAssertEqual(rowCount, 4, "Expected 4 rows: header + 3 items")
|
||||
|
||||
// Verify items are actually sorted by sortOrder (ascending)
|
||||
let rows = controller.flatItems
|
||||
let itemRows = rows.filter { $0.isReorderable }
|
||||
XCTAssertEqual(itemRows.count, 3, "Should have 3 reorderable items")
|
||||
|
||||
// Extract sortOrder values from the custom items
|
||||
let sortOrders: [Double] = itemRows.compactMap {
|
||||
if case .customItem(let item) = $0 { return item.sortOrder }
|
||||
return nil
|
||||
}
|
||||
XCTAssertEqual(sortOrders, [1.0, 2.0, 3.0], "Items should be in ascending sortOrder: First, Second, Third")
|
||||
}
|
||||
|
||||
// MARK: - Day Number Calculation Tests
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// Shared test fixtures and helpers for Itinerary tests.
|
||||
//
|
||||
|
||||
import CoreLocation
|
||||
import Foundation
|
||||
@testable import SportsTime
|
||||
|
||||
@@ -71,13 +72,14 @@ enum ItineraryTestHelpers {
|
||||
isPlayoff: false
|
||||
)
|
||||
|
||||
let coord = TestFixtures.coordinates[city] ?? CLLocationCoordinate2D(latitude: 40.0, longitude: -80.0)
|
||||
let stadium = Stadium(
|
||||
id: "stadium-\(city)",
|
||||
name: "\(city) Stadium",
|
||||
city: city,
|
||||
state: "XX",
|
||||
latitude: 40.0,
|
||||
longitude: -80.0,
|
||||
latitude: coord.latitude,
|
||||
longitude: coord.longitude,
|
||||
capacity: 40000,
|
||||
sport: .mlb
|
||||
)
|
||||
|
||||
@@ -56,10 +56,10 @@ struct RegionMapSelectorTests {
|
||||
#expect(RegionMapSelector.regionForCoordinate(coord) == .central)
|
||||
}
|
||||
|
||||
@Test("Central: Chicago (-87.62)")
|
||||
@Test("Central: Chicago (-87.62) — actually East by longitude boundary")
|
||||
func central_chicago() {
|
||||
let coord = CLLocationCoordinate2D(latitude: 41.88, longitude: -89.0)
|
||||
#expect(RegionMapSelector.regionForCoordinate(coord) == .central)
|
||||
let coord = CLLocationCoordinate2D(latitude: 41.88, longitude: -87.6553)
|
||||
#expect(RegionMapSelector.regionForCoordinate(coord) == .east)
|
||||
}
|
||||
|
||||
@Test("Central: exactly at west boundary (-102)")
|
||||
|
||||
Reference in New Issue
Block a user