## Summary - consolidate internal platform naming from `Tenant` to `Environment` / `ManagedEnvironment` across models, controllers, services, and Filament resources - rename environment-scoped UI surfaces such as dashboards, chooser flows, navigation, and related widgets to match the updated environment-first domain language - align middleware, onboarding/review lifecycle services, jobs, and route/context controllers with the new environment-scoped architecture ## Validation - not rerun as part of this commit/push/PR request ## Notes - branch is 1 commit ahead of `platform-dev` - main commit: `refactor: consolidate internal tenant model naming` Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #355
54 lines
2.3 KiB
PHP
54 lines
2.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Resources\EnvironmentReviewResource;
|
|
use App\Filament\Resources\EnvironmentReviewResource\Pages\ListEnvironmentReviews;
|
|
use App\Filament\Resources\EnvironmentReviewResource\Pages\ViewEnvironmentReview;
|
|
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 environment 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 = composeEnvironmentReviewForTest($targetTenant, $reviewOwner);
|
|
|
|
$this->actingAs($member)
|
|
->get(EnvironmentReviewResource::tenantScopedUrl('index', tenant: $targetTenant))
|
|
->assertNotFound();
|
|
|
|
$this->actingAs($member)
|
|
->get(EnvironmentReviewResource::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 = composeEnvironmentReviewForTest($tenant, $owner);
|
|
|
|
$this->actingAs($readonly)
|
|
->get(EnvironmentReviewResource::tenantScopedUrl('view', ['record' => $review], $tenant))
|
|
->assertOk();
|
|
|
|
setAdminEnvironmentContext($tenant);
|
|
|
|
Livewire::actingAs($readonly)
|
|
->test(ListEnvironmentReviews::class)
|
|
->assertActionVisible('create_review')
|
|
->assertActionDisabled('create_review')
|
|
->assertActionExists('create_review', fn ($action): bool => $action->getTooltip() === UiTooltips::insufficientPermission());
|
|
|
|
Livewire::actingAs($readonly)
|
|
->test(ViewEnvironmentReview::class, ['record' => $review->getKey()])
|
|
->assertActionVisible('publish_review')
|
|
->assertActionDisabled('publish_review')
|
|
->assertActionVisible('archive_review')
|
|
->assertActionDisabled('archive_review');
|
|
});
|