<?php

declare(strict_types=1);

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

it('maps restore preview decisions to canonical badge semantics', function (): void {
    $created = BadgeCatalog::spec(BadgeDomain::RestorePreviewDecision, 'created');
    expect($created->label)->toBe('Will create');
    expect($created->color)->toBe('success');

    $mappedExisting = BadgeCatalog::spec(BadgeDomain::RestorePreviewDecision, 'mapped_existing');
    expect($mappedExisting->label)->toBe('Will map existing');
    expect($mappedExisting->color)->toBe('info');

    $createdCopy = BadgeCatalog::spec(BadgeDomain::RestorePreviewDecision, 'created_copy');
    expect($createdCopy->label)->toBe('Will create copy');
    expect($createdCopy->color)->toBe('warning');

    $skipped = BadgeCatalog::spec(BadgeDomain::RestorePreviewDecision, 'skipped');
    expect($skipped->label)->toBe('Will skip');
    expect($skipped->color)->toBe('gray');

    $failed = BadgeCatalog::spec(BadgeDomain::RestorePreviewDecision, 'failed');
    expect($failed->label)->toBe('Cannot apply');
    expect($failed->color)->toBe('danger');

    $dryRun = BadgeCatalog::spec(BadgeDomain::RestorePreviewDecision, 'dry_run');
    expect($dryRun->label)->toBe('Preview only');
    expect($dryRun->color)->toBe('warning');

    $current = BadgeCatalog::spec(BadgeDomain::RestorePreviewDecision, 'current');
    expect($current->label)->toBe('Current basis');
    expect($current->color)->toBe('success');

    $invalidated = BadgeCatalog::spec(BadgeDomain::RestorePreviewDecision, 'invalidated');
    expect($invalidated->label)->toBe('Invalidated');
    expect($invalidated->color)->toBe('warning');
});

it('maps restore results statuses to canonical badge semantics', function (): void {
    $applied = BadgeCatalog::spec(BadgeDomain::RestoreResultStatus, 'applied');
    expect($applied->label)->toBe('Applied');
    expect($applied->color)->toBe('success');

    $dryRun = BadgeCatalog::spec(BadgeDomain::RestoreResultStatus, 'dry_run');
    expect($dryRun->label)->toBe('Preview only');
    expect($dryRun->color)->toBe('info');

    $mapped = BadgeCatalog::spec(BadgeDomain::RestoreResultStatus, 'mapped');
    expect($mapped->label)->toBe('Mapped to existing item');
    expect($mapped->color)->toBe('info');

    $skipped = BadgeCatalog::spec(BadgeDomain::RestoreResultStatus, 'skipped');
    expect($skipped->label)->toBe('Not applied');
    expect($skipped->color)->toBe('gray');

    $manualRequired = BadgeCatalog::spec(BadgeDomain::RestoreResultStatus, 'manual_required');
    expect($manualRequired->label)->toBe('Manual follow-up needed');
    expect($manualRequired->color)->toBe('warning');

    $failed = BadgeCatalog::spec(BadgeDomain::RestoreResultStatus, 'failed');
    expect($failed->label)->toBe('Apply failed');
    expect($failed->color)->toBe('danger');

    $completed = BadgeCatalog::spec(BadgeDomain::RestoreResultStatus, 'completed');
    expect($completed->label)->toBe('Completed');
    expect($completed->color)->toBe('success');

    $followUp = BadgeCatalog::spec(BadgeDomain::RestoreResultStatus, 'completed_with_follow_up');
    expect($followUp->label)->toBe('Follow-up required');
    expect($followUp->color)->toBe('warning');
});
