<?php

declare(strict_types=1);

use App\Support\Badges\BadgeCatalog;
use App\Support\Badges\BadgeDomain;

it('maps all evidence snapshot statuses and completeness states to known badge specs', function (BadgeDomain $domain, string $value): void {
    $spec = BadgeCatalog::spec($domain, $value);

    expect($spec->label)->not->toBe('Unknown')
        ->and($spec->icon)->not->toBeNull();
})->with([
    'queued status' => [BadgeDomain::EvidenceSnapshotStatus, 'queued'],
    'generating status' => [BadgeDomain::EvidenceSnapshotStatus, 'generating'],
    'active status' => [BadgeDomain::EvidenceSnapshotStatus, 'active'],
    'superseded status' => [BadgeDomain::EvidenceSnapshotStatus, 'superseded'],
    'expired status' => [BadgeDomain::EvidenceSnapshotStatus, 'expired'],
    'failed status' => [BadgeDomain::EvidenceSnapshotStatus, 'failed'],
    'complete completeness' => [BadgeDomain::EvidenceCompleteness, 'complete'],
    'partial completeness' => [BadgeDomain::EvidenceCompleteness, 'partial'],
    'missing completeness' => [BadgeDomain::EvidenceCompleteness, 'missing'],
    'stale completeness' => [BadgeDomain::EvidenceCompleteness, 'stale'],
]);

it('reclassifies valid-empty and freshness evidence states with explicit labels', function (): void {
    expect(BadgeCatalog::spec(BadgeDomain::EvidenceCompleteness, 'complete')->label)->toBe('Coverage ready')
        ->and(BadgeCatalog::spec(BadgeDomain::EvidenceCompleteness, 'missing')->label)->toBe('Not collected yet')
        ->and(BadgeCatalog::spec(BadgeDomain::EvidenceCompleteness, 'missing')->color)->toBe('info')
        ->and(BadgeCatalog::spec(BadgeDomain::EvidenceCompleteness, 'stale')->label)->toBe('Refresh recommended')
        ->and(BadgeCatalog::spec(BadgeDomain::EvidenceCompleteness, 'stale')->color)->toBe('warning');
});

it('exposes shared governance-artifact truth badges for evidence semantics', function (): void {
    expect(BadgeCatalog::spec(BadgeDomain::GovernanceArtifactContent, 'partial')->label)->toBe('Partially complete')
        ->and(BadgeCatalog::spec(BadgeDomain::GovernanceArtifactFreshness, 'stale')->label)->toBe('Refresh recommended')
        ->and(BadgeCatalog::spec(BadgeDomain::GovernanceArtifactActionability, 'required')->label)->toBe('Action required');
});
