43 lines
1.3 KiB
Swift
43 lines
1.3 KiB
Swift
import ClawdbotKit
|
|
import Testing
|
|
|
|
@Suite struct CanvasA2UITests {
|
|
@Test func commandStringsAreStable() {
|
|
#expect(ClawdbotCanvasA2UICommand.push.rawValue == "canvas.a2ui.push")
|
|
#expect(ClawdbotCanvasA2UICommand.pushJSONL.rawValue == "canvas.a2ui.pushJSONL")
|
|
#expect(ClawdbotCanvasA2UICommand.reset.rawValue == "canvas.a2ui.reset")
|
|
}
|
|
|
|
@Test func jsonlDecodesAndValidatesV0_8() throws {
|
|
let jsonl = """
|
|
{"beginRendering":{"surfaceId":"main","timestamp":1}}
|
|
{"surfaceUpdate":{"surfaceId":"main","ops":[]}}
|
|
{"dataModelUpdate":{"dataModel":{"title":"Hello"}}}
|
|
{"deleteSurface":{"surfaceId":"main"}}
|
|
"""
|
|
|
|
let messages = try ClawdbotCanvasA2UIJSONL.decodeMessagesFromJSONL(jsonl)
|
|
#expect(messages.count == 4)
|
|
}
|
|
|
|
@Test func jsonlRejectsV0_9CreateSurface() {
|
|
let jsonl = """
|
|
{"createSurface":{"surfaceId":"main"}}
|
|
"""
|
|
|
|
#expect(throws: Error.self) {
|
|
_ = try ClawdbotCanvasA2UIJSONL.decodeMessagesFromJSONL(jsonl)
|
|
}
|
|
}
|
|
|
|
@Test func jsonlRejectsUnknownShape() {
|
|
let jsonl = """
|
|
{"wat":{"nope":1}}
|
|
"""
|
|
|
|
#expect(throws: Error.self) {
|
|
_ = try ClawdbotCanvasA2UIJSONL.decodeMessagesFromJSONL(jsonl)
|
|
}
|
|
}
|
|
}
|