TenantAtlas/tests/Unit/Badges/RestoreUiBadgesTest.php
ahmido 3c3daae405 feat: normalize operator outcome taxonomy (#186)
## Summary
- introduce a shared operator outcome taxonomy with semantic axes, severity bands, and next-action policy
- apply the taxonomy to operations, evidence/review completeness, baseline semantics, and restore semantics
- harden badge rendering, tenant-safe filtering/search behavior, and operator-facing summary/notification wording
- add the spec kit artifacts, reference documentation, and regression coverage for diagnostic-vs-primary state handling

## Testing
- focused Pest coverage for taxonomy registry and badge guardrails
- operations presentation and notification tests
- evidence, baseline, restore, and tenant-scope regression tests

## Notes
- Livewire v4.0+ compliance is preserved in the existing Filament v5 stack
- panel provider registration remains unchanged in bootstrap/providers.php
- no new globally searchable resource was added; adopted resources remain tenant-safe and out of global search where required
- no new destructive action family was introduced; existing actions keep their current authorization and confirmation behavior
- no new frontend asset strategy was introduced; existing deploy flow with filament:assets remains unchanged

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #186
2026-03-22 12:13:34 +00:00

55 lines
2.3 KiB
PHP

<?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');
});
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');
});