<?php

declare(strict_types=1);

use App\Support\Badges\TagBadgeCatalog;
use App\Support\Badges\TagBadgeDomain;
use App\Support\Badges\TagBadgeSpec;
use App\Support\Inventory\InventoryPolicyTypeMeta;

it('never returns status-like colors for tag badges', function (): void {
    $forbidden = ['success', 'warning', 'danger'];

    foreach (TagBadgeDomain::cases() as $domain) {
        $known = TagBadgeCatalog::spec($domain, 'known');
        expect($known->color)->not->toBeIn($forbidden);
        expect($known->color)->toBeIn(TagBadgeSpec::allowedColors());

        $unknown = TagBadgeCatalog::spec($domain, 'unknown-value');
        expect($unknown->color)->not->toBeIn($forbidden);
        expect($unknown->color)->toBeIn(TagBadgeSpec::allowedColors());
    }
});

it('uses only neutral colors for all configured policy types', function (): void {
    $forbidden = ['success', 'warning', 'danger'];

    foreach (InventoryPolicyTypeMeta::all() as $meta) {
        if (! is_array($meta)) {
            continue;
        }

        $type = $meta['type'] ?? null;
        if (! is_string($type) || trim($type) === '') {
            continue;
        }

        $spec = TagBadgeCatalog::spec(TagBadgeDomain::PolicyType, $type);
        expect($spec->color)->not->toBeIn($forbidden);
        expect($spec->color)->toBeIn(TagBadgeSpec::allowedColors());
    }
});
