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

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 <noreply@anthropic.com>
This commit is contained in:
jedarden 2026-05-22 17:31:19 -04:00
parent 0e849ef220
commit a6019cc82d

View file

@ -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();