<?php

use App\Livewire\BulkOperationProgress;
use App\Models\OperationRun;
use Filament\Facades\Filament;
use Livewire\Livewire;

test('progress widget limits to five active runs and exposes overflow count', function () {
    [$user, $tenant] = createUserWithTenant(role: 'owner');
    $this->actingAs($user);
    Filament::setTenant($tenant, true);

    OperationRun::factory()->count(7)->create([
        'tenant_id' => $tenant->id,
        'status' => 'queued',
        'outcome' => 'pending',
    ]);

    $component = Livewire::actingAs($user)
        ->test(BulkOperationProgress::class)
        ->call('refreshRuns');

    expect($component->get('runs'))->toHaveCount(6);
    expect($component->get('overflowCount'))->toBe(2);
})->group('ops-ux');
