shouldReceive('isMember')->andReturnTrue(); $resolver->shouldReceive('primeMemberships')->andReturnNull(); $resolver->shouldReceive('can') ->andReturnUsing(static fn ($user, $tenant, string $capability): bool => $capability === Capabilities::TENANT_VIEW); app()->instance(CapabilityResolver::class, $resolver); Filament::setTenant($tenant, true); $policy = Policy::factory()->create([ 'tenant_id' => (int) $tenant->getKey(), ]); $baselineProfile = BaselineProfile::factory()->active()->create([ 'workspace_id' => (int) $tenant->workspace_id, ]); $backupVersion = PolicyVersion::factory()->create([ 'tenant_id' => (int) $tenant->getKey(), 'policy_id' => (int) $policy->getKey(), 'version_number' => 1, 'capture_purpose' => PolicyVersionCapturePurpose::Backup->value, ]); $baselinePurposeVersion = PolicyVersion::factory()->create([ 'tenant_id' => (int) $tenant->getKey(), 'policy_id' => (int) $policy->getKey(), 'version_number' => 2, 'capture_purpose' => PolicyVersionCapturePurpose::BaselineCompare->value, 'baseline_profile_id' => (int) $baselineProfile->getKey(), ]); Livewire::actingAs($user) ->test(ListPolicyVersions::class) ->assertCanSeeTableRecords([$backupVersion]) ->assertCanNotSeeTableRecords([$baselinePurposeVersion]); $this->actingAs($user) ->get(PolicyVersionResource::getUrl('view', ['record' => $baselinePurposeVersion], tenant: $tenant)) ->assertNotFound(); }); it('shows baseline-purpose policy versions for actors with tenant.sync', function (): void { [$user, $tenant] = createUserWithTenant(role: 'owner'); app()->forgetInstance(CapabilityResolver::class); Filament::setTenant($tenant, true); $policy = Policy::factory()->create([ 'tenant_id' => (int) $tenant->getKey(), ]); $baselineProfile = BaselineProfile::factory()->active()->create([ 'workspace_id' => (int) $tenant->workspace_id, ]); $backupVersion = PolicyVersion::factory()->create([ 'tenant_id' => (int) $tenant->getKey(), 'policy_id' => (int) $policy->getKey(), 'version_number' => 1, 'capture_purpose' => PolicyVersionCapturePurpose::Backup->value, ]); $baselinePurposeVersion = PolicyVersion::factory()->create([ 'tenant_id' => (int) $tenant->getKey(), 'policy_id' => (int) $policy->getKey(), 'version_number' => 2, 'capture_purpose' => PolicyVersionCapturePurpose::BaselineCapture->value, 'baseline_profile_id' => (int) $baselineProfile->getKey(), ]); Livewire::actingAs($user) ->test(ListPolicyVersions::class) ->assertCanSeeTableRecords([$backupVersion, $baselinePurposeVersion]); });