Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

toolPresentation.test.ts

95 lines2.6 KB

1import { describe, expect, it } from "@effect/vitest";
2​
3import { extractToolActivityPresentation } from "./toolPresentation.ts";
4​
5describe("extractToolActivityPresentation", () => {
6 it("reads provider-neutral presentation fields", () => {
7 expect(
8 extractToolActivityPresentation({
9 toolSurface: "browser",
10 toolIcon: {
11 _tag: "website",
12 pageUrl: "https://example.com/docs",
13 faviconUrl: "https://example.com/favicon.png",
14 faviconUrlDark: "https://example.com/favicon-dark.png",
15 },
16 toolSource: {
17 key: "integration:example",
18 name: "Example",
19 kind: "integration",
20 icon: {
21 _tag: "themed-logo",
22 logoUrl: "https://example.com/logo-light.png",
23 logoUrlDark: "https://example.com/logo-dark.png",
24 },
25 },
26 }),
27 ).toEqual({
28 toolSurface: "browser",
29 toolIcon: {
30 _tag: "website",
31 pageUrl: "https://example.com/docs",
32 faviconUrl: "https://example.com/favicon.png",
33 faviconUrlDark: "https://example.com/favicon-dark.png",
34 },
35 toolSource: {
36 key: "integration:example",
37 name: "Example",
38 kind: "integration",
39 icon: {
40 _tag: "themed-logo",
41 logoUrl: "https://example.com/logo-light.png",
42 logoUrlDark: "https://example.com/logo-dark.png",
43 },
44 },
45 });
46 });
47​
48 it("reads provider-neutral native app icons", () => {
49 expect(
50 extractToolActivityPresentation({
51 toolSurface: "computer",
52 toolIcon: {
53 _tag: "native-app",
54 app: { _tag: "app-id", appId: "com.example.Editor" },
55 },
56 toolSource: {
57 key: "native-app:com.example.editor",
58 name: "Editor",
59 kind: "computer",
60 },
61 }),
62 ).toEqual({
63 toolSurface: "computer",
64 toolIcon: {
65 _tag: "native-app",
66 app: { _tag: "app-id", appId: "com.example.Editor" },
67 },
68 toolSource: {
69 key: "native-app:com.example.editor",
70 name: "Editor",
71 kind: "computer",
72 },
73 });
74 });
75​
76 it("does not infer presentation from provider-specific payload data", () => {
77 expect(
78 extractToolActivityPresentation({
79 data: {
80 item: {
81 arguments: { code: 'await sky.click({ app: "Finder" })' },
82 result: {
83 _meta: {
84 "codex/toolSurface": {
85 kind: "computerUse",
86 app: { kind: "displayName", displayName: "Finder" },
87 },
88 },
89 },
90 },
91 },
92 }),
93 ).toEqual({});
94 });
95});