## Summary - replace the legacy Tenant and TenantMembership core models with ManagedEnvironment and ManagedEnvironmentMembership - propagate the managed environment naming and key changes across Filament resources, pages, controllers, jobs, models, and supporting runtime paths - add feature 279 spec artifacts and focused managed-environment test coverage for model behavior, route binding, panel context, authorization, and legacy guardrails ## Validation - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/ManagedEnvironment/LegacyTenantCoreGuardTest.php tests/Feature/ManagedEnvironment/ManagedEnvironmentAuthorizationTest.php tests/Feature/ManagedEnvironment/ManagedEnvironmentPanelContextTest.php tests/Feature/ManagedEnvironment/ManagedEnvironmentRouteBindingTest.php tests/Unit/ManagedEnvironment/ManagedEnvironmentContextResolverTest.php tests/Unit/ManagedEnvironment/ManagedEnvironmentModelTest.php` - `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent` ## Notes - branch pushed from commit `1123b122` - browser smoke test file was added but not run in this pass Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #335
74 lines
2.8 KiB
PHP
74 lines
2.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Resources\TenantResource;
|
|
use App\Models\ProviderConnection;
|
|
use App\Support\Providers\ProviderConsentStatus;
|
|
use App\Support\Providers\ProviderVerificationStatus;
|
|
|
|
it('renders provider connections CTA with canonical tenantless URL on tenant detail page', function (): void {
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner');
|
|
|
|
$this->actingAs($user)
|
|
->get(TenantResource::getUrl('view', ['record' => $tenant], tenant: $tenant))
|
|
->assertOk()
|
|
->assertSee('/admin/provider-connections?managed_environment_id='.(string) $tenant->external_id, false);
|
|
});
|
|
|
|
it('keeps the canonical provider connections CTA when the tenant needs a default microsoft connection', function (): void {
|
|
$tenant = \App\Models\ManagedEnvironment::factory()->active()->create();
|
|
[$user, $tenant] = createUserWithTenant(
|
|
tenant: $tenant,
|
|
role: 'owner',
|
|
ensureDefaultMicrosoftProviderConnection: false,
|
|
);
|
|
|
|
\App\Models\ProviderConnection::factory()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'managed_environment_id' => (int) $tenant->getKey(),
|
|
'provider' => 'microsoft',
|
|
'display_name' => 'Fallback Connection',
|
|
'is_default' => false,
|
|
]);
|
|
|
|
$this->actingAs($user)
|
|
->get(TenantResource::getUrl('view', ['record' => $tenant], tenant: $tenant))
|
|
->assertOk()
|
|
->assertSee('/admin/provider-connections?managed_environment_id='.(string) $tenant->external_id, false);
|
|
});
|
|
|
|
it('renders the tenant provider summary with lifecycle, consent, and verification only', function (): void {
|
|
$tenant = \App\Models\ManagedEnvironment::factory()->active()->create();
|
|
[$user, $tenant] = createUserWithTenant(
|
|
tenant: $tenant,
|
|
role: 'owner',
|
|
ensureDefaultMicrosoftProviderConnection: false,
|
|
);
|
|
|
|
ProviderConnection::factory()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'managed_environment_id' => (int) $tenant->getKey(),
|
|
'provider' => 'microsoft',
|
|
'display_name' => 'Canonical Summary Connection',
|
|
'is_default' => true,
|
|
'is_enabled' => false,
|
|
'consent_status' => ProviderConsentStatus::Granted->value,
|
|
'verification_status' => ProviderVerificationStatus::Healthy->value,
|
|
]);
|
|
|
|
$this->actingAs($user)
|
|
->get(TenantResource::getUrl('view', ['record' => $tenant], tenant: $tenant))
|
|
->assertOk()
|
|
->assertSee('Provider connection')
|
|
->assertSee('Canonical Summary Connection')
|
|
->assertSee('Lifecycle')
|
|
->assertSee('Disabled')
|
|
->assertSee('Consent')
|
|
->assertSee('Granted')
|
|
->assertSee('Verification')
|
|
->assertSee('Healthy')
|
|
->assertDontSee('Connected')
|
|
->assertDontSee('Legacy health');
|
|
});
|