mirror of
https://github.com/hanzoai/bot.git
synced 2026-11-01 07:38:30 +00:00
Comprehensive rename of all openclaw references to hanzo-bot equivalents: - Package: openclaw → @hanzo/bot - Binary: openclaw → hanzo-bot - Types: OpenClaw* → Bot* - Env vars: OPENCLAW_* → BOT_* - Android: ai.openclaw.android → ai.hanzo.bot.android - iOS/macOS: ai.openclaw.* → ai.hanzo.* - Swift modules: OpenClaw* → Bot* - Plugins: openclaw.plugin.json → bot.plugin.json - Paths: .openclaw/ → .hanzo/bot/ - URLs: github.com/openclaw → github.com/hanzoai
57 lines
1.8 KiB
Swift
57 lines
1.8 KiB
Swift
import HanzoBotProtocol
|
|
import Foundation
|
|
import Testing
|
|
@testable import HanzoBot
|
|
|
|
@Suite(.serialized) struct VoiceWakeGlobalSettingsSyncTests {
|
|
@Test func appliesVoiceWakeChangedEventToAppState() async {
|
|
let previous = await MainActor.run { AppStateStore.shared.swabbleTriggerWords }
|
|
|
|
await MainActor.run {
|
|
AppStateStore.shared.applyGlobalVoiceWakeTriggers(["before"])
|
|
}
|
|
|
|
let payload = HanzoBotProtocol.AnyCodable(["triggers": ["hanzo-bot", "computer"]])
|
|
let evt = EventFrame(
|
|
type: "event",
|
|
event: "voicewake.changed",
|
|
payload: payload,
|
|
seq: nil,
|
|
stateversion: nil)
|
|
|
|
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 ignoresVoiceWakeChangedEventWithInvalidPayload() async {
|
|
let previous = await MainActor.run { AppStateStore.shared.swabbleTriggerWords }
|
|
|
|
await MainActor.run {
|
|
AppStateStore.shared.applyGlobalVoiceWakeTriggers(["before"])
|
|
}
|
|
|
|
let payload = HanzoBotProtocol.AnyCodable(["unexpected": 123])
|
|
let evt = EventFrame(
|
|
type: "event",
|
|
event: "voicewake.changed",
|
|
payload: payload,
|
|
seq: nil,
|
|
stateversion: nil)
|
|
|
|
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)
|
|
}
|
|
}
|
|
}
|