Stabilize unit and UI tests for SportsTime

This commit is contained in:
treyt
2026-02-18 13:00:15 -06:00
parent 1488be7c1f
commit 20ac1a7e59
49 changed files with 432 additions and 325 deletions

View File

@@ -15,7 +15,7 @@ struct ScenarioAPlannerTests {
// MARK: - Test Data
private let planner = ScenarioAPlanner()
private let calendar = Calendar.current
private let calendar = TestClock.calendar
// Coordinates for testing
private let nycCoord = CLLocationCoordinate2D(latitude: 40.7580, longitude: -73.9855)
@@ -27,7 +27,7 @@ struct ScenarioAPlannerTests {
@Test("plan: no games in date range returns noGamesInRange failure")
func plan_noGamesInRange_returnsFailure() {
let startDate = Date()
let startDate = TestClock.now
let endDate = startDate.addingTimeInterval(86400 * 7)
let prefs = TripPreferences(
@@ -58,7 +58,7 @@ struct ScenarioAPlannerTests {
@Test("plan: games outside date range returns noGamesInRange")
func plan_gamesOutsideDateRange_returnsNoGamesInRange() {
let startDate = Date()
let startDate = TestClock.now
let endDate = startDate.addingTimeInterval(86400 * 7)
// Game is after the date range
@@ -97,7 +97,7 @@ struct ScenarioAPlannerTests {
@Test("plan: with selectedRegions filters to those regions")
func plan_withSelectedRegions_filtersGames() {
let startDate = Date()
let startDate = TestClock.now
let endDate = startDate.addingTimeInterval(86400 * 7)
let gameDate = startDate.addingTimeInterval(86400 * 2)
@@ -144,7 +144,7 @@ struct ScenarioAPlannerTests {
@Test("plan: with mustStopLocation filters to that city")
func plan_withMustStopLocation_filtersToCity() {
let startDate = Date()
let startDate = TestClock.now
let endDate = startDate.addingTimeInterval(86400 * 14)
let gameDate = startDate.addingTimeInterval(86400 * 2)
@@ -185,7 +185,7 @@ struct ScenarioAPlannerTests {
@Test("plan: mustStopLocation with no games in that city returns noGamesInRange")
func plan_mustStopNoGamesInCity_returnsNoGamesInRange() {
let startDate = Date()
let startDate = TestClock.now
let endDate = startDate.addingTimeInterval(86400 * 7)
let gameDate = startDate.addingTimeInterval(86400 * 2)
@@ -222,7 +222,7 @@ struct ScenarioAPlannerTests {
@Test("plan: multiple must-stop cities are required without excluding other route games")
func plan_multipleMustStops_requireCoverageWithoutExclusiveFiltering() {
let startDate = Date()
let startDate = TestClock.now
let endDate = startDate.addingTimeInterval(86400 * 10)
let nycStadium = makeStadium(id: "nyc", city: "New York", coordinate: nycCoord)
@@ -273,7 +273,7 @@ struct ScenarioAPlannerTests {
@Test("plan: single game in range returns success with one option")
func plan_singleGame_returnsSuccess() {
let startDate = Date()
let startDate = TestClock.now
let endDate = startDate.addingTimeInterval(86400 * 7)
let gameDate = startDate.addingTimeInterval(86400 * 2)
@@ -309,7 +309,7 @@ struct ScenarioAPlannerTests {
@Test("plan: multiple games at same stadium creates single stop")
func plan_multipleGamesAtSameStadium_createsSingleStop() {
let startDate = Date()
let startDate = TestClock.now
let endDate = startDate.addingTimeInterval(86400 * 7)
let stadium = makeStadium(id: "stadium1", city: "New York", coordinate: nycCoord)
@@ -353,7 +353,7 @@ struct ScenarioAPlannerTests {
@Test("Invariant: returned games are within date range")
func invariant_returnedGamesWithinDateRange() {
let startDate = Date()
let startDate = TestClock.now
let endDate = startDate.addingTimeInterval(86400 * 7)
let stadium = makeStadium(id: "stadium1", city: "New York", coordinate: nycCoord)
@@ -388,7 +388,7 @@ struct ScenarioAPlannerTests {
@Test("Invariant: A-B-A creates 3 stops not 2")
func invariant_visitSameCityTwice_createsThreeStops() {
let startDate = Date()
let startDate = TestClock.now
let endDate = startDate.addingTimeInterval(86400 * 10)
let nycStadium = makeStadium(id: "nyc", city: "New York", coordinate: nycCoord)
@@ -437,7 +437,7 @@ struct ScenarioAPlannerTests {
@Test("Property: success always has non-empty options")
func property_successHasNonEmptyOptions() {
let startDate = Date()
let startDate = TestClock.now
let endDate = startDate.addingTimeInterval(86400 * 7)
let stadium = makeStadium(id: "stadium1", city: "New York", coordinate: nycCoord)