feat(ticket): add cancel ticket functionality and corresponding tests
This commit is contained in:
@@ -80,6 +80,38 @@ class AdminAppTicketControllerTest extends TestCase
|
||||
->assertJsonPath('meta.total', 1);
|
||||
}
|
||||
|
||||
public function test_it_cancels_a_ticket_from_the_authenticated_tenant(): void
|
||||
{
|
||||
$tenant = $this->createTenant('ticket-cancellation');
|
||||
$admin = $this->createAdminAppUser($tenant);
|
||||
$this->grantTicketsMenu($tenant);
|
||||
Sanctum::actingAs($admin);
|
||||
$ticket = $this->createTicket($tenant, $admin);
|
||||
|
||||
$this->postJson("/api/v1/adminapp/tenant/tickets/{$ticket->id}/cancel")
|
||||
->assertOk()
|
||||
->assertJsonPath('data.id', $ticket->id)
|
||||
->assertJsonPath('data.status', Ticket::STATUS_CANCELLED)
|
||||
->assertJsonPath('data.status_label', 'Cancelado');
|
||||
|
||||
$this->assertNotNull($ticket->fresh()->cancelled_at);
|
||||
}
|
||||
|
||||
public function test_it_does_not_cancel_a_ticket_with_another_terminal_status(): void
|
||||
{
|
||||
$tenant = $this->createTenant('ticket-cancellation');
|
||||
$admin = $this->createAdminAppUser($tenant);
|
||||
$this->grantTicketsMenu($tenant);
|
||||
Sanctum::actingAs($admin);
|
||||
$ticket = $this->createTicket($tenant, $admin, ['disabled_at' => now()]);
|
||||
|
||||
$this->postJson("/api/v1/adminapp/tenant/tickets/{$ticket->id}/cancel")
|
||||
->assertUnprocessable()
|
||||
->assertJsonValidationErrors('status');
|
||||
|
||||
$this->assertNull($ticket->fresh()->cancelled_at);
|
||||
}
|
||||
|
||||
public function test_it_searches_by_id_and_does_not_search_by_uuid(): void
|
||||
{
|
||||
$tenant = $this->createTenant('fiesta_futbol_infantil');
|
||||
|
||||
Reference in New Issue
Block a user