## 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
47 lines
1.8 KiB
PHP
47 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Support\Badges\BadgeCatalog;
|
|
use App\Support\Badges\BadgeDomain;
|
|
|
|
it('maps policy snapshot mode values to canonical badge semantics', function (): void {
|
|
$full = BadgeCatalog::spec(BadgeDomain::PolicySnapshotMode, 'full');
|
|
expect($full->label)->toBe('Full');
|
|
expect($full->color)->toBe('success');
|
|
|
|
$metadataOnly = BadgeCatalog::spec(BadgeDomain::PolicySnapshotMode, 'metadata_only');
|
|
expect($metadataOnly->label)->toBe('Metadata only');
|
|
expect($metadataOnly->color)->toBe('warning');
|
|
});
|
|
|
|
it('maps policy restore mode values to canonical badge semantics', function (): void {
|
|
$enabled = BadgeCatalog::spec(BadgeDomain::PolicyRestoreMode, 'enabled');
|
|
expect($enabled->label)->toBe('Enabled');
|
|
expect($enabled->color)->toBe('success');
|
|
|
|
$previewOnly = BadgeCatalog::spec(BadgeDomain::PolicyRestoreMode, 'preview-only');
|
|
expect($previewOnly->label)->toBe('Preview only');
|
|
expect($previewOnly->color)->toBe('warning');
|
|
});
|
|
|
|
it('maps policy risk values to canonical badge semantics', function (): void {
|
|
$low = BadgeCatalog::spec(BadgeDomain::PolicyRisk, 'low');
|
|
expect($low->label)->toBe('Low');
|
|
expect($low->color)->toBe('gray');
|
|
|
|
$mediumHigh = BadgeCatalog::spec(BadgeDomain::PolicyRisk, 'medium-high');
|
|
expect($mediumHigh->label)->toBe('Medium-high');
|
|
expect($mediumHigh->color)->toBe('danger');
|
|
});
|
|
|
|
it('maps ignored-at presence to canonical badge semantics', function (): void {
|
|
$notIgnored = BadgeCatalog::spec(BadgeDomain::IgnoredAt, null);
|
|
expect($notIgnored->label)->toBe('No');
|
|
expect($notIgnored->color)->toBe('gray');
|
|
|
|
$ignored = BadgeCatalog::spec(BadgeDomain::IgnoredAt, '2026-01-01T00:00:00Z');
|
|
expect($ignored->label)->toBe('Yes');
|
|
expect($ignored->color)->toBe('warning');
|
|
});
|