<?php

declare(strict_types=1);

use App\Support\Inventory\InventoryPolicyTypeMeta;

it('exposes baseline-supported foundation types and identity strategies from canonical metadata', function (): void {
    config()->set('tenantpilot.foundation_types', [
        [
            'type' => 'assignmentFilter',
            'label' => 'Assignment Filter',
            'baseline_compare' => [
                'supported' => true,
                'identity_strategy' => 'display_name',
            ],
        ],
        [
            'type' => 'intuneRoleDefinition',
            'label' => 'Intune RBAC Role Definition',
            'baseline_compare' => [
                'supported' => true,
                'identity_strategy' => 'external_id',
            ],
        ],
        [
            'type' => 'intuneRoleAssignment',
            'label' => 'Intune RBAC Role Assignment',
            'baseline_compare' => [
                'supported' => false,
                'identity_strategy' => 'external_id',
            ],
        ],
    ]);

    expect(collect(InventoryPolicyTypeMeta::baselineSupportedFoundations())->pluck('type')->all())
        ->toBe(['assignmentFilter', 'intuneRoleDefinition']);

    expect(InventoryPolicyTypeMeta::isBaselineSupportedFoundation('intuneRoleDefinition'))->toBeTrue();
    expect(InventoryPolicyTypeMeta::isBaselineSupportedFoundation('intuneRoleAssignment'))->toBeFalse();
    expect(InventoryPolicyTypeMeta::baselineCompareIdentityStrategy('intuneRoleDefinition'))->toBe('external_id');
    expect(InventoryPolicyTypeMeta::baselineCompareIdentityStrategy('assignmentFilter'))->toBe('display_name');
});
