withoutMiddleware(EnsurePlatformSession::class); $this->user = User::create([ 'public_id' => 'phase9-user-001', 'name' => 'Phase9 User', 'email' => 'phase9@example.com', ]); $this->organization = Organization::create([ 'owner_ref' => $this->user->public_id, 'name' => 'Phase9 Org', 'slug' => 'phase9-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_reports_page_loads_with_summary(): void { $visitor = Visitor::create([ 'owner_ref' => $this->user->public_id, 'organization_id' => $this->organization->id, 'full_name' => 'Report Guest', 'is_frequent' => true, 'visit_count' => 6, ]); 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(), 'checked_out_at' => now()->addHour(), 'badge_code' => 'RPT1', 'qr_token' => 'rpt-token', 'badge_expires_at' => now()->addHours(8), ]); $this->actingAs($this->user) ->get(route('frontdesk.reports.index')) ->assertOk() ->assertSee('Reports') ->assertSee('Report Guest'); } public function test_reports_can_export_csv(): void { $this->actingAs($this->user) ->get(route('frontdesk.reports.export')) ->assertOk() ->assertHeader('content-type', 'text/csv; charset=UTF-8'); } public function test_daily_report_command_runs(): void { $this->organization->update([ 'settings' => array_merge($this->organization->settings ?? [], [ 'report_daily_recipients' => ['admin@example.com'], ]), ]); $this->artisan('frontdesk:send-daily-reports')->assertSuccessful(); } }