2026-06-17 20:05:53 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
use App\Ai\Templates\ImageCardTemplate;
|
2026-06-17 21:59:41 +00:00
|
|
|
use App\Ai\Templates\TemplateContext;
|
2026-07-18 18:12:26 +00:00
|
|
|
use App\Ai\Templates\TweetCardImageTemplate;
|
|
|
|
|
use App\Ai\Templates\TweetCardTemplate;
|
2026-06-17 22:52:38 +00:00
|
|
|
use App\Enums\Ai\ContentStyle;
|
2026-06-17 21:59:41 +00:00
|
|
|
use App\Models\Workspace;
|
|
|
|
|
use Illuminate\JsonSchema\JsonSchemaTypeFactory;
|
2026-06-17 20:05:53 +00:00
|
|
|
|
|
|
|
|
test('image card template exposes its identity', function () {
|
|
|
|
|
$t = new ImageCardTemplate;
|
2026-06-17 21:59:41 +00:00
|
|
|
$workspace = Workspace::factory()->create();
|
|
|
|
|
$context = new TemplateContext($workspace, null, 'instagram_feed', 0, false);
|
|
|
|
|
|
2026-06-17 22:52:38 +00:00
|
|
|
expect($t->style())->toBe(ContentStyle::ImageCard)
|
|
|
|
|
->and($t->key())->toBe('image_card')
|
2026-06-17 20:05:53 +00:00
|
|
|
->and($t->needsAccount())->toBeFalse()
|
2026-07-18 18:12:26 +00:00
|
|
|
->and($t->appliesBrandVisuals())->toBeTrue()
|
2026-06-17 21:59:41 +00:00
|
|
|
->and($t->promptView($context))->toBe('prompts.post_content.generator')
|
2026-06-17 20:05:53 +00:00
|
|
|
->and($t->supportedFormats())->toBe([]);
|
|
|
|
|
});
|
|
|
|
|
|
2026-07-18 18:12:26 +00:00
|
|
|
test('tweet-card templates do not apply brand visuals', function () {
|
|
|
|
|
expect((new TweetCardTemplate)->appliesBrandVisuals())->toBeFalse()
|
|
|
|
|
->and((new TweetCardImageTemplate)->appliesBrandVisuals())->toBeFalse();
|
|
|
|
|
});
|
|
|
|
|
|
2026-06-17 21:59:41 +00:00
|
|
|
test('image card carousel context returns carousel schema shape', function () {
|
|
|
|
|
$t = new ImageCardTemplate;
|
|
|
|
|
$workspace = Workspace::factory()->create();
|
|
|
|
|
$context = new TemplateContext($workspace, null, 'instagram_carousel', 3, true);
|
|
|
|
|
|
|
|
|
|
$schema = new JsonSchemaTypeFactory;
|
|
|
|
|
$result = $t->schema($schema, $context);
|
|
|
|
|
|
|
|
|
|
expect($result)->toHaveKeys(['caption', 'slides'])
|
|
|
|
|
->and($t->promptView($context))->toBe('prompts.post_content.generator');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('image card single context returns single schema shape', function () {
|
|
|
|
|
$t = new ImageCardTemplate;
|
|
|
|
|
$workspace = Workspace::factory()->create();
|
|
|
|
|
$context = new TemplateContext($workspace, null, 'instagram_feed', 1, false);
|
|
|
|
|
|
|
|
|
|
$schema = new JsonSchemaTypeFactory;
|
|
|
|
|
$result = $t->schema($schema, $context);
|
|
|
|
|
|
|
|
|
|
expect($result)->toHaveKeys(['content', 'image_title', 'image_body', 'image_keywords']);
|
2026-06-17 20:05:53 +00:00
|
|
|
});
|