## 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
148 lines
5.5 KiB
PHP
148 lines
5.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Resources\ProviderConnectionResource;
|
|
use App\Filament\Resources\ProviderConnectionResource\Pages\ListProviderConnections;
|
|
use App\Models\ProviderConnection;
|
|
use App\Support\Providers\ProviderConsentStatus;
|
|
use App\Support\Providers\ProviderVerificationStatus;
|
|
use Filament\Facades\Filament;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Livewire\Livewire;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('promotes consent and verification to the default-visible provider connection list axes', function (): void {
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner', ensureDefaultMicrosoftProviderConnection: false);
|
|
|
|
$connection = ProviderConnection::factory()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'display_name' => 'Contoso',
|
|
'provider' => 'microsoft',
|
|
'is_default' => true,
|
|
'consent_status' => ProviderConsentStatus::Granted->value,
|
|
'verification_status' => ProviderVerificationStatus::Degraded->value,
|
|
'status' => 'connected',
|
|
'health_status' => 'ok',
|
|
]);
|
|
|
|
$this->actingAs($user);
|
|
$tenant->makeCurrent();
|
|
Filament::setTenant($tenant, true);
|
|
|
|
$component = Livewire::actingAs($user)
|
|
->test(ListProviderConnections::class)
|
|
->assertCanSeeTableRecords([$connection]);
|
|
|
|
$table = $component->instance()->getTable();
|
|
$visibleColumnNames = collect($table->getVisibleColumns())
|
|
->map(fn ($column): string => $column->getName())
|
|
->values()
|
|
->all();
|
|
|
|
expect($visibleColumnNames)->toContain('consent_status', 'verification_status')
|
|
->and($visibleColumnNames)->not->toContain('status')
|
|
->and($visibleColumnNames)->not->toContain('health_status')
|
|
->and($table->getColumn('status')?->isToggledHiddenByDefault())->toBeTrue()
|
|
->and($table->getColumn('health_status')?->isToggledHiddenByDefault())->toBeTrue();
|
|
});
|
|
|
|
it('separates current state from diagnostics on the provider connection view page', function (): void {
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner', ensureDefaultMicrosoftProviderConnection: false);
|
|
|
|
$connection = ProviderConnection::factory()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'display_name' => 'Truthful Connection',
|
|
'provider' => 'microsoft',
|
|
'is_default' => true,
|
|
'consent_status' => ProviderConsentStatus::Granted->value,
|
|
'verification_status' => ProviderVerificationStatus::Degraded->value,
|
|
'status' => 'connected',
|
|
'health_status' => 'ok',
|
|
]);
|
|
|
|
$this->actingAs($user)
|
|
->get(ProviderConnectionResource::getUrl('view', ['record' => $connection], tenant: $tenant))
|
|
->assertOk()
|
|
->assertSeeInOrder([
|
|
'Current state',
|
|
'Consent',
|
|
'Granted',
|
|
'Verification',
|
|
'Degraded',
|
|
'Diagnostics',
|
|
'Legacy status',
|
|
'Connected',
|
|
'Legacy health',
|
|
'OK',
|
|
]);
|
|
});
|
|
|
|
it('shows current consent and verification context before diagnostics on the provider connection edit page', function (): void {
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner', ensureDefaultMicrosoftProviderConnection: false);
|
|
|
|
$connection = ProviderConnection::factory()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'display_name' => 'Editable Truthful Connection',
|
|
'provider' => 'microsoft',
|
|
'is_default' => true,
|
|
'consent_status' => ProviderConsentStatus::Granted->value,
|
|
'verification_status' => ProviderVerificationStatus::Blocked->value,
|
|
'status' => 'connected',
|
|
'health_status' => 'ok',
|
|
]);
|
|
|
|
$this->actingAs($user)
|
|
->get(ProviderConnectionResource::getUrl('edit', ['record' => $connection], tenant: $tenant))
|
|
->assertOk()
|
|
->assertSeeInOrder([
|
|
'Current state',
|
|
'Consent',
|
|
'Granted',
|
|
'Verification',
|
|
'Blocked',
|
|
'Diagnostics',
|
|
'Legacy status',
|
|
'Connected',
|
|
'Legacy health',
|
|
'OK',
|
|
]);
|
|
});
|
|
|
|
it('does not treat consented but unverified connections as ready across provider surfaces', function (): void {
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner', ensureDefaultMicrosoftProviderConnection: false);
|
|
|
|
$connection = ProviderConnection::factory()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'display_name' => 'Unknown Verification Connection',
|
|
'provider' => 'microsoft',
|
|
'is_default' => true,
|
|
'consent_status' => ProviderConsentStatus::Granted->value,
|
|
'verification_status' => ProviderVerificationStatus::Unknown->value,
|
|
'status' => 'connected',
|
|
'health_status' => 'ok',
|
|
]);
|
|
|
|
$this->actingAs($user);
|
|
$tenant->makeCurrent();
|
|
Filament::setTenant($tenant, true);
|
|
|
|
Livewire::actingAs($user)
|
|
->test(ListProviderConnections::class)
|
|
->assertCanSeeTableRecords([$connection])
|
|
->assertSee('Granted')
|
|
->assertSee('Unknown')
|
|
->assertDontSee('Ready');
|
|
|
|
$this->get(ProviderConnectionResource::getUrl('view', ['record' => $connection], tenant: $tenant))
|
|
->assertOk()
|
|
->assertSee('Granted')
|
|
->assertSee('Unknown')
|
|
->assertDontSee('Ready');
|
|
});
|