// // KordantUITestsLaunchTests.swift // KordantUITests // // Created by Mike Freno on 5/25/26. // import XCTest /// Launch tests that verify the app starts correctly on different device configurations. /// These tests run for each target application configuration (e.g., iPhone and iPad). final class KordantUITestsLaunchTests: XCTestCase { override class var runsForEachTargetApplicationUIConfiguration: Bool { true } override func setUpWithError() throws { continueAfterFailure = false } /// Verify the app launches and captures the initial screenshot. /// This is useful for device farm screenshot verification. func testLaunch() throws { let app = XCUIApplication() app.launchArguments = ["-UITesting"] app.launchEnvironment["UITestScenario"] = UITestScenario.authenticated.rawValue app.launch() // Allow the app to settle and load initial data let dashboardTab = app.tabBars.buttons["Dashboard"] let authScreen = app.staticTexts["Kordant"] // Wait for either auth screen or dashboard to appear let appeared = XCTWaiter.wait(for: [ XCTNSPredicateExpectation( predicate: NSPredicate(format: "exists == true"), object: dashboardTab ), XCTNSPredicateExpectation( predicate: NSPredicate(format: "exists == true"), object: authScreen ) ], timeout: 10) XCTAssertEqual(app.state, .runningForeground, "App should be running in foreground") XCTAssertNotEqual(app.state, .unknown, "App state should be known") // Capture launch screenshot for App Store Connect previews let screenshot = app.screenshot() let attachment = XCTAttachment(screenshot: screenshot) attachment.name = "Launch Screen" attachment.lifetime = .keepAlways add(attachment) } /// Verify the app launches in unauthenticated mode and shows auth UI func testLaunchUnauthenticated() throws { let app = XCUIApplication() app.launchArguments = ["-UITesting"] app.launchEnvironment["UITestScenario"] = UITestScenario.unauthenticated.rawValue app.launch() // Verify auth UI appears let brandName = app.staticTexts["Kordant"] XCTAssertTrue(brandName.waitForExistence(timeout: 5), "Auth screen should show Kordant branding") // Verify the app is responsive let googleButton = app.buttons["Continue with Google"] XCTAssertTrue(googleButton.waitForExistence(timeout: 3), "Google sign-in button should exist") } /// Verify the app launches in authenticated mode and shows the main interface func testLaunchAuthenticated() throws { let app = XCUIApplication() app.launchArguments = ["-UITesting"] app.launchEnvironment["UITestScenario"] = UITestScenario.authenticated.rawValue app.launch() // Verify main UI appears let dashboardNav = app.navigationBars["Dashboard"] XCTAssertTrue(dashboardNav.waitForExistence(timeout: 5), "Dashboard should appear for authenticated user") // Tab bar should be visible XCTAssertTrue(app.tabBars.buttons["Dashboard"].exists, "Dashboard tab should exist") XCTAssertTrue(app.tabBars.buttons["Settings"].exists, "Settings tab should exist") } }