fix: resolve test failures related to v0.5.12 changes (#491)

* fix: update tests for new batch delete and update mechanism changes

**sessions-routes.test.ts:**
- Add missing batchRemove mock to controller mock
- Fix "No batchRemove export defined" error

**update-controller.test.ts:**
- Update test to expect direct npm/npm.cmd calls instead of dirname(process.execPath)
- Update timeout from 120000 to 10 * 60 * 1000 (10 minutes)
- Update spawn path check to use dynamic global prefix (expect.any)

Tests now match the refactored update mechanism that uses npm prefix -g
for reliable path resolution.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* test: add speechSynthesis mock to message-item-highlight tests

* test: fix all failing tests

- Add approvals mock to session-settings test
- Fix NSwitch stub to properly emit events
- Update usage stats test expectations for new field structure
- Mock getDb in model-context tests to avoid database lock errors
- Add speechSynthesis API mock to message-item-highlight tests

Related to v0.5.12 feature changes

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ekko
2026-05-06 21:37:13 +08:00
committed by GitHub
parent a1c5798e65
commit 5df8734495
7 changed files with 75 additions and 13 deletions
+2
View File
@@ -16,6 +16,7 @@ const usageBatchMock = vi.fn(async (ctx: any) => { ctx.body = {} })
const usageSingleMock = vi.fn(async (ctx: any) => { ctx.body = { input_tokens: 0, output_tokens: 0 } })
const usageStatsMock = vi.fn(async (ctx: any) => { ctx.body = { total_input_tokens: 0, total_output_tokens: 0 } })
const contextLengthMock = vi.fn(async (ctx: any) => { ctx.body = { context_length: 200000 } })
const batchRemoveMock = vi.fn(async (ctx: any) => { ctx.body = { deleted: 1, failed: 0, errors: [] } })
vi.mock('../../packages/server/src/controllers/hermes/sessions', () => ({
listConversations: listConversationsMock,
@@ -27,6 +28,7 @@ vi.mock('../../packages/server/src/controllers/hermes/sessions', () => ({
search: searchMock,
get: getMock,
remove: removeMock,
batchRemove: batchRemoveMock,
rename: renameMock,
setWorkspace: setWorkspaceMock,
listWorkspaceFolders: listWorkspaceFoldersMock,