proper closer status

This commit is contained in:
Mark Gregory
2026-06-23 11:01:55 +01:00
parent e12ab543e8
commit a6148f9bfd
8 changed files with 329 additions and 50 deletions
@@ -222,6 +222,66 @@ final class TicketConversationTest extends TestCase
self::assertSame($fixtures['high']->id, $ticket->priority_id);
}
public function test_closing_ticket_requires_a_closure_comment(): void
{
$fixtures = $this->seedLookupData();
$owner = $this->user();
$agent = $this->agent();
$ticket = $this->ticket([
'owner' => $owner,
'agent' => $agent,
'status_id' => $fixtures['open']->id,
'priority_id' => $fixtures['normal']->id,
]);
$this->actingAs($agent)
->from(route('helpdesk.tickets.show', $ticket))
->post(route('helpdesk.tickets.status.update', $ticket), [
'status_id' => $fixtures['closed']->id,
])
->assertRedirect(route('helpdesk.tickets.show', $ticket))
->assertSessionHasErrors('closure_comment');
$ticket->refresh();
self::assertSame($fixtures['open']->id, $ticket->status_id);
self::assertNull($ticket->completed_at);
}
public function test_closing_ticket_creates_a_closure_comment(): void
{
$fixtures = $this->seedLookupData();
$owner = $this->user();
$agent = $this->agent();
$ticket = $this->ticket([
'owner' => $owner,
'agent' => $agent,
'status_id' => $fixtures['open']->id,
'priority_id' => $fixtures['normal']->id,
]);
$this->actingAs($agent)
->post(route('helpdesk.tickets.status.update', $ticket), [
'status_id' => $fixtures['closed']->id,
'closure_comment' => 'Issue resolved and verified before closure.',
'closure_internal' => '0',
])
->assertRedirect(route('helpdesk.tickets.show', $ticket));
$ticket->refresh();
self::assertSame($fixtures['closed']->id, $ticket->status_id);
self::assertNotNull($ticket->completed_at);
$this->assertDatabaseHas('helpdesk_comments', [
'ticket_id' => $ticket->id,
'user_id' => $agent->id,
'subject' => 'Closure comment',
'body' => 'Issue resolved and verified before closure.',
'is_internal' => false,
]);
}
public function test_unassigned_agent_cannot_update_another_users_ticket(): void
{
$fixtures = $this->seedLookupData();