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

main
ts 57 lines 1.83 KB
Raw
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 });