style updates

This commit is contained in:
Mark Gregory
2026-06-23 13:39:02 +01:00
parent e79cadc7f8
commit 3be4ff590f
129 changed files with 482 additions and 404 deletions
@@ -41,7 +41,7 @@ final class HelpdeskSettingsBrowserTest extends DuskTestCase
private function openSettingsSection(Browser $browser, string $section, string $expectedHeading): Browser
{
return $browser
->click('@helpdesk-settings-section-'.$section)
->click('@helpdesk-settings-section-' . $section)
->waitForText($expectedHeading, 10);
}
}
@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Modules\Helpdesk\Tests\Browser;
use Laravel\Dusk\Browser;
use Modules\Helpdesk\Models\CannedResponse;
use Modules\Helpdesk\Models\Comment;
use Modules\Helpdesk\Tests\Concerns\BuildsHelpdeskFixtures;
use Tests\DuskTestCase;
@@ -19,7 +18,7 @@ final class HelpdeskTicketBrowserTest extends DuskTestCase
$fixtures = $this->seedLookupData();
$user = $this->user(['name' => 'Ticket Browser User']);
$subject = 'Browser created helpdesk ticket '.uniqid();
$subject = 'Browser created helpdesk ticket ' . uniqid();
$this->browse(function (Browser $browser) use ($user, $fixtures, $subject): void {
$browser->loginAs($user)
@@ -65,11 +64,10 @@ final class HelpdeskTicketBrowserTest extends DuskTestCase
'user_id' => $user->id,
'parent_id' => null,
'title' => 'Browser canned response',
'body' => '<p>Hello Response Browser User</p><p>Inserted canned browser response for '.$ticket->reference.'</p>',
'body' => '<p>Hello Response Browser User</p><p>Inserted canned browser response for ' . $ticket->reference . '</p>',
'is_internal' => false,
]);
Comment::query()->create([
'ticket_id' => $ticket->id,
'user_id' => $user->id,
@@ -91,7 +89,7 @@ final class HelpdeskTicketBrowserTest extends DuskTestCase
$this->assertDatabaseHas('helpdesk_comments', [
'ticket_id' => $ticket->id,
'parent_id' => null,
'body' => '<p>Hello Response Browser User</p><p>Inserted canned browser response for '.$ticket->reference.'</p>',
'body' => '<p>Hello Response Browser User</p><p>Inserted canned browser response for ' . $ticket->reference . '</p>',
]);
$this->assertDatabaseHas('helpdesk_comments', [
@@ -137,7 +135,7 @@ document.body.appendChild(form);
form.submit();
JS);
$browser->waitForLocation('/helpdesk/tickets/'.$ticketId, 10);
$browser->waitForLocation('/helpdesk/tickets/' . $ticketId, 10);
}
private function setHelpdeskEditor(Browser $browser, string $dusk, string $html): void
@@ -134,7 +134,7 @@ trait BuildsHelpdeskFixtures
unset($attributes['owner'], $attributes['agent']);
return Ticket::query()->create(array_merge([
'reference' => 'HD-'.now()->format('Y').'-'.str_pad((string) random_int(1, 99999), 5, '0', STR_PAD_LEFT),
'reference' => 'HD-' . now()->format('Y') . '-' . str_pad((string) random_int(1, 99999), 5, '0', STR_PAD_LEFT),
'user_id' => $owner->id,
'agent_id' => $agent?->id,
'status_id' => $this->ticketStatus()->id,
@@ -32,7 +32,7 @@ final class GitAndAttachmentTest extends TestCase
'branch' => 'develop',
'author_name' => 'Mark Gregory',
'author_email' => 'mark@example.com',
'message' => 'Resolve '.$ticket->reference.' ticket save redirect',
'message' => 'Resolve ' . $ticket->reference . ' ticket save redirect',
'url' => 'https://example.com/commit/b',
'committed_at' => now(),
]);
@@ -25,12 +25,12 @@ final class GitWebhookIngestionTest extends TestCase
]);
$ticket = $this->ticket(['project_id' => $fixtures['project']->id]);
$payload = [
'ref' => 'refs/heads/feature/'.$ticket->reference.'-automation',
'ref' => 'refs/heads/feature/' . $ticket->reference . '-automation',
'commits' => [
[
'id' => str_repeat('a', 40),
'message' => $ticket->reference.' Add webhook ingestion',
'url' => 'https://github.example.test/org/repo/commit/'.str_repeat('a', 40),
'message' => $ticket->reference . ' Add webhook ingestion',
'url' => 'https://github.example.test/org/repo/commit/' . str_repeat('a', 40),
'timestamp' => '2026-06-15T10:00:00+00:00',
'author' => ['name' => 'Mark Gregory', 'email' => 'mark@example.com'],
],
@@ -43,7 +43,7 @@ final class GitWebhookIngestionTest extends TestCase
'HTTP_ACCEPT' => 'application/json',
'HTTP_X_GITHUB_EVENT' => 'push',
'HTTP_X_GITHUB_DELIVERY' => 'delivery-123',
'HTTP_X_HUB_SIGNATURE_256' => 'sha256='.hash_hmac('sha256', $json, 'github-secret'),
'HTTP_X_HUB_SIGNATURE_256' => 'sha256=' . hash_hmac('sha256', $json, 'github-secret'),
], $json);
$response->assertStatus(202)->assertJsonPath('status', 'accepted')->assertJsonPath('linked_count', 1);
@@ -53,7 +53,7 @@ final class GitWebhookIngestionTest extends TestCase
'ticket_id' => $ticket->id,
'hash' => str_repeat('a', 40),
'short_hash' => str_repeat('a', 12),
'branch' => 'feature/'.$ticket->reference.'-automation',
'branch' => 'feature/' . $ticket->reference . '-automation',
]);
$this->assertDatabaseHas('helpdesk_git_webhook_logs', [
@@ -96,7 +96,7 @@ final class GitWebhookIngestionTest extends TestCase
'CONTENT_TYPE' => 'application/json',
'HTTP_ACCEPT' => 'application/json',
'HTTP_X_GITHUB_EVENT' => 'ping',
'HTTP_X_HUB_SIGNATURE_256' => 'sha256='.hash_hmac('sha256', $json, 'github-secret'),
'HTTP_X_HUB_SIGNATURE_256' => 'sha256=' . hash_hmac('sha256', $json, 'github-secret'),
], $json);
$response->assertStatus(202)->assertJsonPath('status', 'ignored');
@@ -125,8 +125,8 @@ final class GitWebhookIngestionTest extends TestCase
'commits' => [
[
'id' => str_repeat('c', 40),
'message' => 'Fix '.$ticket->reference.' SLA report',
'url' => 'https://gitlab.example.test/org/repo/-/commit/'.str_repeat('c', 40),
'message' => 'Fix ' . $ticket->reference . ' SLA report',
'url' => 'https://gitlab.example.test/org/repo/-/commit/' . str_repeat('c', 40),
'timestamp' => '2026-06-15T11:00:00+00:00',
'author' => ['name' => 'Support Agent', 'email' => 'agent@example.com'],
],
@@ -21,7 +21,7 @@ final class HelpdeskLivewireAssetsTest extends TestCase
self::assertLessThan(
strpos($layout, '@fluxScripts'),
strpos($layout, '@livewireScripts'),
'Livewire scripts must be loaded before Flux scripts so settings CRUD actions fire in the browser.'
'Livewire scripts must be loaded before Flux scripts so settings CRUD actions fire in the browser.',
);
}
}
@@ -95,7 +95,7 @@ final class RedmineInspiredHelpdeskFeatureTest extends TestCase
->test(TicketShow::class, ['ticket' => $ticket])
->set('canned_response_id', $response->id)
->call('applyCannedResponse')
->assertSet('commentBody', 'Hello Customer Jane, ticket '.$ticket->reference.' is being reviewed by Agent Smith.');
->assertSet('commentBody', 'Hello Customer Jane, ticket ' . $ticket->reference . ' is being reviewed by Agent Smith.');
}
public function test_sla_service_records_first_response_and_resolution_breaches(): void
@@ -214,7 +214,7 @@ final class SettingsCrudTest extends TestCase
$checklist = ChecklistTemplate::query()->where('slug', 'release-checklist')->firstOrFail();
Livewire::test(SettingsManager::class)
->call('editChecklistTemplate', $checklist->id)
->set('checklistTemplateForm.items_text', "Updated item")
->set('checklistTemplateForm.items_text', 'Updated item')
->call('saveChecklistTemplate')
->assertHasNoErrors();
$this->assertDatabaseHas('helpdesk_checklist_templates', ['id' => $checklist->id]);
@@ -4,8 +4,8 @@ declare(strict_types=1);
namespace Modules\Helpdesk\Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Models\Company;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Storage;
@@ -13,6 +13,7 @@ use Livewire\Livewire;
use Modules\Helpdesk\Livewire\TicketShow;
use Modules\Helpdesk\Models\Attachment;
use Modules\Helpdesk\Models\Comment;
use Modules\Helpdesk\Services\TicketService;
use Modules\Helpdesk\Tests\Concerns\BuildsHelpdeskFixtures;
use Tests\TestCase;
@@ -69,7 +70,6 @@ final class TicketConversationTest extends TestCase
]);
}
public function test_comment_post_endpoint_creates_lotus_identity_and_search_text(): void
{
$fixtures = $this->seedLookupData();
@@ -98,7 +98,7 @@ final class TicketConversationTest extends TestCase
$fixtures = $this->seedLookupData();
$owner = $this->user();
$ticket = $this->ticket(['owner' => $owner, 'status_id' => $fixtures['open']->id, 'priority_id' => $fixtures['normal']->id]);
$parent = app(\Modules\Helpdesk\Services\TicketService::class)->comment($ticket, $owner, '<p>Parent response</p>');
$parent = app(TicketService::class)->comment($ticket, $owner, '<p>Parent response</p>');
$this->actingAs($owner)
->post(route('helpdesk.tickets.comments.store', $ticket), [
@@ -115,8 +115,6 @@ final class TicketConversationTest extends TestCase
self::assertSame('RE: Parent response', $reply->subject);
}
public function test_existing_ticket_accepts_multiple_supporting_file_attachments(): void
{
Storage::fake((string) config('helpdesk.disk', 'public'));
@@ -187,7 +185,7 @@ final class TicketConversationTest extends TestCase
$admin = $this->user(['company_id' => $company->id, 'is_platform_admin' => true]);
$owner = $this->user(['company_id' => $company->id]);
$ticket = $this->ticket(['owner' => $owner, 'status_id' => $fixtures['open']->id, 'priority_id' => $fixtures['normal']->id]);
$comment = app(\Modules\Helpdesk\Services\TicketService::class)->comment($ticket, $owner, '<p>Delete me</p>');
$comment = app(TicketService::class)->comment($ticket, $owner, '<p>Delete me</p>');
$this->actingAs($admin)
->delete(route('helpdesk.tickets.comments.destroy', [$ticket, $comment]))
@@ -44,7 +44,6 @@ final class TicketCrudTest extends TestCase
]);
}
public function test_ticket_create_does_not_validate_before_submit(): void
{
$this->seedLookupData();
@@ -137,7 +136,7 @@ final class TicketCrudTest extends TestCase
$ticket = Ticket::query()->where('subject', 'Reference check')->firstOrFail();
self::assertStringStartsWith('HD-'.now()->format('Y').'-', $ticket->reference);
self::assertStringStartsWith('HD-' . now()->format('Y') . '-', $ticket->reference);
self::assertNotNull($ticket->last_activity_at);
}
}
@@ -13,7 +13,7 @@ final class TicketFirstResponseSlaFilesTest extends TestCase
*/
public function test_public_response_updates_first_response_sla_state(): void
{
$servicePath = dirname(__DIR__, 2).'/Services/SlaService.php';
$servicePath = dirname(__DIR__, 2) . '/Services/SlaService.php';
self::assertFileExists($servicePath);
@@ -30,8 +30,8 @@ final class TicketFirstResponseSlaFilesTest extends TestCase
*/
public function test_ticket_show_synchronises_first_response_from_existing_public_comments(): void
{
$componentPath = dirname(__DIR__, 2).'/Livewire/TicketShow.php';
$servicePath = dirname(__DIR__, 2).'/Services/SlaService.php';
$componentPath = dirname(__DIR__, 2) . '/Livewire/TicketShow.php';
$servicePath = dirname(__DIR__, 2) . '/Services/SlaService.php';
$component = file_get_contents($componentPath);
$service = file_get_contents($servicePath);
@@ -48,7 +48,7 @@ final class TicketFirstResponseSlaFilesTest extends TestCase
*/
public function test_sla_card_has_clear_responded_and_awaiting_public_reply_states(): void
{
$viewPath = dirname(__DIR__, 2).'/Resources/views/livewire/ticket-show.blade.php';
$viewPath = dirname(__DIR__, 2) . '/Resources/views/livewire/ticket-show.blade.php';
$view = file_get_contents($viewPath);
@@ -13,7 +13,7 @@ final class TicketPublicResponseVisibilityFilesTest extends TestCase
*/
public function test_main_ticket_response_form_has_public_visibility_control(): void
{
$viewPath = dirname(__DIR__, 2).'/Resources/views/livewire/ticket-show.blade.php';
$viewPath = dirname(__DIR__, 2) . '/Resources/views/livewire/ticket-show.blade.php';
self::assertFileExists($viewPath);
@@ -33,7 +33,7 @@ final class TicketPublicResponseVisibilityFilesTest extends TestCase
*/
public function test_threaded_responses_have_public_visibility_control_and_badges(): void
{
$partialPath = dirname(__DIR__, 2).'/Resources/views/partials/comment-thread.blade.php';
$partialPath = dirname(__DIR__, 2) . '/Resources/views/partials/comment-thread.blade.php';
self::assertFileExists($partialPath);
@@ -13,8 +13,8 @@ final class TicketSlaOperationalDetailFilesTest extends TestCase
*/
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';
$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);
@@ -33,8 +33,8 @@ final class TicketSlaOperationalDetailFilesTest extends TestCase
*/
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';
$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);
@@ -55,8 +55,8 @@ final class TicketSlaOperationalDetailFilesTest extends TestCase
*/
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';
$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);
@@ -75,7 +75,7 @@ final class TicketSlaOperationalDetailFilesTest extends TestCase
*/
public function test_public_reply_count_uses_all_ticket_comments(): void
{
$componentPath = dirname(__DIR__, 2).'/Livewire/TicketShow.php';
$componentPath = dirname(__DIR__, 2) . '/Livewire/TicketShow.php';
$component = file_get_contents($componentPath);
@@ -26,6 +26,7 @@ final class TicketTimerButtonSizeFilesTest extends TestCase
self::assertStringNotContainsString('px-3 py-1.5 text-xs', $view);
self::assertStringNotContainsString('ticket-timer.js', $view);
}
/**
* Ensure the active timer action also remains readable and single-line.
*/
@@ -16,7 +16,7 @@ class TicketTimerFilesTest extends TestCase
$this->assertStringStartsWith('<div', $view);
$this->assertFalse(
str_starts_with($view, '<style'),
'The ticket timer Livewire view must not start with a <style> tag.'
'The ticket timer Livewire view must not start with a <style> tag.',
);
}
@@ -50,7 +50,7 @@ final class WorkflowNotificationTest extends TestCase
'event' => 'ticket.created',
'recipient' => 'requester@example.com',
'status' => 'sent',
'subject' => 'Ticket '.$ticket->reference.' raised for Requester Name',
'subject' => 'Ticket ' . $ticket->reference . ' raised for Requester Name',
]);
}
@@ -18,39 +18,39 @@ final class TicketReferenceServiceTest extends TestCase
{
$reference = app(TicketReferenceService::class)->next();
self::assertSame('HD-'.now()->format('Y').'-00001', $reference);
self::assertSame('HD-' . now()->format('Y') . '-00001', $reference);
}
public function test_it_generates_the_next_reference_after_existing_tickets(): void
{
$this->ticket(['reference' => 'HD-'.now()->format('Y').'-00041']);
$this->ticket(['reference' => 'HD-' . now()->format('Y') . '-00041']);
$reference = app(TicketReferenceService::class)->next();
self::assertSame('HD-'.now()->format('Y').'-00042', $reference);
self::assertSame('HD-' . now()->format('Y') . '-00042', $reference);
}
public function test_it_does_not_reuse_soft_deleted_ticket_references(): void
{
$year = now()->format('Y');
$ticket = $this->ticket(['reference' => 'HD-'.$year.'-00002']);
$ticket = $this->ticket(['reference' => 'HD-' . $year . '-00002']);
$ticket->delete();
$reference = app(TicketReferenceService::class)->next();
self::assertSame('HD-'.$year.'-00003', $reference);
self::assertSame('HD-' . $year . '-00003', $reference);
}
public function test_it_uses_the_highest_reference_suffix_instead_of_latest_database_id(): void
{
$year = now()->format('Y');
$this->ticket(['reference' => 'HD-'.$year.'-00042']);
$this->ticket(['reference' => 'HD-'.$year.'-00002']);
$this->ticket(['reference' => 'HD-' . $year . '-00042']);
$this->ticket(['reference' => 'HD-' . $year . '-00002']);
$reference = app(TicketReferenceService::class)->next();
self::assertSame('HD-'.$year.'-00043', $reference);
self::assertSame('HD-' . $year . '-00043', $reference);
}
}