<?php

declare(strict_types=1);

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

it('maps triage review states to centralized badge semantics', function (): void {
    $notReviewed = BadgeCatalog::spec(BadgeDomain::ManagedEnvironmentTriageReviewState, ManagedEnvironmentTriageReview::DERIVED_STATE_NOT_REVIEWED);
    $reviewed = BadgeCatalog::spec(BadgeDomain::ManagedEnvironmentTriageReviewState, ManagedEnvironmentTriageReview::STATE_REVIEWED);
    $followUpNeeded = BadgeCatalog::spec(BadgeDomain::ManagedEnvironmentTriageReviewState, ManagedEnvironmentTriageReview::STATE_FOLLOW_UP_NEEDED);
    $changedSinceReview = BadgeCatalog::spec(BadgeDomain::ManagedEnvironmentTriageReviewState, ManagedEnvironmentTriageReview::DERIVED_STATE_CHANGED_SINCE_REVIEW);

    expect($notReviewed->label)->toBe('Not reviewed')
        ->and($notReviewed->color)->toBe('gray')
        ->and($reviewed->label)->toBe('Reviewed')
        ->and($reviewed->color)->toBe('success')
        ->and($followUpNeeded->label)->toBe('Follow-up needed')
        ->and($followUpNeeded->color)->toBe('danger')
        ->and($changedSinceReview->label)->toBe('Changed since review')
        ->and($changedSinceReview->color)->toBe('warning');
});

it('falls back to the unknown badge semantics for invalid review states', function (): void {
    $unknown = BadgeCatalog::spec(BadgeDomain::ManagedEnvironmentTriageReviewState, 'invalid_state');

    expect($unknown->label)->toBe('Unknown')
        ->and($unknown->color)->toBe('gray');
});
