chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
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: [] })
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user