@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, 04:45 UTC

main
ts 94 lines 2.52 KB
Raw
1 import {
2 BearerConnectionTarget,
3 RelayConnectionTarget,
4 SshConnectionTarget,
5 } from "@t3tools/client-runtime/connection";
6 import { EnvironmentId } from "@t3tools/contracts";
7 import { describe, expect, it } from "vite-plus/test";
8
9 import { folderDropTarget } from "./folderDrop";
10
11 const environmentId = EnvironmentId.make("saved-local");
12 const base = { environmentId, label: "server" };
13 const savedServer = (httpBaseUrl: string, connectionId = "saved-1") => ({
14 target: new BearerConnectionTarget({ ...base, connectionId }),
15 httpBaseUrl,
16 });
17 const thinClient = {
18 localEnvironmentDisabled: true,
19 environmentId,
20 primaryEnvironmentId: null,
21 isDesktopRenderer: true,
22 primaryRunsInWsl: false,
23 };
24
25 describe("folderDropTarget", () => {
26 it.each([
27 [
28 "the bundled primary",
29 {
30 ...thinClient,
31 localEnvironmentDisabled: false,
32 primaryEnvironmentId: environmentId,
33 connection: null,
34 },
35 "local",
36 ],
37 [
38 "the bundled primary running in WSL",
39 {
40 ...thinClient,
41 localEnvironmentDisabled: false,
42 primaryEnvironmentId: environmentId,
43 primaryRunsInWsl: true,
44 connection: null,
45 },
46 { wslBackendId: "primary" },
47 ],
48 [
49 "a saved loopback server on desktop",
50 { ...thinClient, connection: savedServer("http://127.0.0.1:3773") },
51 "local",
52 ],
53 [
54 "a saved LAN server",
55 { ...thinClient, connection: savedServer("http://192.168.1.20:3773") },
56 "remote",
57 ],
58 [
59 "a saved loopback server in a browser",
60 { ...thinClient, isDesktopRenderer: false, connection: savedServer("http://localhost:3773") },
61 "remote",
62 ],
63 [
64 "a desktop WSL backend",
65 { ...thinClient, connection: savedServer("http://127.0.0.1:3774", "local:wsl:Ubuntu") },
66 { wslBackendId: "wsl:Ubuntu" },
67 ],
68 [
69 "an SSH forward on loopback",
70 {
71 ...thinClient,
72 connection: {
73 target: new SshConnectionTarget({ ...base, connectionId: "ssh-1" }),
74 httpBaseUrl: "http://127.0.0.1:41000",
75 },
76 },
77 "remote",
78 ],
79 [
80 "a relay connection",
81 {
82 ...thinClient,
83 connection: {
84 target: new RelayConnectionTarget(base),
85 httpBaseUrl: "https://relay.t3.codes",
86 },
87 },
88 "remote",
89 ],
90 ["an unprepared connection", { ...thinClient, connection: null }, "remote"],
91 ] as const)("targets %s", (_name, input, expected) => {
92 expect(folderDropTarget(input)).toEqual(expected);
93 });
94 });