<?php

declare(strict_types=1);

use App\Support\Badges\BadgeCatalog;
use App\Support\Badges\BadgeDomain;
use App\Support\Providers\Capabilities\ProviderCapabilityRegistry;

it('defines the canonical provider capability keys and operation mappings', function (): void {
    $registry = app(ProviderCapabilityRegistry::class);

    expect($registry->keys())->toBe([
        'provider_connection_check',
        'inventory_read',
        'configuration_read',
        'restore_execute',
        'directory_groups_read',
        'directory_role_definitions_read',
    ])
        ->and($registry->keysForOperationType('inventory.sync'))->toBe(['inventory_read'])
        ->and($registry->keysForOperationType('directory.role_definitions.sync'))->toBe(['directory_role_definitions_read'])
        ->and($registry->get('restore_execute')->providerRequirementKeys)->toBe([
            'permissions.intune_configuration',
            'permissions.intune_rbac_assignments',
        ])
        ->and($registry->get('directory_role_definitions_read')->providerRequirementKeys)->toBe([
            'provider.directory_role_definitions',
            'permissions.admin_consent',
        ]);
});

it('registers provider capability status badge semantics', function (): void {
    expect(BadgeCatalog::spec(BadgeDomain::ProviderCapabilityStatus, 'supported')->label)->toBe('Supported')
        ->and(BadgeCatalog::spec(BadgeDomain::ProviderCapabilityStatus, 'missing')->color)->toBe('warning')
        ->and(BadgeCatalog::spec(BadgeDomain::ProviderCapabilityStatus, 'blocked')->color)->toBe('danger')
        ->and(BadgeCatalog::spec(BadgeDomain::ProviderCapabilityStatus, 'not_applicable')->label)->toBe('Not applicable');
});
