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:
@@ -3,12 +3,9 @@
|
||||
<div class="flex items-center justify-between">
|
||||
<h2 class="font-semibold">Ticket #{{ $ticket->id }}</h2>
|
||||
<div class="flex items-center gap-3">
|
||||
<button
|
||||
type="button"
|
||||
wire:click="reprocess"
|
||||
<button type="button" wire:click="reprocess"
|
||||
wire:confirm="Weet je zeker dat je ticket #{{ $ticket->id }} opnieuw wilt verwerken?"
|
||||
class="text-sm px-3 py-1 rounded bg-slate-900 text-white"
|
||||
>
|
||||
class="text-sm px-3 py-1 rounded bg-slate-900 text-white">
|
||||
Herverwerk ticket
|
||||
</button>
|
||||
<span class="text-sm px-2 py-1 rounded bg-slate-100">Status: {{ $ticket->status }}</span>
|
||||
@@ -19,14 +16,14 @@
|
||||
<div class="mt-3 rounded bg-green-100 text-green-700 p-2 text-sm">{{ session('success') }}</div>
|
||||
@endif
|
||||
|
||||
@if($ticket->needs_article_draft)
|
||||
@if ($ticket->needs_article_draft)
|
||||
<div class="mt-3 rounded bg-amber-50 border border-amber-300 p-3">
|
||||
<div class="text-sm font-semibold text-amber-900 mb-1">Kennisbank-gat gedetecteerd</div>
|
||||
<p class="text-sm text-amber-900">
|
||||
Er is geen geschikt artikel in de kennisbank gevonden voor deze vraag.
|
||||
</p>
|
||||
@php($suggestion = $ticket->result_payload['draft_article_suggestion'] ?? null)
|
||||
@if(is_array($suggestion))
|
||||
@if (is_array($suggestion))
|
||||
<div class="mt-3">
|
||||
<p class="text-sm font-semibold text-amber-900">Voorgestelde titel</p>
|
||||
<p class="text-sm text-amber-900">{{ $suggestion['title'] ?? '-' }}</p>
|
||||
@@ -39,12 +36,13 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if($ticket->support_reply && !$ticket->needs_article_draft)
|
||||
@if ($ticket->support_reply && !$ticket->needs_article_draft)
|
||||
<div class="mt-3 rounded bg-blue-50 border border-blue-200 p-3">
|
||||
<div class="text-sm font-semibold text-blue-900 mb-1">Concept reactie voor klant</div>
|
||||
@if(is_array($ticket->result_payload['quick_reply'] ?? null))
|
||||
@if (is_array($ticket->result_payload['quick_reply'] ?? null))
|
||||
<div class="mb-2 inline-flex rounded bg-blue-100 px-2 py-1 text-xs text-blue-900">
|
||||
Snelantwoord gebruikt: #{{ $ticket->result_payload['quick_reply']['id'] ?? '-' }} {{ $ticket->result_payload['quick_reply']['title'] ?? '' }}
|
||||
Snelantwoord gebruikt: #{{ $ticket->result_payload['quick_reply']['id'] ?? '-' }}
|
||||
{{ $ticket->result_payload['quick_reply']['title'] ?? '' }}
|
||||
</div>
|
||||
@endif
|
||||
<pre class="text-sm whitespace-pre-wrap text-blue-900">{{ $ticket->support_reply }}</pre>
|
||||
@@ -52,24 +50,25 @@
|
||||
@endif
|
||||
|
||||
<p class="mt-3 text-sm text-slate-800"><strong>Origineel:</strong> {{ $ticket->message }}</p>
|
||||
@if($ticket->normalized_message)
|
||||
<p class="mt-2 text-sm text-slate-800"><strong>Genormaliseerd:</strong> {{ $ticket->normalized_message }}</p>
|
||||
@if ($ticket->normalized_message)
|
||||
<p class="mt-2 text-sm text-slate-800"><strong>Genormaliseerd:</strong> {{ $ticket->normalized_message }}
|
||||
</p>
|
||||
@endif
|
||||
@if($ticket->redaction_report)
|
||||
<pre class="text-xs mt-2 bg-slate-50 p-2 rounded overflow-x-auto">{{ json_encode($ticket->redaction_report, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE) }}</pre>
|
||||
@if ($ticket->redaction_report)
|
||||
<pre class="text-xs mt-2 bg-slate-50 p-2 rounded overflow-x-auto">{{ json_encode($ticket->redaction_report, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) }}</pre>
|
||||
@endif
|
||||
@if(is_array($ticket->api_credentials) && !empty($ticket->api_credentials['apiuser']))
|
||||
@if (is_array($ticket->api_credentials) && !empty($ticket->api_credentials['apiuser']))
|
||||
<div class="mt-3 text-sm rounded bg-slate-100 text-slate-700 p-2">
|
||||
API credentials aanwezig voor deze ticket-run. Waarden worden niet getoond.
|
||||
</div>
|
||||
@endif
|
||||
@if($ticket->error_message)
|
||||
@if ($ticket->error_message)
|
||||
<div class="mt-3 text-sm rounded bg-red-100 text-red-700 p-2">{{ $ticket->error_message }}</div>
|
||||
@endif
|
||||
@if($ticket->bestArticle)
|
||||
@if ($ticket->bestArticle)
|
||||
<div class="mt-3 text-sm rounded bg-green-100 text-green-800 p-2">
|
||||
Beste artikel: #{{ $ticket->bestArticle->id }} - {{ $ticket->bestArticle->title }}
|
||||
@if($ticket->confidence !== null)
|
||||
@if ($ticket->confidence !== null)
|
||||
(confidence {{ number_format($ticket->confidence, 2) }})
|
||||
@endif
|
||||
</div>
|
||||
@@ -78,34 +77,35 @@
|
||||
|
||||
<div class="bg-white rounded-xl p-4 shadow">
|
||||
<h3 class="font-semibold mb-3">Toolcalls</h3>
|
||||
@if($ticket->toolCalls->isEmpty())
|
||||
@if ($ticket->toolCalls->isEmpty())
|
||||
<p class="text-sm text-slate-600">Geen toolcalls uitgevoerd of voorgesteld.</p>
|
||||
@else
|
||||
<div class="space-y-2">
|
||||
@foreach($ticket->toolCalls as $toolCall)
|
||||
@foreach ($ticket->toolCalls as $toolCall)
|
||||
<div class="border rounded p-3 text-sm">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="font-medium">
|
||||
{{ $toolCall->action }} ({{ $toolCall->status }})
|
||||
@if($toolCall->article)
|
||||
@if ($toolCall->article)
|
||||
<span class="text-slate-500">via artikel #{{ $toolCall->article->id }}</span>
|
||||
@endif
|
||||
</div>
|
||||
<span class="text-xs text-slate-500">{{ $toolCall->executed_at ?? $toolCall->created_at }}</span>
|
||||
<span
|
||||
class="text-xs text-slate-500">{{ $toolCall->executed_at ?? $toolCall->created_at }}</span>
|
||||
</div>
|
||||
@if($toolCall->parameters)
|
||||
@if ($toolCall->parameters)
|
||||
<div class="mt-2">
|
||||
<div class="text-xs font-semibold text-slate-500">Parameters</div>
|
||||
<pre class="text-xs bg-slate-50 p-2 rounded overflow-x-auto">{{ json_encode($toolCall->parameters, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE) }}</pre>
|
||||
<pre class="text-xs bg-slate-50 p-2 rounded overflow-x-auto">{{ json_encode($toolCall->parameters, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) }}</pre>
|
||||
</div>
|
||||
@endif
|
||||
@if($toolCall->response)
|
||||
@if ($toolCall->response)
|
||||
<div class="mt-2">
|
||||
<div class="text-xs font-semibold text-slate-500">Response</div>
|
||||
<pre class="text-xs bg-slate-50 p-2 rounded overflow-x-auto">{{ json_encode($toolCall->response, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES) }}</pre>
|
||||
<pre class="text-xs bg-slate-50 p-2 rounded overflow-x-auto">{{ json_encode($toolCall->response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) }}</pre>
|
||||
</div>
|
||||
@endif
|
||||
@if($toolCall->error)
|
||||
@if ($toolCall->error)
|
||||
<div class="mt-2 rounded bg-amber-50 text-amber-900 p-2">{{ $toolCall->error }}</div>
|
||||
@endif
|
||||
</div>
|
||||
@@ -118,8 +118,9 @@
|
||||
<h3 class="font-semibold mb-3">Verwerkingsstappen</h3>
|
||||
@php($orderedLogs = $ticket->logs->sortBy([['created_at', 'desc'], ['id', 'desc']]))
|
||||
@php($latestLog = $orderedLogs->first())
|
||||
@if($ticket->status === 'processing' && $latestLog)
|
||||
<div class="mb-3 rounded border border-blue-200 bg-blue-50 p-2 text-sm text-blue-900 flex items-center justify-between">
|
||||
@if ($ticket->status === 'processing' && $latestLog)
|
||||
<div
|
||||
class="mb-3 rounded border border-blue-200 bg-blue-50 p-2 text-sm text-blue-900 flex items-center justify-between">
|
||||
<span>Huidige stap: <strong>{{ $latestLog->step }}</strong></span>
|
||||
<span class="inline-flex items-center gap-1">
|
||||
<span class="inline-block h-2 w-2 rounded-full bg-blue-600 animate-pulse"></span>
|
||||
@@ -128,17 +129,17 @@
|
||||
</div>
|
||||
@endif
|
||||
<div class="space-y-2">
|
||||
@foreach($orderedLogs as $log)
|
||||
@foreach ($orderedLogs as $log)
|
||||
<div class="border rounded p-3 text-sm">
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="font-medium">{{ $log->step }} ({{ $log->status }})</span>
|
||||
<span class="text-xs text-slate-500">{{ $log->created_at }}</span>
|
||||
</div>
|
||||
@if($log->message)
|
||||
@if ($log->message)
|
||||
<div class="text-slate-700 mt-1">{{ $log->message }}</div>
|
||||
@endif
|
||||
@if($log->context)
|
||||
<pre class="text-xs mt-2 bg-slate-50 p-2 rounded overflow-x-auto">{{ json_encode($log->context, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE) }}</pre>
|
||||
@if ($log->context)
|
||||
<pre class="text-xs mt-2 bg-slate-50 p-2 rounded overflow-x-auto">{{ json_encode($log->context, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) }}</pre>
|
||||
@endif
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
Reference in New Issue
Block a user