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
+19 -2
View File
@@ -204,8 +204,25 @@ describe('native-style Hermes usage analytics DB aggregation', () => {
{ model: 'tool-model', input_tokens: 30, output_tokens: 20, cache_read_tokens: 5, cache_write_tokens: 1, reasoning_tokens: 2, sessions: 1 },
])
expect(result.by_day).toHaveLength(2)
expect(result.by_day[0]).toEqual({ date: day(now - 86400), tokens: 10, cache: 1, sessions: 1, cost: 0.005 })
expect(result.by_day[1]).toMatchObject({ date: day(now), tokens: 203, cache: 15, sessions: 3 })
expect(result.by_day[0]).toEqual({
date: day(now - 86400),
input_tokens: 7,
output_tokens: 3,
cache_read_tokens: 1,
cache_write_tokens: 0,
sessions: 1,
errors: 0,
cost: 0.005,
})
expect(result.by_day[1]).toMatchObject({
date: day(now),
input_tokens: 131,
output_tokens: 72,
cache_read_tokens: 15,
cache_write_tokens: 3,
sessions: 3,
errors: 0,
})
expect(result.by_day[1].cost).toBeCloseTo(0.038)
})