Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ipc.test.ts

70 lines2.0 KB

1import * as Schema from "effect/Schema";
2import { describe, expect, it } from "vite-plus/test";
3​
4import { DesktopEnvironmentBootstrapSchema, DesktopWslStateSchema } from "./ipc.ts";
5​
6describe("DesktopEnvironmentBootstrapSchema", () => {
7 const decode = Schema.decodeUnknownSync(DesktopEnvironmentBootstrapSchema);
8​
9 it("preserves the concrete running distro separately from the backend id", () => {
10 expect(
11 decode({
12 id: "wsl:default",
13 label: "WSL (Ubuntu)",
14 runningDistro: "Ubuntu",
15 httpBaseUrl: "http://127.0.0.1:3774/",
16 wsBaseUrl: "ws://127.0.0.1:3774/",
17 }),
18 ).toEqual({
19 id: "wsl:default",
20 label: "WSL (Ubuntu)",
21 runningDistro: "Ubuntu",
22 httpBaseUrl: "http://127.0.0.1:3774/",
23 wsBaseUrl: "ws://127.0.0.1:3774/",
24 });
25 });
26​
27 it("allows non-running and non-WSL bootstraps to report no running distro", () => {
28 expect(
29 decode({
30 id: "primary",
31 label: "Windows",
32 runningDistro: null,
33 httpBaseUrl: null,
34 wsBaseUrl: null,
35 }).runningDistro,
36 ).toBeNull();
37 });
38});
39​
40​
41describe("DesktopWslStateSchema diagnostics", () => {
42 const decode = Schema.decodeUnknownSync(DesktopWslStateSchema);
43​
44 it("preserves structured post-preflight failure evidence", () => {
45 const diagnostic = {
46 occurredAt: "2026-08-10T06:00:00.000Z",
47 phase: "runtime-exit",
48 message: "backend exited with code 1",
49 distro: "Ubuntu",
50 wslVersion: 2,
51 nodePath: "/home/user/.cache/t3code/node",
52 httpBaseUrl: "http://172.20.0.2:3774/",
53 bindHost: "172.20.0.2",
54 port: 3774,
55 restartAttempt: 2,
56 pid: 4242,
57 } as const;
58 expect(
59 decode({
60 enabled: true,
61 distro: "Ubuntu",
62 available: true,
63 wslOnly: false,
64 distros: [{ name: "Ubuntu", isDefault: true, version: 2 }],
65 preflightError: null,
66 diagnostic,
67 }).diagnostic,
68 ).toEqual(diagnostic);
69 });
70});