Add unit and feature tests for ticket processing and article management
- Implement Fake repositories and services for testing purposes. - Create tests for Article API including creation, validation, and listing. - Develop ProcessTicketJobFlowTest to validate ticket processing logic. - Add QuickReplyAdminTest for creating and updating quick replies. - Implement TicketAndArticleModelTest to ensure proper cascading deletes and credential encryption. - Create TicketIngestionTest for ticket creation and job dispatching. - Add TicketShowPageTest to verify rendering of quick replies and tool calls. - Implement unit tests for ClassifierPromptBuilder, EmbeddingService, LlmJsonDecoder, QuickReplyResolver, SupportReplyService, TicketResultPayloadBuilder, TicketToolCallService, and ToolCallRequestValidator.
This commit is contained in:
40
tests/Unit/QuickReplyResolverTest.php
Normal file
40
tests/Unit/QuickReplyResolverTest.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\Article;
|
||||
use App\Models\QuickReply;
|
||||
use App\Services\QuickReplyResolver;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class QuickReplyResolverTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_it_returns_null_without_article(): void
|
||||
{
|
||||
$resolver = new QuickReplyResolver;
|
||||
$this->assertNull($resolver->resolveForArticle(null));
|
||||
}
|
||||
|
||||
public function test_it_returns_first_active_quick_reply(): void
|
||||
{
|
||||
$article = Article::query()->create([
|
||||
'title' => 'DNS',
|
||||
'content' => 'content',
|
||||
]);
|
||||
|
||||
$inactive = QuickReply::query()->create(['title' => 'B Reply', 'content' => 'B', 'is_active' => false]);
|
||||
$activeB = QuickReply::query()->create(['title' => 'Z Reply', 'content' => 'Z', 'is_active' => true]);
|
||||
$activeA = QuickReply::query()->create(['title' => 'A Reply', 'content' => 'A', 'is_active' => true]);
|
||||
|
||||
$article->quickReplies()->sync([$inactive->id, $activeB->id, $activeA->id]);
|
||||
|
||||
$resolver = new QuickReplyResolver;
|
||||
$resolved = $resolver->resolveForArticle($article);
|
||||
|
||||
$this->assertInstanceOf(QuickReply::class, $resolved);
|
||||
$this->assertSame($activeA->id, $resolved->id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user