TenantAtlas/tests/Unit/Badges/RestoreUiBadgesTest.php
ahmido a107e7e41b feat: restore safety integrity and queue slide-over (#210)
## Summary
- add the Spec 181 restore-safety layer with scope fingerprinting, preview/check integrity states, execution safety snapshots, result attention, and operator-facing copy across the wizard, restore detail, and canonical operation detail
- add focused unit and feature coverage for restore-safety assessment, result attention, and restore-linked operation detail
- switch the finding exceptions queue `Inspect exception` action to a native Filament slide-over while preserving query-param-backed inline summary behavior

## Testing
- `vendor/bin/sail artisan test --compact tests/Feature/Monitoring/FindingExceptionsQueueTest.php tests/Feature/Filament/RestoreSafetyIntegrityWizardTest.php tests/Feature/Filament/RestoreResultAttentionSurfaceTest.php tests/Feature/Operations/RestoreLinkedOperationDetailTest.php tests/Unit/Support/RestoreSafety`

## Notes
- Spec 181 checklist is complete (`specs/181-restore-safety-integrity/checklists/requirements.md`)
- the branch still has unchecked follow-up tasks in `specs/181-restore-safety-integrity/tasks.md`: `T012`, `T018`, `T019`, `T023`, `T025`, `T029`, `T032`, `T033`, `T041`, `T042`, `T043`, `T044`
- Filament v5 / Livewire v4 compliance is preserved, no panel provider registration changes were made, no global-search behavior was added, destructive actions remain confirmation-gated, and no new Filament assets were introduced

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #210
2026-04-06 23:37:14 +00:00

75 lines
3.2 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');
$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');
});