<?php

namespace Tests\Feature;

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

class AdminDashboardTest extends TestCase
{
    use RefreshDatabase;

    public function test_authenticated_admin_can_view_operational_dashboard(): void
    {
        $admin = Admin::factory()->create();

        $this->actingAs($admin, 'admin')
            ->withSession(['admin_last_activity' => time()])
            ->get(route('admin.dashboard'))
            ->assertOk()
            ->assertSee('Security Command Center')
            ->assertSee('Total Users')
            ->assertSee('System Health')
            ->assertSee('User Management');
    }

    public function test_every_sidebar_module_opens_a_real_page(): void
    {
        $admin = Admin::factory()->create();

        foreach (['users', 'devices', 'tracking', 'alerts', 'subscriptions', 'payments', 'notifications', 'reports', 'settings', 'roles'] as $module) {
            $this->actingAs($admin, 'admin')
                ->withSession(['admin_last_activity' => time()])
                ->get(route('admin.modules.index', $module))
                ->assertOk()
                ->assertSee('Search, filter and review platform records.');
        }
    }
}
