Stabilize unit and UI tests for SportsTime
This commit is contained in:
@@ -24,7 +24,7 @@ struct ScenarioBPlannerTests {
|
||||
|
||||
@Test("plan: no selected games returns failure")
|
||||
func plan_noSelectedGames_returnsFailure() {
|
||||
let startDate = Date()
|
||||
let startDate = TestClock.now
|
||||
let endDate = startDate.addingTimeInterval(86400 * 7)
|
||||
|
||||
let prefs = TripPreferences(
|
||||
@@ -58,7 +58,7 @@ struct ScenarioBPlannerTests {
|
||||
|
||||
@Test("plan: single selected game returns success with that game")
|
||||
func plan_singleSelectedGame_returnsSuccess() {
|
||||
let startDate = Date()
|
||||
let startDate = TestClock.now
|
||||
let endDate = startDate.addingTimeInterval(86400 * 7)
|
||||
let gameDate = startDate.addingTimeInterval(86400 * 2)
|
||||
|
||||
@@ -97,7 +97,7 @@ struct ScenarioBPlannerTests {
|
||||
|
||||
@Test("plan: all selected games appear in every route")
|
||||
func plan_allSelectedGamesAppearInRoutes() {
|
||||
let startDate = Date()
|
||||
let startDate = TestClock.now
|
||||
let endDate = startDate.addingTimeInterval(86400 * 10)
|
||||
|
||||
let nycStadium = makeStadium(id: "nyc", city: "New York", coordinate: nycCoord)
|
||||
@@ -147,7 +147,7 @@ struct ScenarioBPlannerTests {
|
||||
// Bug: planTrip() was overriding the 7-day date range with just anchor dates,
|
||||
// causing only the anchor game to appear in results.
|
||||
|
||||
let startDate = Date()
|
||||
let startDate = TestClock.now
|
||||
let endDate = startDate.addingTimeInterval(86400 * 7) // 7-day span
|
||||
|
||||
// NYC and Boston are geographically close (drivable)
|
||||
@@ -205,7 +205,7 @@ struct ScenarioBPlannerTests {
|
||||
// Regression test: Verify that the planner considers games across the entire
|
||||
// date range, not just on the anchor game dates.
|
||||
|
||||
let startDate = Date()
|
||||
let startDate = TestClock.now
|
||||
|
||||
// 7-day date range
|
||||
let day1 = startDate
|
||||
@@ -266,15 +266,15 @@ struct ScenarioBPlannerTests {
|
||||
let stadium = makeStadium(id: "stadium1", city: "New York", coordinate: nycCoord)
|
||||
|
||||
// Game on a specific date
|
||||
let gameDate = Date().addingTimeInterval(86400 * 5)
|
||||
let gameDate = TestClock.now.addingTimeInterval(86400 * 5)
|
||||
let game = makeGame(id: "game1", stadiumId: "stadium1", dateTime: gameDate)
|
||||
|
||||
let prefs = TripPreferences(
|
||||
planningMode: .gameFirst,
|
||||
sports: [.mlb],
|
||||
mustSeeGameIds: ["game1"],
|
||||
startDate: Date(),
|
||||
endDate: Date().addingTimeInterval(86400 * 30),
|
||||
startDate: TestClock.now,
|
||||
endDate: TestClock.now.addingTimeInterval(86400 * 30),
|
||||
leisureLevel: .moderate,
|
||||
lodgingType: .hotel,
|
||||
numberOfDrivers: 1,
|
||||
@@ -299,7 +299,7 @@ struct ScenarioBPlannerTests {
|
||||
|
||||
@Test("plan: explicit date range with out-of-range selected game returns dateRangeViolation")
|
||||
func plan_explicitDateRange_selectedGameOutsideRange_returnsDateRangeViolation() {
|
||||
let baseDate = Date()
|
||||
let baseDate = TestClock.now
|
||||
let rangeStart = baseDate
|
||||
let rangeEnd = baseDate.addingTimeInterval(86400 * 3)
|
||||
let outOfRangeDate = baseDate.addingTimeInterval(86400 * 10)
|
||||
@@ -347,7 +347,7 @@ struct ScenarioBPlannerTests {
|
||||
// This test verifies that ScenarioB uses arrival time validation
|
||||
// by creating a scenario where travel time makes arrival impossible
|
||||
|
||||
let now = Date()
|
||||
let now = TestClock.now
|
||||
let game1Date = now.addingTimeInterval(86400) // Tomorrow
|
||||
let game2Date = now.addingTimeInterval(86400 + 3600) // Tomorrow + 1 hour (impossible to drive from coast to coast)
|
||||
|
||||
@@ -389,7 +389,7 @@ struct ScenarioBPlannerTests {
|
||||
|
||||
@Test("Invariant: selected games cannot be dropped")
|
||||
func invariant_selectedGamesCannotBeDropped() {
|
||||
let startDate = Date()
|
||||
let startDate = TestClock.now
|
||||
let endDate = startDate.addingTimeInterval(86400 * 14)
|
||||
|
||||
let nycStadium = makeStadium(id: "nyc", city: "New York", coordinate: nycCoord)
|
||||
@@ -431,7 +431,7 @@ struct ScenarioBPlannerTests {
|
||||
|
||||
@Test("Property: success with selected games includes all anchors")
|
||||
func property_successIncludesAllAnchors() {
|
||||
let startDate = Date()
|
||||
let startDate = TestClock.now
|
||||
let endDate = startDate.addingTimeInterval(86400 * 7)
|
||||
let gameDate = startDate.addingTimeInterval(86400 * 2)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user