Add feature tests for Doctor-related functionalities
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Http\Admin;
|
||||
|
||||
use App\Enums\UserEnum;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PanelControllerTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_guest_is_redirected_to_login(): void
|
||||
{
|
||||
$this->get(route('admin.dashboard'))->assertRedirect(route('login'));
|
||||
}
|
||||
|
||||
public function test_non_admin_user_gets_not_found(): void
|
||||
{
|
||||
$this->actingAs(User::factory()->create(['level' => UserEnum::Doctor->value]))->get(route('admin.dashboard'))->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_admin_sees_dashboard(): void
|
||||
{
|
||||
$this->actingAs(User::factory()->create(['level' => UserEnum::Admin->value]))->get(route('admin.dashboard'))
|
||||
->assertOk()
|
||||
->assertInertia(fn (Assert $page) => $page->component('index'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user