import 'package:flutter_test/flutter_test.dart';
import 'package:unionflow_mobile_apps/features/compliance/domain/entities/compliance_snapshot.dart';

ComplianceSnapshot _build({
  int score = 85,
  bool officer = true,
  String agStatut = 'OK',
}) {
  return ComplianceSnapshot(
    organisationId: 'org-1',
    organisationNom: 'Test',
    referentielComptable: 'SYSCOHADA',
    complianceOfficerDesigne: officer,
    agAnnuelle: ConformiteIndicateur(statut: agStatut, message: ''),
    rapportAirms: const ConformiteIndicateur(statut: 'OK', message: ''),
    dirigeantsAvecCmu: 3,
    tauxKycAJourPct: 80,
    tauxFormationLbcFtPct: 70,
    commissaireAuxComptes: const ConformiteIndicateur(statut: 'OPTIONNEL', message: ''),
    fomusCi: const ConformiteIndicateur(statut: 'EN_VEILLE', message: ''),
    couvertureUboPct: 60,
    scoreGlobal: score,
  );
}

void main() {
  group('ComplianceSnapshot', () {
    test('scoreSeverite — score >=80 → success', () {
      expect(_build(score: 85).scoreSeverite, 'success');
    });

    test('scoreSeverite — 60..79 → warning', () {
      expect(_build(score: 70).scoreSeverite, 'warning');
    });

    test('scoreSeverite — <60 → danger', () {
      expect(_build(score: 50).scoreSeverite, 'danger');
    });

    test('hasAlertesCritiques — score 85 + officer + AG OK → false', () {
      expect(_build().hasAlertesCritiques, isFalse);
    });

    test('hasAlertesCritiques — officer absent → true', () {
      expect(_build(officer: false).hasAlertesCritiques, isTrue);
    });

    test('hasAlertesCritiques — AG en retard → true', () {
      expect(_build(agStatut: 'RETARD').hasAlertesCritiques, isTrue);
    });

    test('hasAlertesCritiques — score <60 → true', () {
      expect(_build(score: 50).hasAlertesCritiques, isTrue);
    });
  });
}
