mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-07-09 17:19:15 +00:00
* fix: fix and improve test isolation and collision with environment * docs: remove unnecessary comment * test(env-isolation): clear CODEBURN_FORCE_MACOS_MAJOR and pin TZ Two env vars read in src/ were not isolated: CODEBURN_FORCE_MACOS_MAJOR (now cleared so it cannot leak between tests) and TZ (now pinned to UTC, since clearing it falls back to the OS zone and would shift date buckets versus a clean CI runner). --------- Co-authored-by: AgentSeal <hello@agentseal.org>
25 lines
1.3 KiB
TypeScript
25 lines
1.3 KiB
TypeScript
import { describe, expect, it, beforeAll } from 'vitest'
|
|
import { buildMenubarPayloadForRange } from '../src/usage-aggregator.js'
|
|
import { getDateRange } from '../src/cli-date.js'
|
|
import { loadPricing } from '../src/models.js'
|
|
|
|
describe('buildMenubarPayloadForRange', () => {
|
|
beforeAll(async () => {
|
|
await loadPricing()
|
|
})
|
|
|
|
it('returns a valid payload and skips optimize findings when optimize:false', async () => {
|
|
const payload = await buildMenubarPayloadForRange(getDateRange('today'), { provider: 'all', optimize: false })
|
|
expect(typeof payload.current.label).toBe('string')
|
|
expect(payload.current.cost).toBeGreaterThanOrEqual(0)
|
|
expect(Array.isArray(payload.current.topProjects)).toBe(true)
|
|
expect(Array.isArray(payload.current.topModels)).toBe(true)
|
|
expect(Array.isArray(payload.history.daily)).toBe(true)
|
|
expect(payload.current.retryTax.totalUSD).toBeGreaterThanOrEqual(0)
|
|
// Codex credits are always present in the payload (display gates them); 0 with no data.
|
|
expect(typeof payload.current.codexCredits).toBe('number')
|
|
expect(payload.current.codexCredits).toBeGreaterThanOrEqual(0)
|
|
// optimize:false => scanAndDetect skipped => empty optimize block regardless of data
|
|
expect(payload.optimize).toEqual({ findingCount: 0, savingsUSD: 0, topFindings: [] })
|
|
})
|
|
})
|