Deploy Ladill Care / deploy (push) Successful in 1m11s
Demo doctors were querying their own public_id, so branches/patients/queues looked empty even though the Pro tenant had data. Co-authored-by: Cursor <cursoragent@cursor.com>
110 lines
3.4 KiB
PHP
110 lines
3.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Http\Middleware\EnsurePlatformSession;
|
|
use App\Models\Appointment;
|
|
use App\Models\Branch;
|
|
use App\Models\Member;
|
|
use App\Models\Organization;
|
|
use App\Models\Patient;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class CareStaffTenantScopeTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_staff_doctor_sees_employer_queue_and_patients(): void
|
|
{
|
|
$this->withoutMiddleware(EnsurePlatformSession::class);
|
|
|
|
$owner = User::create([
|
|
'public_id' => 'demo-pro-owner',
|
|
'name' => 'Demo Pro Owner',
|
|
'email' => 'demo-pro@ladill.com',
|
|
]);
|
|
|
|
$doctor = User::create([
|
|
'public_id' => 'demo-pro-doctor-pid',
|
|
'name' => 'Demo Pro Doctor',
|
|
'email' => 'demo-pro-doctor@ladill.com',
|
|
]);
|
|
|
|
$organization = Organization::create([
|
|
'owner_ref' => $owner->public_id,
|
|
'name' => 'Demo Pro Clinic',
|
|
'slug' => 'demo-pro-clinic',
|
|
'timezone' => 'UTC',
|
|
'settings' => [
|
|
'onboarded' => true,
|
|
'plan' => 'pro',
|
|
'plan_expires_at' => now()->addMonth()->toIso8601String(),
|
|
],
|
|
]);
|
|
|
|
Member::create([
|
|
'owner_ref' => $owner->public_id,
|
|
'organization_id' => $organization->id,
|
|
'user_ref' => $owner->public_id,
|
|
'role' => 'hospital_admin',
|
|
'branch_id' => null,
|
|
]);
|
|
|
|
$branch = Branch::create([
|
|
'owner_ref' => $owner->public_id,
|
|
'organization_id' => $organization->id,
|
|
'name' => 'East Legon Care',
|
|
'is_active' => true,
|
|
]);
|
|
|
|
Member::create([
|
|
'owner_ref' => $owner->public_id,
|
|
'organization_id' => $organization->id,
|
|
'user_ref' => $doctor->public_id,
|
|
'role' => 'doctor',
|
|
'branch_id' => $branch->id,
|
|
]);
|
|
|
|
$patient = Patient::create([
|
|
'uuid' => (string) \Illuminate\Support\Str::uuid(),
|
|
'owner_ref' => $owner->public_id,
|
|
'organization_id' => $organization->id,
|
|
'branch_id' => $branch->id,
|
|
'patient_number' => 'DEMO-8883-00001',
|
|
'first_name' => 'Ama',
|
|
'last_name' => 'Mensah',
|
|
]);
|
|
|
|
Appointment::create([
|
|
'uuid' => (string) \Illuminate\Support\Str::uuid(),
|
|
'owner_ref' => $owner->public_id,
|
|
'organization_id' => $organization->id,
|
|
'branch_id' => $branch->id,
|
|
'patient_id' => $patient->id,
|
|
'type' => Appointment::TYPE_WALK_IN,
|
|
'status' => Appointment::STATUS_WAITING,
|
|
'scheduled_at' => now(),
|
|
'waiting_at' => now(),
|
|
'queue_position' => 1,
|
|
'reason' => 'Toothache',
|
|
'created_by' => $owner->public_id,
|
|
]);
|
|
|
|
$this->actingAs($doctor)
|
|
->get(route('care.queue.index'))
|
|
->assertOk()
|
|
->assertSee('East Legon Care')
|
|
->assertSee('Ama Mensah')
|
|
->assertSee('Toothache')
|
|
->assertDontSee('No patients waiting.');
|
|
|
|
$this->actingAs($doctor)
|
|
->get(route('care.patients.index'))
|
|
->assertOk()
|
|
->assertSee('Ama Mensah')
|
|
->assertSee('DEMO-8883-00001');
|
|
}
|
|
}
|