TenantAtlas/apps/platform/tests/Unit/Support/Ai/AiApprovedSourceInputsTest.php
Ahmed Darrazi 6383f205a1
Some checks failed
PR Fast Feedback / fast-feedback (pull_request) Failing after 1m3s
chore: commit all changes (automated) 2026-04-27T21:17:40Z
2026-04-27 23:17:40 +02:00

55 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
use App\Models\Tenant;
use App\Models\Workspace;
use App\Support\Ai\AiDataClassification;
use App\Support\ProductKnowledge\ContextualHelpResolver;
use App\Support\SupportDiagnostics\SupportDiagnosticBundleBuilder;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
it('exposes only the approved product knowledge source input for ai answer drafts', function (): void {
$source = app(ContextualHelpResolver::class)->aiProductKnowledgeAnswerDraftSource();
expect($source)->toMatchArray([
'use_case_key' => 'product_knowledge.answer_draft',
'source_family' => 'product_knowledge',
'data_classifications' => [
AiDataClassification::ProductKnowledge->value,
AiDataClassification::OperationalMetadata->value,
],
])
->and($source['topics'])->not->toBeEmpty()
->and($source['operational_metadata'])->toHaveKeys(['version', 'topic_count'])
->and($source)->not->toHaveKeys(['tenant', 'tenant_id', 'workspace', 'workspace_id']);
});
it('exposes only the approved redacted support summary input for ai diagnostic drafts', function (): void {
$workspace = Workspace::factory()->create();
$tenant = Tenant::factory()->create([
'workspace_id' => (int) $workspace->getKey(),
]);
$source = app(SupportDiagnosticBundleBuilder::class)->aiSupportDiagnosticsSummaryDraftSource($tenant);
expect($source)->toMatchArray([
'use_case_key' => 'support_diagnostics.summary_draft',
'source_family' => 'support_diagnostics',
'data_classifications' => [
AiDataClassification::RedactedSupportSummary->value,
],
])
->and($source['summary'])->toHaveKeys([
'headline',
'dominant_issue',
'freshness_state',
'redaction_note',
'generated_from',
])
->and(data_get($source, 'redaction.mode'))->toBe('default_redacted')
->and($source)->not->toHaveKeys(['sections', 'context', 'tenant', 'workspace', 'operation_run']);
});