<?php

declare(strict_types=1);

use App\Filament\Resources\ProviderConnectionResource\Pages\ListProviderConnections;
use Filament\Facades\Filament;
use Livewire\Livewire;

it('hides the provider connection header create CTA when no authorized tenant context is available on an empty list', function (): void {
    [$user, $tenant] = createUserWithTenant(role: 'owner');
    $user->tenants()->detach((int) $tenant->getKey());
    app(\App\Services\Auth\CapabilityResolver::class)->clearCache();

    $this->actingAs($user);
    $tenant->makeCurrent();
    Filament::setTenant($tenant, true);

    Livewire::test(ListProviderConnections::class)
        ->assertActionHidden('create');
});
