<?php

declare(strict_types=1);

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

it('maps finding severity values to canonical badge semantics', function (): void {
    $low = BadgeCatalog::spec(BadgeDomain::FindingSeverity, 'low');
    expect($low->label)->toBe('Low');
    expect($low->color)->toBe('gray');

    $medium = BadgeCatalog::spec(BadgeDomain::FindingSeverity, 'medium');
    expect($medium->label)->toBe('Medium');
    expect($medium->color)->toBe('warning');

    $high = BadgeCatalog::spec(BadgeDomain::FindingSeverity, 'high');
    expect($high->label)->toBe('High');
    expect($high->color)->toBe('danger');

    $critical = BadgeCatalog::spec(BadgeDomain::FindingSeverity, 'critical');
    expect($critical->label)->toBe('Critical');
    expect($critical->color)->toBe('danger');
});

it('maps finding status values to canonical badge semantics', function (): void {
    $new = BadgeCatalog::spec(BadgeDomain::FindingStatus, 'new');
    expect($new->label)->toBe('New');
    expect($new->color)->toBe('warning');

    $triaged = BadgeCatalog::spec(BadgeDomain::FindingStatus, 'triaged');
    expect($triaged->label)->toBe('Triaged');
    expect($triaged->color)->toBe('gray');

    $legacyAcknowledged = BadgeCatalog::spec(BadgeDomain::FindingStatus, 'acknowledged');
    expect($legacyAcknowledged->label)->toBe('Unknown');
    expect($legacyAcknowledged->color)->toBe('gray');

    $inProgress = BadgeCatalog::spec(BadgeDomain::FindingStatus, 'in_progress');
    expect($inProgress->label)->toBe('In progress');
    expect($inProgress->color)->toBe('info');

    $reopened = BadgeCatalog::spec(BadgeDomain::FindingStatus, 'reopened');
    expect($reopened->label)->toBe('Reopened');
    expect($reopened->color)->toBe('danger');

    $resolved = BadgeCatalog::spec(BadgeDomain::FindingStatus, 'resolved');
    expect($resolved->label)->toBe('Resolved');
    expect($resolved->color)->toBe('gray');

    $closed = BadgeCatalog::spec(BadgeDomain::FindingStatus, 'closed');
    expect($closed->label)->toBe('Closed');

    $riskAccepted = BadgeCatalog::spec(BadgeDomain::FindingStatus, 'risk_accepted');
    expect($riskAccepted->label)->toBe('Risk accepted');
});

it('maps finding governance validity values to operator-facing attention colors', function (): void {
    $valid = BadgeCatalog::spec(BadgeDomain::FindingRiskGovernanceValidity, 'valid');
    expect($valid->label)->toBe('Valid');
    expect($valid->color)->toBe('success');

    $expiring = BadgeCatalog::spec(BadgeDomain::FindingRiskGovernanceValidity, 'expiring');
    expect($expiring->label)->toBe('Expiring');
    expect($expiring->color)->toBe('warning');

    $rejected = BadgeCatalog::spec(BadgeDomain::FindingRiskGovernanceValidity, 'rejected');
    expect($rejected->label)->toBe('Rejected');
    expect($rejected->color)->toBe('danger');

    $missingSupport = BadgeCatalog::spec(BadgeDomain::FindingRiskGovernanceValidity, 'missing_support');
    expect($missingSupport->label)->toBe('Missing support');
    expect($missingSupport->color)->toBe('danger');
});
