TenantAtlas/tests/Feature/RequiredPermissions/RequiredPermissionsOverviewTest.php

35 lines
1.2 KiB
PHP

<?php
use App\Models\TenantPermission;
it('renders required permissions overview with missing-first ordering and clickable feature cards', function (): void {
[$user, $tenant] = createUserWithTenant(role: 'readonly');
$configured = config('intune_permissions.permissions', []);
if (! is_array($configured) || count($configured) < 2) {
test()->markTestSkipped('Need at least 2 required permissions configured.');
}
$grantedKey = (string) ($configured[0]['key'] ?? '');
$missingKey = (string) ($configured[1]['key'] ?? '');
if ($grantedKey === '' || $missingKey === '') {
test()->markTestSkipped('Configured permission keys missing.');
}
TenantPermission::create([
'tenant_id' => (int) $tenant->getKey(),
'permission_key' => $grantedKey,
'status' => 'granted',
'details' => ['source' => 'db'],
'last_checked_at' => now(),
]);
$this->actingAs($user)
->get("/admin/t/{$tenant->external_id}/required-permissions")
->assertSuccessful()
->assertSee('Blocked', false)
->assertSee('applyFeatureFilter', false)
->assertSeeInOrder([$missingKey, $grantedKey], false);
});