TenantAtlas/apps/platform/tests/Feature/Filament/EnrollmentAutopilotSettingsDisplayTest.php
ahmido e64bae9cfc feat: cut over tenant core to managed environments (#335)
## Summary
- replace the legacy Tenant and TenantMembership core models with ManagedEnvironment and ManagedEnvironmentMembership
- propagate the managed environment naming and key changes across Filament resources, pages, controllers, jobs, models, and supporting runtime paths
- add feature 279 spec artifacts and focused managed-environment test coverage for model behavior, route binding, panel context, authorization, and legacy guardrails

## Validation
- `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/ManagedEnvironment/LegacyTenantCoreGuardTest.php tests/Feature/ManagedEnvironment/ManagedEnvironmentAuthorizationTest.php tests/Feature/ManagedEnvironment/ManagedEnvironmentPanelContextTest.php tests/Feature/ManagedEnvironment/ManagedEnvironmentRouteBindingTest.php tests/Unit/ManagedEnvironment/ManagedEnvironmentContextResolverTest.php tests/Unit/ManagedEnvironment/ManagedEnvironmentModelTest.php`
- `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent`

## Notes
- branch pushed from commit `1123b122`
- browser smoke test file was added but not run in this pass

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #335
2026-05-07 06:38:14 +00:00

143 lines
5.3 KiB
PHP

<?php
use App\Filament\Resources\PolicyResource;
use App\Models\Policy;
use App\Models\PolicyVersion;
use Carbon\CarbonImmutable;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
beforeEach(function () {
[$user, $tenant] = createUserWithTenant(role: 'owner');
$this->tenant = $tenant;
$this->user = $user;
});
test('policy detail renders normalized settings for Autopilot profiles', function () {
$policy = Policy::factory()->create([
'managed_environment_id' => $this->tenant->getKey(),
'external_id' => 'autopilot-1',
'policy_type' => 'windowsAutopilotDeploymentProfile',
'display_name' => 'Autopilot Profile A',
'platform' => 'windows',
]);
PolicyVersion::factory()->create([
'managed_environment_id' => $this->tenant->getKey(),
'policy_id' => $policy->getKey(),
'version_number' => 1,
'policy_type' => $policy->policy_type,
'platform' => $policy->platform,
'created_by' => 'tester@example.com',
'captured_at' => CarbonImmutable::now(),
'snapshot' => [
'@odata.type' => '#microsoft.graph.azureADWindowsAutopilotDeploymentProfile',
'displayName' => 'Autopilot Profile A',
'deviceNameTemplate' => 'DEV-%SERIAL%',
'enableWhiteGlove' => true,
'outOfBoxExperienceSettings' => [
'hideEULA' => true,
'userType' => 'standard',
],
],
]);
$response = $this->actingAs($this->user)
->get(PolicyResource::getUrl('view', ['record' => $policy], tenant: $this->tenant));
$response->assertOk();
$response->assertSee('Settings');
$response->assertSee('Autopilot profile');
$response->assertSee('Device name template');
$response->assertSee('DEV-%SERIAL%');
$response->assertSee('Pre-provisioning (White Glove)');
$response->assertSee('Enabled');
$response->assertSee('OOBE: Hide EULA');
$response->assertSee('OOBE: User type');
});
test('policy detail renders normalized settings for Enrollment Status Page (ESP)', function () {
$policy = Policy::factory()->create([
'managed_environment_id' => $this->tenant->getKey(),
'external_id' => 'esp-1',
'policy_type' => 'windowsEnrollmentStatusPage',
'display_name' => 'ESP A',
'platform' => 'windows',
]);
PolicyVersion::factory()->create([
'managed_environment_id' => $this->tenant->getKey(),
'policy_id' => $policy->getKey(),
'version_number' => 1,
'policy_type' => $policy->policy_type,
'platform' => $policy->platform,
'created_by' => 'tester@example.com',
'captured_at' => CarbonImmutable::now(),
'snapshot' => [
'@odata.type' => '#microsoft.graph.windowsEnrollmentStatusPageConfiguration',
'displayName' => 'ESP A',
'priority' => 1,
'showInstallationProgress' => true,
'installProgressTimeoutInMinutes' => 60,
'selectedMobileAppIds' => ['app-1', 'app-2'],
],
]);
$response = $this->actingAs($this->user)
->get(PolicyResource::getUrl('view', ['record' => $policy], tenant: $this->tenant));
$response->assertOk();
$response->assertSee('Settings');
$response->assertSee('Enrollment Status Page (ESP)');
$response->assertSee('Priority');
$response->assertSee('1');
$response->assertSee('Show installation progress');
$response->assertSee('Enabled');
$response->assertSee('Selected mobile app IDs');
$response->assertSee('app-1');
$response->assertSee('app-2');
});
test('policy detail renders normalized settings for platform restrictions (enrollment)', function () {
$policy = Policy::factory()->create([
'managed_environment_id' => $this->tenant->getKey(),
'external_id' => 'enroll-restrict-1',
'policy_type' => 'deviceEnrollmentPlatformRestrictionsConfiguration',
'display_name' => 'Restriction A',
'platform' => 'all',
]);
PolicyVersion::factory()->create([
'managed_environment_id' => $this->tenant->getKey(),
'policy_id' => $policy->getKey(),
'version_number' => 1,
'policy_type' => $policy->policy_type,
'platform' => $policy->platform,
'created_by' => 'tester@example.com',
'captured_at' => CarbonImmutable::now(),
'snapshot' => [
'@odata.type' => '#microsoft.graph.deviceEnrollmentPlatformRestrictionConfiguration',
'displayName' => 'Restriction A',
'deviceEnrollmentConfigurationType' => 'deviceEnrollmentPlatformRestrictionConfiguration',
'platformRestriction' => [
'platformBlocked' => false,
'personalDeviceEnrollmentBlocked' => true,
'blockedSkus' => ['sku-1'],
],
],
]);
$response = $this->actingAs($this->user)
->get(PolicyResource::getUrl('view', ['record' => $policy], tenant: $this->tenant));
$response->assertOk();
$response->assertSee('Settings');
$response->assertSee('Platform restrictions (enrollment)');
$response->assertSee('Platform: Personal device enrollment blocked');
$response->assertSee('Enabled');
$response->assertSee('Platform: Blocked SKUs');
$response->assertSee('sku-1');
});