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,153 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Http\Middleware\EnsurePlatformSession;
|
||||
use App\Models\Branch;
|
||||
use App\Models\Member;
|
||||
use App\Models\Organization;
|
||||
use App\Models\User;
|
||||
use App\Models\Visit;
|
||||
use App\Models\Visitor;
|
||||
use App\Services\Frontdesk\VisitorTypeService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\TestCase;
|
||||
|
||||
class FrontdeskPhase8Test extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected User $user;
|
||||
|
||||
protected Organization $organization;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Storage::fake('public');
|
||||
$this->withoutMiddleware(EnsurePlatformSession::class);
|
||||
|
||||
$this->user = User::create([
|
||||
'public_id' => 'phase8-user-001',
|
||||
'name' => 'Phase8 User',
|
||||
'email' => 'phase8@example.com',
|
||||
]);
|
||||
|
||||
$this->organization = Organization::create([
|
||||
'owner_ref' => $this->user->public_id,
|
||||
'name' => 'Phase8 Org',
|
||||
'slug' => 'phase8-org',
|
||||
'settings' => [
|
||||
'onboarded' => true,
|
||||
'badge_expiry_hours' => 8,
|
||||
'badge_template' => ['show_qr' => true, 'show_photo' => true],
|
||||
],
|
||||
]);
|
||||
|
||||
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_badge_template_settings_can_be_updated(): void
|
||||
{
|
||||
$this->actingAs($this->user)
|
||||
->put(route('frontdesk.settings.badge.update'), [
|
||||
'show_photo' => '1',
|
||||
'show_qr' => '1',
|
||||
'show_host' => '1',
|
||||
'show_company' => '0',
|
||||
'show_type' => '1',
|
||||
'primary_color' => '#ff0000',
|
||||
'footer_text' => 'Property of Phase8 Org',
|
||||
])
|
||||
->assertRedirect();
|
||||
|
||||
$settings = $this->organization->fresh()->settings;
|
||||
$this->assertSame('#ff0000', $settings['badge_template']['primary_color']);
|
||||
$this->assertFalse($settings['badge_template']['show_company']);
|
||||
}
|
||||
|
||||
public function test_check_in_stores_photo_from_base64(): void
|
||||
{
|
||||
$png = 'data:image/png;base64,'.base64_encode(UploadedFile::fake()->image('photo.png')->getContent());
|
||||
|
||||
$this->actingAs($this->user)
|
||||
->post(route('frontdesk.visits.store'), [
|
||||
'full_name' => 'Photo Guest',
|
||||
'visitor_type' => 'visitor',
|
||||
'policies_accepted' => '1',
|
||||
'photo_data' => $png,
|
||||
])
|
||||
->assertRedirect();
|
||||
|
||||
$visit = Visit::first();
|
||||
$this->assertNotNull($visit->photo_path);
|
||||
Storage::disk('public')->assertExists($visit->photo_path);
|
||||
}
|
||||
|
||||
public function test_badge_preview_renders_for_checked_in_visit(): void
|
||||
{
|
||||
$visitor = Visitor::create([
|
||||
'owner_ref' => $this->user->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'full_name' => 'Badge 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' => 'ABC123',
|
||||
'qr_token' => 'qr-token-123',
|
||||
'badge_expires_at' => now()->addHours(8),
|
||||
]);
|
||||
|
||||
$this->actingAs($this->user)
|
||||
->get(route('frontdesk.visits.badge.preview', $visit))
|
||||
->assertOk()
|
||||
->assertSee('Badge Guest')
|
||||
->assertSee('ABC123');
|
||||
}
|
||||
|
||||
public function test_evacuation_badges_page_lists_current_visitors(): void
|
||||
{
|
||||
$visitor = Visitor::create([
|
||||
'owner_ref' => $this->user->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'full_name' => 'Inside Guest',
|
||||
]);
|
||||
|
||||
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' => 'EVAC1',
|
||||
'qr_token' => 'evac-token',
|
||||
'badge_expires_at' => now()->addHours(8),
|
||||
]);
|
||||
|
||||
$this->actingAs($this->user)
|
||||
->get(route('frontdesk.security.evacuation.badges'))
|
||||
->assertOk()
|
||||
->assertSee('Inside Guest');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user