## Summary - hard-cut environment-owned CTA links into workspace hubs to canonical `environment_id` filters - add shared workspace-hub environment filter resolution and visible filtered-state rendering across in-scope hubs - update workspace hub pages, link helpers, and focused test coverage for explicit environment CTA filtering ## Validation - Not run in this workflow Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #370
63 lines
2.8 KiB
PHP
63 lines
2.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Resources\ManagedEnvironmentResource;
|
|
use App\Models\OperationRun;
|
|
use App\Support\ManagedEnvironmentLinks;
|
|
use App\Support\OperationRunLinks;
|
|
use App\Support\Workspaces\WorkspaceContext;
|
|
|
|
it('generates canonical managed-environment route families only', function (): void {
|
|
[$user, $tenant] = createMinimalUserWithTenant(role: 'owner');
|
|
|
|
$this->actingAs($user)
|
|
->withSession([WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id]);
|
|
|
|
$urls = [
|
|
ManagedEnvironmentLinks::indexUrl($tenant),
|
|
ManagedEnvironmentLinks::viewUrl($tenant),
|
|
ManagedEnvironmentLinks::requiredPermissionsUrl($tenant),
|
|
ManagedEnvironmentLinks::diagnosticsUrl($tenant),
|
|
ManagedEnvironmentLinks::accessScopesUrl($tenant),
|
|
ManagedEnvironmentLinks::operationsUrl($tenant),
|
|
ManagedEnvironmentLinks::providerConnectionsUrl($tenant),
|
|
ManagedEnvironmentResource::getUrl('index'),
|
|
ManagedEnvironmentResource::getUrl('view', ['record' => $tenant]),
|
|
ManagedEnvironmentResource::getUrl('edit', ['record' => $tenant]),
|
|
ManagedEnvironmentResource::getUrl('memberships', ['record' => $tenant]),
|
|
OperationRunLinks::index($tenant),
|
|
];
|
|
|
|
$run = OperationRun::factory()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'managed_environment_id' => (int) $tenant->getKey(),
|
|
]);
|
|
|
|
$urls[] = OperationRunLinks::tenantlessView($run);
|
|
|
|
foreach ($urls as $url) {
|
|
expect($url)
|
|
->not->toContain('/admin/tenants')
|
|
->not->toContain('/admin/t/');
|
|
}
|
|
|
|
expect(ManagedEnvironmentLinks::viewUrl($tenant))->toContain('/admin/workspaces/')
|
|
->and(ManagedEnvironmentLinks::viewUrl($tenant))->toContain('/environments/'.$tenant->getRouteKey())
|
|
->and(ManagedEnvironmentLinks::requiredPermissionsUrl($tenant))->toEndWith('/required-permissions')
|
|
->and(ManagedEnvironmentLinks::diagnosticsUrl($tenant))->toEndWith('/diagnostics')
|
|
->and(ManagedEnvironmentLinks::accessScopesUrl($tenant))->toEndWith('/access-scopes')
|
|
->and(ManagedEnvironmentLinks::providerConnectionsUrl($tenant))->toContain('/admin/provider-connections?environment_id='.(int) $tenant->getKey())
|
|
->and(OperationRunLinks::index($tenant))->toContain('/admin/workspaces/')
|
|
->and(OperationRunLinks::tenantlessView($run))->toContain('/admin/workspaces/');
|
|
});
|
|
|
|
it('keeps the retired ManagedEnvironmentResource out of global search', function (): void {
|
|
[$user, $tenant] = createMinimalUserWithTenant(role: 'owner');
|
|
|
|
$this->actingAs($user)
|
|
->withSession([WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id]);
|
|
|
|
expect(ManagedEnvironmentResource::getGlobalSearchResults((string) $tenant->name))->toHaveCount(0);
|
|
});
|