Link demo specialty desks after SSO remap and tighten keyword matching.
Deploy Ladill Care / deploy (push) Successful in 58s
Deploy Ladill Care / deploy (push) Successful in 58s
Specialty seeder looked up members by email user_ref only, so remapped demo logins never got practitioner.member_id and saw every module. Also stop short keywords like "ent" matching "dentistry". Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -198,6 +198,25 @@ class CareSpecialtyAccessTest extends TestCase
|
||||
->assertDontSee('Blood Bank');
|
||||
}
|
||||
|
||||
public function test_dentistry_specialty_does_not_match_ent_keyword(): void
|
||||
{
|
||||
[$doctor, $member] = $this->makeStaff('doctor', 'dentist-ent-trap');
|
||||
Practitioner::create([
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'branch_id' => $this->branch->id,
|
||||
'member_id' => $member->id,
|
||||
'user_ref' => $doctor->public_id,
|
||||
'name' => 'Dr Dentist',
|
||||
'specialty' => 'Dentistry',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$this->assertTrue($this->modules->specialistBelongsToModule($this->organization, $member, 'dentistry'));
|
||||
$this->assertFalse($this->modules->specialistBelongsToModule($this->organization, $member, 'ent'));
|
||||
$this->assertSame('none', $this->modules->memberAccessLevel($this->organization, $member, 'ent'));
|
||||
}
|
||||
|
||||
public function test_gp_can_refer_into_restricted_specialty_queue(): void
|
||||
{
|
||||
[$doctor, $member] = $this->makeStaff('doctor', 'gp2');
|
||||
|
||||
@@ -378,4 +378,55 @@ class DemoSeedCommandTest extends TestCase
|
||||
$this->assertNotSame('unresolved', $waiter->queue_routing_status);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_specialty_doctor_links_after_sso_public_id_remap(): void
|
||||
{
|
||||
$owner = User::create([
|
||||
'public_id' => 'demo-pro-specialty-link-owner',
|
||||
'name' => 'Ladill Demo (Pro)',
|
||||
'email' => 'demo-pro@ladill.com',
|
||||
]);
|
||||
|
||||
$this->artisan('demo:seed', [
|
||||
'identity' => 'demo-pro@ladill.com',
|
||||
'--plan' => 'pro',
|
||||
])->assertSuccessful();
|
||||
|
||||
$org = Organization::query()->where('owner_ref', $owner->public_id)->firstOrFail();
|
||||
|
||||
$dentist = User::create([
|
||||
'public_id' => 'demo-pro-dentistry-public-id',
|
||||
'name' => 'Dr. Ama Dental (Pro)',
|
||||
'email' => 'demo-pro-dentistry@ladill.com',
|
||||
]);
|
||||
|
||||
$member = \App\Models\Member::query()
|
||||
->where('organization_id', $org->id)
|
||||
->where('user_ref', 'demo-pro-dentistry@ladill.com')
|
||||
->firstOrFail();
|
||||
|
||||
// Simulate Identity SSO remapping member.user_ref from email → public_id.
|
||||
$member->forceFill(['user_ref' => $dentist->public_id])->save();
|
||||
|
||||
$this->artisan('demo:seed', [
|
||||
'identity' => 'demo-pro@ladill.com',
|
||||
'--plan' => 'pro',
|
||||
])->assertSuccessful();
|
||||
|
||||
$member->refresh();
|
||||
$this->assertSame($dentist->public_id, $member->user_ref);
|
||||
|
||||
$linked = \App\Models\Practitioner::query()
|
||||
->where('organization_id', $org->id)
|
||||
->where('member_id', $member->id)
|
||||
->where('specialty', 'Dentistry')
|
||||
->get();
|
||||
$this->assertCount(1, $linked, 'Home-branch dentistry desk must link to the remapped member');
|
||||
$this->assertSame((int) $member->branch_id, (int) $linked->first()->branch_id);
|
||||
|
||||
$modules = app(\App\Services\Care\SpecialtyModuleService::class);
|
||||
$this->assertTrue($modules->isDeskSpecialist($org, $member));
|
||||
$keys = collect($modules->enabledModulesForMember($org, $member))->pluck('key')->all();
|
||||
$this->assertSame(['dentistry'], $keys);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user