<?php

use App\Services\Intune\PolicyNormalizer;

test('group policy configuration normalized diff keys use definition display names', function () {
    $flat = app(PolicyNormalizer::class)->flattenForDiff(
        snapshot: [
            'id' => 'gpo-1',
            'displayName' => 'Admin Templates Alpha',
            '@odata.type' => '#microsoft.graph.groupPolicyConfiguration',
            'definitionValues' => [
                [
                    'enabled' => true,
                    'definition@odata.bind' => 'https://graph.microsoft.com/beta/deviceManagement/groupPolicyDefinitions(\'def-1\')',
                    '#Definition_Id' => 'def-1',
                    '#Definition_displayName' => 'Block legacy auth',
                    '#Definition_categoryPath' => 'Windows Components\\Security Options',
                ],
            ],
        ],
        policyType: 'groupPolicyConfiguration',
        platform: 'windows',
    );

    $keys = array_keys($flat);

    expect($keys)->toContain('Administrative Template settings > Windows Components\\Security Options > Block legacy auth (def-1)');
    expect(implode("\n", $keys))->not->toContain('graph.microsoft.com');
});
