complete story 1.3 with qa test & added future recommendations to the dev

This commit is contained in:
Naser Mansour
2025-12-26 14:04:24 +02:00
parent 84d9c2f66a
commit ebb6841ed0
29 changed files with 760 additions and 101 deletions
+65
View File
@@ -0,0 +1,65 @@
<?php
use App\Models\User;
test('admin can access admin routes', function () {
$admin = User::factory()->admin()->create();
$response = $this->actingAs($admin)->get('/admin/dashboard');
$response->assertStatus(200);
});
test('client cannot access admin routes', function () {
$client = User::factory()->individual()->create();
$response = $this->actingAs($client)->get('/admin/dashboard');
$response->assertForbidden();
});
test('company client cannot access admin routes', function () {
$client = User::factory()->company()->create();
$response = $this->actingAs($client)->get('/admin/dashboard');
$response->assertForbidden();
});
test('unauthenticated user redirected to login', function () {
$response = $this->get('/admin/dashboard');
$response->assertRedirect(route('login'));
});
test('unauthenticated user redirected to login for client routes', function () {
$response = $this->get('/client/dashboard');
$response->assertRedirect(route('login'));
});
test('client can access client routes', function () {
$client = User::factory()->individual()->create();
$response = $this->actingAs($client)->get('/client/dashboard');
$response->assertStatus(200);
});
test('admin can access client routes', function () {
$admin = User::factory()->admin()->create();
$response = $this->actingAs($admin)->get('/client/dashboard');
$response->assertStatus(200);
});
test('deactivated user logged out on request', function () {
$user = User::factory()->deactivated()->create();
// Simulate an authenticated session with deactivated user
$response = $this->actingAs($user)->get('/client/dashboard');
$response->assertRedirect(route('login'));
$this->assertGuest();
});