Files
bot/apps/shared/BotKit/Tests/BotKitTests/ToolResultTextFormatterTests.swift
zeekay c715d72ffd Merge openclaw/main via rebrand bridge
Merged 3580 upstream commits from openclaw/main through a bridge branch
that applied the openclaw→hanzo-bot rebrand before merging.

Key upstream additions:
- Android device diagnostics and notification actions
- Device-auth v2 migration improvements
- Docker CLI packaging fixes
- Ollama discovery log demotion
- Channel health monitoring
- Slack native streaming
- Linq iMessage channel
- Gemini OAuth and FTS improvements
- Inbound sender metadata
- Daemon PATH improvements
- Canvas host and onboarding enhancements
- Security hardening (session files, exec allowlist)
2026-02-26 22:47:28 -08:00

55 lines
1.5 KiB
Swift

import Testing
@testable import BotChatUI
@Suite("ToolResultTextFormatter")
struct ToolResultTextFormatterTests {
@Test func leavesPlainTextUntouched() {
let result = ToolResultTextFormatter.format(text: "All good", toolName: "nodes")
#expect(result == "All good")
}
@Test func summarizesNodesListJSON() {
let json = """
{
"ts": 1771610031380,
"nodes": [
{
"displayName": "iPhone 16 Pro Max",
"connected": true,
"platform": "ios"
}
]
}
"""
let result = ToolResultTextFormatter.format(text: json, toolName: "nodes")
#expect(result.contains("1 node found."))
#expect(result.contains("iPhone 16 Pro Max"))
#expect(result.contains("connected"))
}
@Test func summarizesErrorJSONAndDropsAgentPrefix() {
let json = """
{
"status": "error",
"tool": "nodes",
"error": "agent=main node=iPhone gateway=default action=invoke: pairing required"
}
"""
let result = ToolResultTextFormatter.format(text: json, toolName: "nodes")
#expect(result == "Error: pairing required")
}
@Test func suppressesUnknownStructuredPayload() {
let json = """
{
"foo": "bar"
}
"""
let result = ToolResultTextFormatter.format(text: json, toolName: "nodes")
#expect(result.isEmpty)
}
}