Let guests check out by badge code or QR scan before leaving, with device and staff kiosk API routes. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -8,6 +8,8 @@ use App\Models\Device;
|
||||
use App\Models\Member;
|
||||
use App\Models\Organization;
|
||||
use App\Models\User;
|
||||
use App\Models\Visit;
|
||||
use App\Models\Visitor;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
@@ -122,4 +124,60 @@ class FrontdeskPhase11Test extends TestCase
|
||||
->assertOk()
|
||||
->assertJsonPath('status', 'already_synced');
|
||||
}
|
||||
|
||||
public function test_kiosk_device_can_check_out_visitor_by_badge_code(): void
|
||||
{
|
||||
$device = Device::create([
|
||||
'owner_ref' => $this->user->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'name' => 'Checkout Kiosk',
|
||||
'type' => 'kiosk',
|
||||
'device_token' => 'checkout-kiosk-token',
|
||||
'status' => 'online',
|
||||
]);
|
||||
|
||||
$visitor = Visitor::create([
|
||||
'owner_ref' => $this->user->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'full_name' => 'Leaving Guest',
|
||||
]);
|
||||
|
||||
$visit = Visit::create([
|
||||
'owner_ref' => $this->user->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'visitor_id' => $visitor->id,
|
||||
'visitor_type' => 'visitor',
|
||||
'status' => Visit::STATUS_CHECKED_IN,
|
||||
'checked_in_at' => now(),
|
||||
'badge_code' => 'LEAVE123',
|
||||
'qr_token' => 'qr-checkout-token-32chars-long-ok',
|
||||
]);
|
||||
|
||||
$this->postJson(route('frontdesk.kiosk.device.check-out', $device->device_token), [
|
||||
'badge_code' => 'leave123',
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath('visit.visitor_name', 'Leaving Guest')
|
||||
->assertJsonPath('visit.badge_code', 'LEAVE123');
|
||||
|
||||
$this->assertSame(Visit::STATUS_CHECKED_OUT, $visit->fresh()->status);
|
||||
}
|
||||
|
||||
public function test_kiosk_device_check_out_rejects_unknown_badge(): void
|
||||
{
|
||||
$device = Device::create([
|
||||
'owner_ref' => $this->user->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'name' => 'Checkout Kiosk',
|
||||
'type' => 'kiosk',
|
||||
'device_token' => 'checkout-kiosk-token-2',
|
||||
'status' => 'online',
|
||||
]);
|
||||
|
||||
$this->postJson(route('frontdesk.kiosk.device.check-out', $device->device_token), [
|
||||
'badge_code' => 'UNKNOWN1',
|
||||
])
|
||||
->assertStatus(422)
|
||||
->assertJsonValidationErrors('credentials');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user