Files
WMS/Modules/Helpdesk/Tests/Feature/TicketSlaOperationalDetailFilesTest.php
T
2026-06-23 13:39:02 +01:00

90 lines
3.7 KiB
PHP

<?php
declare(strict_types=1);
namespace Modules\Helpdesk\Tests\Feature;
use PHPUnit\Framework\TestCase;
final class TicketSlaOperationalDetailFilesTest extends TestCase
{
/**
* SLA cards must show operationally useful first-response detail.
*/
public function test_first_response_sla_card_shows_duration_responder_and_timestamp(): void
{
$componentPath = dirname(__DIR__, 2) . '/Livewire/TicketShow.php';
$viewPath = dirname(__DIR__, 2) . '/Resources/views/livewire/ticket-show.blade.php';
$component = file_get_contents($componentPath);
$view = file_get_contents($viewPath);
self::assertIsString($component);
self::assertIsString($view);
self::assertStringContainsString('firstResponseSlaDetail', $component);
self::assertStringContainsString('Responded in ', $component);
self::assertStringContainsString('firstResponderName', $component);
self::assertStringContainsString('Responder', $view);
self::assertStringContainsString('Responded at', $view);
}
/**
* SLA cards should use clear met, due-soon and breached states.
*/
public function test_sla_cards_have_colour_coded_state_helpers(): void
{
$componentPath = dirname(__DIR__, 2) . '/Livewire/TicketShow.php';
$viewPath = dirname(__DIR__, 2) . '/Resources/views/livewire/ticket-show.blade.php';
$component = file_get_contents($componentPath);
$view = file_get_contents($viewPath);
self::assertIsString($component);
self::assertIsString($view);
self::assertStringContainsString('firstResponseIsDueSoon', $component);
self::assertStringContainsString('resolutionIsDueSoon', $component);
self::assertStringContainsString('firstResponseSlaClasses', $view);
self::assertStringContainsString('resolutionSlaClasses', $view);
self::assertStringContainsString('border-amber-300', $component);
self::assertStringContainsString('border-red-300', $component);
self::assertStringContainsString('border-emerald-200', $component);
}
/**
* The ticket page should expose an SLA audit trail for support managers.
*/
public function test_sla_audit_trail_is_visible_on_ticket_page(): void
{
$servicePath = dirname(__DIR__, 2) . '/Services/SlaService.php';
$viewPath = dirname(__DIR__, 2) . '/Resources/views/livewire/ticket-show.blade.php';
$service = file_get_contents($servicePath);
$view = file_get_contents($viewPath);
self::assertIsString($service);
self::assertIsString($view);
self::assertStringContainsString('SLA audit trail', $view);
self::assertStringContainsString('$ticket->slaEvents->take(5)', $view);
self::assertStringContainsString('actor_name', $service);
self::assertStringContainsString('response_seconds', $service);
self::assertStringContainsString('resolved_seconds', $service);
}
/**
* Public reply counts must include threaded public replies, not only root comments.
*/
public function test_public_reply_count_uses_all_ticket_comments(): void
{
$componentPath = dirname(__DIR__, 2) . '/Livewire/TicketShow.php';
$component = file_get_contents($componentPath);
self::assertIsString($component);
self::assertStringContainsString('Comment::query()', $component);
self::assertStringContainsString("where('ticket_id', \$ticket->id)", $component);
self::assertStringContainsString("\$comments->where('is_internal', false)->count()", $component);
self::assertStringNotContainsString('$ticket->comments()
->active()', $component);
}
}