refactor(tests): TDD rewrite of all unit tests with spec documentation

Complete rewrite of unit test suite using TDD methodology:

Planning Engine Tests:
- GameDAGRouterTests: Beam search, anchor games, transitions
- ItineraryBuilderTests: Stop connection, validators, EV enrichment
- RouteFiltersTests: Region, time window, scoring filters
- ScenarioA/B/C/D PlannerTests: All planning scenarios
- TravelEstimatorTests: Distance, duration, travel days
- TripPlanningEngineTests: Orchestration, caching, preferences

Domain Model Tests:
- AchievementDefinitionsTests, AnySportTests, DivisionTests
- GameTests, ProgressTests, RegionTests, StadiumTests
- TeamTests, TravelSegmentTests, TripTests, TripPollTests
- TripPreferencesTests, TripStopTests, SportTests

Service Tests:
- FreeScoreAPITests, RouteDescriptionGeneratorTests
- SuggestedTripsGeneratorTests

Export Tests:
- ShareableContentTests (card types, themes, dimensions)

Bug fixes discovered through TDD:
- ShareCardDimensions: mapSnapshotSize exceeded available width (960x480)
- ScenarioBPlanner: Added anchor game validation filter

All tests include:
- Specification tests (expected behavior)
- Invariant tests (properties that must always hold)
- Edge case tests (boundary conditions)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-01-16 14:07:41 -06:00
parent 035dd6f5de
commit 8162b4a029
102 changed files with 13409 additions and 9883 deletions

View File

@@ -29,6 +29,22 @@ import CoreLocation
/// We find: @Red Sox (Jan 5), @Blue Jays (Jan 8), vs Orioles (Jan 12)
/// Output: Route visiting Boston Toronto New York
///
/// - Expected Behavior:
/// - No followTeamId returns .failure with .missingTeamSelection
/// - No date range returns .failure with .missingDateRange
/// - No team games found returns .failure with .noGamesInRange
/// - No games in date range/region returns .failure with .noGamesInRange
/// - filterToTeam returns BOTH home and away games for the team
/// - With selectedRegions only includes games in those regions
/// - No valid routes .failure with .noValidRoutes
/// - All routes fail constraints .failure with .constraintsUnsatisfiable
/// - Success returns sorted itineraries based on leisureLevel
///
/// - Invariants:
/// - All returned games have homeTeamId == teamId OR awayTeamId == teamId
/// - Games are chronologically ordered within each stop
/// - Duplicate routes are removed
///
final class ScenarioDPlanner: ScenarioPlanner {
// MARK: - ScenarioPlanner Protocol