2026-05-03 12:36:50 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
use App\Ai\Agents\PostContentReviewer;
|
|
|
|
|
use App\Models\Workspace;
|
|
|
|
|
use Illuminate\JsonSchema\JsonSchemaTypeFactory;
|
|
|
|
|
|
|
|
|
|
test('instructions render brand context and language', function () {
|
|
|
|
|
$workspace = Workspace::factory()->make([
|
|
|
|
|
'name' => 'TryPost',
|
2026-06-12 20:09:39 +00:00
|
|
|
'brand_voice_traits' => ['friendly', 'concise'],
|
2026-05-03 12:36:50 +00:00
|
|
|
'content_language' => 'pt-BR',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$agent = new PostContentReviewer(workspace: $workspace);
|
|
|
|
|
$instructions = $agent->instructions();
|
|
|
|
|
|
|
|
|
|
expect($instructions)->toContain('TryPost');
|
2026-06-12 20:09:39 +00:00
|
|
|
expect($instructions)->toContain('friendly'); // "Be warm and friendly."
|
|
|
|
|
expect($instructions)->toContain('short'); // "Keep sentences short and objective."
|
2026-05-03 12:36:50 +00:00
|
|
|
expect($instructions)->toContain('pt-BR');
|
|
|
|
|
});
|
|
|
|
|
|
2026-08-05 22:45:30 +00:00
|
|
|
test('instructions use Ukrainian when the workspace content language is uk', function () {
|
|
|
|
|
$workspace = Workspace::factory()->make([
|
|
|
|
|
'content_language' => 'uk',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
expect((new PostContentReviewer(workspace: $workspace))->instructions())
|
|
|
|
|
->toContain('Output language: uk.');
|
|
|
|
|
});
|
|
|
|
|
|
2026-05-03 12:36:50 +00:00
|
|
|
test('schema requires suggestions array with original/suggestion/reason', function () {
|
|
|
|
|
$workspace = Workspace::factory()->make();
|
|
|
|
|
$agent = new PostContentReviewer(workspace: $workspace);
|
|
|
|
|
|
|
|
|
|
$schema = $agent->schema(new JsonSchemaTypeFactory);
|
|
|
|
|
expect($schema)->toHaveKey('suggestions');
|
|
|
|
|
});
|