Initial Ladill Frontdesk release with deploy pipeline.
Visitor management app with SSO, kiosk, badges, reports, and Gitea CI deploy to frontdesk.ladill.com. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
<?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');
|
||||
}
|
||||
|
||||
public function test_app_layout_supports_dark_mode_toggle_markup(): void
|
||||
{
|
||||
$this->actingAs($this->user)
|
||||
->get(route('frontdesk.dashboard'))
|
||||
->assertOk()
|
||||
->assertSee('Toggle dark mode', false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user