Spaces:
Paused
Paused
| import OpenClawKit | |
| import Testing | |
| struct CanvasA2UITests { | |
| func commandStringsAreStable() { | |
| #expect(OpenClawCanvasA2UICommand.push.rawValue == "canvas.a2ui.push") | |
| #expect(OpenClawCanvasA2UICommand.pushJSONL.rawValue == "canvas.a2ui.pushJSONL") | |
| #expect(OpenClawCanvasA2UICommand.reset.rawValue == "canvas.a2ui.reset") | |
| } | |
| 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 OpenClawCanvasA2UIJSONL.decodeMessagesFromJSONL(jsonl) | |
| #expect(messages.count == 4) | |
| } | |
| func jsonlRejectsV0_9CreateSurface() { | |
| let jsonl = """ | |
| {"createSurface":{"surfaceId":"main"}} | |
| """ | |
| #expect(throws: Error.self) { | |
| _ = try OpenClawCanvasA2UIJSONL.decodeMessagesFromJSONL(jsonl) | |
| } | |
| } | |
| func jsonlRejectsUnknownShape() { | |
| let jsonl = """ | |
| {"wat":{"nope":1}} | |
| """ | |
| #expect(throws: Error.self) { | |
| _ = try OpenClawCanvasA2UIJSONL.decodeMessagesFromJSONL(jsonl) | |
| } | |
| } | |
| } | |