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

showcaseEnvironmentRows.test.ts

70 lines2.1 KB

1import { EnvironmentId } from "@t3tools/contracts";
2import { assert, it } from "@effect/vitest";
3​
4import type { ConnectedEnvironmentSummary } from "../../state/remote-runtime-types";
5import {
6 applyShowcaseLocalEnvironmentDisplayUrls,
7 resolveShowcaseEnvironmentUpdateDisplayUrl,
8} from "./showcaseEnvironmentRows";
9​
10function environment(
11 environmentId: string,
12 environmentLabel: string,
13 displayUrl = "http://127.0.0.1:3773/",
14): ConnectedEnvironmentSummary {
15 return {
16 environmentId: EnvironmentId.make(environmentId),
17 environmentLabel,
18 displayUrl,
19 isRelayManaged: false,
20 connectionState: "connected",
21 connectionError: null,
22 connectionErrorTraceId: null,
23 };
25​
26it("presents showcase transports as remote endpoints", () => {
27 const environments = applyShowcaseLocalEnvironmentDisplayUrls([
28 environment("runtime-id-1", "Moonbase Terminal"),
29 environment("runtime-id-2", "Suspense Station"),
30 environment("runtime-id-3", "Kernel Cabin"),
31 ]);
32​
33 assert.deepStrictEqual(
34 environments.map(({ displayUrl }) => displayUrl),
35 [
36 "https://moonbase.tail9f3a.ts.net/",
37 "https://suspense-vps.hel1.t3.sh/",
38 "http://100.82.16.5:3773/",
39 ],
40 );
41});
42​
43it("leaves environments outside the showcase fixture unchanged", () => {
44 const original = environment(
45 "runtime-id-4",
46 "My Workstation",
47 "https://workstation.example.test/",
48 );
49​
50 assert.deepStrictEqual(applyShowcaseLocalEnvironmentDisplayUrls([original]), [original]);
51});
52​
53it("does not persist a cosmetic showcase URL when only the label is saved", () => {
54 assert.equal(
55 resolveShowcaseEnvironmentUpdateDisplayUrl({
56 actualDisplayUrl: "http://127.0.0.1:3773/",
57 presentedDisplayUrl: "https://moonbase.tail9f3a.ts.net/",
58 submittedDisplayUrl: "https://moonbase.tail9f3a.ts.net/",
59 }),
60 "http://127.0.0.1:3773/",
61 );
62 assert.equal(
63 resolveShowcaseEnvironmentUpdateDisplayUrl({
64 actualDisplayUrl: "http://127.0.0.1:3773/",
65 presentedDisplayUrl: "https://moonbase.tail9f3a.ts.net/",
66 submittedDisplayUrl: "https://new-host.example.com/",
67 }),
68 "https://new-host.example.com/",
69 );
70});