Files
honeyDueKMP/iosApp/CaseraUITests/TestConfiguration/TestLaunchConfig.swift
Trey t 7444f73b46 Close all 25 codex audit findings across KMP, iOS, and Android
Remediate all P0-S priority findings from cross-platform architecture audit:
- Harden token storage with EncryptedSharedPreferences (Android) and Keychain (iOS)
- Add SSL pinning and certificate validation to API clients
- Fix subscription cache race conditions and add thread-safe access
- Add input validation for document uploads and file type restrictions
- Refactor DocumentApi to use proper multipart upload flow
- Add rate limiting awareness and retry logic to API layer
- Harden subscription tier enforcement in SubscriptionHelper
- Add biometric prompt for sensitive actions (Login, Onboarding)
- Fix notification permission handling and device registration
- Add UI test infrastructure (page objects, fixtures, smoke tests)
- Add CI workflow for mobile builds

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 13:15:34 -06:00

65 lines
2.2 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.
/// Disables animations and forces English locale.
static let standardArguments: [String] = [
"-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]
)
}
}