TenantAtlas/tests/Unit/Badges/ProviderConnectionBadgesTest.php
ahmido dc46c4fa58 feat: complete provider truth cleanup (#207)
## Summary
- implement Spec 179 to make tenant lifecycle, provider consent, and provider verification the primary truth axes on the targeted Filament surfaces
- demote legacy tenant app status and legacy provider status and health to diagnostic-only roles, add centralized badge mappings for provider consent and verification, and keep provider connections excluded from global search
- add the full Spec 179 artifact set under `specs/179-provider-truth-cleanup/` plus focused Pest coverage for tenant truth cleanup, provider truth cleanup, RBAC, discovery safety, and badge semantics
- fix the numeric out-of-scope tenant route regression so inaccessible `/admin/tenants/{id}` paths return `404 Not Found` instead of `500`

## Testing
- `vendor/bin/sail artisan test --compact tests/Feature/Filament/TenantLifecycleStatusDomainSeparationTest.php`
- `vendor/bin/sail artisan test --compact tests/Feature/Filament/TenantTruthCleanupSpec179Test.php`
- `vendor/bin/sail artisan test --compact tests/Feature/Filament/ProviderConnectionsDbOnlyTest.php`
- `vendor/bin/sail artisan test --compact tests/Feature/ProviderConnections/ProviderConnectionTruthCleanupSpec179Test.php`
- `vendor/bin/sail artisan test --compact tests/Feature/ProviderConnections/RequiredFiltersTest.php`
- `vendor/bin/sail artisan test --compact tests/Feature/Tenants/TenantProviderConnectionsCtaTest.php`
- `vendor/bin/sail artisan test --compact tests/Feature/Rbac/TenantResourceAuthorizationTest.php`
- `vendor/bin/sail artisan test --compact tests/Feature/ProviderConnections/ProviderConnectionListAuthorizationTest.php`
- `vendor/bin/sail artisan test --compact tests/Feature/ProviderConnections/ProviderConnectionAuthorizationTest.php`
- `vendor/bin/sail artisan test --compact tests/Feature/Rbac/AdminGlobalSearchContextSafetyTest.php`
- `vendor/bin/sail artisan test --compact tests/Feature/Filament/TenantGlobalSearchLifecycleScopeTest.php`
- `vendor/bin/sail artisan test --compact tests/Feature/Filament/TenantScopingTest.php`
- `vendor/bin/sail artisan test --compact tests/Unit/Badges/TenantBadgesTest.php`
- `vendor/bin/sail artisan test --compact tests/Unit/Badges/ProviderConnectionBadgesTest.php`

## Manual validation
- integrated-browser smoke on `/admin/tenants`, tenant detail, `/admin/provider-connections`, provider detail, and provider edit
- verified out-of-scope tenant and provider URLs return `404 Not Found` with the current session

## Notes
- branch: `179-provider-truth-cleanup`
- commit: `e54c6632`
- target: `dev`

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #207
2026-04-05 00:48:31 +00:00

79 lines
3.1 KiB
PHP

<?php
declare(strict_types=1);
use App\Support\Badges\BadgeCatalog;
use App\Support\Badges\BadgeDomain;
it('maps provider consent status safely', function (): void {
$unknown = BadgeCatalog::spec(BadgeDomain::ProviderConsentStatus, 'unknown');
expect($unknown->color)->toBe('gray');
expect($unknown->label)->toBe('Unknown');
$required = BadgeCatalog::spec(BadgeDomain::ProviderConsentStatus, 'required');
expect($required->color)->toBe('warning');
expect($required->label)->toBe('Required');
$granted = BadgeCatalog::spec(BadgeDomain::ProviderConsentStatus, 'granted');
expect($granted->color)->toBe('success');
expect($granted->label)->toBe('Granted');
$failed = BadgeCatalog::spec(BadgeDomain::ProviderConsentStatus, 'failed');
expect($failed->color)->toBe('danger');
expect($failed->label)->toBe('Failed');
});
it('maps provider verification status safely', function (): void {
$unknown = BadgeCatalog::spec(BadgeDomain::ProviderVerificationStatus, 'unknown');
expect($unknown->color)->toBe('gray');
expect($unknown->label)->toBe('Unknown');
$pending = BadgeCatalog::spec(BadgeDomain::ProviderVerificationStatus, 'pending');
expect($pending->color)->toBe('info');
expect($pending->label)->toBe('Pending');
$healthy = BadgeCatalog::spec(BadgeDomain::ProviderVerificationStatus, 'healthy');
expect($healthy->color)->toBe('success');
expect($healthy->label)->toBe('Healthy');
$blocked = BadgeCatalog::spec(BadgeDomain::ProviderVerificationStatus, 'blocked');
expect($blocked->color)->toBe('danger');
expect($blocked->label)->toBe('Blocked');
});
it('maps provider connection legacy status safely', function (): void {
$connected = BadgeCatalog::spec(BadgeDomain::ProviderConnectionStatus, 'connected');
expect($connected->color)->toBe('success');
expect($connected->label)->toBe('Connected');
$needsConsent = BadgeCatalog::spec(BadgeDomain::ProviderConnectionStatus, 'needs_consent');
expect($needsConsent->color)->toBe('warning');
expect($needsConsent->label)->toBe('Needs consent');
$error = BadgeCatalog::spec(BadgeDomain::ProviderConnectionStatus, 'error');
expect($error->color)->toBe('danger');
expect($error->label)->toBe('Error');
$disabled = BadgeCatalog::spec(BadgeDomain::ProviderConnectionStatus, 'disabled');
expect($disabled->color)->toBe('gray');
expect($disabled->label)->toBe('Disabled');
});
it('maps provider connection legacy health safely', function (): void {
$ok = BadgeCatalog::spec(BadgeDomain::ProviderConnectionHealth, 'ok');
expect($ok->color)->toBe('success');
expect($ok->label)->toBe('OK');
$degraded = BadgeCatalog::spec(BadgeDomain::ProviderConnectionHealth, 'degraded');
expect($degraded->color)->toBe('warning');
expect($degraded->label)->toBe('Degraded');
$down = BadgeCatalog::spec(BadgeDomain::ProviderConnectionHealth, 'down');
expect($down->color)->toBe('danger');
expect($down->label)->toBe('Down');
$unknown = BadgeCatalog::spec(BadgeDomain::ProviderConnectionHealth, 'unknown');
expect($unknown->color)->toBe('gray');
expect($unknown->label)->toBe('Unknown');
});