Files
Sportstime/SportsTime/Core/Theme/DemoMode.swift
Trey t d53f222489 feat: add XCUITest suite with 10 critical flow tests and QA test plan
Add comprehensive UI test infrastructure with Page Object pattern,
accessibility identifiers, UI test mode (--ui-testing, --reset-state,
--disable-animations), and 10 passing tests covering app launch, tab
navigation, trip wizard, trip saving, settings, schedule, and
accessibility at XXXL Dynamic Type. Also adds a 229-case QA test plan
Excel workbook for manual QA handoff.

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

89 lines
2.4 KiB
Swift

//
// DemoMode.swift
// SportsTime
//
// Environment key and configuration for automated demo mode.
// When enabled, UI elements auto-select as they scroll into view.
//
import SwiftUI
// MARK: - Demo Mode Environment Key
private struct DemoModeKey: EnvironmentKey {
static let defaultValue = false
}
extension EnvironmentValues {
var isDemoMode: Bool {
get { self[DemoModeKey.self] }
set { self[DemoModeKey.self] = newValue }
}
}
// MARK: - Demo Mode Configuration
/// Configuration for the demo flow
enum DemoConfig {
/// Delay before auto-selecting an item (seconds)
static let selectionDelay: Double = 0.5
/// Demo mode date selections
static let demoStartDate: Date = {
var components = DateComponents()
components.year = 2026
components.month = 6
components.day = 11
return Calendar.current.date(from: components) ?? Date()
}()
static let demoEndDate: Date = {
var components = DateComponents()
components.year = 2026
components.month = 6
components.day = 16
return Calendar.current.date(from: components) ?? Date()
}()
/// Demo mode planning mode selection
static let demoPlanningMode: PlanningMode = .dateRange
/// Demo mode sport selection
static let demoSport: Sport = .mlb
/// Demo mode region selection
static let demoRegion: Region = .central
/// Demo mode sort option
static let demoSortOption: TripSortOption = .mostGames
/// Demo mode trip index to select (0-indexed)
static let demoTripIndex: Int = 3
}
// MARK: - Launch Arguments
extension ProcessInfo {
/// Check if app was launched in demo mode
static var isDemoMode: Bool {
ProcessInfo.processInfo.arguments.contains("-DemoMode")
}
/// Check if app was launched for UI testing.
/// When true, the app suppresses non-essential popups, disables analytics
/// and CloudKit sync, forces Pro mode, and disables animations.
static var isUITesting: Bool {
ProcessInfo.processInfo.arguments.contains("--ui-testing")
}
/// Check if state should be reset before the test run.
static var shouldResetState: Bool {
ProcessInfo.processInfo.arguments.contains("--reset-state")
}
/// Check if animations should be disabled.
static var shouldDisableAnimations: Bool {
ProcessInfo.processInfo.arguments.contains("--disable-animations")
}
}