hermes-agent/ui-tui/src/lib/billingDialog.test.ts
Brooklyn Nicholson 9c274db89f feat(tui): billing wall opens a confirm dialog
Open the shared ConfirmPrompt (full-width, themed, same lane as approval/clarify)
rather than a truncating status-bar notice. One recovery action: Nous → /topup
(opens the rich billing overlay), other providers → their billing page, or /model
to switch when there's no URL. The transcript keeps the full guidance; the dialog
is the concise actionable layer.
2026-07-22 18:09:08 -05:00

37 lines
1.3 KiB
TypeScript

import type { BillingBlock } from '@hermes/shared/billing'
import { describe, expect, it } from 'vitest'
import { billingDialogCopy } from './billingDialog.js'
function makeBlock(overrides: Partial<BillingBlock> = {}): BillingBlock {
return {
billing_url: 'https://openrouter.ai/settings/credits',
is_nous: false,
message: 'out of credits',
model: 'x',
provider: 'openrouter',
provider_label: 'OpenRouter',
...overrides
}
}
describe('billingDialogCopy', () => {
it('routes Nous to the /topup flow', () => {
const copy = billingDialogCopy(makeBlock({ is_nous: true, provider: 'nous', provider_label: 'Nous Portal' }))
expect(copy.title).toContain('Nous')
expect(copy.confirmLabel).toBe('Top up')
expect(copy.cancelLabel).toBe('Dismiss')
})
it('offers to open a third-party provider billing page', () => {
const copy = billingDialogCopy(makeBlock())
expect(copy.title).toContain('OpenRouter')
expect(copy.confirmLabel).toBe('Open billing page')
})
it('falls back to switching providers when there is no URL', () => {
const copy = billingDialogCopy(makeBlock({ billing_url: null, provider_label: 'DeepSeek' }))
expect(copy.title).toContain('DeepSeek')
expect(copy.confirmLabel).toBe('Switch provider')
})
})