(string) Str::uuid(), 'name' => 'Demo Free', 'email' => 'demo-free@ladill.com', ]); $this->artisan('demo:seed', [ 'identity' => $user->email, '--plan' => 'free', ])->assertSuccessful(); $org = Organization::query()->where('owner_ref', $user->public_id)->firstOrFail(); $this->assertSame('free', app(PlanService::class)->planKey($org)); $this->assertTrue((bool) ($org->settings['onboarded'] ?? false)); $this->assertSame(1, Branch::query()->where('organization_id', $org->id)->count()); $this->assertSame(1, Device::query()->where('organization_id', $org->id)->where('type', 'kiosk')->count()); $this->assertGreaterThan(0, Host::query()->where('organization_id', $org->id)->count()); $this->assertGreaterThan(0, Visitor::query()->where('organization_id', $org->id)->count()); $this->assertSame(40, Visit::query()->where('organization_id', $org->id)->count()); } public function test_pro_plan_uses_org_settings_and_multi_branch(): void { $user = User::create([ 'public_id' => (string) Str::uuid(), 'name' => 'Demo Pro', 'email' => 'demo-pro@ladill.com', ]); $this->artisan('demo:seed', [ 'identity' => $user->public_id, '--plan' => 'pro', ])->assertSuccessful(); $org = Organization::query()->where('owner_ref', $user->public_id)->firstOrFail(); $this->assertSame('pro', app(PlanService::class)->planKey($org)); $this->assertNotEmpty($org->settings['plan_expires_at'] ?? null); $this->assertGreaterThanOrEqual(3, (int) ($org->settings['billed_branches'] ?? 0)); $this->assertGreaterThan(1, Branch::query()->where('organization_id', $org->id)->count()); $this->assertGreaterThan(1, Device::query()->where('organization_id', $org->id)->where('type', 'kiosk')->count()); $this->assertGreaterThan(40, Visit::query()->where('organization_id', $org->id)->count()); $this->assertGreaterThan(0, WatchlistEntry::query()->where('organization_id', $org->id)->count()); } public function test_idempotent_and_reset_only_touches_owner_data(): void { $user = User::create([ 'public_id' => (string) Str::uuid(), 'name' => 'Demo Enterprise', 'email' => 'demo-enterprise@ladill.com', ]); $other = User::create([ 'public_id' => (string) Str::uuid(), 'name' => 'Other', 'email' => 'other@example.com', ]); $otherOrg = Organization::create([ 'owner_ref' => $other->public_id, 'name' => 'Other Org', 'slug' => 'other-org', 'settings' => ['onboarded' => true, 'plan' => 'free'], ]); $this->artisan('demo:seed', ['identity' => $user->email, '--plan' => 'enterprise'])->assertSuccessful(); $org = Organization::query()->where('owner_ref', $user->public_id)->firstOrFail(); $firstVisits = Visit::query()->where('organization_id', $org->id)->count(); $this->artisan('demo:seed', ['identity' => $user->email, '--plan' => 'enterprise'])->assertSuccessful(); $this->assertSame($firstVisits, Visit::query()->where('organization_id', $org->id)->count()); $this->artisan('demo:seed', [ 'identity' => $user->email, '--plan' => 'free', '--reset' => true, ])->assertSuccessful(); $this->assertNotNull(Organization::query()->find($otherOrg->id)); $fresh = Organization::query()->where('owner_ref', $user->public_id)->firstOrFail(); $this->assertSame('free', app(PlanService::class)->planKey($fresh)); $this->assertSame(1, Branch::query()->where('organization_id', $fresh->id)->count()); $this->assertSame(40, Visit::query()->where('organization_id', $fresh->id)->count()); } public function test_demo_world_continuity_and_staff_roles(): void { $user = User::create([ 'public_id' => 'demo-world-frontdesk-id', 'name' => 'Ladill Demo (Pro)', 'email' => 'demo-pro@ladill.com', ]); $this->artisan('demo:seed', [ 'identity' => $user->email, '--plan' => 'pro', ])->assertSuccessful(); $org = Organization::query()->where('owner_ref', $user->public_id)->firstOrFail(); $this->assertSame(DemoWorld::business('pro')['name'], $org->name); $ama = DemoWorld::personByKey('ama-mensah'); $this->assertNotNull($ama); $visitor = Visitor::query() ->where('organization_id', $org->id) ->where('phone', $ama['phone']) ->first(); $this->assertNotNull($visitor); $this->assertSame($ama['email'], $visitor->email); $this->assertSame(DemoWorld::companyNameForPerson($ama), $visitor->company); $this->assertTrue( Member::query() ->where('organization_id', $org->id) ->where('user_ref', 'demo-pro-receptionist@ladill.com') ->where('role', 'receptionist') ->exists() ); } }