<?php

declare(strict_types=1);

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

it('maps provider consent status safely', function (): void {
    $unknown = BadgeCatalog::spec(BadgeDomain::ProviderConsentStatus, 'unknown');
    expect($unknown->color)->toBe('gray');
    expect($unknown->label)->toBe('Unknown');

    $required = BadgeCatalog::spec(BadgeDomain::ProviderConsentStatus, 'required');
    expect($required->color)->toBe('warning');
    expect($required->label)->toBe('Required');

    $granted = BadgeCatalog::spec(BadgeDomain::ProviderConsentStatus, 'granted');
    expect($granted->color)->toBe('success');
    expect($granted->label)->toBe('Granted');

    $failed = BadgeCatalog::spec(BadgeDomain::ProviderConsentStatus, 'failed');
    expect($failed->color)->toBe('danger');
    expect($failed->label)->toBe('Failed');
});

it('maps provider verification status safely', function (): void {
    $unknown = BadgeCatalog::spec(BadgeDomain::ProviderVerificationStatus, 'unknown');
    expect($unknown->color)->toBe('gray');
    expect($unknown->label)->toBe('Unknown');

    $pending = BadgeCatalog::spec(BadgeDomain::ProviderVerificationStatus, 'pending');
    expect($pending->color)->toBe('info');
    expect($pending->label)->toBe('Pending');

    $healthy = BadgeCatalog::spec(BadgeDomain::ProviderVerificationStatus, 'healthy');
    expect($healthy->color)->toBe('success');
    expect($healthy->label)->toBe('Healthy');

    $blocked = BadgeCatalog::spec(BadgeDomain::ProviderVerificationStatus, 'blocked');
    expect($blocked->color)->toBe('danger');
    expect($blocked->label)->toBe('Blocked');

    $degraded = BadgeCatalog::spec(BadgeDomain::ProviderVerificationStatus, 'degraded');
    expect($degraded->color)->toBe('warning');
    expect($degraded->label)->toBe('Degraded');
});

it('does not reuse consent labels for provider verification summaries', function (): void {
    expect(BadgeCatalog::spec(BadgeDomain::ProviderConsentStatus, 'required')->label)->toBe('Required')
        ->and(BadgeCatalog::spec(BadgeDomain::ProviderVerificationStatus, 'pending')->label)->toBe('Pending')
        ->and(BadgeCatalog::spec(BadgeDomain::ProviderConsentStatus, 'required')->label)
        ->not->toBe(BadgeCatalog::spec(BadgeDomain::ProviderVerificationStatus, 'pending')->label);
});

it('does not expose legacy provider status badge domains anymore', function (): void {
    $domainValues = collect(BadgeDomain::cases())
        ->map(fn (BadgeDomain $domain): string => $domain->value)
        ->all();

    expect($domainValues)->not->toContain('provider_connection.status', 'provider_connection.health');
});
