2026-06-17 20:35:18 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-06-17 21:59:41 +00:00
|
|
|
use App\Ai\Templates\TemplateContext;
|
2026-06-17 20:35:18 +00:00
|
|
|
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:35:18 +00:00
|
|
|
|
|
|
|
|
test('tweet card template identity', function () {
|
|
|
|
|
$t = new TweetCardTemplate;
|
2026-06-17 21:59:41 +00:00
|
|
|
$workspace = Workspace::factory()->create();
|
|
|
|
|
$singleContext = new TemplateContext($workspace, null, 'x_post', 1, false);
|
|
|
|
|
$carouselContext = new TemplateContext($workspace, null, 'instagram_carousel', 2, true);
|
|
|
|
|
|
2026-06-17 22:52:38 +00:00
|
|
|
expect($t->style())->toBe(ContentStyle::TweetCard)
|
|
|
|
|
->and($t->key())->toBe('tweet_card')
|
2026-06-17 20:35:18 +00:00
|
|
|
->and($t->needsAccount())->toBeTrue()
|
2026-06-18 14:11:23 +00:00
|
|
|
->and($t->style()->isTweetCard())->toBeTrue()
|
2026-06-17 21:59:41 +00:00
|
|
|
->and($t->promptView($singleContext))->toBe('prompts.post_content.tweet_card')
|
|
|
|
|
->and($t->promptView($carouselContext))->toBe('prompts.post_content.tweet_card_carousel');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('tweet card single schema returns tweet_text only', function () {
|
|
|
|
|
$t = new TweetCardTemplate;
|
|
|
|
|
$workspace = Workspace::factory()->create();
|
|
|
|
|
$context = new TemplateContext($workspace, null, 'x_post', 1, false);
|
|
|
|
|
|
|
|
|
|
$schema = new JsonSchemaTypeFactory;
|
|
|
|
|
$result = $t->schema($schema, $context);
|
|
|
|
|
|
|
|
|
|
expect($result)->toHaveKey('tweet_text')
|
|
|
|
|
->and($result)->not->toHaveKey('caption');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('tweet card carousel schema returns caption and slides', function () {
|
|
|
|
|
$t = new TweetCardTemplate;
|
|
|
|
|
$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']);
|
2026-06-17 20:35:18 +00:00
|
|
|
});
|