mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-30 22:51:46 +00:00
refactor(tests): dedupe ios gateway and deeplink fixtures
This commit is contained in:
@@ -3,6 +3,19 @@ import SwabbleKit
|
||||
import Testing
|
||||
@testable import OpenClaw
|
||||
|
||||
private let openclawTranscript = "hey openclaw do thing"
|
||||
|
||||
private func openclawSegments(postTriggerStart: TimeInterval) -> [WakeWordSegment] {
|
||||
makeSegments(
|
||||
transcript: openclawTranscript,
|
||||
words: [
|
||||
("hey", 0.0, 0.1),
|
||||
("openclaw", 0.2, 0.1),
|
||||
("do", postTriggerStart, 0.1),
|
||||
("thing", postTriggerStart + 0.2, 0.1),
|
||||
])
|
||||
}
|
||||
|
||||
@Suite struct VoiceWakeManagerExtractCommandTests {
|
||||
@Test func extractCommandReturnsNilWhenNoTriggerFound() {
|
||||
let transcript = "hello world"
|
||||
@@ -13,17 +26,9 @@ import Testing
|
||||
}
|
||||
|
||||
@Test func extractCommandTrimsTokensAndResult() {
|
||||
let transcript = "hey openclaw do thing"
|
||||
let segments = makeSegments(
|
||||
transcript: transcript,
|
||||
words: [
|
||||
("hey", 0.0, 0.1),
|
||||
("openclaw", 0.2, 0.1),
|
||||
("do", 0.9, 0.1),
|
||||
("thing", 1.1, 0.1),
|
||||
])
|
||||
let segments = openclawSegments(postTriggerStart: 0.9)
|
||||
let cmd = VoiceWakeManager.extractCommand(
|
||||
from: transcript,
|
||||
from: openclawTranscript,
|
||||
segments: segments,
|
||||
triggers: [" openclaw "],
|
||||
minPostTriggerGap: 0.3)
|
||||
@@ -31,17 +36,9 @@ import Testing
|
||||
}
|
||||
|
||||
@Test func extractCommandReturnsNilWhenGapTooShort() {
|
||||
let transcript = "hey openclaw do thing"
|
||||
let segments = makeSegments(
|
||||
transcript: transcript,
|
||||
words: [
|
||||
("hey", 0.0, 0.1),
|
||||
("openclaw", 0.2, 0.1),
|
||||
("do", 0.35, 0.1),
|
||||
("thing", 0.5, 0.1),
|
||||
])
|
||||
let segments = openclawSegments(postTriggerStart: 0.35)
|
||||
let cmd = VoiceWakeManager.extractCommand(
|
||||
from: transcript,
|
||||
from: openclawTranscript,
|
||||
segments: segments,
|
||||
triggers: ["openclaw"],
|
||||
minPostTriggerGap: 0.3)
|
||||
@@ -57,17 +54,9 @@ import Testing
|
||||
}
|
||||
|
||||
@Test func extractCommandIgnoresEmptyTriggers() {
|
||||
let transcript = "hey openclaw do thing"
|
||||
let segments = makeSegments(
|
||||
transcript: transcript,
|
||||
words: [
|
||||
("hey", 0.0, 0.1),
|
||||
("openclaw", 0.2, 0.1),
|
||||
("do", 0.9, 0.1),
|
||||
("thing", 1.1, 0.1),
|
||||
])
|
||||
let segments = openclawSegments(postTriggerStart: 0.9)
|
||||
let cmd = VoiceWakeManager.extractCommand(
|
||||
from: transcript,
|
||||
from: openclawTranscript,
|
||||
segments: segments,
|
||||
triggers: ["", " ", "openclaw"],
|
||||
minPostTriggerGap: 0.3)
|
||||
|
||||
Reference in New Issue
Block a user