Files
orca/src/preload/usage-provider-api.test.ts
T
Neil eb18eaf2b6 feat(usage): add Muse Code local usage provider (#22379)
* feat(usage): add Muse Code local usage provider

Scan Muse session logs (including subagent logs, which hold usage the parent
log does not) for model_completed token events and surface them as a fourth
local usage provider: shared scan worker, persisted per-file cache reused by
mtime/size, cross-log dedupe, Stats tab, and Usage Overview integration.
Muse logs carry no price, so the provider reports tokens only.

* fix(usage): name Muse in Stats & Usage copy; skip partial-cost warning when nothing is priced

* fix(usage): surface unreadable Muse sessions root; name Muse in remaining Stats & Usage copy

* fix(usage): count distinct same-content Muse records within one log
2026-09-22 22:44:10 -07:00

34 lines
1.3 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest'
import { createUsageProviderApi } from './usage-provider-api'
describe('usage provider preload API', () => {
it('keeps every provider on its existing IPC channels', async () => {
const invoke = vi.fn().mockResolvedValue(undefined)
const query = { scope: 'orca' as const, range: '30d' as const }
for (const prefix of ['claudeUsage', 'codexUsage', 'openCodeUsage', 'museUsage'] as const) {
const api = createUsageProviderApi({ invoke } as never, prefix)
await api.getScanState()
await api.setEnabled({ enabled: true })
await api.refresh()
await api.getSnapshot({ ...query, limit: 7 })
await api.getSummary(query)
await api.getDaily(query)
await api.getBreakdown({ ...query, kind: 'project' })
await api.getRecentSessions({ ...query, limit: 4 })
expect(invoke.mock.calls).toEqual([
[`${prefix}:getScanState`],
[`${prefix}:setEnabled`, { enabled: true }],
[`${prefix}:refresh`, undefined],
[`${prefix}:getSnapshot`, { ...query, limit: 7 }],
[`${prefix}:getSummary`, query],
[`${prefix}:getDaily`, query],
[`${prefix}:getBreakdown`, { ...query, kind: 'project' }],
[`${prefix}:getRecentSessions`, { ...query, limit: 4 }]
])
invoke.mockClear()
}
})
})