TenantAtlas/tests/Feature/Support/Badges/FindingBadgeTest.php
ahmido 55aef627aa feat: harden finding governance health surfaces (#197)
## Summary
- harden findings and finding-exception Filament surfaces so workflow state, governance validity, overdue urgency, and next action are operator-first
- add tenant stats widgets, segmented tabs, richer governance warnings, and baseline/dashboard attention propagation for overdue and lapsed governance states
- add Spec 166 artifacts plus regression coverage for findings, badges, baseline summaries, tenantless operation viewer behavior, and critical table standards

## Verification
- `vendor/bin/sail bin pint --dirty --format agent`
- `vendor/bin/sail artisan test --compact`

## Filament Notes
- Livewire v4.0+ compliance: yes, implementation stays on Filament v5 / Livewire v4 APIs only
- Provider registration: unchanged, Laravel 12 panel/provider registration remains in `bootstrap/providers.php`
- Global search: unchanged in this slice; `FindingExceptionResource` stays not globally searchable, no new globally searchable resource was introduced
- Destructive actions: existing revoke/reject/approve/renew/workflow mutations remain capability-gated and confirmation-gated where already defined
- Asset strategy: no new assets added; existing deploy process remains unchanged, including `php artisan filament:assets` when registered assets are used
- Testing plan delivered: findings list/detail, exception register, dashboard attention, baseline summary, badge semantics, and tenantless operation viewer coverage

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #197
2026-03-28 10:11:12 +00:00

68 lines
2.5 KiB
PHP

<?php
declare(strict_types=1);
use App\Models\Finding;
use App\Support\Badges\BadgeCatalog;
use App\Support\Badges\BadgeDomain;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
it('renders resolved status badge with neutral color', function (): void {
$spec = BadgeCatalog::spec(BadgeDomain::FindingStatus, Finding::STATUS_RESOLVED);
expect($spec->label)->toBe('Resolved')
->and($spec->color)->toBe('gray')
->and($spec->icon)->toBe('heroicon-o-check-circle');
});
it('still renders new status badge', function (): void {
$spec = BadgeCatalog::spec(BadgeDomain::FindingStatus, Finding::STATUS_NEW);
expect($spec->label)->toBe('New')
->and($spec->color)->toBe('warning');
});
it('still renders acknowledged status badge', function (): void {
$spec = BadgeCatalog::spec(BadgeDomain::FindingStatus, Finding::STATUS_ACKNOWLEDGED);
expect($spec->label)->toBe('Triaged')
->and($spec->color)->toBe('gray');
});
it('renders v2 workflow status badges', function (): void {
$triaged = BadgeCatalog::spec(BadgeDomain::FindingStatus, Finding::STATUS_TRIAGED);
$inProgress = BadgeCatalog::spec(BadgeDomain::FindingStatus, Finding::STATUS_IN_PROGRESS);
$reopened = BadgeCatalog::spec(BadgeDomain::FindingStatus, Finding::STATUS_REOPENED);
$closed = BadgeCatalog::spec(BadgeDomain::FindingStatus, Finding::STATUS_CLOSED);
$riskAccepted = BadgeCatalog::spec(BadgeDomain::FindingStatus, Finding::STATUS_RISK_ACCEPTED);
expect($triaged->label)->toBe('Triaged')
->and($inProgress->label)->toBe('In progress')
->and($reopened->label)->toBe('Reopened')
->and($closed->label)->toBe('Closed')
->and($riskAccepted->label)->toBe('Risk accepted');
});
it('renders permission_posture finding type badge', function (): void {
$spec = BadgeCatalog::spec(BadgeDomain::FindingType, Finding::FINDING_TYPE_PERMISSION_POSTURE);
expect($spec->label)->toBe('Permission posture')
->and($spec->color)->toBe('warning')
->and($spec->icon)->toBe('heroicon-m-shield-exclamation');
});
it('renders drift finding type badge', function (): void {
$spec = BadgeCatalog::spec(BadgeDomain::FindingType, Finding::FINDING_TYPE_DRIFT);
expect($spec->label)->toBe('Drift')
->and($spec->color)->toBe('info');
});
it('renders unknown for unrecognized finding type', function (): void {
$spec = BadgeCatalog::spec(BadgeDomain::FindingType, 'nonexistent_type');
expect($spec->label)->toBe('Unknown');
});