TenantAtlas/tests/Unit/PolicyNormalizerSettingsCatalogTest.php
Ahmed Darrazi 58e6a4e980 feat(settings-catalog): Add category display and definition caching
- Add SettingsCatalogCategoryResolver service with 3-tier caching
- Add SettingsCatalogCategory model and migration
- Add warm-cache commands for definitions and categories
- Update PolicyNormalizer to display categories in settings table
- Fix extraction of nested children in choiceSettingValue
- Add category inheritance from parent settings
- Skip template IDs with {tenantid} placeholder in Graph API calls
- Update Livewire table with Category, Data Type, and Description columns

Related tests updated and passing.
2025-12-21 00:40:20 +01:00

53 lines
2.1 KiB
PHP

<?php
use App\Services\Intune\PolicyNormalizer;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
uses(TestCase::class);
uses(RefreshDatabase::class);
beforeEach(function () {
$this->normalizer = app(PolicyNormalizer::class);
});
it('normalizes settings catalog settings into key value entries', function () {
$snapshot = [
'@odata.type' => '#microsoft.graph.deviceManagementConfigurationPolicy',
'settings' => [
[
'settingInstance' => [
'@odata.type' => '#microsoft.graph.deviceManagementConfigurationSimpleSettingInstance',
'settingDefinitionId' => 'device_vendor_msft_policy_config_system_minimumpinlength',
'simpleSettingValue' => [
'value' => 12,
],
],
],
[
'settingInstance' => [
'@odata.type' => '#microsoft.graph.deviceManagementConfigurationChoiceSettingInstance',
'settingDefinitionId' => 'device_vendor_msft_policy_config_winhello_usebiometrics',
'choiceSettingValue' => [
'value' => 'device_vendor_msft_policy_config_winhello_usebiometrics_true',
],
],
],
],
];
$result = $this->normalizer->normalize($snapshot, 'settingsCatalogPolicy', 'windows');
expect($result['status'])->toBe('success');
expect($result)->toHaveKey('settings_table');
$rows = $result['settings_table']['rows'];
expect($rows[0]['definition'])->toContain('Minimum'); // Prettified display name
expect($rows[0]['data_type'])->toBe('Number'); // User-friendly type
expect($rows[0]['value'])->toBe('12');
expect($rows[0])->toHaveKey('category');
expect($rows[0])->toHaveKey('description');
expect($rows[1]['definition'])->toContain('Winhello'); // Prettified display name
expect($rows[1]['data_type'])->toBe('Choice'); // User-friendly type
expect($rows[1]['value'])->toBe('Enabled'); // Formatted from choice value
});