Skip to content
TypeScript

fix(web): file save session browser test no longer hangs on the discovery poll (#29813)

Julius Marminge2d2299aaaf76
diff --git a/apps/web/src/components/files/fileSaveSessions.browser.test.tsx b/apps/web/src/components/files/fileSaveSessions.browser.test.tsx
index aff76479b74..70456e2d92b 100644
--- a/apps/web/src/components/files/fileSaveSessions.browser.test.tsx
+++ b/apps/web/src/components/files/fileSaveSessions.browser.test.tsx
@@ -1,5 +1,5 @@
import { render, fakeTimers } from "../../../test/render";
-import { EnvironmentId } from "@t3tools/contracts";
+import { type AuthSessionState, EnvironmentId } from "@t3tools/contracts";
import { AsyncResult } from "effect/reactivity";
import { StrictMode } from "react";
import { describe, expect, it, vi } from "vite-plus/test";
@@ -12,10 +12,18 @@ vi.mock(import("@t3tools/client-runtime/state/runtime"), async (original) => ({
...(await original()),
runAtomCommand: runAtomCommand as never,
}));
-vi.mock(import("~/state/session"), async (original) => ({
- ...(await original()),
- readEnvironmentScope: () => true,
-}));
+// The real session atom boots the connection runtime, whose endless discovery poll
+// would keep vi.runAllTimersAsync from ever draining once its timers are faked.
+vi.mock(import("~/state/session"), async (original) => {
+ const actual = await original();
+ const reactivity = await import("effect/reactivity");
+ const signedOut = reactivity.Atom.make(reactivity.AsyncResult.initial<AuthSessionState>());
+ return {
+ ...actual,
+ environmentSession: { ...actual.environmentSession, sessionStateAtom: () => signedOut },
+ readEnvironmentScope: () => true,
+ };
+});
vi.mock(import("./projectFilesQueryState"), async (original) => ({
...(await original()),
confirmProjectFileQueryData: () => true,