40 lines
1.3 KiB
PHP
40 lines
1.3 KiB
PHP
<?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(4)->create([
|
|
'tenant_id' => $tenant->id,
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'type' => 'inventory_sync',
|
|
'status' => 'queued',
|
|
'outcome' => 'pending',
|
|
'created_at' => now(),
|
|
]);
|
|
|
|
OperationRun::factory()->count(3)->create([
|
|
'tenant_id' => $tenant->id,
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'type' => 'inventory_sync',
|
|
'status' => 'queued',
|
|
'outcome' => 'pending',
|
|
'created_at' => now()->subHour(),
|
|
]);
|
|
|
|
$component = Livewire::actingAs($user)
|
|
->test(BulkOperationProgress::class)
|
|
->call('refreshRuns');
|
|
|
|
expect($component->get('runs'))->toHaveCount(6);
|
|
expect($component->get('overflowCount'))->toBe(2);
|
|
expect($component->get('runs')->map(fn (OperationRun $run): string => $run->freshnessState()->value)->unique()->values()->all())
|
|
->toEqualCanonicalizing(['fresh_active', 'likely_stale']);
|
|
})->group('ops-ux');
|