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

import { ResultSummary } from '../ResultSummary'

describe('ResultSummary', () => {
  it('zeigt Firma im Titel + zählt Konform-KPI aus result.results', () => {
    const results = {
      check_id: 'abc123',
      extracted_profile: { company_profile: { companyName: 'Bayerische Motoren Werke Aktiengesellschaft' } },
      results: [
        { doc_type: 'impressum', completeness_pct: 100, correctness_pct: 100, error: '',
          checks: [{ id: 'a', label: 'X', passed: true, severity: 'HIGH', matched_text: '', level: 1 }] },
        { doc_type: 'dse', completeness_pct: 50, correctness_pct: 50, error: '',
          checks: [
            { id: 'b', label: 'Y', passed: false, severity: 'HIGH', matched_text: '', level: 1 },
            { id: 'c', label: 'Z', passed: false, severity: 'INFO', matched_text: '', level: 1 },
          ] },
      ],
    }
    render(<ResultSummary results={results} />)
    expect(screen.getByText(/Bayerische Motoren Werke/)).toBeInTheDocument()
    // 4 Kachel-Labels + Konform 1/2 (impressum konform, dse nicht)
    expect(screen.getByText('Dokumente')).toBeInTheDocument()
    expect(screen.getByText('Konform')).toBeInTheDocument()
    expect(screen.getByText('Offene Pflichtangaben')).toBeInTheDocument()
    expect(screen.getByText('Zu prüfen')).toBeInTheDocument()
    expect(screen.getByText('1/2')).toBeInTheDocument()
  })
})
