feat: TypeWhisper Flow sessions, Phase 4 UX, and GitHub Pages privacy site
Migrate keyboard dictation to continuous Flow sessions with auto-start, tap-to-toggle recording, 60s countdown, five-step onboarding, and App Group IPC. Add docs/ GitHub Pages site with en/zh privacy policy for App Store compliance.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
// FlowSessionBridgeTests.swift
|
||||
// OSGKeyboardTests
|
||||
|
||||
import XCTest
|
||||
@testable import OSGKeyboardShared
|
||||
|
||||
final class FlowSessionBridgeTests: XCTestCase {
|
||||
|
||||
private func makeDefaults() -> UserDefaults {
|
||||
let suite = "group.com.osgkeyboard.shared.tests.flow.\(UUID().uuidString)"
|
||||
let defaults = UserDefaults(suiteName: suite)!
|
||||
defaults.removePersistentDomain(forName: suite)
|
||||
return defaults
|
||||
}
|
||||
|
||||
func testSessionActiveRequiresFreshHeartbeat() {
|
||||
let defaults = makeDefaults()
|
||||
FlowSessionBridge.markSessionActive(duration: 60, defaults: defaults)
|
||||
XCTAssertTrue(FlowSessionBridge.isSessionActive(defaults: defaults))
|
||||
|
||||
let staleHeartbeat = Date().timeIntervalSince1970 - 10
|
||||
defaults.set(staleHeartbeat, forKey: FlowSessionKeys.flowHeartbeat)
|
||||
XCTAssertFalse(FlowSessionBridge.isSessionActive(defaults: defaults))
|
||||
}
|
||||
|
||||
func testRecordingStateRoundTrip() {
|
||||
let defaults = makeDefaults()
|
||||
FlowSessionBridge.setRecordingState(.recording, defaults: defaults)
|
||||
XCTAssertEqual(FlowSessionBridge.recordingState(defaults: defaults), .recording)
|
||||
|
||||
FlowSessionBridge.setRecordingState(.stopped, defaults: defaults)
|
||||
XCTAssertEqual(FlowSessionBridge.recordingState(defaults: defaults), .stopped)
|
||||
}
|
||||
|
||||
func testConsumeTranscriptionResultClearsKey() {
|
||||
let defaults = makeDefaults()
|
||||
FlowSessionBridge.storeTranscriptionResult("hello", defaults: defaults)
|
||||
XCTAssertEqual(FlowSessionBridge.consumeTranscriptionResult(defaults: defaults), "hello")
|
||||
XCTAssertNil(FlowSessionBridge.consumeTranscriptionResult(defaults: defaults))
|
||||
}
|
||||
|
||||
func testClearFlowStateRemovesSessionKeys() {
|
||||
let defaults = makeDefaults()
|
||||
FlowSessionBridge.markSessionActive(defaults: defaults)
|
||||
FlowSessionBridge.storeTranscriptionResult("x", defaults: defaults)
|
||||
FlowSessionBridge.clearFlowState(defaults: defaults)
|
||||
|
||||
XCTAssertFalse(defaults.bool(forKey: FlowSessionKeys.flowSessionActive))
|
||||
XCTAssertNil(FlowSessionBridge.consumeTranscriptionResult(defaults: defaults))
|
||||
XCTAssertEqual(FlowSessionBridge.recordingState(defaults: defaults), .idle)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user