actingAs($user); $tenant->makeCurrent(); Filament::setTenant($tenant, true); $connection = ProviderConnection::factory()->create([ 'tenant_id' => $tenant->getKey(), 'status' => 'disabled', ]); Livewire::test(EditProviderConnection::class, ['record' => $connection->getRouteKey()]) ->assertActionVisible('enable_connection') ->assertActionDisabled('enable_connection') ->assertActionExists('enable_connection', function (Action $action): bool { return $action->getTooltip() === 'You do not have permission to manage provider connections.'; }) ->mountAction('enable_connection') ->callMountedAction() ->assertSuccessful(); $connection->refresh(); expect($connection->status)->toBe('disabled'); }); it('shows disable connection action as visible but disabled for readonly members', function () { [$user, $tenant] = createUserWithTenant(role: 'readonly'); $this->actingAs($user); $tenant->makeCurrent(); Filament::setTenant($tenant, true); $connection = ProviderConnection::factory()->create([ 'tenant_id' => $tenant->getKey(), 'status' => 'connected', ]); Livewire::test(EditProviderConnection::class, ['record' => $connection->getRouteKey()]) ->assertActionVisible('disable_connection') ->assertActionDisabled('disable_connection') ->assertActionExists('disable_connection', function (Action $action): bool { return $action->getTooltip() === 'You do not have permission to manage provider connections.'; }) ->mountAction('disable_connection') ->callMountedAction() ->assertSuccessful(); $connection->refresh(); expect($connection->status)->toBe('connected'); }); it('shows enable connection action as enabled for owner members', function () { [$user, $tenant] = createUserWithTenant(role: 'owner'); $this->actingAs($user); $tenant->makeCurrent(); Filament::setTenant($tenant, true); $connection = ProviderConnection::factory()->create([ 'tenant_id' => $tenant->getKey(), 'status' => 'disabled', ]); Livewire::test(EditProviderConnection::class, ['record' => $connection->getRouteKey()]) ->assertActionVisible('enable_connection') ->assertActionEnabled('enable_connection'); }); });