// // TripSavingTests.swift // SportsTimeUITests // // Tests the end-to-end trip saving flow: plan → select → save → verify in My Trips. // import XCTest final class TripSavingTests: BaseUITestCase { /// Plans a trip, selects an option, saves it, and verifies it appears in My Trips. @MainActor func testSaveTripAppearsInMyTrips() { let home = HomeScreen(app: app) home.waitForLoad() home.tapStartPlanning() // Plan a trip using date range mode let wizard = TripWizardScreen(app: app) wizard.waitForLoad() wizard.selectDateRangeMode() wizard.nextMonthButton.scrollIntoView(in: app.scrollViews.firstMatch) wizard.selectDateRange( targetMonth: "June", targetYear: "2026", startDay: "2026-06-11", endDay: "2026-06-16" ) wizard.selectSport("mlb") wizard.selectRegion("central") wizard.tapPlanTrip() // Select first trip option let options = TripOptionsScreen(app: app) options.waitForLoad() options.selectTrip(at: 0) // Save the trip let detail = TripDetailScreen(app: app) detail.waitForLoad() detail.assertSaveState(isSaved: false) detail.tapFavorite() // Allow save to persist detail.assertSaveState(isSaved: true) captureScreenshot(named: "TripSaving-Favorited") // Navigate back to My Trips tab // Dismiss the entire wizard sheet: Detail → Options → Wizard → Cancel app.navigationBars.buttons.firstMatch.tap() // Back from detail to options // Back from options to wizard let wizardBackBtn = app.navigationBars.buttons.firstMatch wizardBackBtn.waitUntilHittable(timeout: BaseUITestCase.shortTimeout).tap() // Cancel the wizard sheet wizard.tapCancel() // Now the tab bar is accessible home.switchToTab(home.myTripsTab) // Assert: Saved trip appears (empty state should NOT be visible) let myTrips = MyTripsScreen(app: app) myTrips.assertHasTrips() } }