@devries-cameron20 / t3code-1 / commits / c5514042ad
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

test(client-runtime): cover webhookAddress and imageAttachmentSize helpers (#39668)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Neil Daquioag committed Nov 20, 2026 at 17:58 UTC c5514042adfb2cb2323c75b449ffd5e950c6a40b
2 files changed +90
packages/client-runtime/src/imageAttachmentSize.test.ts new
+48
@@ -0,0 +1,48 @@
1 +import { describe, expect, it } from "vite-plus/test";
2 +
3 +import {
4 + IMAGE_ATTACHMENT_MAX_EDGE,
5 + downscalableImageMimeType,
6 + fitImageAttachmentSize,
7 +} from "./imageAttachmentSize.ts";
8 +
9 +describe("downscalableImageMimeType", () => {
10 + it.each([
11 + ["image/png", "image/png"],
12 + ["image/jpeg", "image/jpeg"],
13 + ["image/jpg", "image/jpeg"],
14 + ["IMAGE/PNG", "image/png"],
15 + ])("normalizes %s to %s", (input, expected) => {
16 + expect(downscalableImageMimeType(input)).toBe(expected);
17 + });
18 +
19 + it.each(["image/gif", "image/webp", "text/plain"])("rejects %s", (input) => {
20 + expect(downscalableImageMimeType(input)).toBeNull();
21 + });
22 +});
23 +
24 +describe("fitImageAttachmentSize", () => {
25 + it("returns null when the image already fits", () => {
26 + expect(fitImageAttachmentSize({ width: 800, height: 600 })).toBeNull();
27 + expect(
28 + fitImageAttachmentSize({
29 + width: IMAGE_ATTACHMENT_MAX_EDGE,
30 + height: IMAGE_ATTACHMENT_MAX_EDGE,
31 + }),
32 + ).toBeNull();
33 + });
34 +
35 + it("scales the longest edge down to the limit", () => {
36 + expect(fitImageAttachmentSize({ width: 4000, height: 2000 })).toEqual({
37 + width: 2000,
38 + height: 1000,
39 + });
40 + });
41 +
42 + it("clamps the short edge of extreme aspect ratios to at least 1px", () => {
43 + expect(fitImageAttachmentSize({ width: 1, height: 10000 })).toEqual({
44 + width: 1,
45 + height: IMAGE_ATTACHMENT_MAX_EDGE,
46 + });
47 + });
48 +});
packages/client-runtime/src/webhookAddress.test.ts new
+42
@@ -0,0 +1,42 @@
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 +});