// // HomeTests.swift // SportsTimeUITests // // Tests for the Home tab: hero card, start planning, and toolbar button. // QA Sheet: F-012, F-013, F-020 // import XCTest final class HomeTests: BaseUITestCase { /// F-012: Hero card displays — "Adventure Awaits" text visible, Start Planning tappable. @MainActor func testF012_HeroCardDisplaysCorrectly() { let home = HomeScreen(app: app) home.waitForLoad() XCTAssertTrue(home.adventureAwaitsText.exists, "Hero card should display 'Adventure Awaits'") XCTAssertTrue(home.startPlanningButton.isHittable, "Start Planning button should be tappable") captureScreenshot(named: "F012-HeroCard") } /// F-013: Start Planning opens wizard sheet with "Plan a Trip" title. @MainActor func testF013_StartPlanningOpensWizard() { let home = HomeScreen(app: app) home.waitForLoad() home.tapStartPlanning() let wizard = TripWizardScreen(app: app) wizard.waitForLoad() XCTAssertTrue(wizard.navigationTitle.exists, "Wizard should show 'Plan a Trip' title") captureScreenshot(named: "F013-WizardOpened") } /// F-020: Create trip toolbar button (+) opens the same wizard sheet. @MainActor func testF020_CreateTripToolbarButtonOpensWizard() { let home = HomeScreen(app: app) home.waitForLoad() home.createTripToolbarButton.waitUntilHittable( timeout: BaseUITestCase.shortTimeout ).tap() let wizard = TripWizardScreen(app: app) wizard.waitForLoad() XCTAssertTrue(wizard.navigationTitle.exists, "Toolbar '+' button should open trip wizard") captureScreenshot(named: "F020-ToolbarCreateTrip") } /// F-014: Featured trips carousel loads and is visible. @MainActor func testF014_FeaturedTripsCarouselLoads() { let home = HomeScreen(app: app) home.waitForLoad() // Featured trips load asynchronously — wait for them to appear // Then scroll to make them visible. Use the app itself as scroll target // since NavigationStack + ScrollView can nest scroll containers. let section = home.featuredTripsSection if !section.waitForExistence(timeout: BaseUITestCase.longTimeout) { // Try scrolling to find it section.scrollIntoView(in: app.scrollViews.firstMatch, maxScrolls: 15) } XCTAssertTrue(section.exists, "Featured trips section should be visible") captureScreenshot(named: "F014-FeaturedTrips") } /// F-019: Planning tips section is visible at bottom of home tab. @MainActor func testF019_PlanningTipsSectionVisible() { let home = HomeScreen(app: app) home.waitForLoad() // Tips section is at the very bottom — need to scroll far down. // The home screen has nested scroll views; swipe on the main view. let section = home.tipsSection var scrollAttempts = 0 while !section.exists && scrollAttempts < 15 { app.swipeUp(velocity: .slow) scrollAttempts += 1 } XCTAssertTrue(section.exists, "Planning tips section should be visible") captureScreenshot(named: "F019-PlanningTips") } }