TenantAtlas/tests/Unit/TenantRequiredPermissionsFeatureImpactTest.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

68 lines
1.9 KiB
PHP

<?php
use App\Services\Intune\TenantRequiredPermissionsViewModelBuilder;
it('aggregates feature impacts without double-counting within a feature', function (): void {
$rows = [
[
'key' => 'P1',
'type' => 'application',
'description' => null,
'features' => ['backup'],
'status' => 'missing',
'details' => null,
],
[
'key' => 'P2',
'type' => 'delegated',
'description' => null,
'features' => ['backup'],
'status' => 'missing',
'details' => null,
],
[
'key' => 'P3',
'type' => 'application',
'description' => null,
'features' => ['backup', 'drift'],
'status' => 'granted',
'details' => null,
],
[
'key' => 'P4',
'type' => 'application',
'description' => null,
'features' => ['drift'],
'status' => 'missing',
'details' => null,
],
[
'key' => 'P5',
'type' => 'application',
'description' => null,
'features' => ['backup', 'backup'],
'status' => 'missing',
'details' => null,
],
];
$impacts = TenantRequiredPermissionsViewModelBuilder::deriveFeatureImpacts($rows);
$byFeature = collect($impacts)->keyBy('feature')->all();
expect($byFeature['backup'])->toMatchArray([
'feature' => 'backup',
'missing' => 3,
'required_application' => 3,
'required_delegated' => 1,
'blocked' => true,
]);
expect($byFeature['drift'])->toMatchArray([
'feature' => 'drift',
'missing' => 1,
'required_application' => 2,
'required_delegated' => 0,
'blocked' => true,
]);
});