<?php

namespace Tests\Feature;

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

class ReportTest extends TestCase
{
    use RefreshDatabase;

    protected function setUp(): void
    {
        parent::setUp();
        $this->seed();
    }

    public function test_authenticated_admin_can_access_reports_page(): void
    {
        $admin = User::where('email', 'admin@smkn1gunungagung.sch.id')->first();
        $admin->update(['force_password_change' => false]);
        $this->actingAs($admin);

        $response = $this->get('/reports');
        $response->assertStatus(200);
    }

    public function test_livewire_report_index_renders_with_filters(): void
    {
        $admin = User::where('email', 'admin@smkn1gunungagung.sch.id')->first();
        $admin->update(['force_password_change' => false]);
        $this->actingAs($admin);

        Livewire::test(ReportIndex::class)
            ->set('month', '2026-07')
            ->set('selectedStatus', 'Hadir')
            ->assertStatus(200);
    }
}
