## 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
82 lines
3.0 KiB
PHP
82 lines
3.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Resources\EnvironmentReviewResource\Pages\ViewEnvironmentReview;
|
|
use App\Models\EnvironmentReview;
|
|
use App\Support\EnvironmentReviewStatus;
|
|
use Filament\Actions\Action;
|
|
use Filament\Actions\ActionGroup;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Livewire\Features\SupportTesting\Testable;
|
|
use Livewire\Livewire;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
function environmentReviewHeaderActions(Testable $component): array
|
|
{
|
|
$instance = $component->instance();
|
|
|
|
if ($instance->getCachedHeaderActions() === []) {
|
|
$instance->cacheInteractsWithHeaderActions();
|
|
}
|
|
|
|
return $instance->getCachedHeaderActions();
|
|
}
|
|
|
|
function environmentReviewHeaderPrimaryNames(Testable $component): array
|
|
{
|
|
return collect(environmentReviewHeaderActions($component))
|
|
->reject(static fn ($action): bool => $action instanceof ActionGroup)
|
|
->map(static fn ($action): ?string => $action instanceof Action ? $action->getName() : null)
|
|
->filter()
|
|
->values()
|
|
->all();
|
|
}
|
|
|
|
function environmentReviewHeaderGroupLabels(Testable $component): array
|
|
{
|
|
return collect(environmentReviewHeaderActions($component))
|
|
->filter(static fn ($action): bool => $action instanceof ActionGroup)
|
|
->map(static fn (ActionGroup $action): string => (string) $action->getLabel())
|
|
->values()
|
|
->all();
|
|
}
|
|
|
|
it('keeps ready reviews to one primary action and renders related navigation in the summary context', function (): void {
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner');
|
|
$review = composeEnvironmentReviewForTest($tenant, $user);
|
|
|
|
setAdminEnvironmentContext($tenant);
|
|
|
|
$component = Livewire::actingAs($user)
|
|
->test(ViewEnvironmentReview::class, ['record' => $review->getKey()])
|
|
->assertSee('Related context')
|
|
->assertSee('Evidence snapshot');
|
|
|
|
expect(environmentReviewHeaderPrimaryNames($component))->toBe(['publish_review'])
|
|
->and(environmentReviewHeaderGroupLabels($component))->toBe(['More', 'Danger']);
|
|
});
|
|
|
|
it('promotes executive-pack export as the only visible primary action after publication', function (): void {
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner');
|
|
$review = composeEnvironmentReviewForTest($tenant, $user);
|
|
|
|
$review->forceFill([
|
|
'status' => EnvironmentReviewStatus::Published->value,
|
|
'published_at' => now(),
|
|
'published_by_user_id' => (int) $user->getKey(),
|
|
])->save();
|
|
|
|
setAdminEnvironmentContext($tenant);
|
|
|
|
$component = Livewire::actingAs($user)
|
|
->test(ViewEnvironmentReview::class, ['record' => $review->getKey()])
|
|
->assertActionVisible('export_executive_pack')
|
|
->assertActionEnabled('export_executive_pack');
|
|
|
|
expect(environmentReviewHeaderPrimaryNames($component))->toBe(['export_executive_pack'])
|
|
->and(environmentReviewHeaderGroupLabels($component))->toContain('More')
|
|
->and(environmentReviewHeaderPrimaryNames($component))->not->toContain('refresh_review', 'publish_review');
|
|
});
|