Files
bot/apps/macos/Tests/OpenClawIPCTests/VoiceWakeGlobalSettingsSyncTests.swift
zooqueen 071e3f1082 rebrand: openclaw -> hanzo bot across entire codebase
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
2026-03-19 13:52:32 -07:00

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)
}
}
}