<?php

namespace Tests\Feature;

use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class LoginPageTest extends TestCase
{
    use RefreshDatabase;

    public function test_root_redirects_guests_to_login(): void
    {
        $response = $this->get('/');

        $response->assertRedirect('/login');
    }

    public function test_custom_login_page_is_rendered(): void
    {
        $response = $this->get('/login');

        $response->assertOk();
        $response->assertSee('HIPL CRM');
        $response->assertSee('Login to CRM');
        $response->assertSee('Secure Admin Access');
    }

    public function test_authenticated_users_are_redirected_from_root_to_dashboard(): void
    {
        $user = User::factory()->create();

        $response = $this->actingAs($user)->get('/');

        $response->assertRedirect('/dashboard');
    }
}
