import { describe, expect, it } from 'vitest'

import { hourlyBillingConfigSchema } from '../../src/validation/projects'

describe('hourly billing config budget validation', () => {
  it('accepts the project hourly budget fields required by the spec', () => {
    const result = hourlyBillingConfigSchema.safeParse({
      rate_per_hour: 150,
      overtime_enabled: false,
      overtime_threshold_hours: 8,
      overtime_multiplier: 1.5,
      budget_hours: 80,
      budget_alert_pct: 80,
      budget_alert_email: true,
      budget_alert_inapp: true,
      budget_alert_fired_at: null,
    })

    expect(result.success).toBe(true)
  })

  it('rejects invalid budget alert percentages', () => {
    const result = hourlyBillingConfigSchema.safeParse({
      rate_per_hour: 150,
      overtime_enabled: false,
      overtime_threshold_hours: 8,
      overtime_multiplier: 1.5,
      budget_hours: 80,
      budget_alert_pct: 101,
    })

    expect(result.success).toBe(false)
  })
})
