- 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.
54 lines
1.8 KiB
PHP
54 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Models\Article;
|
|
use App\Models\Ticket;
|
|
use App\Services\Tools\TicketToolCallService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\Fakes\FakeDomainInfoTool;
|
|
use Tests\Fakes\FakeTicketProcessingLoggerService;
|
|
use Tests\TestCase;
|
|
|
|
class TicketToolCallServiceTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_it_skips_when_action_not_allowed(): void
|
|
{
|
|
$service = new TicketToolCallService(new FakeDomainInfoTool, new FakeTicketProcessingLoggerService);
|
|
|
|
$article = Article::query()->create(['title' => 'A', 'content' => 'B', 'allowed_actions' => []]);
|
|
$ticket = Ticket::query()->create(['message' => 'vraag']);
|
|
|
|
$record = $service->executeRequestedTool($ticket, $article, [
|
|
'action' => 'domain_inf',
|
|
'parameters' => ['sld' => 'example', 'tld' => 'nl'],
|
|
]);
|
|
|
|
$this->assertNotNull($record);
|
|
$this->assertSame('skipped', $record->status);
|
|
}
|
|
|
|
public function test_it_executes_domain_info_when_allowed_and_credentials_present(): void
|
|
{
|
|
$fakeTool = new FakeDomainInfoTool;
|
|
$service = new TicketToolCallService($fakeTool, new FakeTicketProcessingLoggerService);
|
|
|
|
$article = Article::query()->create(['title' => 'A', 'content' => 'B', 'allowed_actions' => ['domain_inf']]);
|
|
$ticket = Ticket::query()->create([
|
|
'message' => 'vraag',
|
|
'api_credentials' => ['apiuser' => 'u', 'apipassword' => 'p'],
|
|
]);
|
|
|
|
$record = $service->executeRequestedTool($ticket, $article, [
|
|
'action' => 'domain_inf',
|
|
'parameters' => ['sld' => 'example', 'tld' => 'nl'],
|
|
]);
|
|
|
|
$this->assertNotNull($record);
|
|
$this->assertSame('success', $record->status);
|
|
$this->assertCount(1, $fakeTool->calls);
|
|
}
|
|
}
|