singleloginsystem/tests/Feature/DashboardTest.php
= 1a7134419c Refactor: Improve dependency injection for dashboard components and enhance SAML logging
- Removed inline data definitions from multiple dashboard components for roles, users, and connected apps, replacing them with service-based computed properties.
- Added comprehensive debug and error-level logging throughout `SamlIdpService` and related controllers to improve traceability of SAML flows.
- Cleaned up and centralized SAML-related logic, improving maintainability and error handling consistency.
- Deleted unused `hr-permission.blade.php` component to reduce code redundancy.
2026-06-01 13:05:59 +00:00

49 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
use App\Models\{Role, User};
test('guests are redirected to the login page', function (): void {
$response = $this->get(route('dashboard'));
$response->assertRedirect(route('login'));
});
test('authenticated users without admin roles are redirected to the user dashboard', function (): void {
$user = User::factory()->create();
$this->actingAs($user);
$response = $this->get(route('dashboard'));
$response->assertRedirect(route('dashboard.user'));
});
test('authenticated admin users are redirected to the admin dashboard', function (): void {
Role::findOrCreate('admin', 'web');
$user = User::factory()->create();
$user->assignRole('admin');
$this->actingAs($user);
$response = $this->get(route('dashboard'));
$response->assertRedirect(route('dashboard.admin'));
});
test('authenticated users can visit the user dashboard', function (): void {
Role::findOrCreate('user', 'web');
$user = User::factory()->create();
$user->assignRole('user');
$this->actingAs($user);
$response = $this->get(route('dashboard.user'));
$response->assertOk();
});
test('authenticated admin users can visit the admin dashboard', function (): void {
Role::findOrCreate('admin', 'web');
$user = User::factory()->create();
$user->assignRole('admin');
$this->actingAs($user);
$response = $this->get(route('dashboard.admin'));
$response->assertOk();
});