<?php

declare(strict_types=1);

use App\Filament\Resources\ProviderConnectionResource;
use App\Models\ProviderConnection;
use Illuminate\Support\Facades\Bus;

it('renders Provider Connections DB-only (no outbound HTTP, no background work)', function (): void {
    [$user, $tenant] = createUserWithTenant(role: 'owner');

    $connection = ProviderConnection::factory()->create([
        'tenant_id' => $tenant->getKey(),
        'display_name' => 'Contoso',
        'entra_tenant_id' => fake()->uuid(),
        'provider' => 'microsoft',
    ]);

    $this->actingAs($user);

    Bus::fake();

    assertNoOutboundHttp(function () use ($tenant, $connection): void {
        $this->get(ProviderConnectionResource::getUrl('index', tenant: $tenant))
            ->assertOk()
            ->assertSee('Contoso');

        $this->get(ProviderConnectionResource::getUrl('edit', ['record' => $connection], tenant: $tenant))
            ->assertOk()
            ->assertSee('Contoso');
    });

    Bus::assertNothingDispatched();
});
