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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user