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

52 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
use App\Filament\Pages\TenantOnboardingWizard;
use App\Models\TenantOnboardingSession;
use App\Models\TenantPermission;
use Livewire\Livewire;
it('renders stored permission statuses on the permissions step', 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);
TenantPermission::create([
'tenant_id' => $tenant->getKey(),
'permission_key' => 'DeviceManagementApps.Read.All',
'status' => 'granted',
'details' => ['source' => 'test'],
'last_checked_at' => now(),
]);
TenantOnboardingSession::factory()->create([
'tenant_id' => $tenant->getKey(),
'created_by_user_id' => $user->getKey(),
'status' => 'active',
'current_step' => 'permissions',
'payload' => [
'tenant_id' => $tenant->tenant_id,
'environment' => $tenant->environment,
'name' => $tenant->name,
],
]);
Livewire::withQueryParams([
'tenant' => (string) $tenant->external_id,
])
->test(TenantOnboardingWizard::class)
->assertSee('Required permissions')
->assertSee('DeviceManagementApps.Read.All')
->assertSee('Granted');
});