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

import { AgentPflichtTable } from '../AgentPflichtTable'
import type { McCoverage } from '../_agentTypes'

const COV: McCoverage[] = [
  { mc_id: 'IMP-MC-002', status: 'ok', label: 'Email-Adresse',
    found: 'kundenbetreuung@bmw.de' },
  { mc_id: 'IMP-MC-010', status: 'possibly_applicable',
    label: 'Verbraucher-Streitbeilegung-Hinweis' },
  { mc_id: 'IMP-MC-009', status: 'na', label: 'Verantwortlicher § 18 MStV' },
]

describe('AgentPflichtTable', () => {
  it('zeigt Label + gefundenen Wert, aber KEINE mc_id', () => {
    render(<AgentPflichtTable coverage={COV} />)
    expect(screen.getByText('Email-Adresse')).toBeInTheDocument()
    expect(screen.getByText('kundenbetreuung@bmw.de')).toBeInTheDocument()
    // Reverse-Engineering-Schutz: mc_id darf NICHT erscheinen.
    expect(screen.queryByText(/IMP-MC-/)).not.toBeInTheDocument()
  })

  it('Verdikt-Header zählt die Status', () => {
    render(<AgentPflichtTable coverage={COV} />)
    expect(screen.getByText(/1 vorhanden/)).toBeInTheDocument()
    expect(screen.getByText(/1 zu prüfen/)).toBeInTheDocument()
  })
})
