## Summary - add a shared workspace hub registry for canonical workspace-scoped navigation entry - keep sidebar and global workspace hub URLs free of inherited environment query and filter state - add focused feature and browser coverage for workspace hub shell and data-scope contracts ## Validation - 54 focused feature tests passed (205 assertions) - 1 browser smoke test passed (361 assertions) - `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent` - `git diff --check` Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #369
78 lines
3.6 KiB
PHP
78 lines
3.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Pages\Governance\DecisionRegister;
|
|
use App\Filament\Pages\Governance\GovernanceInbox;
|
|
use App\Filament\Pages\Monitoring\FindingExceptionsQueue;
|
|
use App\Filament\Pages\Reviews\CustomerReviewWorkspace;
|
|
use App\Filament\Resources\ProviderConnectionResource;
|
|
use App\Models\ManagedEnvironment;
|
|
use App\Support\Navigation\WorkspaceHubRegistry;
|
|
use App\Support\OperationRunLinks;
|
|
use App\Support\Workspaces\WorkspaceContext;
|
|
use Filament\Facades\Filament;
|
|
|
|
it('Spec314 sidebar from environment dashboard opens critical workspace hubs without environment context', function (string $hub, Closure $urlFactory): void {
|
|
$environment = ManagedEnvironment::factory()->active()->create([
|
|
'name' => 'Active Environment Context',
|
|
'external_id' => 'active-environment-context',
|
|
]);
|
|
|
|
[$user, $environment] = createUserWithTenant(tenant: $environment, role: 'owner');
|
|
$workspace = $environment->workspace()->firstOrFail();
|
|
|
|
Filament::setTenant($environment, true);
|
|
|
|
$url = $urlFactory($workspace);
|
|
|
|
expect(WorkspaceHubRegistry::hasForbiddenQuery($url))->toBeFalse();
|
|
|
|
$this->actingAs($user)
|
|
->withSession([
|
|
WorkspaceContext::SESSION_KEY => (int) $workspace->getKey(),
|
|
WorkspaceContext::LAST_TENANT_IDS_SESSION_KEY => [
|
|
(string) $workspace->getKey() => (int) $environment->getKey(),
|
|
],
|
|
])
|
|
->get($url)
|
|
->assertOk()
|
|
->assertSee($workspace->name)
|
|
->assertSee(__('localization.shell.no_environment_selected'))
|
|
->assertDontSee(__('localization.shell.environment_scope').': Active Environment Context');
|
|
})->with([
|
|
'provider connections' => ['provider_connections', fn ($workspace): string => ProviderConnectionResource::getUrl('index', panel: 'admin')],
|
|
'finding exceptions queue' => ['finding_exceptions_queue', fn ($workspace): string => FindingExceptionsQueue::getUrl(panel: 'admin')],
|
|
'operations' => ['operations', fn ($workspace): string => OperationRunLinks::index()],
|
|
'decision register' => ['decision_register', fn ($workspace): string => DecisionRegister::getUrl(panel: 'admin')],
|
|
'customer reviews' => ['customer_reviews', fn ($workspace): string => CustomerReviewWorkspace::getUrl(panel: 'admin')],
|
|
'governance inbox' => ['governance_inbox', fn ($workspace): string => GovernanceInbox::getUrl(panel: 'admin')],
|
|
]);
|
|
|
|
it('Spec314 remembered environment does not affect workspace hub sidebar urls or shell context', function (): void {
|
|
$rememberedEnvironment = ManagedEnvironment::factory()->active()->create([
|
|
'name' => 'Remembered Environment Boundary',
|
|
'external_id' => 'remembered-environment-boundary',
|
|
]);
|
|
|
|
[$user, $rememberedEnvironment] = createUserWithTenant(tenant: $rememberedEnvironment, role: 'owner');
|
|
$workspace = $rememberedEnvironment->workspace()->firstOrFail();
|
|
|
|
$this->actingAs($user);
|
|
Filament::setTenant($rememberedEnvironment, true);
|
|
session()->put(WorkspaceContext::SESSION_KEY, (int) $workspace->getKey());
|
|
session()->put(WorkspaceContext::LAST_TENANT_IDS_SESSION_KEY, [
|
|
(string) $workspace->getKey() => (int) $rememberedEnvironment->getKey(),
|
|
]);
|
|
|
|
$url = ProviderConnectionResource::getUrl('index', panel: 'admin');
|
|
|
|
expect($url)->not->toContain('managed_environment_id')
|
|
->and($url)->not->toContain('tenant=');
|
|
|
|
$this->get($url)
|
|
->assertOk()
|
|
->assertSee(__('localization.shell.no_environment_selected'))
|
|
->assertDontSee(__('localization.shell.environment_scope').': Remembered Environment Boundary');
|
|
});
|