## Summary - remove remaining legacy scope query hint parsing from shared workspace and environment scoping seams so hubs only narrow via explicit `environment_id` - align canonical link generation across workspace hubs, provider connections, audit log, alerts, and decision register flows - add focused Spec 341 regression coverage for canonical link/query behavior and legacy alias rejection - include the Spec 341 artifacts and move the review screenshots into `specs/341-canonical-link-query-cleanup/artifacts/screenshots/` - ignore local `.playwright-mcp` browser tool output so it does not pollute future commits or pull requests ## Validation - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/Navigation --filter=Spec341` - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/Navigation/Spec341CanonicalLinkQueryCleanupTest.php tests/Feature/Navigation/WorkspaceHubEnvironmentFilterContractTest.php tests/Feature/ProviderConnections/ProviderConnectionsWorkspaceHubContractTest.php` - `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent` - `git diff --check` ## Notes - Livewire v4 compliance unchanged - Filament provider registration remains in `apps/platform/bootstrap/providers.php` - no globally searchable resource behavior was changed in this slice - no destructive action behavior was changed - no new Filament assets; deploy `filament:assets` posture is unchanged Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #413
142 lines
5.7 KiB
PHP
142 lines
5.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Resources\ProviderConnectionResource;
|
|
use App\Filament\Resources\ProviderConnectionResource\Pages\ListProviderConnections;
|
|
use App\Models\ManagedEnvironment;
|
|
use App\Models\ProviderConnection;
|
|
use App\Support\Workspaces\WorkspaceContext;
|
|
use Filament\Facades\Filament;
|
|
use Livewire\Livewire;
|
|
|
|
it('Spec314 provider connections sidebar entry is workspace wide', function (): void {
|
|
$environmentA = ManagedEnvironment::factory()->active()->create([
|
|
'name' => 'Provider Environment A',
|
|
'external_id' => 'provider-environment-a',
|
|
]);
|
|
[$user, $environmentA] = createUserWithTenant(tenant: $environmentA, role: 'owner');
|
|
|
|
$environmentB = ManagedEnvironment::factory()->active()->create([
|
|
'workspace_id' => (int) $environmentA->workspace_id,
|
|
'name' => 'Provider Environment B',
|
|
'external_id' => 'provider-environment-b',
|
|
]);
|
|
createUserWithTenant(tenant: $environmentB, user: $user, role: 'owner');
|
|
|
|
ProviderConnection::factory()->create([
|
|
'workspace_id' => (int) $environmentA->workspace_id,
|
|
'managed_environment_id' => (int) $environmentA->getKey(),
|
|
'display_name' => 'Spec314 Provider A',
|
|
]);
|
|
ProviderConnection::factory()->create([
|
|
'workspace_id' => (int) $environmentB->workspace_id,
|
|
'managed_environment_id' => (int) $environmentB->getKey(),
|
|
'display_name' => 'Spec314 Provider B',
|
|
]);
|
|
|
|
Filament::setTenant($environmentA, true);
|
|
|
|
$url = ProviderConnectionResource::getUrl('index', panel: 'admin');
|
|
|
|
expect($url)->not->toContain('managed_environment_id');
|
|
|
|
$this->actingAs($user)
|
|
->withSession([
|
|
WorkspaceContext::SESSION_KEY => (int) $environmentA->workspace_id,
|
|
WorkspaceContext::LAST_ENVIRONMENT_IDS_SESSION_KEY => [
|
|
(string) $environmentA->workspace_id => (int) $environmentA->getKey(),
|
|
],
|
|
])
|
|
->get($url)
|
|
->assertOk()
|
|
->assertSee('Spec314 Provider A')
|
|
->assertSee('Spec314 Provider B')
|
|
->assertSee(__('localization.shell.choose_environment'))
|
|
->assertDontSee(__('localization.shell.no_environment_selected'));
|
|
});
|
|
|
|
it('Spec314 provider connections keeps explicit environment CTA filters explicit', function (): void {
|
|
$environment = ManagedEnvironment::factory()->active()->create([
|
|
'external_id' => 'provider-explicit-environment',
|
|
]);
|
|
[$user, $environment] = createUserWithTenant(tenant: $environment, role: 'owner');
|
|
|
|
$url = ProviderConnectionResource::getUrl('index', [
|
|
'environment_id' => (int) $environment->getKey(),
|
|
], panel: 'admin');
|
|
|
|
expect($url)
|
|
->toContain('environment_id='.(int) $environment->getKey())
|
|
->not->toContain('managed_environment_id=');
|
|
|
|
$this->actingAs($user)
|
|
->withSession([WorkspaceContext::SESSION_KEY => (int) $environment->workspace_id])
|
|
->get($url)
|
|
->assertOk();
|
|
});
|
|
|
|
it('Spec314 provider connections ignores stale persisted environment filters on clean entry', function (): void {
|
|
$environmentA = ManagedEnvironment::factory()->active()->create([
|
|
'external_id' => 'provider-stale-a',
|
|
]);
|
|
[$user, $environmentA] = createUserWithTenant(tenant: $environmentA, role: 'owner');
|
|
|
|
$environmentB = ManagedEnvironment::factory()->active()->create([
|
|
'workspace_id' => (int) $environmentA->workspace_id,
|
|
'external_id' => 'provider-stale-b',
|
|
]);
|
|
createUserWithTenant(tenant: $environmentB, user: $user, role: 'owner');
|
|
|
|
$connectionA = ProviderConnection::factory()->create([
|
|
'workspace_id' => (int) $environmentA->workspace_id,
|
|
'managed_environment_id' => (int) $environmentA->getKey(),
|
|
'display_name' => 'Spec314 Provider Stale A',
|
|
]);
|
|
$connectionB = ProviderConnection::factory()->create([
|
|
'workspace_id' => (int) $environmentB->workspace_id,
|
|
'managed_environment_id' => (int) $environmentB->getKey(),
|
|
'display_name' => 'Spec314 Provider Stale B',
|
|
]);
|
|
|
|
$this->actingAs($user);
|
|
setAdminPanelContext();
|
|
session()->put(WorkspaceContext::SESSION_KEY, (int) $environmentA->workspace_id);
|
|
|
|
$component = Livewire::actingAs($user)->test(ListProviderConnections::class);
|
|
$filtersSessionKey = $component->instance()->getTableFiltersSessionKey();
|
|
|
|
session()->put($filtersSessionKey, [
|
|
'tenant' => ['value' => (string) $environmentA->external_id],
|
|
]);
|
|
|
|
Livewire::actingAs($user)
|
|
->test(ListProviderConnections::class)
|
|
->assertCanSeeTableRecords([$connectionA, $connectionB]);
|
|
|
|
expect(data_get(session()->get($filtersSessionKey, []), 'tenant.value'))->toBeNull();
|
|
});
|
|
|
|
it('Spec341 provider connections translates environment_id query into an active table filter', function (): void {
|
|
$environment = ManagedEnvironment::factory()->active()->create([
|
|
'external_id' => 'spec341-provider-connections-env',
|
|
]);
|
|
[$user, $environment] = createUserWithTenant(tenant: $environment, role: 'owner');
|
|
|
|
ProviderConnection::factory()->create([
|
|
'workspace_id' => (int) $environment->workspace_id,
|
|
'managed_environment_id' => (int) $environment->getKey(),
|
|
'display_name' => 'Spec341 Provider Filtered',
|
|
]);
|
|
|
|
$this->actingAs($user);
|
|
setAdminPanelContext();
|
|
session()->put(WorkspaceContext::SESSION_KEY, (int) $environment->workspace_id);
|
|
|
|
Livewire::actingAs($user)
|
|
->withQueryParams(['environment_id' => (int) $environment->getKey()])
|
|
->test(ListProviderConnections::class)
|
|
->assertSet('tableFilters.tenant.value', (string) $environment->slug)
|
|
->assertSet('tableDeferredFilters.tenant.value', (string) $environment->slug);
|
|
});
|