The Coline App SDK: apps, tools, file types and surfaces that run inside Coline workspaces, and public websites with Coline Sites. TypeScript, with an in-memory test workspace. MIT.
| 5 | it("builds declarative stack trees", () => { |
| 6 | const tree = ui.stack([ |
| 7 | ui.heading("Notes"), |
| 8 | ui.text("Welcome"), |
| 9 | ui.button("New note", { |
| 10 | action: { |
| 11 | type: "create_note", |
| 12 | }, |
| 13 | }), |
| 14 | ]); |
| 15 |
| 16 | const parsed = colineUiNodeSchema.parse(tree); |
| 17 | expect(parsed.type).toBe("Stack"); |
| 18 | }); |
| 19 |
| 20 | it("builds file cards and empty states", () => { |
| 21 | const card = ui.fileCard({ |
| 22 | title: "Roadmap", |
| 23 | subtitle: "Updated just now", |
| 24 | fileId: "file_123", |
| 25 | }); |
| 26 | const empty = ui.emptyState({ |
| 27 | title: "No notes yet", |
| 28 | description: "Create your first note.", |
| 29 | }); |
| 30 |
| 31 | expect(colineUiNodeSchema.parse(card).type).toBe("FileCard"); |
| 32 | expect(colineUiNodeSchema.parse(empty).type).toBe("EmptyState"); |
| 33 | }); |
| 34 |
| 35 | it("builds typed UI actions", () => { |
| 36 | expect( |
| 37 | colineUiActionSchema.parse(actions.openFile("file_123")), |
| 38 | ).toEqual({ |
| 39 | type: "open_file", |
| 40 | payload: { |
| 41 | fileId: "file_123", |
| 42 | }, |
| 43 | }); |
| 44 | }); |
| 45 | }); |
| 46 |