@devries-cameron20 / t3code Mirror · read-only / commits / 8cfd2b5211
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

test(shared): cover advertised endpoint URL normalization and compatibility (#39651)

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

Neil Daquioag committed Nov 20, 2026 at 18:07 UTC 8cfd2b5211e9c377379a52195bdb31924655e845
1 file changed +57
packages/shared/src/advertisedEndpoint.test.ts new
+57
@@ -0,0 +1,57 @@
1 +import { describe, expect, it } from "vite-plus/test";
2 +
3 +import {
4 + createAdvertisedEndpoint,
5 + type CreateAdvertisedEndpointInput,
6 + normalizeHttpBaseUrl,
7 +} from "./advertisedEndpoint.ts";
8 +
9 +describe("normalizeHttpBaseUrl", () => {
10 + it("rejects non-http(s) schemes", () => {
11 + expect(() => normalizeHttpBaseUrl("ftp://example.com")).toThrow(/HTTP or HTTPS/);
12 + });
13 +});
14 +
15 +describe("createAdvertisedEndpoint", () => {
16 + const input = {
17 + id: "e1",
18 + label: "Local",
19 + provider: { id: "desktop-core", label: "Desktop", kind: "core", isAddon: false },
20 + reachability: "loopback",
21 + source: "desktop-core",
22 + } satisfies Omit<CreateAdvertisedEndpointInput, "httpBaseUrl">;
23 +
24 + it("marks plain-http endpoints as mixed-content blocked for hosted apps", () => {
25 + const endpoint = createAdvertisedEndpoint({
26 + ...input,
27 + httpBaseUrl: "http://192.168.1.10:8317",
28 + });
29 + expect(endpoint.compatibility.hostedHttpsApp).toBe("mixed-content-blocked");
30 + expect(endpoint.compatibility.desktopApp).toBe("compatible");
31 + expect(endpoint.wsBaseUrl).toBe("ws://192.168.1.10:8317/");
32 + });
33 +
34 + it("leaves https endpoints as unknown by default", () => {
35 + expect(
36 + createAdvertisedEndpoint({ ...input, httpBaseUrl: "https://example.com" }).compatibility
37 + .hostedHttpsApp,
38 + ).toBe("unknown");
39 + });
40 +
41 + it("uses an explicit hosted-https compatibility flag as given", () => {
42 + expect(
43 + createAdvertisedEndpoint({
44 + ...input,
45 + httpBaseUrl: "https://example.com",
46 + hostedHttpsCompatibility: "compatible",
47 + }).compatibility.hostedHttpsApp,
48 + ).toBe("compatible");
49 + expect(
50 + createAdvertisedEndpoint({
51 + ...input,
52 + httpBaseUrl: "https://example.com",
53 + hostedHttpsCompatibility: "mixed-content-blocked",
54 + }).compatibility.hostedHttpsApp,
55 + ).toBe("mixed-content-blocked");
56 + });
57 +});