<?php

declare(strict_types=1);

use App\Support\Ai\AiDataClassification;
use App\Support\Ai\AiPolicyMode;
use App\Support\Ai\AiUseCaseCatalog;

it('locks the first slice to the two approved private-only use cases', function (): void {
    $definitions = app(AiUseCaseCatalog::class)->all();

    expect($definitions)->toHaveCount(2)
        ->and($definitions[0])->toMatchArray([
            'key' => 'product_knowledge.answer_draft',
            'label' => 'Product knowledge answer draft',
            'future_consumer' => 'ContextualHelpResolver',
            'source_family' => 'product_knowledge',
            'tenant_context_permitted' => false,
        ])
        ->and($definitions[0]['allowed_provider_classes'])->toBe(['local_private'])
        ->and($definitions[0]['allowed_data_classifications'])->toBe([
            'product_knowledge',
            'operational_metadata',
        ])
        ->and($definitions[1])->toMatchArray([
            'key' => 'support_diagnostics.summary_draft',
            'label' => 'Support diagnostics summary draft',
            'future_consumer' => 'SupportDiagnosticBundleBuilder',
            'source_family' => 'support_diagnostics',
            'tenant_context_permitted' => true,
        ])
        ->and($definitions[1]['allowed_provider_classes'])->toBe(['local_private'])
        ->and($definitions[1]['allowed_data_classifications'])->toBe([
            'redacted_support_summary',
        ]);
});

it('derives provider and blocked-data summaries from the catalog for the workspace policy surface', function (): void {
    $catalog = app(AiUseCaseCatalog::class);

    expect($catalog->allowedProviderClassLabelsForMode(AiPolicyMode::Disabled))->toBe([])
        ->and($catalog->allowedProviderClassLabelsForMode(AiPolicyMode::PrivateOnly))->toBe(['Local private'])
        ->and($catalog->blockedDataClassificationLabels())->toBe([
            AiDataClassification::PersonalData->label(),
            AiDataClassification::CustomerConfidential->label(),
            AiDataClassification::RawProviderPayload->label(),
        ]);
});
