<?php

declare(strict_types=1);

use App\Filament\Widgets\Tenant\RecentOperationsSummary;
use App\Models\OperationRun;
use Livewire\Livewire;

it('renders recent operations from the record tenant in admin panel context', function (): void {
    [$user, $tenant] = createUserWithTenant(role: 'owner');

    $this->actingAs($user);

    OperationRun::factory()->create([
        'workspace_id' => (int) $tenant->workspace_id,
        'tenant_id' => (int) $tenant->getKey(),
        'type' => 'provider.connection.check',
        'status' => 'completed',
        'outcome' => 'success',
    ]);

    Livewire::actingAs($user)
        ->test(RecentOperationsSummary::class, ['record' => $tenant])
        ->assertSee('Recent operations')
        ->assertSee('Provider connection check')
        ->assertDontSee('No operations yet.');
});
