TenantAtlas/apps/platform/tests/Feature/TenantReview/TenantReviewRbacTest.php
ahmido 3ec582a182 feat: retire legacy tenant route surfaces (#352)
## Summary
- retire legacy `/admin/t` and active `/admin/tenants` product surfaces in favor of canonical workspace-scoped managed-environment routes
- centralize runtime URL generation through `ManagedEnvironmentLinks` and update intended URL handling to reject legacy tenant paths
- remove dormant tenant panel runtime, rename test helpers to the admin environment context, and add guard coverage for route/helper regressions

## Validation
- targeted Feature guard, workspace, provider connection, required permissions, and Filament test lanes run under Sail
- browser smoke coverage run for provider connection and workspace RBAC environment access flows
- formatting and diff checks completed with Pint and `git diff --check`

## Notes
- Filament remains on v5 with Livewire v4
- provider registration stays in `apps/platform/bootstrap/providers.php`
- retired tenant resource global search is disabled and destructive action confirmation rules remain unchanged

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #352
2026-05-12 23:35:03 +00:00

54 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
use App\Filament\Resources\TenantReviewResource;
use App\Filament\Resources\TenantReviewResource\Pages\ListTenantReviews;
use App\Filament\Resources\TenantReviewResource\Pages\ViewTenantReview;
use App\Models\ManagedEnvironment;
use App\Models\User;
use App\Support\Auth\UiTooltips;
use Livewire\Livewire;
it('returns not found for non-members on the tenant review library and detail routes', function (): void {
$targetTenant = ManagedEnvironment::factory()->create();
[$member] = createUserWithTenant(role: 'owner');
$reviewOwner = User::factory()->create();
createUserWithTenant(tenant: $targetTenant, user: $reviewOwner, role: 'owner');
$review = composeTenantReviewForTest($targetTenant, $reviewOwner);
$this->actingAs($member)
->get(TenantReviewResource::tenantScopedUrl('index', tenant: $targetTenant))
->assertNotFound();
$this->actingAs($member)
->get(TenantReviewResource::tenantScopedUrl('view', ['record' => $review], $targetTenant))
->assertNotFound();
});
it('allows readonly members to inspect reviews but keeps create actions disabled', function (): void {
$tenant = ManagedEnvironment::factory()->create();
[$owner, $tenant] = createUserWithTenant(tenant: $tenant, role: 'owner');
[$readonly] = createUserWithTenant(tenant: $tenant, user: User::factory()->create(), role: 'readonly');
$review = composeTenantReviewForTest($tenant, $owner);
$this->actingAs($readonly)
->get(TenantReviewResource::tenantScopedUrl('view', ['record' => $review], $tenant))
->assertOk();
setAdminEnvironmentContext($tenant);
Livewire::actingAs($readonly)
->test(ListTenantReviews::class)
->assertActionVisible('create_review')
->assertActionDisabled('create_review')
->assertActionExists('create_review', fn ($action): bool => $action->getTooltip() === UiTooltips::insufficientPermission());
Livewire::actingAs($readonly)
->test(ViewTenantReview::class, ['record' => $review->getKey()])
->assertActionVisible('publish_review')
->assertActionDisabled('publish_review')
->assertActionVisible('archive_review')
->assertActionDisabled('archive_review');
});