Files
ladill-frontdesk/tests/Feature/FrontdeskPhase11Test.php
T
isaaccladandCursor ce6d7c5f80
Deploy Ladill Frontdesk / deploy (push) Successful in 25s
Remove dark mode and fix boot splash HTML breakage.
Drop dark-mode toggle, fd-theme storage, and Tailwind dark variant to match sibling Ladill apps. Include boot splash in app-layout instead of regex middleware that truncated the body tag on Alpine x-init.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-27 20:59:23 +00:00

126 lines
3.8 KiB
PHP

<?php
namespace Tests\Feature;
use App\Http\Middleware\EnsurePlatformSession;
use App\Models\Branch;
use App\Models\Device;
use App\Models\Member;
use App\Models\Organization;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\RateLimiter;
use Tests\TestCase;
class FrontdeskPhase11Test extends TestCase
{
use RefreshDatabase;
protected User $user;
protected Organization $organization;
protected function setUp(): void
{
parent::setUp();
$this->withoutMiddleware(EnsurePlatformSession::class);
$this->user = User::create([
'public_id' => 'phase11-user-001',
'name' => 'Phase11 User',
'email' => 'phase11@example.com',
]);
$this->organization = Organization::create([
'owner_ref' => $this->user->public_id,
'name' => 'Phase11 Org',
'slug' => 'phase11-org',
'settings' => ['onboarded' => true, 'badge_expiry_hours' => 8],
]);
Member::create([
'owner_ref' => $this->user->public_id,
'organization_id' => $this->organization->id,
'user_ref' => $this->user->public_id,
'role' => 'org_admin',
]);
Branch::create([
'owner_ref' => $this->user->public_id,
'organization_id' => $this->organization->id,
'name' => 'HQ',
'is_active' => true,
]);
}
public function test_dashboard_stats_are_cached(): void
{
Cache::flush();
$this->actingAs($this->user)->get(route('frontdesk.dashboard'))->assertOk();
$this->assertTrue(Cache::has('fd:dashboard:'.$this->user->public_id.':'.$this->organization->id.':all'));
}
public function test_kiosk_device_route_is_rate_limited(): void
{
RateLimiter::clear('kiosk-device');
$device = Device::create([
'owner_ref' => $this->user->public_id,
'organization_id' => $this->organization->id,
'name' => 'Limited Kiosk',
'type' => 'kiosk',
'device_token' => 'rate-limit-token',
'status' => 'offline',
]);
for ($i = 0; $i < 31; $i++) {
$response = $this->postJson(route('frontdesk.kiosk.device.check-in', $device->device_token), [
'full_name' => 'Guest '.$i,
'visitor_type' => 'visitor',
'policies_accepted' => 1,
]);
}
$response->assertStatus(429);
}
public function test_offline_sync_replays_queued_check_in(): void
{
$device = Device::create([
'owner_ref' => $this->user->public_id,
'organization_id' => $this->organization->id,
'branch_id' => Branch::first()->id,
'name' => 'Offline Kiosk',
'type' => 'kiosk',
'device_token' => 'offline-sync-token',
'status' => 'online',
]);
$clientId = '550e8400-e29b-41d4-a716-446655440000';
$this->postJson('/api/kiosk/offline-sync', [
'client_id' => $clientId,
'payload' => [
'full_name' => 'Offline Guest',
'visitor_type' => 'visitor',
'policies_accepted' => true,
],
], ['X-Device-Token' => $device->device_token])
->assertCreated()
->assertJsonPath('status', 'synced');
$this->postJson('/api/kiosk/offline-sync', [
'client_id' => $clientId,
'payload' => [
'full_name' => 'Offline Guest',
'visitor_type' => 'visitor',
'policies_accepted' => true,
],
], ['X-Device-Token' => $device->device_token])
->assertOk()
->assertJsonPath('status', 'already_synced');
}
}