mirror of
https://github.com/hanzoai/bot.git
synced 2026-11-01 17:14:58 +00:00
Automated rebrand of all openclaw references to hanzo bot: - Package: openclaw -> @hanzo/bot - Binary: openclaw -> hanzo-bot - Config: ~/.openclaw -> ~/.hanzo/bot - Docker: ghcr.io/hanzoai/bot - Env vars: OPENCLAW_* -> BOT_* - Bundle IDs: ai.hanzo.bot.* - Product name: Hanzo Bot
55 lines
1.9 KiB
Swift
55 lines
1.9 KiB
Swift
import Foundation
|
|
import Hanzo BotProtocol
|
|
import Testing
|
|
@testable import Hanzo Bot
|
|
|
|
@Suite(.serialized) struct VoiceWakeGlobalSettingsSyncTests {
|
|
private func voiceWakeChangedEvent(payload: Hanzo BotProtocol.AnyCodable) -> EventFrame {
|
|
EventFrame(
|
|
type: "event",
|
|
event: "voicewake.changed",
|
|
payload: payload,
|
|
seq: nil,
|
|
stateversion: nil)
|
|
}
|
|
|
|
private func applyTriggersAndCapturePrevious(_ triggers: [String]) async -> [String] {
|
|
let previous = await MainActor.run { AppStateStore.shared.swabbleTriggerWords }
|
|
await MainActor.run {
|
|
AppStateStore.shared.applyGlobalVoiceWakeTriggers(triggers)
|
|
}
|
|
return previous
|
|
}
|
|
|
|
@Test func `applies voice wake changed event to app state`() async {
|
|
let previous = await applyTriggersAndCapturePrevious(["before"])
|
|
let evt = self.voiceWakeChangedEvent(payload: Hanzo BotProtocol.AnyCodable(["triggers": [
|
|
"@hanzo/bot",
|
|
"computer",
|
|
]]))
|
|
|
|
await VoiceWakeGlobalSettingsSync.shared.handle(push: .event(evt))
|
|
|
|
let updated = await MainActor.run { AppStateStore.shared.swabbleTriggerWords }
|
|
#expect(updated == ["@hanzo/bot", "computer"])
|
|
|
|
await MainActor.run {
|
|
AppStateStore.shared.applyGlobalVoiceWakeTriggers(previous)
|
|
}
|
|
}
|
|
|
|
@Test func `ignores voice wake changed event with invalid payload`() async {
|
|
let previous = await applyTriggersAndCapturePrevious(["before"])
|
|
let evt = self.voiceWakeChangedEvent(payload: Hanzo BotProtocol.AnyCodable(["unexpected": 123]))
|
|
|
|
await VoiceWakeGlobalSettingsSync.shared.handle(push: .event(evt))
|
|
|
|
let updated = await MainActor.run { AppStateStore.shared.swabbleTriggerWords }
|
|
#expect(updated == ["before"])
|
|
|
|
await MainActor.run {
|
|
AppStateStore.shared.applyGlobalVoiceWakeTriggers(previous)
|
|
}
|
|
}
|
|
}
|