Files
OSGKeyboard/OSGKeyboardTests/FlowHomePiPStatusPolicyTests.swift
T
Rocky 4dce67df84 chore(release): bump version to 2.1.6 (build 131)
Version: CURRENT_PROJECT_VERSION 130 -> 131 (project.yml, AGENTS.md, READMEs,
docs/llms.txt).

fix(flow): host-app identification now compiles in every build configuration
(Debug, TestFlight, Release). The arbiter probe and HostAppIdentity were
DEBUG-only, so TestFlight/App Store builds never knew the host bundle id and
could not auto-return after a startflow handoff. Debug-only logging and the
Home test card are unchanged.

Also includes the pending work in the tree:
- Home: single account/setup card surface (HomeAccountSurfacePolicy/Views)
- Wide screens: voice key row and centred mic placement, iPhone Duo layout
- Keyboard: clipboard skill ranking and AI skill layout updates
- Debug: account session handoff to the Simulator (+ import script)
- Docs: portfolio assets, privacy policy URL, site/README refresh
2026-10-29 11:54:13 +08:00

125 lines
3.6 KiB
Swift

// FlowHomePiPStatusPolicyTests.swift
// OSGKeyboardTests
@testable import OSGKeyboard
import XCTest
final class FlowHomePiPStatusPolicyTests: XCTestCase {
func testPreparingAndRecoveringExposeAttemptProgress() {
XCTAssertEqual(
descriptor(for: .preparing(attempt: 1, total: 3)),
.progress(
localizationKey: "home.flow.preparingProgress",
attempt: 1,
total: 3
)
)
XCTAssertEqual(
descriptor(for: .recovering(attempt: 2, total: 3)),
.progress(
localizationKey: "home.flow.recoveringProgress",
attempt: 2,
total: 3
)
)
}
func testTakeoverAndFailureUseActionableStatuses() {
XCTAssertEqual(
descriptor(for: .waitingForForeground),
.text(localizationKey: "home.flow.waitingForForeground")
)
XCTAssertEqual(
descriptor(for: .failed(.systemRejected)),
.text(localizationKey: "home.flow.recoveryFailed")
)
}
func testActiveSessionDoesNotClaimReadyWithoutReadyContract() {
XCTAssertEqual(
FlowHomePiPStatusPolicy.descriptor(
lifecycle: .active,
isStarting: false,
isRecording: false,
isProcessing: false,
isActive: true,
isHostReady: false
),
.text(localizationKey: "home.flow.notReady")
)
XCTAssertEqual(
FlowHomePiPStatusPolicy.descriptor(
lifecycle: .active,
isStarting: false,
isRecording: false,
isProcessing: false,
isActive: true,
isHostReady: true
),
.text(localizationKey: "home.flow.label")
)
}
func testRetryAppearsOnlyForRecoverableFailureWithPermissions() {
XCTAssertTrue(
FlowHomePiPStatusPolicy.canRetry(
lifecycle: .failed(.timedOut),
needsPermissionSetup: false
)
)
XCTAssertFalse(
FlowHomePiPStatusPolicy.canRetry(
lifecycle: .failed(.timedOut),
needsPermissionSetup: true
)
)
XCTAssertFalse(
FlowHomePiPStatusPolicy.canRetry(
lifecycle: .recovering(attempt: 1, total: 3),
needsPermissionSetup: false
)
)
}
func testLocalAndPolishOnlySetupLinksToTextPolish() {
XCTAssertEqual(
HomeServiceSetupPolicy.apiKeyDeepLink(
isLocalEngine: true,
isASRConfigured: true
),
.textPolish
)
XCTAssertEqual(
HomeServiceSetupPolicy.apiKeyDeepLink(
isLocalEngine: false,
isASRConfigured: true
),
.textPolish
)
}
func testCloudSetupLinksToSpeechRecognitionWhenASRIsMissing() {
XCTAssertEqual(
HomeServiceSetupPolicy.apiKeyDeepLink(
isLocalEngine: false,
isASRConfigured: false
),
.speechRecognition
)
}
private func descriptor(
for lifecycle: FlowPiPLifecycleState
) -> FlowHomePiPStatusDescriptor {
FlowHomePiPStatusPolicy.descriptor(
lifecycle: lifecycle,
isStarting: false,
isRecording: false,
isProcessing: false,
isActive: false,
isHostReady: false
)
}
}