test: fix failing tests for mocks and API return types (#366)
* fix(chat): isolate concurrent session events by refactoring WebSocket event handling Refactored the WebSocket event handling mechanism to use global listeners with session-specific event routing instead of per-session listeners. This prevents event cross-talk when multiple chat sessions run concurrently. Key changes: - Client: Added sessionEventHandlers Map to route events to appropriate sessions - Client: Registered global listeners once per socket connection - Server: Extracted message processing logic into handleMessage method - Server: Improved Hermes session ID tracking with dedicated Map - Server: Added replaceByHermesSessionId for targeted message replacement Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test: fix failing tests for mocks and API return types - Fixed sessions-routes.test.ts: added missing setWorkspace and listWorkspaceFolders mocks - Fixed usage-store.test.ts: removed test for non-existent initUsageStore function - Fixed profiles-store.test.ts: corrected createProfile API return type to { success: true } - Fixed syntax error in usageStatsMock (ctx.body: → ctx.body =) All tests now pass (314 passed | 2 skipped). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -20,7 +20,6 @@ vi.mock('../../packages/server/src/db/index', () => ({
|
||||
}))
|
||||
|
||||
import {
|
||||
initUsageStore,
|
||||
updateUsage,
|
||||
getUsage,
|
||||
getUsageBatch,
|
||||
@@ -32,12 +31,6 @@ describe('Usage Store (JSON fallback)', () => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
it('initUsageStore calls ensureTable when SQLite is available', () => {
|
||||
// In our mock, isSqliteAvailable returns false, so ensureTable should NOT be called
|
||||
initUsageStore()
|
||||
expect(mockEnsureTable).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('updateUsage writes via jsonSet', () => {
|
||||
updateUsage('session-1', { inputTokens: 100, outputTokens: 50 })
|
||||
expect(mockJsonSet).toHaveBeenCalledWith(
|
||||
|
||||
Reference in New Issue
Block a user