50 lines
1.3 KiB
Swift
50 lines
1.3 KiB
Swift
import Foundation
|
|
import UIKit
|
|
import ComposeApp
|
|
|
|
/// Runtime contract between the app and XCUITests.
|
|
enum UITestRuntime {
|
|
static let uiTestingFlag = "--ui-testing"
|
|
static let disableAnimationsFlag = "--disable-animations"
|
|
static let resetStateFlag = "--reset-state"
|
|
static let mockAuthFlag = "--ui-test-mock-auth"
|
|
|
|
static var launchArguments: [String] {
|
|
ProcessInfo.processInfo.arguments
|
|
}
|
|
|
|
static var isEnabled: Bool {
|
|
launchArguments.contains(uiTestingFlag)
|
|
}
|
|
|
|
static var shouldDisableAnimations: Bool {
|
|
isEnabled && launchArguments.contains(disableAnimationsFlag)
|
|
}
|
|
|
|
static var shouldResetState: Bool {
|
|
isEnabled && launchArguments.contains(resetStateFlag)
|
|
}
|
|
|
|
static var shouldMockAuth: Bool {
|
|
isEnabled && launchArguments.contains(mockAuthFlag)
|
|
}
|
|
|
|
static func configureForLaunch() {
|
|
guard isEnabled else { return }
|
|
|
|
if shouldDisableAnimations {
|
|
UIView.setAnimationsEnabled(false)
|
|
}
|
|
|
|
UserDefaults.standard.set(true, forKey: "ui_testing_mode")
|
|
}
|
|
|
|
static func resetStateIfRequested() {
|
|
guard shouldResetState else { return }
|
|
|
|
DataManager.shared.clear()
|
|
OnboardingState.shared.reset()
|
|
ThemeManager.shared.currentTheme = .bright
|
|
}
|
|
}
|