68 lines
2.5 KiB
PHP
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 success color', function (): void {
|
|
$spec = BadgeCatalog::spec(BadgeDomain::FindingStatus, Finding::STATUS_RESOLVED);
|
|
|
|
expect($spec->label)->toBe('Resolved')
|
|
->and($spec->color)->toBe('success')
|
|
->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');
|
|
});
|