mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
59b2fbbb4b
* feat(ios): add Talk camera flip and mic selection * chore(ios): sync native i18n inventory and locale artifacts for talk camera/mic strings * chore(ios): commit regenerated Localizable.xcstrings for new talk strings * fix(ios): extract Talk composer controls * chore(ios): resync native i18n inventory and locale artifacts atop landed Android entries * fix(ios): repair Talk composer CI checks * chore(i18n): commit regenerated Android locale outputs from catalog reconciliation * chore(i18n): sync Android locale outputs after rebase
87 lines
3.0 KiB
Swift
87 lines
3.0 KiB
Swift
import Testing
|
|
@testable import OpenClawChatUI
|
|
|
|
@MainActor
|
|
struct ChatTalkControlTests {
|
|
@Test func `legacy initializer shape receives additive feedback defaults`() {
|
|
let control = OpenClawChatTalkControl(
|
|
isEnabled: false,
|
|
isListening: false,
|
|
isSpeaking: false,
|
|
isGatewayConnected: true,
|
|
statusText: "Off",
|
|
providerLabel: "",
|
|
toggle: { _ in })
|
|
|
|
#expect(control.level == 0)
|
|
#expect(control.partialTranscript.isEmpty)
|
|
#expect(control.recentTranscript.isEmpty)
|
|
#expect(control.inputDevices.isEmpty)
|
|
#expect(control.selectedInputDeviceID == nil)
|
|
#expect(control.selectInputDevice == nil)
|
|
#expect(control.cameraFacing == nil)
|
|
#expect(control.flipCamera == nil)
|
|
}
|
|
|
|
@Test func `feedback and input selection fields preserve supplied values`() {
|
|
var selectedID: String? = "unchanged"
|
|
var flipCount = 0
|
|
let devices = [OpenClawChatAudioInputDevice(id: "mic-1", name: "Desk Mic")]
|
|
let control = OpenClawChatTalkControl(
|
|
isEnabled: true,
|
|
isListening: true,
|
|
isSpeaking: false,
|
|
isGatewayConnected: true,
|
|
statusText: "Listening",
|
|
providerLabel: "",
|
|
level: 0.6,
|
|
partialTranscript: "hello",
|
|
recentTranscript: ["earlier"],
|
|
inputDevices: devices,
|
|
selectedInputDeviceID: "mic-1",
|
|
selectInputDevice: { selectedID = $0 },
|
|
cameraFacing: .back,
|
|
flipCamera: { flipCount += 1 },
|
|
toggle: { _ in })
|
|
|
|
control.selectInputDevice?(nil)
|
|
control.flipCamera?()
|
|
|
|
#expect(control.level == 0.6)
|
|
#expect(control.partialTranscript == "hello")
|
|
#expect(control.recentTranscript == ["earlier"])
|
|
#expect(control.inputDevices == devices)
|
|
#expect(control.selectedInputDeviceID == "mic-1")
|
|
#expect(selectedID == nil)
|
|
#expect(control.cameraFacing == .back)
|
|
#expect(flipCount == 1)
|
|
}
|
|
}
|
|
|
|
struct ChatTalkTranscriptStripModelTests {
|
|
@Test func `model trims blanks bounds finals and prefers partial preview`() {
|
|
let model = ChatTalkTranscriptStripModel(
|
|
recentTranscript: [" ", " first ", "second", "third"],
|
|
partialTranscript: " live words ",
|
|
limit: 2)
|
|
|
|
#expect(model.recentTranscript == ["second", "third"])
|
|
#expect(model.partialTranscript == "live words")
|
|
#expect(model.collapsedText == "live words")
|
|
#expect(model.hasTranscript)
|
|
}
|
|
|
|
@Test func `model falls back to latest final and hides empty transcript`() {
|
|
let finalOnly = ChatTalkTranscriptStripModel(
|
|
recentTranscript: ["first", "second"],
|
|
partialTranscript: "")
|
|
let empty = ChatTalkTranscriptStripModel(
|
|
recentTranscript: [" "],
|
|
partialTranscript: "\n")
|
|
|
|
#expect(finalOnly.collapsedText == "second")
|
|
#expect(empty.collapsedText == nil)
|
|
#expect(!empty.hasTranscript)
|
|
}
|
|
}
|