From a6019cc82d77eeb8be284bb9162093257b9d7299 Mon Sep 17 00:00:00 2001 From: jedarden Date: Fri, 22 May 2026 17:31:19 -0400 Subject: [PATCH] test(bf-3oy5): fix mock setup for SemanticNarrativePanel tests The vi.mock() callback was capturing mockManagerInstance at module load time when it was undefined. Fixed by: 1. Changing mock to vi.fn() without return value 2. Adding mockReturnValue(mockManagerInstance) in beforeEach This ensures the mock returns the properly configured instance when getSemanticNarrativeManager() is called during panel construction. Co-Authored-By: Claude Opus 4.7 --- src/tui/components/SemanticNarrativePanel.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/tui/components/SemanticNarrativePanel.test.ts b/src/tui/components/SemanticNarrativePanel.test.ts index b32fbfd..da8ab66 100644 --- a/src/tui/components/SemanticNarrativePanel.test.ts +++ b/src/tui/components/SemanticNarrativePanel.test.ts @@ -75,7 +75,7 @@ class MockSemanticNarrativeManager { let mockManagerInstance: MockSemanticNarrativeManager; vi.mock('../../semanticNarrative.js', () => ({ - getSemanticNarrativeManager: vi.fn(() => mockManagerInstance), + getSemanticNarrativeManager: vi.fn(), })); // Import after mocking @@ -203,6 +203,9 @@ describe('SemanticNarrativePanel', () => { mockManagerInstance.onUpdate = vi.fn(() => () => {}); mockManagerInstance.clear = vi.fn(); + // Update the mock to return the new instance + (getSemanticNarrativeManager as Mock).mockReturnValue(mockManagerInstance); + mockScreen = createMockScreen(); onSelectCallback = vi.fn();