@devries-cameron20 / t3code Mirror · read-only / commits / efeeb7737b
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 23, 19:15 UTC

refactor(web): import connection storage as a namespace in its test (#16315)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Julius Marminge committed Oct 5, 2026 at 21:42 UTC efeeb7737bed89bbfc6dc81662058f8ce7fba2ea
1 file changed +18 -21
apps/web/src/connection/storage.test.ts
+18 -21
@@ -12,12 +12,7 @@ import * as Schema from "effect/Schema";
12 import * as Stream from "effect/Stream";
13 import { afterEach, vi } from "vite-plus/test";
14
15 -import {
16 - makeBrowserGitHubRoutingPermissions,
17 - makeCatalogBackend,
18 - makeCatalogStore,
19 - layer as connectionStorageLayer,
20 -} from "./storage";
15 +import * as ConnectionStorage from "./storage";
16
17 const emptyCatalog = {
18 schemaVersion: 1,
@@ -35,12 +30,12 @@ afterEach(() => {
30 vi.restoreAllMocks();
31 });
32
38 -describe("makeCatalogStore", () => {
33 +describe("ConnectionStorage.makeCatalogStore", () => {
34 it.effect("quarantines malformed catalogs and starts from an empty document", () =>
35 Effect.gen(function* () {
36 const writes: string[] = [];
37 const quarantined: string[] = [];
43 - const store = yield* makeCatalogStore({
38 + const store = yield* ConnectionStorage.makeCatalogStore({
39 read: Effect.succeed("{not-json"),
40 write: (raw) => Effect.sync(() => writes.push(raw)),
41 quarantine: (raw) => Effect.sync(() => quarantined.push(raw)),
@@ -59,7 +54,7 @@ describe("makeCatalogStore", () => {
54 reason: "remote-unavailable",
55 detail: "permission denied",
56 });
62 - const store = yield* makeCatalogStore({
57 + const store = yield* ConnectionStorage.makeCatalogStore({
58 read: Effect.fail(failure),
59 write: () => Effect.void,
60 });
@@ -74,7 +69,7 @@ const fixedHandle = (database: IDBDatabase) => ({
69 invalidate: () => Effect.void,
70 });
71
77 -describe("makeCatalogBackend", () => {
72 +describe("ConnectionStorage.makeCatalogBackend", () => {
73 it.effect("reports a closed IndexedDB connection as a typed read and write failure", () =>
74 Effect.gen(function* () {
75 vi.stubGlobal("window", {});
@@ -83,7 +78,7 @@ describe("makeCatalogBackend", () => {
78 throw new DOMException("The database connection is closing.", "InvalidStateError");
79 },
80 } as unknown as IDBDatabase;
86 - const backend = makeCatalogBackend(fixedHandle(database));
81 + const backend = ConnectionStorage.makeCatalogBackend(fixedHandle(database));
82
83 const readError = yield* Effect.flip(backend.read);
84 const writeError = yield* Effect.flip(backend.write("{}"));
@@ -103,7 +98,7 @@ describe("makeCatalogBackend", () => {
98 setConnectionCatalog,
99 },
100 });
106 - const backend = makeCatalogBackend(fixedHandle({} as IDBDatabase));
101 + const backend = ConnectionStorage.makeCatalogBackend(fixedHandle({} as IDBDatabase));
102
103 const error = yield* backend.write("{}").pipe(Effect.flip);
104
@@ -128,7 +123,7 @@ describe("makeCatalogBackend", () => {
123 },
124 }),
125 });
131 - const backend = makeCatalogBackend(
126 + const backend = ConnectionStorage.makeCatalogBackend(
127 fixedHandle({ transaction: () => transaction } as unknown as IDBDatabase),
128 );
129
@@ -176,7 +171,7 @@ describe("environment cache removal", () => {
171 ),
172 yield* Effect.flip(cache.clearVcsRefs(EnvironmentId.make("env"))),
173 ] as const;
179 - }).pipe(Effect.provide(connectionStorageLayer));
174 + }).pipe(Effect.provide(ConnectionStorage.layer));
175
176 expect(threadError.message).toContain("Commit aborted");
177 expect(refsError.message).toContain("Commit aborted");
@@ -201,7 +196,7 @@ describe("IndexedDB connection recovery", () => {
196 cache.loadThread(EnvironmentId.make("env"), ThreadId.make("thread")),
197 );
198 expect(error.message).toContain("Storage is unavailable");
204 - }).pipe(Effect.provide(connectionStorageLayer));
199 + }).pipe(Effect.provide(ConnectionStorage.layer));
200
201 expect(open).toHaveBeenCalledOnce();
202 }),
@@ -254,7 +249,7 @@ describe("IndexedDB connection recovery", () => {
249 );
250 expect(recovered.every(Option.isNone)).toBe(true);
251 expect(open).toHaveBeenCalledTimes(2);
257 - }).pipe(Effect.provide(connectionStorageLayer));
252 + }).pipe(Effect.provide(ConnectionStorage.layer));
253
254 expect(first.close).not.toHaveBeenCalled();
255 expect(second.close).toHaveBeenCalledOnce();
@@ -302,7 +297,7 @@ describe("IndexedDB connection closed without a close event", () => {
297 const loaded = yield* cache.loadThread(EnvironmentId.make("env"), ThreadId.make("thread"));
298 expect(Option.isNone(loaded)).toBe(true);
299 expect(open).toHaveBeenCalledTimes(2);
305 - }).pipe(Effect.provide(connectionStorageLayer));
300 + }).pipe(Effect.provide(ConnectionStorage.layer));
301 }),
302 );
303 });
@@ -329,8 +324,8 @@ describe("browser GitHub routing permissions", () => {
324 };
325 const firstBrowser = Object.assign(new EventTarget(), { localStorage });
326 const secondBrowser = Object.assign(new EventTarget(), { localStorage });
332 - const first = makeBrowserGitHubRoutingPermissions(firstBrowser);
333 - const second = makeBrowserGitHubRoutingPermissions(secondBrowser);
327 + const first = ConnectionStorage.makeBrowserGitHubRoutingPermissions(firstBrowser);
328 + const second = ConnectionStorage.makeBrowserGitHubRoutingPermissions(secondBrowser);
329 const entry = {
330 target: new PrimaryConnectionTarget({
331 environmentId: EnvironmentId.make("first"),
@@ -352,7 +347,7 @@ describe("browser GitHub routing permissions", () => {
347 yield* first.set(entry, "read-write");
348 expect(yield* second.get(entry)).toBe("read-write");
349 const oldPermissions = Option.getOrThrow(yield* Stream.runHead(first.changes));
355 - const staleCatalog = yield* makeCatalogStore({
350 + const staleCatalog = yield* ConnectionStorage.makeCatalogStore({
351 read: Effect.succeed(
352 encodeCatalog({ ...emptyCatalog, githubRoutingPermissions: oldPermissions }),
353 ),
@@ -377,7 +372,9 @@ describe("browser GitHub routing permissions", () => {
372 yield* staleCatalog.update((document) => ({ ...document, accountId: "updated" }));
373 expect(yield* second.get(entry)).toBe("off");
374 expect(yield* first.get(other)).toBe("read");
380 - expect(yield* makeBrowserGitHubRoutingPermissions(firstBrowser).get(entry)).toBe("off");
375 + expect(
376 + yield* ConnectionStorage.makeBrowserGitHubRoutingPermissions(firstBrowser).get(entry),
377 + ).toBe("off");
378
379 yield* first.set(entry, "read-write");
380 yield* second.forget(entry.target.environmentId);