test(bf-3oy5): fix mock setup for SemanticNarrativePanel tests
Some checks are pending
CI / test (18.x) (push) Waiting to run
CI / test (20.x) (push) Waiting to run
CI / test (22.x) (push) Waiting to run

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 <noreply@anthropic.com>
This commit is contained in:
jedarden 2026-05-22 17:25:00 -04:00
parent cd24f596f7
commit 5ff569a67a

View file

@ -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