014-enrollment-autopilot #20
@ -1,5 +1,6 @@
|
|||||||
@php
|
@php
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Support\Js;
|
||||||
|
|
||||||
// Extract state from Filament ViewEntry
|
// Extract state from Filament ViewEntry
|
||||||
$state = $getState();
|
$state = $getState();
|
||||||
@ -7,6 +8,34 @@
|
|||||||
$warnings = $state['warnings'] ?? [];
|
$warnings = $state['warnings'] ?? [];
|
||||||
$settings = $state['settings'] ?? [];
|
$settings = $state['settings'] ?? [];
|
||||||
$settingsTable = $state['settings_table'] ?? null;
|
$settingsTable = $state['settings_table'] ?? null;
|
||||||
|
|
||||||
|
$stringifyValue = function (mixed $value): string {
|
||||||
|
if (is_null($value)) {
|
||||||
|
return 'N/A';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_bool($value)) {
|
||||||
|
return $value ? 'Enabled' : 'Disabled';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_scalar($value)) {
|
||||||
|
return (string) $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($value)) {
|
||||||
|
return Js::from($value)->toHtml();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_object($value)) {
|
||||||
|
if (method_exists($value, '__toString')) {
|
||||||
|
return (string) $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Js::from((array) $value)->toHtml();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'N/A';
|
||||||
|
};
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
<div class="space-y-4">
|
<div class="space-y-4">
|
||||||
@ -96,7 +125,7 @@
|
|||||||
</span>
|
</span>
|
||||||
@else
|
@else
|
||||||
<span class="text-sm text-gray-900 dark:text-white break-words">
|
<span class="text-sm text-gray-900 dark:text-white break-words">
|
||||||
{{ Str::limit($row['value'] ?? 'N/A', 200) }}
|
{{ Str::limit($stringifyValue($row['value'] ?? null), 200) }}
|
||||||
</span>
|
</span>
|
||||||
@endif
|
@endif
|
||||||
</dd>
|
</dd>
|
||||||
@ -124,7 +153,7 @@
|
|||||||
</dt>
|
</dt>
|
||||||
<dd class="mt-1 sm:mt-0 sm:col-span-2">
|
<dd class="mt-1 sm:mt-0 sm:col-span-2">
|
||||||
<span class="text-sm text-gray-900 dark:text-white break-words">
|
<span class="text-sm text-gray-900 dark:text-white break-words">
|
||||||
{{ Str::limit($entry['value'] ?? 'N/A', 200) }}
|
{{ Str::limit($stringifyValue($entry['value'] ?? null), 200) }}
|
||||||
</span>
|
</span>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Filament\Resources\PolicyResource;
|
||||||
|
use App\Models\Policy;
|
||||||
|
use App\Models\PolicyVersion;
|
||||||
|
use App\Models\Tenant;
|
||||||
|
use App\Models\User;
|
||||||
|
use Carbon\CarbonImmutable;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
|
test('policy settings standard view renders array values without crashing', function () {
|
||||||
|
$tenant = Tenant::create([
|
||||||
|
'tenant_id' => 'tenant-arrays',
|
||||||
|
'name' => 'Tenant Arrays',
|
||||||
|
'metadata' => [],
|
||||||
|
'is_current' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$tenant->makeCurrent();
|
||||||
|
|
||||||
|
$policy = Policy::create([
|
||||||
|
'tenant_id' => $tenant->id,
|
||||||
|
'external_id' => 'policy-arrays-1',
|
||||||
|
'policy_type' => 'windowsAutopilotDeploymentProfile',
|
||||||
|
'display_name' => 'Autopilot Policy With Arrays',
|
||||||
|
'platform' => 'windows',
|
||||||
|
]);
|
||||||
|
|
||||||
|
PolicyVersion::create([
|
||||||
|
'tenant_id' => $tenant->id,
|
||||||
|
'policy_id' => $policy->id,
|
||||||
|
'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.windowsAutopilotDeploymentProfile',
|
||||||
|
'displayName' => 'Autopilot Policy With Arrays',
|
||||||
|
'roleScopeTagIds' => ['0', '1'],
|
||||||
|
'outOfBoxExperienceSettings' => [
|
||||||
|
'hideEULA' => true,
|
||||||
|
'userType' => 'standard',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user = User::factory()->create();
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)
|
||||||
|
->get(PolicyResource::getUrl('view', ['record' => $policy]).'?tab=settings');
|
||||||
|
|
||||||
|
$response->assertOk();
|
||||||
|
$response->assertSee('Settings');
|
||||||
|
$response->assertSee('Scope tag IDs');
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue
Block a user