feat(scanner): add scan attempt detail endpoint
This commit is contained in:
@@ -143,6 +143,53 @@ class ScannerTicketControllerTest extends TestCase
|
||||
->assertJsonPath('data.0.id', $matching->id);
|
||||
}
|
||||
|
||||
public function test_scanner_can_read_its_scan_attempt_detail(): void
|
||||
{
|
||||
$ticket = $this->createTicket('abababab-abab-4bab-8bab-abababababab');
|
||||
$scanAttempt = $this->createScanAttempt($ticket->ticket, [
|
||||
'ticket_id' => $ticket->id,
|
||||
]);
|
||||
Sanctum::actingAs($this->scanner);
|
||||
|
||||
$this->getJson("/api/v1/scanner/attempts/{$scanAttempt->id}")
|
||||
->assertOk()
|
||||
->assertJsonPath('data.scan_attempt.id', $scanAttempt->id)
|
||||
->assertJsonPath('data.scan_attempt.ticket_id', $ticket->id)
|
||||
->assertJsonPath('data.scan_attempt.result', ScanAttemptResult::Accepted->value)
|
||||
->assertJsonPath('data.ticket.id', $ticket->id)
|
||||
->assertJsonPath('data.ticket.ticket', $ticket->ticket)
|
||||
->assertJsonPath('data.ticket.client', $this->ticketOwner->nombre_apellido)
|
||||
->assertJsonPath('data.client.id', $this->ticketOwner->id)
|
||||
->assertJsonPath('data.client.nombre_apellido', $this->ticketOwner->nombre_apellido);
|
||||
}
|
||||
|
||||
public function test_scanner_cannot_read_another_scanners_attempt_detail(): void
|
||||
{
|
||||
$otherScanner = User::factory()->create([
|
||||
'rol_codigo' => RoleCode::Scanner->value,
|
||||
'tenant_codigo' => $this->tenant->codigo,
|
||||
]);
|
||||
$scanAttempt = $this->createScanAttempt('not-this-scanner', [], $otherScanner);
|
||||
Sanctum::actingAs($this->scanner);
|
||||
|
||||
$this->getJson("/api/v1/scanner/attempts/{$scanAttempt->id}")
|
||||
->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_scan_attempt_detail_returns_null_ticket_and_client_when_unassociated(): void
|
||||
{
|
||||
$scanAttempt = $this->createScanAttempt('not-a-ticket', [
|
||||
'result' => ScanAttemptResult::TicketNotFound,
|
||||
]);
|
||||
Sanctum::actingAs($this->scanner);
|
||||
|
||||
$this->getJson("/api/v1/scanner/attempts/{$scanAttempt->id}")
|
||||
->assertOk()
|
||||
->assertJsonPath('data.scan_attempt.id', $scanAttempt->id)
|
||||
->assertJsonPath('data.ticket', null)
|
||||
->assertJsonPath('data.client', null);
|
||||
}
|
||||
|
||||
public function test_scanner_can_read_an_authorized_ticket_detail_by_uuid(): void
|
||||
{
|
||||
$ticket = $this->createTicket('44444444-4444-4444-8444-444444444444');
|
||||
|
||||
Reference in New Issue
Block a user