refactor: rename app from Severed to OpenAppLock
Full rename ahead of App Store submission: project, targets, bundle identifiers (dev.bchen.Severed -> dev.bchen.OpenAppLock), entitlements file, app entry point, user-facing onboarding strings, test helpers, and docs. Verified: all 62 unit tests pass.
This commit is contained in:
97
OpenAppLockTests/LaunchSupportTests.swift
Normal file
97
OpenAppLockTests/LaunchSupportTests.swift
Normal file
@@ -0,0 +1,97 @@
|
||||
//
|
||||
// LaunchSupportTests.swift
|
||||
// OpenAppLockTests
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Testing
|
||||
|
||||
@testable import OpenAppLock
|
||||
|
||||
@MainActor
|
||||
@Suite("Launch configuration parsing")
|
||||
struct LaunchConfigurationTests {
|
||||
@Test("Defaults are production settings")
|
||||
func defaults() {
|
||||
let config = LaunchConfiguration.parse(arguments: ["OpenAppLockApp"])
|
||||
#expect(!config.isUITesting)
|
||||
#expect(config.onboardingCompleted == nil)
|
||||
#expect(config.seedScenario == nil)
|
||||
}
|
||||
|
||||
@Test("UI testing flags are recognized")
|
||||
func uiTestingFlags() {
|
||||
let config = LaunchConfiguration.parse(arguments: [
|
||||
"OpenAppLockApp", "-ui-testing", "-onboarding-completed", "-seed-scenario=standard",
|
||||
])
|
||||
#expect(config.isUITesting)
|
||||
#expect(config.onboardingCompleted == true)
|
||||
#expect(config.seedScenario == .standard)
|
||||
}
|
||||
|
||||
@Test("Onboarding can be forced on")
|
||||
func onboardingRequired() {
|
||||
let config = LaunchConfiguration.parse(arguments: ["OpenAppLockApp", "-onboarding-required"])
|
||||
#expect(config.onboardingCompleted == false)
|
||||
}
|
||||
|
||||
@Test("Unknown seed scenarios are ignored")
|
||||
func unknownScenario() {
|
||||
let config = LaunchConfiguration.parse(arguments: ["OpenAppLockApp", "-seed-scenario=nope"])
|
||||
#expect(config.seedScenario == nil)
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Suite("Seeded sample rules")
|
||||
struct SampleRulesTests {
|
||||
@Test(
|
||||
"Seeded active rules are genuinely active at any time of day",
|
||||
arguments: [(0, 30), (9, 0), (12, 30), (23, 50)]
|
||||
)
|
||||
func activeRuleIsActive(hour: Int, minute: Int) {
|
||||
let now = date(2025, 1, 6, hour, minute)
|
||||
let rule = SampleRules.activeRule(named: "Work Time", hardMode: false, now: now, calendar: utc)
|
||||
#expect(rule.status(at: now, calendar: utc).isActive)
|
||||
}
|
||||
|
||||
@Test(
|
||||
"Seeded upcoming rules are not active but will start",
|
||||
arguments: [(0, 30), (9, 0), (12, 30), (23, 50)]
|
||||
)
|
||||
func upcomingRuleIsUpcoming(hour: Int, minute: Int) {
|
||||
let now = date(2025, 1, 6, hour, minute)
|
||||
let rule = SampleRules.upcomingRule(named: "Sleep", now: now, calendar: utc)
|
||||
let status = rule.status(at: now, calendar: utc)
|
||||
#expect(!status.isActive)
|
||||
if case .upcoming = status {} else {
|
||||
Issue.record("Expected upcoming, got \(status)")
|
||||
}
|
||||
}
|
||||
|
||||
@Test("Hard mode scenario seeds a locked active rule")
|
||||
func hardModeScenario() {
|
||||
let now = date(2025, 1, 6, 12, 0)
|
||||
let rule = SampleRules.activeRule(named: "Locked In", hardMode: true, now: now, calendar: utc)
|
||||
#expect(RulePolicy.isHardLocked(rule, at: now, calendar: utc))
|
||||
}
|
||||
|
||||
@Test("Mock authorization approves on request")
|
||||
func mockAuthorization() async {
|
||||
let provider = MockAuthorizationProvider()
|
||||
let auth = ScreenTimeAuthorization(provider: provider)
|
||||
#expect(auth.status == .notDetermined)
|
||||
await auth.request()
|
||||
#expect(auth.status == .approved)
|
||||
#expect(!auth.lastRequestFailed)
|
||||
}
|
||||
|
||||
@Test("Mock authorization can simulate denial")
|
||||
func mockAuthorizationDenied() async {
|
||||
let provider = MockAuthorizationProvider(requestShouldFail: true)
|
||||
let auth = ScreenTimeAuthorization(provider: provider)
|
||||
await auth.request()
|
||||
#expect(auth.status == .denied)
|
||||
#expect(auth.lastRequestFailed)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user