create(['name' => 'Tenant A']); $tenantB = Tenant::factory()->create(['name' => 'Tenant B']); [$user] = createUserWithTenant($tenantA, role: 'owner'); $this->actingAs($user) ->get(ProviderConnectionResource::getUrl('index', tenant: $tenantB)) ->assertNotFound(); }); it('does not show non-member tenants in the choose-tenant list', function (): void { $tenantA = Tenant::factory()->create(['name' => 'Tenant A']); $tenantB = Tenant::factory()->create(['name' => 'Tenant B']); [$user] = createUserWithTenant($tenantA, role: 'owner'); $this->actingAs($user) ->get('/admin/choose-tenant') ->assertOk() ->assertSee('Tenant A') ->assertDontSee('Tenant B'); }); it('scopes global search results to the current tenant and denies non-members', function (): void { $tenantA = Tenant::factory()->create(['name' => 'Tenant A']); $tenantB = Tenant::factory()->create(['name' => 'Tenant B']); [$user] = createUserWithTenant($tenantA, role: 'owner'); ProviderConnection::factory()->create([ 'tenant_id' => $tenantA->getKey(), 'display_name' => 'Acme Connection A', ]); ProviderConnection::factory()->create([ 'tenant_id' => $tenantB->getKey(), 'display_name' => 'Acme Connection B', ]); $this->actingAs($user); Filament::setTenant($tenantA, true); $resultsA = ProviderConnectionResource::getGlobalSearchResults('Acme'); expect($resultsA)->toHaveCount(1); expect((string) $resultsA->first()?->title)->toBe('Acme Connection A'); Filament::setTenant($tenantB, true); $resultsB = ProviderConnectionResource::getGlobalSearchResults('Acme'); expect($resultsB)->toHaveCount(0); Filament::setTenant(null, true); $resultsNone = ProviderConnectionResource::getGlobalSearchResults('Acme'); expect($resultsNone)->toHaveCount(0); });