@devries-cameron20 / t3code Mirror · read-only
Fork 0

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, 03:37 UTC

main
ts 42 lines 1.43 KB
Raw
1 import { describe, expect, it } from "vite-plus/test";
2
3 import { webhookAddress } from "./webhookAddress.ts";
4
5 const endpoint = {
6 path: "/hooks/abc",
7 url: null,
8 hasSecret: true,
9 };
10
11 describe("webhookAddress", () => {
12 it("returns the public endpoint URL copyable with no note", () => {
13 const result = webhookAddress(
14 { ...endpoint, url: "https://connect.example.com/hooks/abc" },
15 null,
16 );
17 expect(result.address).toBe("https://connect.example.com/hooks/abc");
18 expect(result.copyable).toBe(true);
19 expect(result.note).toBeNull();
20 });
21
22 it("is not copyable and points at T3 Connect when no base URL exists", () => {
23 const result = webhookAddress(endpoint, null);
24 expect(result.address).toBe("/hooks/abc");
25 expect(result.copyable).toBe(false);
26 expect(result.note).toContain("T3 Connect");
27 });
28
29 it("warns that loopback addresses only work on this computer", () => {
30 const result = webhookAddress(endpoint, "http://127.0.0.1:8787");
31 expect(result.address).toBe("http://127.0.0.1:8787/hooks/abc");
32 expect(result.copyable).toBe(true);
33 expect(result.note).toContain("Only this computer");
34 });
35
36 it("explains reachability for non-loopback hosts", () => {
37 const result = webhookAddress(endpoint, "https://home.example.net");
38 expect(result.address).toBe("https://home.example.net/hooks/abc");
39 expect(result.copyable).toBe(true);
40 expect(result.note).toContain("Tailscale");
41 });
42 });