Files
honeyDueKMP/iosApp/HoneyDueUITests/TestConfiguration/TestLaunchConfig.swift
treyt 5c360a2796 Rearchitect UI test suite for complete, non-flaky coverage against live API
- Migrate Suite4-10, SmokeTests, NavigationCriticalPathTests to AuthenticatedTestCase
  with seeded admin account and real backend login
- Add 34 accessibility identifiers across 11 app views (task completion, profile,
  notifications, theme, join residence, manage users, forms)
- Create FeatureCoverageTests (14 tests) covering previously untested features:
  profile edit, theme selection, notification prefs, task completion, manage users,
  join residence, task templates
- Create MultiUserSharingTests (18 API tests) and MultiUserSharingUITests (8 XCUI
  tests) for full cross-user residence sharing lifecycle
- Add cleanup infrastructure: SuiteZZ_CleanupTests auto-wipes test data after runs,
  cleanup_test_data.sh script for manual reset via admin API
- Add share code API methods to TestAccountAPIClient (generateShareCode, joinWithCode,
  getShareCode, listResidenceUsers, removeUser)
- Fix app bugs found by tests:
  - ResidencesListView join callback now uses forceRefresh:true
  - APILayer invalidates task cache when residence count changes
  - AllTasksView auto-reloads tasks when residence list changes
- Fix test quality: keyboard focus waits, Save/Add button label matching,
  Documents tab label (Docs), remove API verification from UI tests
- DataLayerTests and PasswordResetTests now verify through UI, not API calls

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 17:32:13 -05:00

69 lines
2.4 KiB
Swift

import XCTest
/// Centralized app launch configuration for UI tests.
///
/// Provides consistent launch arguments and environment variables across
/// all test suites. Disables animations and sets locale to English for
/// deterministic test behavior.
enum TestLaunchConfig {
/// Standard launch arguments for UI test mode.
/// Includes `--ui-testing` so the app's `UITestRuntime.isEnabled` is true,
/// which skips async auth checks, StoreKit, and push notification registration.
static let standardArguments: [String] = [
"--ui-testing",
"--disable-animations",
"--complete-onboarding",
"-UITEST_MODE", "1",
"-AppleLanguages", "(en)",
"-AppleLocale", "en_US",
"-UIAnimationsEnabled", "NO"
]
/// Launch environment variables for UI tests.
static let standardEnvironment: [String: String] = [
"UITEST_MODE": "1",
"ANIMATIONS_DISABLED": "1"
]
/// Configure and launch app with standard test settings.
///
/// - Parameters:
/// - additionalArguments: Extra launch arguments to append.
/// - additionalEnvironment: Extra environment variables to merge.
/// - Returns: The launched `XCUIApplication` instance.
@discardableResult
static func launchApp(
additionalArguments: [String] = [],
additionalEnvironment: [String: String] = [:]
) -> XCUIApplication {
let app = XCUIApplication()
app.launchArguments = standardArguments + additionalArguments
var env = standardEnvironment
additionalEnvironment.forEach { env[$0.key] = $0.value }
app.launchEnvironment = env
app.launch()
return app
}
/// Launch app pre-authenticated (skips login flow).
///
/// Passes test credentials via launch arguments and environment so the
/// app can bypass the normal authentication flow during UI tests.
///
/// - Parameters:
/// - email: Test user email address.
/// - token: Test authentication token.
/// - Returns: The launched `XCUIApplication` instance.
@discardableResult
static func launchAuthenticated(
email: String = "test@example.com",
token: String = "test-token-12345"
) -> XCUIApplication {
return launchApp(
additionalArguments: ["-TEST_AUTH_EMAIL", email, "-TEST_AUTH_TOKEN", token],
additionalEnvironment: ["TEST_AUTH_EMAIL": email, "TEST_AUTH_TOKEN": token]
)
}
}