Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Collect mocked AI chat imports before timed test setup

pulse-triage[bot]8bbdacc4f187
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
index eafbd373be..feef248bef 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
@@ -1,4 +1,4 @@
-import { describe, expect, it, vi, afterEach, beforeAll, beforeEach } from 'vitest';
+import { describe, expect, it, vi, afterEach, beforeEach } from 'vitest';
import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';
import { Show, createSignal } from 'solid-js';
import type { AIChatExplanationRequest } from '@/stores/aiChat';
@@ -7,6 +7,10 @@ import type { QueuedFollowUp } from '../hooks/useChat';
import { WORKFLOW_STATUS_PACE_MS } from '../workflowStatusDisplay';
import aiChatSource from '../index.tsx?raw';
import { logger } from '@/utils/logger';
+// Vitest hoists vi.hoisted/vi.mock before these imports. Collect the component
+// here so cold Vite transforms do not consume a functional setup-hook budget.
+import { AIChat, resetAIChatComposerDraftStashForTests } from '../index';
+import { resetAIRuntimeState } from '@/stores/aiRuntimeState';
// ── Hoisted mocks (vi.mock factories reference these) ──────────────────────
@@ -484,22 +488,6 @@ vi.mock('@/hooks/useResources', () => ({
useResources: () => ({ byType: mockByType, resources: mockResources }),
}));
-// ── Lazy import after mocks ────────────────────────────────────────────────
-
-let AIChat: typeof import('../index').AIChat;
-let resetAIChatComposerDraftStashForTests: typeof import('../index').resetAIChatComposerDraftStashForTests;
-let resetAIRuntimeState: typeof import('@/stores/aiRuntimeState').resetAIRuntimeState;
-
-beforeAll(async () => {
- const [chatModule, runtimeModule] = await Promise.all([
- import('../index'),
- import('@/stores/aiRuntimeState'),
- ]);
- AIChat = chatModule.AIChat;
- resetAIChatComposerDraftStashForTests = chatModule.resetAIChatComposerDraftStashForTests;
- resetAIRuntimeState = runtimeModule.resetAIRuntimeState;
-});
-
// ── Helpers ────────────────────────────────────────────────────────────────
function renderChat(onClose = vi.fn()) {