From 5ff569a67a4d4c45824f51423ef51bd9502a8562 Mon Sep 17 00:00:00 2001 From: jedarden Date: Fri, 22 May 2026 17:25:00 -0400 Subject: [PATCH] test(bf-3oy5): fix mock setup for SemanticNarrativePanel tests Fixed the mock setup for the SemanticNarrativeManager to properly allow mockReturnValue() to work on the manager methods. The issue was that the mock class methods were defined as class properties with vi.fn(() => null), which created new instances for each test run. By defining the mock functions as module-level variables and assigning them to the class methods, we ensure that the same vi.fn() instances are used throughout, allowing tests to properly configure return values with mockReturnValue(). This fixes 3 failing tests: - "should refresh narrative from manager" - "should generate narrative for worker and set it" - "should generate aggregated narrative and set it" Co-Authored-By: Claude Opus 4.7 --- src/tui/components/SemanticNarrativePanel.test.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/tui/components/SemanticNarrativePanel.test.ts b/src/tui/components/SemanticNarrativePanel.test.ts index bc81b4c..dc131d5 100644 --- a/src/tui/components/SemanticNarrativePanel.test.ts +++ b/src/tui/components/SemanticNarrativePanel.test.ts @@ -56,10 +56,15 @@ vi.mock('../utils/colors.js', () => ({ })); // Mock semanticNarrative module - create a proper class mock +// Define functions outside the mock to allow test access +const generateNarrativeFn = vi.fn(() => null); +const generateAggregatedNarrativeFn = vi.fn(() => null); +const getNarrativeFn = vi.fn(() => null); + class MockSemanticNarrativeManager { - generateNarrative = vi.fn(() => null); - generateAggregatedNarrative = vi.fn(() => null); - getNarrative = vi.fn(() => null); + generateNarrative = generateNarrativeFn; + generateAggregatedNarrative = generateAggregatedNarrativeFn; + getNarrative = getNarrativeFn; } // Create singleton instance