The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { MCP_APPS, mcpHandoffAction } from "./mcpApps"; |
| 4 | |
| 5 | const MCP_URL = "https://prod-a1.t3coderelay.com/mcp?x=1&y=two words"; |
| 6 | |
| 7 | describe("MCP app links", () => { |
| 8 | it("fill in T3 Code and the encoded URL", () => { |
| 9 | const opened = (id: string) => { |
| 10 | const app = MCP_APPS.find((candidate) => candidate.id === id)!; |
| 11 | return new URL(mcpHandoffAction(app, MCP_URL)!.link); |
| 12 | }; |
| 13 | const poke = opened("poke"); |
| 14 | expect(poke.searchParams.get("name")).toBe("T3 Code"); |
| 15 | expect(poke.searchParams.get("url")).toBe(MCP_URL); |
| 16 | const claude = opened("claude"); |
| 17 | expect(claude.searchParams.get("connectorName")).toBe("T3 Code"); |
| 18 | expect(claude.searchParams.get("connectorUrl")).toBe(MCP_URL); |
| 19 | }); |
| 20 | |
| 21 | // The desktop app opens only https links and the app launch links it lists. |
| 22 | it.each(MCP_APPS.map((app) => [app.name, app] as const))("%s opens only https", (_, app) => { |
| 23 | const action = mcpHandoffAction(app, MCP_URL); |
| 24 | for (const url of [action?.link, app.docs].filter((value) => value != null)) { |
| 25 | expect(new URL(url).protocol).toBe("https:"); |
| 26 | } |
| 27 | // Grok Bot's app link prefills the message it copies. |
| 28 | const appLink = action?.appLink == null ? null : new URL(action.appLink); |
| 29 | expect(appLink?.protocol ?? null).toBe(app.id === "grok-bot" ? "grokbot:" : null); |
| 30 | if (appLink) expect(appLink.searchParams.get("text")).toBe(action?.copy?.text); |
| 31 | }); |
| 32 | }); |