- 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.
49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Jobs\ProcessTicketJob;
|
|
use App\Models\Ticket;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Queue;
|
|
use Tests\TestCase;
|
|
|
|
class TicketIngestionTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_it_ingests_ticket_and_dispatches_processing_job(): void
|
|
{
|
|
Queue::fake();
|
|
|
|
$response = $this->postJson('/api/tickets', [
|
|
'message' => 'Mijn mail werkt niet',
|
|
'api_credentials' => [
|
|
'apiuser' => 'demo',
|
|
'apipassword' => 'secret',
|
|
],
|
|
]);
|
|
|
|
$response->assertStatus(202)
|
|
->assertJsonPath('status', 'queued');
|
|
|
|
$ticket = Ticket::query()->latest('id')->first();
|
|
$this->assertNotNull($ticket);
|
|
$this->assertSame('queued', $ticket->status);
|
|
$this->assertSame('demo', $ticket->api_credentials['apiuser']);
|
|
|
|
$raw = DB::table('tickets')->where('id', $ticket->id)->value('api_credentials');
|
|
$this->assertIsString($raw);
|
|
$this->assertStringNotContainsString('secret', $raw);
|
|
|
|
Queue::assertPushed(ProcessTicketJob::class);
|
|
}
|
|
|
|
public function test_it_validates_required_message(): void
|
|
{
|
|
$response = $this->postJson('/api/tickets', []);
|
|
$response->assertStatus(422);
|
|
}
|
|
}
|