@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 29 lines 1.12 KB
Raw
1 import * as Cause from "effect/Cause";
2 import { AsyncResult, AtomRegistry } from "effect/reactivity";
3 import { describe, expect, it, vi } from "vite-plus/test";
4
5 import { connectionAtomRuntime } from "./runtime";
6
7 function visit(path: string): Disposable {
8 const previous = `${window.location.pathname}${window.location.search}`;
9 window.history.replaceState(window.history.state, "", path);
10 return {
11 [Symbol.dispose]: () => window.history.replaceState(window.history.state, "", previous),
12 };
13 }
14
15 describe("connectionAtomRuntime", () => {
16 it("connects to no environment on the guest page", async () => {
17 using _page = visit("/guest?share=share-1");
18 using socket = vi.spyOn(window, "WebSocket");
19 const registry = AtomRegistry.make();
20 using _mounted = { [Symbol.dispose]: registry.mount(connectionAtomRuntime) };
21 await vi.waitFor(() => {
22 const result = registry.get(connectionAtomRuntime);
23 expect(AsyncResult.isFailure(result) && String(Cause.squash(result.cause))).toContain(
24 "The guest page has no environment connection.",
25 );
26 });
27 expect(socket).not.toHaveBeenCalled();
28 });
29 });