Add feature tests for Doctor-related functionalities
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Http\Client\Doctor;
|
||||
|
||||
use App\Enums\UserEnum;
|
||||
use App\Models\Document;
|
||||
use App\Models\DocumentAssignment;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DashboardControllerTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_index_requires_authentication(): void
|
||||
{
|
||||
$this->get(route('dashboard.index'))->assertRedirect(route('login'));
|
||||
}
|
||||
|
||||
public function test_index_renders_requester_pending_cases_and_stats(): void
|
||||
{
|
||||
$user = User::factory()->create(['level' => UserEnum::Vet->value]);
|
||||
Document::factory()->count(7)->registered()->create(['requester_id' => $user->id]);
|
||||
Document::factory()->registered()->create();
|
||||
|
||||
$this->actingAs($user)->get(route('dashboard.index'))
|
||||
->assertOk()
|
||||
->assertInertia(fn (Assert $page) => $page
|
||||
->component('Dashboard/Dashboard')
|
||||
->has('cases.data', 5)
|
||||
->where('stats.pending_cases', 7)
|
||||
->where('stats.is_doctor', false));
|
||||
}
|
||||
|
||||
public function test_index_renders_doctor_assigned_cases(): void
|
||||
{
|
||||
$doctor = User::factory()->create(['level' => UserEnum::Doctor->value]);
|
||||
$document = Document::factory()->inProgress()->create();
|
||||
DocumentAssignment::factory()->create(['document_id' => $document->id, 'user_id' => $doctor->id]);
|
||||
Document::factory()->inProgress()->create();
|
||||
|
||||
$this->actingAs($doctor)->get(route('dashboard.index'))
|
||||
->assertOk()
|
||||
->assertInertia(fn (Assert $page) => $page
|
||||
->has('cases.data', 1)
|
||||
->where('cases.data.0.id', $document->id)
|
||||
->where('stats.is_doctor', true));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user