mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 21:07:01 -06:00
9ead0ae921
Fix live model inference edge cases across provider streaming, model switching, outbound delivery, and gateway tool resolution. Includes live/provider issue fixes and leaves #89100 explicitly partial for the remaining FM-2 group routing case.
65 lines
2.4 KiB
Swift
65 lines
2.4 KiB
Swift
import Testing
|
|
@testable import OpenClaw
|
|
|
|
@Suite(.serialized) struct VoiceWakeForwarderTests {
|
|
@Test func `prefixed transcript uses machine name`() {
|
|
let transcript = "hello world"
|
|
let prefixed = VoiceWakeForwarder.prefixedTranscript(transcript, machineName: "My-Mac")
|
|
|
|
#expect(prefixed.starts(with: "User talked via voice recognition on"))
|
|
#expect(prefixed.contains("My-Mac"))
|
|
#expect(prefixed.hasSuffix("\n\nhello world"))
|
|
}
|
|
|
|
@Test func `forward options defaults`() {
|
|
let opts = VoiceWakeForwarder.ForwardOptions()
|
|
#expect(opts.sessionKey == "main")
|
|
#expect(opts.thinking == nil)
|
|
#expect(opts.deliver == true)
|
|
#expect(opts.to == nil)
|
|
#expect(opts.channel == .webchat)
|
|
#expect(opts.channel.shouldDeliver(opts.deliver) == false)
|
|
}
|
|
|
|
@Test func `selected forward options use session delivery context`() {
|
|
let entry = VoiceWakeForwarder.SessionRouteEntry(
|
|
key: "agent:main:telegram:group:6812765697",
|
|
channel: "telegram",
|
|
lastChannel: "telegram",
|
|
lastTo: "telegram:6812765697",
|
|
deliveryContext: .init(channel: "telegram", to: "telegram:6812765697"))
|
|
|
|
let opts = VoiceWakeForwarder.forwardOptions(
|
|
sessionKey: entry.key,
|
|
routeEntry: entry,
|
|
voiceWakeTrigger: "open claw")
|
|
|
|
#expect(opts.sessionKey == "agent:main:telegram:group:6812765697")
|
|
#expect(opts.channel == .telegram)
|
|
#expect(opts.to == "telegram:6812765697")
|
|
#expect(opts.voiceWakeTrigger == "open claw")
|
|
#expect(opts.thinking == nil)
|
|
#expect(opts.channel.shouldDeliver(opts.deliver) == true)
|
|
}
|
|
|
|
@Test func `selected forward options parse channel scoped session fallback`() {
|
|
let opts = VoiceWakeForwarder.forwardOptions(
|
|
sessionKey: "agent:main:discord:channel:123:456",
|
|
routeEntry: nil)
|
|
|
|
#expect(opts.channel == .discord)
|
|
#expect(opts.to == "123:456")
|
|
#expect(opts.channel.shouldDeliver(opts.deliver) == true)
|
|
}
|
|
|
|
@Test func `selected forward options keep internal sessions on webchat`() {
|
|
let opts = VoiceWakeForwarder.forwardOptions(
|
|
sessionKey: "agent:main:work",
|
|
routeEntry: nil)
|
|
|
|
#expect(opts.channel == .webchat)
|
|
#expect(opts.to == nil)
|
|
#expect(opts.channel.shouldDeliver(opts.deliver) == false)
|
|
}
|
|
}
|