diff --git a/packages/dashboard/src/__tests__/chat-routes.test.ts b/packages/dashboard/src/__tests__/chat-routes.test.ts index 14ea8c8dea..b8268dc74a 100644 --- a/packages/dashboard/src/__tests__/chat-routes.test.ts +++ b/packages/dashboard/src/__tests__/chat-routes.test.ts @@ -11,6 +11,7 @@ function createSSERequest(): Request { const emitter = new EventEmitter(); emitter.setMaxListeners(50); (emitter as any).query = {}; // required: routes read req.query.projectId + (emitter as any).headers = {}; // required: routes read req.headers["last-event-id"] return emitter as unknown as Request; } @@ -1204,6 +1205,15 @@ describe("Chat API Routes", () => { }); describe("SSE stream lifecycle", () => { + beforeEach(() => { + mockSendMessage.mockResolvedValue(undefined); + mockChatStreamManager.reset(); + mockChatStreamManager.getBufferedEvents.mockClear(); + mockChatStreamManager.subscribe.mockClear(); + mockChatStreamManager.broadcast.mockClear(); + mockChatStreamManager.cleanupSession.mockClear(); + }); + /** * Helper to invoke the chat SSE route handler directly. * Tests the SSE route behavior by calling the handler with mock req/res. diff --git a/packages/dashboard/src/__tests__/routes-github.test.ts b/packages/dashboard/src/__tests__/routes-github.test.ts index 49c0db9635..3d1958923a 100644 --- a/packages/dashboard/src/__tests__/routes-github.test.ts +++ b/packages/dashboard/src/__tests__/routes-github.test.ts @@ -2409,6 +2409,10 @@ describe("POST /tasks/:id/review/refresh", () => { store = createMockStore(); }); + afterEach(() => { + vi.restoreAllMocks(); + }); + function buildApp() { const app = express(); app.use(express.json()); diff --git a/packages/dashboard/src/__tests__/routes-secrets-sync.test.ts b/packages/dashboard/src/__tests__/routes-secrets-sync.test.ts index 6dc41bdabe..c97443928c 100644 --- a/packages/dashboard/src/__tests__/routes-secrets-sync.test.ts +++ b/packages/dashboard/src/__tests__/routes-secrets-sync.test.ts @@ -50,6 +50,7 @@ describe("routes secrets sync", () => { beforeEach(async () => { vi.restoreAllMocks(); + mockedFetchFromRemoteNode.mockClear(); fixture = await createFixture("fn-secrets-sync-"); secrets = fixture.secretsStore; diff --git a/packages/dashboard/src/__tests__/routes-settings.test.ts b/packages/dashboard/src/__tests__/routes-settings.test.ts index 2d4c4a1df8..b964ece831 100644 --- a/packages/dashboard/src/__tests__/routes-settings.test.ts +++ b/packages/dashboard/src/__tests__/routes-settings.test.ts @@ -1141,6 +1141,10 @@ describe("PUT /settings/global", () => { store = createMockStore(); }); + afterEach(() => { + vi.restoreAllMocks(); + }); + function buildApp() { const app = express(); app.use(express.json());