<?php

declare(strict_types=1);

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

it('maps tenant status values to canonical badge semantics', function (): void {
    $active = BadgeCatalog::spec(BadgeDomain::TenantStatus, 'active');
    expect($active->label)->toBe('Active');
    expect($active->color)->toBe('success');

    $archived = BadgeCatalog::spec(BadgeDomain::TenantStatus, 'archived');
    expect($archived->label)->toBe('Archived');
    expect($archived->color)->toBe('gray');

    $unknown = BadgeCatalog::spec(BadgeDomain::TenantStatus, 'suspended');
    expect($unknown->label)->toBe('Invalid lifecycle');
    expect($unknown->color)->toBe('danger');

    $error = BadgeCatalog::spec(BadgeDomain::TenantStatus, 'error');
    expect($error->label)->toBe('Invalid lifecycle');
    expect($error->color)->toBe('danger');
});

it('does not expose retired app status as active tenant badge semantics', function (): void {
    $domainValues = collect(BadgeDomain::cases())
        ->map(fn (BadgeDomain $domain): string => $domain->value)
        ->all();

    expect($domainValues)->not->toContain('tenant_app_status')
        ->and(BadgeCatalog::mapper(BadgeDomain::TenantStatus))->not->toBeNull()
        ->and(BadgeCatalog::mapper(BadgeDomain::TenantRbacStatus))->not->toBeNull()
        ->and(BadgeCatalog::mapper(BadgeDomain::ManagedEnvironmentPermissionStatus))->not->toBeNull();
});

it('maps tenant RBAC status values to canonical badge semantics', function (): void {
    $configured = BadgeCatalog::spec(BadgeDomain::TenantRbacStatus, 'configured');
    expect($configured->label)->toBe('Configured');
    expect($configured->color)->toBe('success');

    $manual = BadgeCatalog::spec(BadgeDomain::TenantRbacStatus, 'manual_assignment_required');
    expect($manual->label)->toBe('Manual assignment required');
    expect($manual->color)->toBe('warning');

    $notConfigured = BadgeCatalog::spec(BadgeDomain::TenantRbacStatus, 'not_configured');
    expect($notConfigured->label)->toBe('Not configured');
    expect($notConfigured->color)->toBe('gray');
});

it('maps managed environment permission status values to canonical badge semantics', function (): void {
    $granted = BadgeCatalog::spec(BadgeDomain::ManagedEnvironmentPermissionStatus, 'granted');
    expect($granted->label)->toBe('Granted');
    expect($granted->color)->toBe('success');

    $missing = BadgeCatalog::spec(BadgeDomain::ManagedEnvironmentPermissionStatus, 'missing');
    expect($missing->label)->toBe('Missing');
    expect($missing->color)->toBe('warning');

    $error = BadgeCatalog::spec(BadgeDomain::ManagedEnvironmentPermissionStatus, 'error');
    expect($error->label)->toBe('Error');
    expect($error->color)->toBe('danger');
});
