Initial baseline: LaraBlog core with plugin commerce surface.
Captures the current working tree after theme slots, ArticleAccess, and the payment / paid-content plugins so subsequent work has a reviewable git history.
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Ai\Jobs\ModerateCommentJob;
|
||||
use App\Domain\Ai\Jobs\OptimizeArticleContentJob;
|
||||
use App\Models\Article;
|
||||
use App\Models\Category;
|
||||
use App\Models\Comment;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AiPipelineTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_optimize_job_writes_stub_suggestions(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$category = Category::query()->create(['name' => 'c', 'display_order' => 0]);
|
||||
$article = Article::query()->create([
|
||||
'category_id' => $category->id,
|
||||
'user_id' => $user->id,
|
||||
'title' => 'T',
|
||||
'content' => 'Hello world body',
|
||||
'content_format' => 'markdown',
|
||||
'published_at' => now(),
|
||||
'visible' => true,
|
||||
]);
|
||||
|
||||
(new OptimizeArticleContentJob($article->id))->handle(
|
||||
app(\App\Contracts\LlmProvider::class),
|
||||
app(\App\Settings\AiSettings::class),
|
||||
);
|
||||
|
||||
$article->refresh();
|
||||
$this->assertNotEmpty($article->ai_summary);
|
||||
$this->assertIsArray($article->ai_suggestions);
|
||||
}
|
||||
|
||||
public function test_moderate_job_approves_non_spam(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$category = Category::query()->create(['name' => 'c', 'display_order' => 0]);
|
||||
$article = Article::query()->create([
|
||||
'category_id' => $category->id,
|
||||
'user_id' => $user->id,
|
||||
'title' => 'T',
|
||||
'content' => 'Body',
|
||||
'content_format' => 'html',
|
||||
'published_at' => now(),
|
||||
'visible' => true,
|
||||
]);
|
||||
|
||||
$comment = Comment::query()->create([
|
||||
'article_id' => $article->id,
|
||||
'author' => 'a',
|
||||
'content' => 'nice post',
|
||||
'moderation_status' => Comment::STATUS_PENDING_AI,
|
||||
'published_at' => now(),
|
||||
]);
|
||||
|
||||
(new ModerateCommentJob($comment->id))->handle(
|
||||
app(\App\Contracts\LlmProvider::class),
|
||||
app(\App\Settings\AiSettings::class),
|
||||
);
|
||||
|
||||
$this->assertSame(Comment::STATUS_APPROVED, $comment->fresh()->moderation_status);
|
||||
}
|
||||
|
||||
public function test_optimize_action_dispatches_to_ai_content_queue(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
||||
OptimizeArticleContentJob::dispatch(1);
|
||||
|
||||
Queue::assertPushedOn('ai-content', OptimizeArticleContentJob::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user