TenantAtlas/tests/Feature/ManagedTenantOnboardingWizardVerificationReadyTest.php
2026-02-01 12:20:09 +01:00

77 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
use App\Filament\Pages\TenantOnboardingWizard;
use App\Models\OperationRun;
use App\Models\ProviderConnection;
use App\Models\TenantOnboardingSession;
use App\Models\TenantPermission;
use Livewire\Livewire;
it('shows ready state when stored checks indicate success', function (): void {
config()->set('tenantpilot.onboarding.credentials_required', false);
config()->set('intune_permissions.permissions', [[
'key' => 'DeviceManagementApps.Read.All',
'type' => 'application',
'description' => 'Read apps',
'features' => ['apps'],
]]);
[$user, $tenant] = createUserWithTenant(role: 'owner');
$this->actingAs($user);
ProviderConnection::query()->create([
'tenant_id' => (int) $tenant->getKey(),
'provider' => 'microsoft',
'entra_tenant_id' => (string) $tenant->tenant_id,
'display_name' => 'Microsoft Graph',
'is_default' => true,
'status' => 'connected',
'health_status' => 'ok',
'scopes_granted' => [],
'metadata' => [],
]);
TenantPermission::create([
'tenant_id' => $tenant->getKey(),
'permission_key' => 'DeviceManagementApps.Read.All',
'status' => 'granted',
'details' => ['source' => 'test'],
'last_checked_at' => now(),
]);
OperationRun::query()->create([
'tenant_id' => $tenant->getKey(),
'user_id' => $user->getKey(),
'initiator_name' => $user->name,
'type' => 'tenant.rbac.verify',
'status' => 'completed',
'outcome' => 'succeeded',
'run_identity_hash' => 'test',
'summary_counts' => [],
'failure_summary' => [],
'context' => [],
]);
TenantOnboardingSession::factory()->create([
'tenant_id' => $tenant->getKey(),
'created_by_user_id' => $user->getKey(),
'status' => 'active',
'current_step' => 'verification',
'payload' => [
'tenant_id' => $tenant->tenant_id,
'environment' => $tenant->environment,
'name' => $tenant->name,
],
]);
Livewire::withQueryParams([
'tenant' => (string) $tenant->external_id,
])
->test(TenantOnboardingWizard::class)
->assertSee('Ready:');
});