TenantAtlas/tests/Unit/Badges/RestoreRunBadgesTest.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

73 lines
3.0 KiB
PHP

<?php
declare(strict_types=1);
use App\Support\Badges\BadgeCatalog;
use App\Support\Badges\BadgeDomain;
it('maps restore run status values to canonical badge semantics', function (): void {
$draft = BadgeCatalog::spec(BadgeDomain::RestoreRunStatus, 'draft');
expect($draft->label)->toBe('Draft');
expect($draft->color)->toBe('gray');
$previewed = BadgeCatalog::spec(BadgeDomain::RestoreRunStatus, 'previewed');
expect($previewed->label)->toBe('Preview ready');
expect($previewed->color)->toBe('gray');
$queued = BadgeCatalog::spec(BadgeDomain::RestoreRunStatus, 'queued');
expect($queued->label)->toBe('Queued for execution');
expect($queued->color)->toBe('info');
$running = BadgeCatalog::spec(BadgeDomain::RestoreRunStatus, 'running');
expect($running->label)->toBe('Applying restore');
expect($running->color)->toBe('info');
$completed = BadgeCatalog::spec(BadgeDomain::RestoreRunStatus, 'completed');
expect($completed->label)->toBe('Applied successfully');
expect($completed->color)->toBe('success');
$partial = BadgeCatalog::spec(BadgeDomain::RestoreRunStatus, 'partial');
expect($partial->label)->toBe('Applied with follow-up');
expect($partial->color)->toBe('warning');
$completedWithErrors = BadgeCatalog::spec(BadgeDomain::RestoreRunStatus, 'completed_with_errors');
expect($completedWithErrors->label)->toBe('Applied with follow-up');
expect($completedWithErrors->color)->toBe('warning');
$failed = BadgeCatalog::spec(BadgeDomain::RestoreRunStatus, 'failed');
expect($failed->label)->toBe('Restore failed');
expect($failed->color)->toBe('danger');
$aborted = BadgeCatalog::spec(BadgeDomain::RestoreRunStatus, 'aborted');
expect($aborted->label)->toBe('Stopped early');
expect($aborted->color)->toBe('gray');
});
it('never represents a completed outcome with warning/attention meaning', function (): void {
$completed = BadgeCatalog::spec(BadgeDomain::RestoreRunStatus, 'completed');
expect($completed->color)->not->toBe('warning');
});
it('maps restore safety check severity values to canonical badge semantics', function (): void {
$blocking = BadgeCatalog::spec(BadgeDomain::RestoreCheckSeverity, 'blocking');
expect($blocking->label)->toBe('Fix before running');
expect($blocking->color)->toBe('danger');
$warning = BadgeCatalog::spec(BadgeDomain::RestoreCheckSeverity, 'warning');
expect($warning->label)->toBe('Review before running');
expect($warning->color)->toBe('warning');
$safe = BadgeCatalog::spec(BadgeDomain::RestoreCheckSeverity, 'safe');
expect($safe->label)->toBe('Ready to continue');
expect($safe->color)->toBe('success');
$current = BadgeCatalog::spec(BadgeDomain::RestoreCheckSeverity, 'current');
expect($current->label)->toBe('Current checks');
expect($current->color)->toBe('success');
$invalidated = BadgeCatalog::spec(BadgeDomain::RestoreCheckSeverity, 'invalidated');
expect($invalidated->label)->toBe('Invalidated');
expect($invalidated->color)->toBe('warning');
});