Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): keep interrupted environment queries pending #6233

Closedserabi(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/6233/headopened View on GitHub

Showing 2 changed files with 38 additions and 2 deletions.

x
0 of 2 viewed, 2 left
35 additions and 0 deletionsapps/web/src/state/query.test.tsAdded
View file
@@ -0,0 +1,35 @@
+import * as Cause from "effect/Cause";
+import { AsyncResult, Atom } from "effect/unstable/reactivity";
+import { describe, expect, it, vi } from "vite-plus/test";
+​
+const harness = vi.hoisted(() => ({
+ result: null as AsyncResult.AsyncResult<unknown, unknown> | null,
+ refresh: vi.fn(),
+}));
+​
+vi.mock("@effect/atom-react", () => ({
+ useAtomRefresh: () => harness.refresh,
+ useAtomValue: () => harness.result,
+}));
+​
+import { useEnvironmentQuery } from "./query";
+​
+describe("useEnvironmentQuery", () => {
+ it("keeps an interrupted request pending instead of exposing an internal error", () => {
+ harness.result = AsyncResult.failure(Cause.interrupt(1));
+​
+ const query = useEnvironmentQuery(Atom.make(harness.result));
+​
+ expect(query.error).toBeNull();
+ expect(query.isPending).toBe(true);
+ });
+​
+ it("continues to expose genuine environment failures", () => {
+ harness.result = AsyncResult.failure(Cause.fail(new Error("GitHub did not answer.")));
+​
+ const query = useEnvironmentQuery(Atom.make(harness.result));