Skip to content

Commit 2d2299a

Browse files
fix(web): file save session browser test no longer hangs on the discovery poll (#29813)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent f6503f0 commit 2d2299a

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

‎apps/web/src/components/files/fileSaveSessions.browser.test.tsx‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { render, fakeTimers } from "../../../test/render";
2-
import { EnvironmentId } from "@t3tools/contracts";
2+
import { type AuthSessionState, EnvironmentId } from "@t3tools/contracts";
33
import { AsyncResult } from "effect/reactivity";
44
import { StrictMode } from "react";
55
import { describe, expect, it, vi } from "vite-plus/test";
@@ -12,10 +12,18 @@ vi.mock(import("@t3tools/client-runtime/state/runtime"), async (original) => ({
1212
...(await original()),
1313
runAtomCommand: runAtomCommand as never,
1414
}));
15-
vi.mock(import("~/state/session"), async (original) => ({
16-
...(await original()),
17-
readEnvironmentScope: () => true,
18-
}));
15+
// The real session atom boots the connection runtime, whose endless discovery poll
16+
// would keep vi.runAllTimersAsync from ever draining once its timers are faked.
17+
vi.mock(import("~/state/session"), async (original) => {
18+
const actual = await original();
19+
const reactivity = await import("effect/reactivity");
20+
const signedOut = reactivity.Atom.make(reactivity.AsyncResult.initial<AuthSessionState>());
21+
return {
22+
...actual,
23+
environmentSession: { ...actual.environmentSession, sessionStateAtom: () => signedOut },
24+
readEnvironmentScope: () => true,
25+
};
26+
});
1927
vi.mock(import("./projectFilesQueryState"), async (original) => ({
2028
...(await original()),
2129
confirmProjectFileQueryData: () => true,

0 commit comments

Comments
 (0)