mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-13 11:00:50 +00:00
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: 34dd87b0c0
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
56 lines
1.4 KiB
Swift
56 lines
1.4 KiB
Swift
import Testing
|
|
@testable import OpenClawChatUI
|
|
|
|
@Suite("ChatMarkdownPreprocessor")
|
|
struct ChatMarkdownPreprocessorTests {
|
|
@Test func extractsDataURLImages() {
|
|
let base64 = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIHWP4////GQAJ+wP/2hN8NwAAAABJRU5ErkJggg=="
|
|
let markdown = """
|
|
Hello
|
|
|
|
)
|
|
"""
|
|
|
|
let result = ChatMarkdownPreprocessor.preprocess(markdown: markdown)
|
|
|
|
#expect(result.cleaned == "Hello")
|
|
#expect(result.images.count == 1)
|
|
#expect(result.images.first?.image != nil)
|
|
}
|
|
|
|
@Test func stripsInboundUntrustedContextBlocks() {
|
|
let markdown = """
|
|
Conversation info (untrusted metadata):
|
|
```json
|
|
{
|
|
"message_id": "123",
|
|
"sender": "openclaw-ios"
|
|
}
|
|
```
|
|
|
|
Sender (untrusted metadata):
|
|
```json
|
|
{
|
|
"label": "Razor"
|
|
}
|
|
```
|
|
|
|
Razor?
|
|
"""
|
|
|
|
let result = ChatMarkdownPreprocessor.preprocess(markdown: markdown)
|
|
|
|
#expect(result.cleaned == "Razor?")
|
|
}
|
|
|
|
@Test func stripsLeadingTimestampPrefix() {
|
|
let markdown = """
|
|
[Fri 2026-02-20 18:45 GMT+1] How's it going?
|
|
"""
|
|
|
|
let result = ChatMarkdownPreprocessor.preprocess(markdown: markdown)
|
|
|
|
#expect(result.cleaned == "How's it going?")
|
|
}
|
|
}
|