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:
36
tests/Unit/TicketResultPayloadBuilderTest.php
Normal file
36
tests/Unit/TicketResultPayloadBuilderTest.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\QuickReply;
|
||||
use App\Models\TicketToolCall;
|
||||
use App\Services\TicketResultPayloadBuilder;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class TicketResultPayloadBuilderTest extends TestCase
|
||||
{
|
||||
public function test_it_builds_payload_with_optional_fields(): void
|
||||
{
|
||||
$builder = new TicketResultPayloadBuilder;
|
||||
$quickReply = new QuickReply(['id' => 7, 'title' => 'Quick']);
|
||||
$quickReply->id = 7;
|
||||
$toolCall = new TicketToolCall(['action' => 'domain_inf', 'status' => 'success']);
|
||||
|
||||
$payload = $builder->build(
|
||||
[
|
||||
'top_3_candidates' => [['article_id' => 1]],
|
||||
'top_5_candidates' => [['article_id' => 1], ['article_id' => 2]],
|
||||
'classifier_raw_response' => ['mode' => 'llm'],
|
||||
'requested_tool_call' => ['action' => 'domain_inf'],
|
||||
],
|
||||
$toolCall,
|
||||
$quickReply,
|
||||
false,
|
||||
null
|
||||
);
|
||||
|
||||
$this->assertSame(7, $payload['quick_reply']['id']);
|
||||
$this->assertSame('domain_inf', $payload['requested_tool_call']['action']);
|
||||
$this->assertFalse($payload['knowledge_gap']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user