Files
Reflect/Tests iOS/AppLaunchTests.swift
Trey t 16c5c34942 Fix 4 flaky UI tests for iOS 26 compatibility
- AppLaunchTests/StabilityTests: Increase assertTabSelected timeout to
  8s for iOS 26 Liquid Glass delayed isSelected state updates
- DeepLinkTests: Detect SubscriptionStoreView container instead of text
  labels, since Apple's native view shows "Subscription Unavailable" in
  test storefront
- SettingsActionTests: Check for empty state after clearing data, bump
  Settings header timeout to 8s

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 18:59:22 -06:00

62 lines
2.1 KiB
Swift

//
// AppLaunchTests.swift
// Tests iOS
//
// App launch and tab bar navigation tests.
//
import XCTest
final class AppLaunchTests: BaseUITestCase {
override var seedFixture: String? { "empty" }
/// Verify the app launches to the Day tab and all 5 tabs are visible.
func testAppLaunches_TabBarVisible() {
let tabBar = TabBarScreen(app: app)
tabBar.assertTabBarVisible()
// All 5 tabs should exist
XCTAssertTrue(tabBar.dayTab.exists, "Day tab should exist")
XCTAssertTrue(tabBar.monthTab.exists, "Month tab should exist")
XCTAssertTrue(tabBar.yearTab.exists, "Year tab should exist")
XCTAssertTrue(tabBar.insightsTab.exists, "Insights tab should exist")
XCTAssertTrue(tabBar.settingsTab.exists, "Settings tab should exist")
captureScreenshot(name: "app_launched")
}
/// Navigate through every tab and verify each loads.
func testTabNavigation_AllTabsAccessible() {
let tabBar = TabBarScreen(app: app)
// Month tab
tabBar.tapMonth()
assertTabSelected(tabBar.monthTab, name: "Month")
// Year tab
tabBar.tapYear()
assertTabSelected(tabBar.yearTab, name: "Year")
// Insights tab
tabBar.tapInsights()
assertTabSelected(tabBar.insightsTab, name: "Insights")
// Settings tab
tabBar.tapSettings()
assertTabSelected(tabBar.settingsTab, name: "Settings")
// Back to Day
tabBar.tapDay()
assertTabSelected(tabBar.dayTab, name: "Day")
}
/// Wait for a tab to become selected (iOS 26 Liquid Glass may delay state updates).
private func assertTabSelected(_ tab: XCUIElement, name: String, timeout: TimeInterval = 8) {
// Re-query the element to get fresh state, since isSelected can be stale.
let predicate = NSPredicate(format: "isSelected == true")
let expectation = XCTNSPredicateExpectation(predicate: predicate, object: tab)
let result = XCTWaiter.wait(for: [expectation], timeout: timeout)
XCTAssertEqual(result, .completed, "\(name) tab should be selected")
}
}