Restrict lab catalog pricing to admins only.
Deploy Ladill Care / deploy (push) Successful in 38s

Split catalog CRUD onto lab.catalog.manage so technicians keep lab.manage for queue and results workflow without setting investigation prices.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-18 18:58:57 +00:00
co-authored by Cursor
parent 65e54d1253
commit 656f402e8f
12 changed files with 128 additions and 17 deletions
+83 -1
View File
@@ -201,7 +201,89 @@ class CareLabTest extends TestCase
$this->actingAs($this->user)
->get(route('care.lab.queue.index', ['branch_id' => $this->branch->id]))
->assertOk()
->assertSee('Lab work queue');
->assertSee('Lab work queue')
->assertDontSee('Catalog');
}
public function test_lab_technician_cannot_manage_catalog(): void
{
Member::where('user_ref', $this->user->public_id)->update(['role' => 'lab_technician']);
$this->actingAs($this->user)
->get(route('care.lab.catalog.index'))
->assertForbidden();
$this->actingAs($this->user)
->get(route('care.lab.catalog.create'))
->assertForbidden();
$this->actingAs($this->user)
->post(route('care.lab.catalog.store'), [
'name' => 'Unauthorized Test',
'category' => 'blood',
'price_minor' => 1000,
])
->assertForbidden();
$this->actingAs($this->user)
->get(route('care.lab.catalog.edit', $this->investigationType))
->assertForbidden();
$this->actingAs($this->user)
->put(route('care.lab.catalog.update', $this->investigationType), [
'name' => 'Hacked Price',
'category' => 'blood',
'price_minor' => 1,
])
->assertForbidden();
}
public function test_hospital_admin_can_manage_catalog(): void
{
Member::where('user_ref', $this->user->public_id)->update(['role' => 'hospital_admin']);
$this->actingAs($this->user)
->get(route('care.lab.catalog.index'))
->assertOk()
->assertSee('Investigation catalog');
$this->actingAs($this->user)
->get(route('care.lab.catalog.create'))
->assertOk();
$this->actingAs($this->user)
->post(route('care.lab.catalog.store'), [
'name' => 'Lipid Panel',
'code' => 'LIP',
'category' => 'blood',
'price_minor' => 4500,
'is_active' => true,
])
->assertRedirect(route('care.lab.catalog.index'));
$this->assertDatabaseHas('care_investigation_types', [
'organization_id' => $this->organization->id,
'name' => 'Lipid Panel',
'price_minor' => 4500,
]);
$this->actingAs($this->user)
->put(route('care.lab.catalog.update', $this->investigationType), [
'name' => 'Fasting Blood Glucose',
'code' => 'FBG',
'category' => 'blood',
'unit' => 'mmol/L',
'reference_low' => 3.9,
'reference_high' => 6.1,
'price_minor' => 3000,
'is_active' => true,
])
->assertRedirect(route('care.lab.catalog.index'));
$this->assertDatabaseHas('care_investigation_types', [
'id' => $this->investigationType->id,
'price_minor' => 3000,
]);
}
public function test_api_can_request_investigation(): void