<?php

use App\Filament\Widgets\StatsOverviewWidget;
use App\Models\ApiLog;
use App\Models\PricePrediction;
use App\Models\Station;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;

uses(RefreshDatabase::class);

beforeEach(function () {
    $this->admin = User::factory()->admin()->create();
    $this->actingAs($this->admin);
});

it('renders the stats overview widget', function () {
    User::factory()->count(3)->create();
    Station::factory()->count(2)->create();
    PricePrediction::factory()->create(['generated_at' => now()->subHours(2)]);
    ApiLog::factory()->count(2)->create(['status_code' => 200, 'error' => null, 'created_at' => now()->subMinutes(30)]);

    Livewire::test(StatsOverviewWidget::class)
        ->assertOk();
});
