Deploy Ladill Care / deploy (push) Failing after 13s
Healthcare management app: patients, appointments, consultations, lab, pharmacy inventory, billing, and reports at care.ladill.com. Co-authored-by: Cursor <cursoragent@cursor.com>
134 lines
3.9 KiB
PHP
134 lines
3.9 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Http\Middleware\EnsurePlatformSession;
|
|
use App\Models\Branch;
|
|
use App\Models\Department;
|
|
use App\Models\Member;
|
|
use App\Models\Organization;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class CareWebTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected User $user;
|
|
|
|
protected Organization $organization;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->withoutMiddleware(EnsurePlatformSession::class);
|
|
|
|
$this->user = User::create([
|
|
'public_id' => 'test-user-001',
|
|
'name' => 'Test User',
|
|
'email' => 'test@example.com',
|
|
]);
|
|
|
|
$this->organization = Organization::create([
|
|
'owner_ref' => $this->user->public_id,
|
|
'name' => 'Test Clinic',
|
|
'slug' => 'test-clinic',
|
|
'timezone' => 'UTC',
|
|
'settings' => ['onboarded' => true, 'facility_type' => 'clinic'],
|
|
]);
|
|
|
|
Member::create([
|
|
'owner_ref' => $this->user->public_id,
|
|
'organization_id' => $this->organization->id,
|
|
'user_ref' => $this->user->public_id,
|
|
'role' => 'hospital_admin',
|
|
]);
|
|
|
|
$branch = Branch::create([
|
|
'owner_ref' => $this->user->public_id,
|
|
'organization_id' => $this->organization->id,
|
|
'name' => 'Main Branch',
|
|
'is_active' => true,
|
|
]);
|
|
|
|
Department::create([
|
|
'owner_ref' => $this->user->public_id,
|
|
'branch_id' => $branch->id,
|
|
'name' => 'General Outpatient',
|
|
'type' => 'outpatient',
|
|
'is_active' => true,
|
|
]);
|
|
}
|
|
|
|
public function test_guest_is_redirected_to_sso(): void
|
|
{
|
|
$this->get('/dashboard')->assertRedirect();
|
|
}
|
|
|
|
public function test_unonboarded_user_is_redirected_to_onboarding(): void
|
|
{
|
|
Organization::query()->delete();
|
|
Member::query()->delete();
|
|
|
|
$this->actingAs($this->user)
|
|
->get(route('care.dashboard'))
|
|
->assertRedirect(route('care.onboarding.show'));
|
|
}
|
|
|
|
public function test_dashboard_loads_for_authenticated_user(): void
|
|
{
|
|
$this->actingAs($this->user)
|
|
->get(route('care.dashboard'))
|
|
->assertOk()
|
|
->assertSee('Test Clinic');
|
|
}
|
|
|
|
public function test_onboarding_creates_organization(): void
|
|
{
|
|
Organization::query()->delete();
|
|
Member::query()->delete();
|
|
Branch::query()->delete();
|
|
Department::query()->delete();
|
|
|
|
$this->actingAs($this->user)
|
|
->post(route('care.onboarding.store'), [
|
|
'organization_name' => 'Accra Medical Centre',
|
|
'facility_type' => 'hospital',
|
|
'branch_name' => 'Head Office',
|
|
'branch_address' => '123 Main St',
|
|
'branch_phone' => '+233201234567',
|
|
'timezone' => 'Africa/Accra',
|
|
])
|
|
->assertRedirect(route('care.dashboard'));
|
|
|
|
$this->assertDatabaseHas('care_organizations', ['name' => 'Accra Medical Centre']);
|
|
$this->assertDatabaseHas('care_branches', ['name' => 'Head Office']);
|
|
$this->assertDatabaseHas('care_departments', ['name' => 'General Outpatient']);
|
|
}
|
|
|
|
public function test_branches_index_loads(): void
|
|
{
|
|
$this->actingAs($this->user)
|
|
->get(route('care.branches.index'))
|
|
->assertOk()
|
|
->assertSee('Main Branch');
|
|
}
|
|
|
|
public function test_members_index_loads(): void
|
|
{
|
|
$this->actingAs($this->user)
|
|
->get(route('care.members.index'))
|
|
->assertOk()
|
|
->assertSee('test-user-001');
|
|
}
|
|
|
|
public function test_audit_log_index_loads(): void
|
|
{
|
|
$this->actingAs($this->user)
|
|
->get(route('care.audit.index'))
|
|
->assertOk()
|
|
->assertSee('Audit log');
|
|
}
|
|
}
|