<?php

declare(strict_types=1);

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

it('maps policy type tags to canonical label + domain color', function (): void {
    $spec = TagBadgeCatalog::spec(TagBadgeDomain::PolicyType, 'deviceConfiguration');

    expect($spec->label)->toBe('Device Configuration');
    expect($spec->color)->toBe('primary');
    expect($spec->color)->toBeIn(TagBadgeSpec::allowedColors());
});

it('maps policy category tags to canonical label + domain color', function (): void {
    $spec = TagBadgeCatalog::spec(TagBadgeDomain::PolicyCategory, 'Configuration');

    expect($spec->label)->toBe('Configuration');
    expect($spec->color)->toBe('gray');
    expect($spec->color)->toBeIn(TagBadgeSpec::allowedColors());
});

it('falls back to Other: <value> for unknown policy category values', function (): void {
    $spec = TagBadgeCatalog::spec(TagBadgeDomain::PolicyCategory, 'Mystery Category');

    expect($spec->label)->toBe('Other: Mystery Category');
    expect($spec->color)->toBe('gray');
    expect($spec->color)->toBeIn(TagBadgeSpec::allowedColors());
});

it('maps platform tags to canonical Title Case labels', function (): void {
    expect(TagBadgeCatalog::spec(TagBadgeDomain::Platform, 'windows')->label)->toBe('Windows');
    expect(TagBadgeCatalog::spec(TagBadgeDomain::Platform, 'Android')->label)->toBe('Android');
    expect(TagBadgeCatalog::spec(TagBadgeDomain::Platform, 'iOS')->label)->toBe('iOS');
    expect(TagBadgeCatalog::spec(TagBadgeDomain::Platform, 'macOS')->label)->toBe('macOS');
    expect(TagBadgeCatalog::spec(TagBadgeDomain::Platform, 'all')->label)->toBe('All');
});

it('falls back to Other: <value> for unknown platform values', function (): void {
    $spec = TagBadgeCatalog::spec(TagBadgeDomain::Platform, 'plan9');

    expect($spec->label)->toBe('Other: plan9');
    expect($spec->color)->toBe('info');
    expect($spec->color)->toBeIn(TagBadgeSpec::allowedColors());
});

it('maps tenant environment tags to canonical labels + neutral colors', function (): void {
    expect(TagBadgeCatalog::spec(TagBadgeDomain::TenantEnvironment, 'prod')->label)->toBe('Prod');
    expect(TagBadgeCatalog::spec(TagBadgeDomain::TenantEnvironment, 'staging')->label)->toBe('Staging');
    expect(TagBadgeCatalog::spec(TagBadgeDomain::TenantEnvironment, 'dev')->label)->toBe('Dev');
    expect(TagBadgeCatalog::spec(TagBadgeDomain::TenantEnvironment, 'production')->label)->toBe('Prod');
});

it('maps visibility tags to canonical labels + neutral colors', function (): void {
    $active = TagBadgeCatalog::spec(TagBadgeDomain::Visibility, 'active');
    expect($active->label)->toBe('Active');
    expect($active->color)->toBe('gray');
    expect($active->color)->toBeIn(TagBadgeSpec::allowedColors());

    $archived = TagBadgeCatalog::spec(TagBadgeDomain::Visibility, 'archived');
    expect($archived->label)->toBe('Archived');
    expect($archived->color)->toBe('gray');
    expect($archived->color)->toBeIn(TagBadgeSpec::allowedColors());
});

it('maps snapshot type tags to canonical labels + neutral colors', function (): void {
    $full = TagBadgeCatalog::spec(TagBadgeDomain::SnapshotType, 'full');
    expect($full->label)->toBe('Full');
    expect($full->color)->toBe('primary');
    expect($full->color)->toBeIn(TagBadgeSpec::allowedColors());

    $incremental = TagBadgeCatalog::spec(TagBadgeDomain::SnapshotType, 'incremental');
    expect($incremental->label)->toBe('Incremental');
    expect($incremental->color)->toBe('primary');
    expect($incremental->color)->toBeIn(TagBadgeSpec::allowedColors());
});

it('maps backup schedule frequency tags to canonical labels + neutral colors', function (): void {
    $daily = TagBadgeCatalog::spec(TagBadgeDomain::BackupScheduleFrequency, 'daily');
    expect($daily->label)->toBe('Daily');
    expect($daily->color)->toBe('info');
    expect($daily->color)->toBeIn(TagBadgeSpec::allowedColors());

    $weekly = TagBadgeCatalog::spec(TagBadgeDomain::BackupScheduleFrequency, 'weekly');
    expect($weekly->label)->toBe('Weekly');
    expect($weekly->color)->toBe('info');
    expect($weekly->color)->toBeIn(TagBadgeSpec::allowedColors());
});
