Skip to content

The agent that grows with you

test(desktop): five more vitest files load their module graph before the test clock starts

Teknium67dc499d8111
diff --git a/apps/desktop/src/app/chat/browser-popout-handoff.test.tsx b/apps/desktop/src/app/chat/browser-popout-handoff.test.tsx
index fefd1396073..72a679b168f 100644
--- a/apps/desktop/src/app/chat/browser-popout-handoff.test.tsx
+++ b/apps/desktop/src/app/chat/browser-popout-handoff.test.tsx
@@ -17,8 +17,11 @@ vi.mock('./right-rail/real-profile-consent-dialog', () => ({
// spawns, no URL bar, content never paints — #119850).
const TABS_KEY = 'hermes.desktop.previewTabs.v2'
-// Cold module graph, not test logic: the shell pulls in the whole app.
-vi.setConfig({ testTimeout: 90000 })
+// Loaded once at collection, outside every test's budget: vi.resetModules() keeps each module's
+// transformed code, so the fresh copy a test imports only re-evaluates it. Without this the first
+// test pays the cold transform of the whole app the shell pulls in and times out on a loaded runner.
+import '@/store/preview'
+import './browser-popout-shell'
function tabRow(id: string, url: string) {
return { id, target: { kind: 'url', label: 'kanban', source: url, url } }
diff --git a/apps/desktop/src/app/gateway/hooks/use-gateway-request.test.ts b/apps/desktop/src/app/gateway/hooks/use-gateway-request.test.ts
index 08c5b2997a0..71fd8e35396 100644
--- a/apps/desktop/src/app/gateway/hooks/use-gateway-request.test.ts
+++ b/apps/desktop/src/app/gateway/hooks/use-gateway-request.test.ts
@@ -50,6 +50,11 @@ vi.mock('@/hermes', async importOriginal => {
return { ...actual, HermesGateway: FakeHermesGateway }
})
+// A secondary's reopen does `await import('@/store/session-states')` (store/gateway.ts). Load that
+// graph at collection so the first reconnect test is not charged its cold transform, which times it
+// out on a loaded runner.
+import '@/store/session-states'
+
import type * as HermesModule from '@/hermes'
import type { HermesGateway } from '@/hermes'
import {
diff --git a/apps/desktop/src/app/session/hooks/branch-owner-routing.integration.test.ts b/apps/desktop/src/app/session/hooks/branch-owner-routing.integration.test.ts
index a7755ec313d..ab9763577a4 100644
--- a/apps/desktop/src/app/session/hooks/branch-owner-routing.integration.test.ts
+++ b/apps/desktop/src/app/session/hooks/branch-owner-routing.integration.test.ts
@@ -71,6 +71,13 @@ vi.mock('@/hermes', async importOriginal => ({
setApiRequestConnection: vi.fn()
}))
+// Loaded once at collection, outside every test's budget: vi.resetModules() keeps each module's
+// transformed code, so the fresh copy a test imports only re-evaluates it. session-states is the
+// graph a reopened secondary imports lazily (store/gateway.ts). Top-level await rather than a static
+// import: the mock above reads FakeHermesGateway, which a hoisted import would reach before it exists.
+await import('@/store/gateway')
+await import('@/store/session-states')
+
describe('branch owner routing (real router, faked transport)', () => {
beforeEach(() => {
dialed.length = 0
diff --git a/apps/desktop/src/components/pane-shell/tree/renderer/floating-mode-memory.test.tsx b/apps/desktop/src/components/pane-shell/tree/renderer/floating-mode-memory.test.tsx
index dd9c047ca80..8feb298bbd5 100644
--- a/apps/desktop/src/components/pane-shell/tree/renderer/floating-mode-memory.test.tsx
+++ b/apps/desktop/src/components/pane-shell/tree/renderer/floating-mode-memory.test.tsx
@@ -1,3 +1,10 @@
+// Loaded once at collection, outside every test's budget: vi.resetModules() keeps each module's
+// transformed code, so the fresh copy a test imports only re-evaluates it. Without this the first
+// test pays the cold transform of the whole graph and times out on a loaded runner.
+import '@/contrib/registry'
+import '@/store/interface-mode'
+import './floating-panes'
+
import { act, cleanup, fireEvent, render } from '@testing-library/react'
import { afterEach, expect, it, vi } from 'vitest'
diff --git a/apps/desktop/src/store/layout-flipped-sides.test.ts b/apps/desktop/src/store/layout-flipped-sides.test.ts
index f71229ae4c4..f3797f3d7f1 100644
--- a/apps/desktop/src/store/layout-flipped-sides.test.ts
+++ b/apps/desktop/src/store/layout-flipped-sides.test.ts
@@ -1,3 +1,9 @@
+// Loaded once at collection, outside every test's budget: vi.resetModules() keeps each module's
+// transformed code, so the fresh copy a test imports only re-evaluates it. Without this the first
+// test pays the cold transform of the whole graph and times out on a loaded runner.
+import '@/components/pane-shell/tree/store'
+import '@/store/layout'
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
// An edge belongs to the pane that sits on it. Mirrored (⌘\ or the Simple
@@ -16,7 +22,7 @@ describe('side toggles follow the flip', () => {
vi.resetModules()
})
- it('collapses the edge the sidebar / file tree actually sit on', { timeout: 30_000 }, async () => {
+ it('collapses the edge the sidebar / file tree actually sit on', async () => {
const tree = await import('@/components/pane-shell/tree/store')
const layout = await import('@/store/layout')