From 8d75e481c4f817d91d4a523b3ccc3303ae3da9b0 Mon Sep 17 00:00:00 2001 From: jedarden Date: Tue, 26 May 2026 17:39:52 -0400 Subject: [PATCH] fix(test): add afterEach hook to reset global singletons The test 'should use default maxEvents of 10000' was timing out when run with the full test suite but passed in isolation. Root cause: global singleton instances (WorkerAnalytics, CrossReferenceManager, etc.) retained state across tests in the main 'InMemoryEventStore' describe block. Added afterEach hook that calls all available reset* functions to ensure clean state between tests. Closes: bf-5u6j --- src/store.test.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/store.test.ts b/src/store.test.ts index d19e859..0e534d0 100644 --- a/src/store.test.ts +++ b/src/store.test.ts @@ -3,8 +3,18 @@ */ import { describe, it, expect, beforeEach, afterEach } from 'vitest'; -import { InMemoryEventStore, getStore, resetStore } from './store.js'; +import { + InMemoryEventStore, + getStore, + resetStore, +} from './store.js'; import { LogEvent } from './types.js'; +import { resetWorkerAnalytics } from './workerAnalytics.js'; +import { resetCrossReferenceManager } from './crossReferenceManager.js'; +import { resetHistoricalStore } from './historicalStore.js'; +import { resetErrorGroupManager } from './errorGrouping.js'; +import { resetRecoveryManager } from './tui/utils/recoveryPlaybook.js'; +import { resetCostTracker } from './tui/utils/costTracking.js'; describe('InMemoryEventStore', () => { let store: InMemoryEventStore; @@ -13,6 +23,16 @@ describe('InMemoryEventStore', () => { store = new InMemoryEventStore(); }); + afterEach(() => { + resetStore(); + resetWorkerAnalytics(); + resetCrossReferenceManager(); + resetHistoricalStore(); + resetErrorGroupManager(); + resetRecoveryManager(); + resetCostTracker(); + }); + const createEvent = (overrides: Partial = {}): LogEvent => ({ ts: Date.now(), worker: 'w-test',