TenantAtlas/tests/Feature/RequiredPermissions/RequiredPermissionsOverviewTest.php
ahmido 05a604cfb6 Spec 076: Tenant Required Permissions (enterprise remediation UX) (#92)
Implements Spec 076 enterprise remediation UX for tenant required permissions.

Highlights
- Above-the-fold overview (impact + counts) with missing-first experience
- Feature-based grouping, filters/search, copy-to-clipboard for missing app/delegated permissions
- Tenant-scoped deny-as-not-found semantics; DB-only viewing
- Centralized badge semantics (no ad-hoc status mapping)

Testing
- Feature tests for default filters, grouping, copy output, and non-member 404 behavior.

Integration
- Adds deep links from verification checks to the Required permissions page.

Co-authored-by: Ahmed Darrazi <ahmeddarrazi@MacBookPro.fritz.box>
Reviewed-on: #92
2026-02-05 22:08:51 +00:00

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);
});