The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(desktop): six vitest files stop paying cold module loads inside the test timeout
Teknium48c1761cbc7e
diff --git a/apps/desktop/src/app/chat/composer/hooks/use-auto-speak-replies.cross-window.test.tsx b/apps/desktop/src/app/chat/composer/hooks/use-auto-speak-replies.cross-window.test.tsxindex 33350c748d0..d524eccea66 100644--- a/apps/desktop/src/app/chat/composer/hooks/use-auto-speak-replies.cross-window.test.tsx+++ b/apps/desktop/src/app/chat/composer/hooks/use-auto-speak-replies.cross-window.test.tsx@@ -1,3 +1,13 @@+// 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 '@/lib/chat-messages'+import '@/lib/spoken-reply'+import '@/store/voice-playback'+import '@/store/voice-prefs'+import '../scope'+import './use-auto-speak-replies'+import { act, cleanup, renderHook } from '@testing-library/react'import { atom } from 'nanostores'import { afterEach, expect, it, vi } from 'vitest'diff --git a/apps/desktop/src/app/cron/index.test.tsx b/apps/desktop/src/app/cron/index.test.tsxindex ea3aa4a3dc3..f40eebc2a5c 100644--- a/apps/desktop/src/app/cron/index.test.tsx+++ b/apps/desktop/src/app/cron/index.test.tsx@@ -9,6 +9,8 @@ import { queryClient } from '@/lib/query-client'import { $cronFocusJobId, $cronJobs, setCronFocusJobId, setCronJobs } from '@/store/cron'import { notifyCronChanged, setChangeEventsAvailable } from '@/store/live-sync'+import { CronView } from './index'+const getCronJobRuns = vi.fn()const getCronJobs = vi.fn()const triggerCronJob = vi.fn()@@ -42,7 +44,6 @@ const job: CronJob = {const queuedRow = () => window.document.querySelector('[data-slot="cron-run-pending"]')async function renderCron() {- const { CronView } = await import('./index')let result!: ReturnType<typeof render>await act(async () => {diff --git a/apps/desktop/src/app/settings/providers-settings.terminal-disconnect.test.tsx b/apps/desktop/src/app/settings/providers-settings.terminal-disconnect.test.tsxindex bb694198567..0b4c0969fc6 100644--- a/apps/desktop/src/app/settings/providers-settings.terminal-disconnect.test.tsx+++ b/apps/desktop/src/app/settings/providers-settings.terminal-disconnect.test.tsx@@ -6,6 +6,8 @@ import { ConfirmHost } from '@/components/confirm-host'import { $confirmRequest } from '@/store/confirm'import type { OAuthProvider } from '@/types/hermes'+import { ProvidersSettings } from './providers-settings'+const listOAuthProviders = vi.fn()const disconnectOAuthProvider = vi.fn()const startManualProviderOAuth = vi.fn()@@ -68,8 +70,6 @@ afterEach(() => {})async function renderAccounts() {- const { ProvidersSettings } = await import('./providers-settings')-await act(async () => {render(<>diff --git a/apps/desktop/src/store/onboarding-decide.test.ts b/apps/desktop/src/store/onboarding-decide.test.tsindex 3af7ed3b55d..3a95201aa27 100644--- a/apps/desktop/src/store/onboarding-decide.test.ts+++ b/apps/desktop/src/store/onboarding-decide.test.ts@@ -1,3 +1,12 @@+// 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 './live-sync'+import './onboarding-intro'+import './onboarding-presence'+import './onboarding-run'+import './session'+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import type { OnboardingRequest } from './onboarding-run'diff --git a/apps/desktop/src/store/profile-rail-prefs.test.tsx b/apps/desktop/src/store/profile-rail-prefs.test.tsxindex 2f9b83ca838..b61263c9c19 100644--- a/apps/desktop/src/store/profile-rail-prefs.test.tsx+++ b/apps/desktop/src/store/profile-rail-prefs.test.tsx@@ -1,4 +1,14 @@// @vitest-environment jsdom+// Loaded once at collection, outside every hook's budget: vi.resetModules() keeps each module's+// transformed code, so the fresh copy a test imports only re-evaluates it. Without this each+// host's hook pays the cold transform of the whole graph and times out on a loaded runner.+import '@/app/chat/sidebar'+import '@/app/shell/hooks/use-statusbar-items'+import '@/components/pane-shell/tree/model'+import '@/components/pane-shell/tree/store'+import '@/components/ui/sidebar'+import '@/store/profile-rail-prefs'+import { act, cleanup, render, renderHook } from '@testing-library/react'import { MemoryRouter } from 'react-router'import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest'@@ -8,8 +18,7 @@ import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest// the rail. The Webapp (browser-hosted Desktop) always draws the rail as its// dropdown, never the squares; native Desktop keeps the squares until the// dropdown threshold. The host is fixed per page load, so each case loads a-// fresh module graph after declaring its host — in a hook, whose timeout-// absorbs the cold sidebar/statusbar import.+// fresh module graph after declaring its host.type SurfaceWindow = Window & { __HERMES_UI_SURFACE__?: string }diff --git a/apps/desktop/src/store/session-states-profile-rename.test.ts b/apps/desktop/src/store/session-states-profile-rename.test.tsindex 5e1ffec4aec..9070849ec50 100644--- a/apps/desktop/src/store/session-states-profile-rename.test.ts+++ b/apps/desktop/src/store/session-states-profile-rename.test.ts@@ -1,5 +1,14 @@// A profile rename keeps its sessions: every localStorage family keyed by the old profile name must move// to the new one, or the restored tabs dial a backend that no longer exists and 404 forever (#111868).++// 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 '@/lib/storage'+import '@/store/session'+import '@/store/session-states'+import '@/store/transcript-tail-cache'+import { beforeEach, describe, expect, it, vi } from 'vitest'describe('migrateTilesForProfile', () => {