TenantAtlas/apps/platform/tests/Feature/Navigation/WorkspaceHubRegistryTest.php
ahmido d85ef4cc1c Spec 314: enforce workspace hub navigation context contract (#369)
## 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
2026-05-16 09:54:29 +00:00

61 lines
2.9 KiB
PHP

<?php
declare(strict_types=1);
use App\Support\Navigation\WorkspaceHubRegistry;
it('Spec314 lists workspace hubs and explicit exclusions', function (): void {
expect(array_keys(WorkspaceHubRegistry::entries()))
->toContain(
'workspace_home',
'workspace_overview',
'operations',
'provider_connections',
'finding_exceptions_queue',
'evidence_overview',
'review_register',
'customer_review_workspace',
'governance_inbox',
'decision_register',
'audit_log',
'alerts',
'alert_deliveries',
'alert_rules',
'alert_destinations',
'workspace_settings',
'manage_workspaces',
'managed_environments_landing',
)
->and(array_keys(WorkspaceHubRegistry::exclusions()))
->toContain(
'environment_dashboard',
'stored_reports_environment_routes',
'support_request_action_surface',
);
});
it('Spec314 classifies workspace hubs without classifying environment-owned pages', function (): void {
expect(WorkspaceHubRegistry::isWorkspaceHubPath('/admin'))->toBeTrue()
->and(WorkspaceHubRegistry::isWorkspaceHubPath('/admin/workspaces/1/overview'))->toBeTrue()
->and(WorkspaceHubRegistry::isWorkspaceHubPath('/admin/workspaces/1/operations'))->toBeTrue()
->and(WorkspaceHubRegistry::isWorkspaceHubPath('/admin/workspaces/1/environments'))->toBeTrue()
->and(WorkspaceHubRegistry::isWorkspaceHubPath('/admin/workspaces/1/environments/2'))->toBeFalse()
->and(WorkspaceHubRegistry::isExplicitlyExcludedPath('/admin/workspaces/1/environments/2'))->toBeTrue()
->and(WorkspaceHubRegistry::isWorkspaceHubPath('/admin/workspaces/1/environments/2/stored-reports'))->toBeFalse()
->and(WorkspaceHubRegistry::isExplicitlyExcludedPath('/admin/workspaces/1/environments/2/stored-reports'))->toBeTrue();
});
it('Spec314 owns forbidden query keys and environment-like filter keys', function (): void {
expect(WorkspaceHubRegistry::forbiddenQueryKeys())
->toBe(['tenant', 'tenant_id', 'managed_environment_id', 'environment_id', 'tenant_scope', 'tableFilters'])
->and(WorkspaceHubRegistry::environmentLikeFilterKeys())
->toBe(['tenant', 'tenant_id', 'managed_environment_id', 'environment_id', 'environment', 'tenant_scope']);
});
it('Spec314 strips forbidden workspace hub query keys without touching unrelated navigation state', function (): void {
$url = WorkspaceHubRegistry::cleanUrl('/admin/provider-connections?tenant=a&tenant_id=1&managed_environment_id=2&environment_id=3&tenant_scope=all&tableFilters%5Btenant%5D=x&activeTab=failed&family=alerts');
expect($url)->toBe('/admin/provider-connections?activeTab=failed&family=alerts')
->and(WorkspaceHubRegistry::hasForbiddenQuery($url))->toBeFalse();
});