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(); });