Files
openclaw/apps/ios/Tests/Logic/WatchVoiceTurnTrackerTests.swift
Peter Steinberger 245092dc3a feat(ios): add Apple Watch voice turns (#100283)
* feat(ios): add Apple Watch voice turns

* chore(ios): sync native i18n inventory

* fix(ios): preserve Watch message label
2026-07-05 06:40:03 -07:00

31 lines
1.2 KiB
Swift

import Testing
struct WatchVoiceTurnTrackerTests {
@Test func `waits for matching completed voice command`() {
var tracker = WatchVoiceTurnTracker()
tracker.begin(commandId: "voice-command")
#expect(tracker.takeReply(completedCommandId: "other-command", text: "Other reply") == nil)
#expect(tracker.isAwaitingReply)
#expect(tracker.takeReply(completedCommandId: "voice-command", text: "New reply") == "New reply")
#expect(!tracker.isAwaitingReply)
}
@Test func `ignores empty assistant messages until readable reply arrives`() {
var tracker = WatchVoiceTurnTracker()
tracker.begin(commandId: "voice-command")
#expect(tracker.takeReply(completedCommandId: "voice-command", text: " \n") == nil)
#expect(tracker.isAwaitingReply)
#expect(tracker.takeReply(completedCommandId: "voice-command", text: " Ready. ") == "Ready.")
}
@Test func `canceled turn does not speak later assistant message`() {
var tracker = WatchVoiceTurnTracker()
tracker.begin(commandId: "voice-command")
tracker.cancel()
#expect(tracker.takeReply(completedCommandId: "voice-command", text: "Later reply") == nil)
}
}