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>
116 lines
4.2 KiB
Swift
116 lines
4.2 KiB
Swift
//
|
|
// RegionMapSelectorTests.swift
|
|
// SportsTimeTests
|
|
//
|
|
// Regression tests for map tap → region coordinate detection.
|
|
// Bug: invisible accessibility buttons intercepted taps before the
|
|
// coordinate-based logic, causing offset selection (tapping West
|
|
// selected Central). Fix: .allowsHitTesting(false) on button overlay.
|
|
//
|
|
|
|
import CoreLocation
|
|
import Testing
|
|
@testable import SportsTime
|
|
|
|
@Suite("RegionMapSelector — regionForCoordinate")
|
|
@MainActor
|
|
struct RegionMapSelectorTests {
|
|
|
|
// MARK: - West Region (longitude < -102)
|
|
|
|
@Test("West: Los Angeles (-118.24)")
|
|
func west_losAngeles() {
|
|
let coord = CLLocationCoordinate2D(latitude: 34.05, longitude: -118.24)
|
|
#expect(RegionMapSelector.regionForCoordinate(coord) == .west)
|
|
}
|
|
|
|
@Test("West: Seattle (-122.33)")
|
|
func west_seattle() {
|
|
let coord = CLLocationCoordinate2D(latitude: 47.61, longitude: -122.33)
|
|
#expect(RegionMapSelector.regionForCoordinate(coord) == .west)
|
|
}
|
|
|
|
@Test("West: Phoenix (-112.07)")
|
|
func west_phoenix() {
|
|
let coord = CLLocationCoordinate2D(latitude: 33.45, longitude: -112.07)
|
|
#expect(RegionMapSelector.regionForCoordinate(coord) == .west)
|
|
}
|
|
|
|
@Test("West: just inside boundary (-102.01)")
|
|
func west_boundary() {
|
|
let coord = CLLocationCoordinate2D(latitude: 39.0, longitude: -102.01)
|
|
#expect(RegionMapSelector.regionForCoordinate(coord) == .west)
|
|
}
|
|
|
|
// MARK: - Central Region (-102 to -89)
|
|
|
|
@Test("Central: Kansas City (-94.58)")
|
|
func central_kansasCity() {
|
|
let coord = CLLocationCoordinate2D(latitude: 39.10, longitude: -94.58)
|
|
#expect(RegionMapSelector.regionForCoordinate(coord) == .central)
|
|
}
|
|
|
|
@Test("Central: Dallas (-96.80)")
|
|
func central_dallas() {
|
|
let coord = CLLocationCoordinate2D(latitude: 32.78, longitude: -96.80)
|
|
#expect(RegionMapSelector.regionForCoordinate(coord) == .central)
|
|
}
|
|
|
|
@Test("Central: Chicago (-87.62) — actually East by longitude boundary")
|
|
func central_chicago() {
|
|
let coord = CLLocationCoordinate2D(latitude: 41.88, longitude: -87.6553)
|
|
#expect(RegionMapSelector.regionForCoordinate(coord) == .east)
|
|
}
|
|
|
|
@Test("Central: exactly at west boundary (-102)")
|
|
func central_westBoundary() {
|
|
let coord = CLLocationCoordinate2D(latitude: 39.0, longitude: -102.0)
|
|
#expect(RegionMapSelector.regionForCoordinate(coord) == .central)
|
|
}
|
|
|
|
@Test("Central: exactly at east boundary (-89)")
|
|
func central_eastBoundary() {
|
|
let coord = CLLocationCoordinate2D(latitude: 39.0, longitude: -89.0)
|
|
#expect(RegionMapSelector.regionForCoordinate(coord) == .central)
|
|
}
|
|
|
|
// MARK: - East Region (longitude > -89)
|
|
|
|
@Test("East: New York (-73.99)")
|
|
func east_newYork() {
|
|
let coord = CLLocationCoordinate2D(latitude: 40.71, longitude: -73.99)
|
|
#expect(RegionMapSelector.regionForCoordinate(coord) == .east)
|
|
}
|
|
|
|
@Test("East: Miami (-80.19)")
|
|
func east_miami() {
|
|
let coord = CLLocationCoordinate2D(latitude: 25.76, longitude: -80.19)
|
|
#expect(RegionMapSelector.regionForCoordinate(coord) == .east)
|
|
}
|
|
|
|
@Test("East: Atlanta (-84.39)")
|
|
func east_atlanta() {
|
|
let coord = CLLocationCoordinate2D(latitude: 33.75, longitude: -84.39)
|
|
#expect(RegionMapSelector.regionForCoordinate(coord) == .east)
|
|
}
|
|
|
|
@Test("East: just outside boundary (-88.99)")
|
|
func east_boundary() {
|
|
let coord = CLLocationCoordinate2D(latitude: 39.0, longitude: -88.99)
|
|
#expect(RegionMapSelector.regionForCoordinate(coord) == .east)
|
|
}
|
|
|
|
// MARK: - Regression: original bug scenario
|
|
|
|
@Test("Regression: tapping visual West region should not select Central")
|
|
func regression_westTapNotCentral() {
|
|
// User reported tapping the West overlay (around -108 longitude)
|
|
// was selecting Central due to accessibility button overlay intercepting.
|
|
// With .allowsHitTesting(false), the coordinate logic is now used.
|
|
let westernTap = CLLocationCoordinate2D(latitude: 40.0, longitude: -108.0)
|
|
let result = RegionMapSelector.regionForCoordinate(westernTap)
|
|
#expect(result == .west, "Tapping at -108° longitude must select West, not Central")
|
|
#expect(result != .central)
|
|
}
|
|
}
|