import { describe, it, expect } from 'vitest'
import { render, screen } from '@testing-library/react'

import { AgentFindingCard } from '../AgentFindingCard'
import type { Finding } from '../_agentTypes'

const BASE: Finding = {
  check_id: 'IMP-handelsregister', agent: 'impressum', agent_version: '3.0',
  field_id: 'handelsregister', severity: 'HIGH', title: 'X',
  norm: '§ 5 Abs. 1 Nr. 4 TMG', evidence: '', action: 'Tu etwas.',
  confidence: 0.4,
  sources: [{ source_type: 'regex', source_id: 'IMP-MC-004', confidence: 0.4 }],
}

describe('AgentFindingCard — 4-Status', () => {
  it('INSUFFICIENT_EVIDENCE zeigt Verdikt-Pill + Prüf-Hinweis statt FAIL', () => {
    const f: Finding = {
      ...BASE, status: 'insufficient_evidence', severity: 'INFO',
      title: 'Handelsregister-Eintrag: Rechtsform nicht erkennbar',
    }
    render(<AgentFindingCard f={f} />)
    expect(screen.getByText('Unzureichende Evidenz')).toBeInTheDocument()
    expect(screen.getByText('Prüf-Hinweis')).toBeInTheDocument()
    expect(screen.queryByText('Pflicht-Maßnahme')).not.toBeInTheDocument()
  })

  it('FAIL/HIGH zeigt KEINE Verdikt-Pill, aber Pflicht-Maßnahme', () => {
    const f: Finding = { ...BASE, status: 'fail', severity: 'HIGH' }
    render(<AgentFindingCard f={f} />)
    expect(screen.queryByText('Unzureichende Evidenz')).not.toBeInTheDocument()
    expect(screen.getByText('Pflicht-Maßnahme')).toBeInTheDocument()
  })
})
