From 0206cfc1d329f7d8ec04bf325846fa40ba840106 Mon Sep 17 00:00:00 2001 From: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com> Date: Mon, 2 Nov 2026 17:20:54 -0800 Subject: [PATCH] test(web): file save session browser test no longer hangs on the discovery poll The hook's writable-access subscription mounted the real session atom, which boots the connection runtime and its endless platform discovery poll. When that poll scheduled its timers after the test installed fake timers (a slow CI runner), vi.runAllTimersAsync chased it until the 15s test timeout. Stub the session atom with an inert one so the test owns every timer it drains. Co-Authored-By: Claude Opus 5.5 --- .../files/fileSaveSessions.browser.test.tsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/apps/web/src/components/files/fileSaveSessions.browser.test.tsx b/apps/web/src/components/files/fileSaveSessions.browser.test.tsx index aff76479b7410..70456e2d92bb7 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()); + return { + ...actual, + environmentSession: { ...actual.environmentSession, sessionStateAtom: () => signedOut }, + readEnvironmentScope: () => true, + }; +}); vi.mock(import("./projectFilesQueryState"), async (original) => ({ ...(await original()), confirmProjectFileQueryData: () => true,