TenantAtlas/tests/Unit/Badges/RestoreRunBadgesTest.php
ahmido 0b6600b926 059-unified-badges (#71)
## Summary
- centralize all status-like badge semantics via `BadgeCatalog`/`BadgeRenderer` and new per-domain mappings plus coverage for every affected entity
- replace ad-hoc badge colors in Filament tables/views with the shared catalog and add a guard test that blocks new inline semantics
- stabilize restore views by avoiding `@php(...)` shorthand so Blade compiles cleanly, and document BADGE-001 in the constitution/templates

## Testing
- `vendor/bin/sail php vendor/bin/pint --dirty`
- `vendor/bin/sail artisan test tests/Unit/Badges tests/Feature/Guards/NoAdHocStatusBadgesTest.php`
- `vendor/bin/sail artisan test tests/Feature/Monitoring/OperationsDbOnlyTest.php tests/Feature/Monitoring/OperationsTenantScopeTest.php`
- `vendor/bin/sail artisan test tests/Feature/RestoreRunWizardMetadataTest.php tests/Feature/Filament/SettingsCatalogRestoreApplySettingsPatchTest.php`

Co-authored-by: Ahmed Darrazi <ahmeddarrazi@adsmac.local>
Reviewed-on: #71
2026-01-22 23:44:51 +00:00

57 lines
2.2 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('Previewed');
expect($previewed->color)->toBe('gray');
$queued = BadgeCatalog::spec(BadgeDomain::RestoreRunStatus, 'queued');
expect($queued->label)->toBe('Queued');
expect($queued->color)->toBe('warning');
$running = BadgeCatalog::spec(BadgeDomain::RestoreRunStatus, 'running');
expect($running->label)->toBe('Running');
expect($running->color)->toBe('info');
$completed = BadgeCatalog::spec(BadgeDomain::RestoreRunStatus, 'completed');
expect($completed->label)->toBe('Completed');
expect($completed->color)->toBe('success');
$partial = BadgeCatalog::spec(BadgeDomain::RestoreRunStatus, 'partial');
expect($partial->label)->toBe('Partial');
expect($partial->color)->toBe('warning');
$failed = BadgeCatalog::spec(BadgeDomain::RestoreRunStatus, 'failed');
expect($failed->label)->toBe('Failed');
expect($failed->color)->toBe('danger');
});
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('Blocking');
expect($blocking->color)->toBe('danger');
$warning = BadgeCatalog::spec(BadgeDomain::RestoreCheckSeverity, 'warning');
expect($warning->label)->toBe('Warning');
expect($warning->color)->toBe('warning');
$safe = BadgeCatalog::spec(BadgeDomain::RestoreCheckSeverity, 'safe');
expect($safe->label)->toBe('Safe');
expect($safe->color)->toBe('success');
});