TenantAtlas/tests/Feature/078/RelatedLinksOnDetailTest.php
ahmido 1b88d28739 feat: consolidate operation naming surfaces (#202)
## Summary
- align operator-visible OperationRun terminology to canonical `Operations` / `Operation` labels across shared links, notifications, verification/onboarding surfaces, summary widgets, and monitoring/detail pages
- add the Spec 171 planning artifacts under `specs/171-operations-naming-consolidation/`
- close the remaining tenant dashboard and admin copy drift found during browser smoke validation

## Validation
- `export PATH="/bin:/usr/bin:/usr/local/bin:$PATH" && vendor/bin/sail artisan test --compact tests/Unit/Support/RelatedNavigationResolverTest.php tests/Unit/Support/References/RelatedContextReferenceAdapterTest.php tests/Feature/OpsUx/NotificationViewRunLinkTest.php tests/Feature/Guards/ActionSurfaceContractTest.php tests/Feature/Operations/TenantlessOperationRunViewerTest.php tests/Feature/Filament/BackupSetResolvedReferencePresentationTest.php tests/Feature/Filament/TenantVerificationReportWidgetTest.php tests/Feature/Onboarding/OnboardingVerificationTest.php tests/Feature/Onboarding/OnboardingVerificationClustersTest.php tests/Feature/Onboarding/OnboardingVerificationV1_5UxTest.php tests/Feature/Filament/BaselineCompareSummaryConsistencyTest.php tests/Feature/Filament/WorkspaceOverviewContentTest.php tests/Feature/Filament/RecentOperationsSummaryWidgetTest.php tests/Feature/Monitoring/OperationLifecycleAggregateVisibilityTest.php tests/Feature/System/Spec114/OpsTriageActionsTest.php tests/Feature/System/Spec114/OpsFailuresViewTest.php tests/Feature/System/Spec114/OpsStuckViewTest.php`
- `export PATH="/bin:/usr/bin:/usr/local/bin:$PATH" && vendor/bin/sail artisan test --compact tests/Browser/OnboardingDraftRefreshTest.php`
- `export PATH="/bin:/usr/bin:/usr/local/bin:$PATH" && vendor/bin/sail bin pint --dirty --format agent`

## Notes
- no schema or route renames
- Filament / Livewire surface behavior stays within the existing admin and tenant panels
- OperationRunResource remains excluded from global search

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #202
2026-03-30 22:51:06 +00:00

132 lines
4.9 KiB
PHP

<?php
declare(strict_types=1);
use App\Filament\Resources\InventoryItemResource;
use App\Filament\Resources\RestoreRunResource;
use App\Models\OperationRun;
use App\Models\RestoreRun;
use App\Models\Tenant;
use App\Support\Workspaces\WorkspaceContext;
use Filament\Facades\Filament;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
final class RelatedLinksOnDetailTest extends TestCase
{
use RefreshDatabase;
public function test_shows_restore_related_links_on_canonical_detail_for_restore_execute_runs(): void
{
[$user, $tenant] = createUserWithTenant(role: 'owner');
$restoreRun = RestoreRun::factory()->create([
'tenant_id' => (int) $tenant->getKey(),
]);
$run = OperationRun::factory()->create([
'workspace_id' => (int) $tenant->workspace_id,
'tenant_id' => (int) $tenant->getKey(),
'type' => 'restore.execute',
'context' => [
'restore_run_id' => (int) $restoreRun->getKey(),
],
]);
$expectedUrl = RestoreRunResource::getUrl('view', ['record' => $restoreRun], tenant: $tenant);
$response = $this->actingAs($user)
->withSession([WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id])
->get(route('admin.operations.view', ['run' => (int) $run->getKey()]))
->assertOk()
->assertSee('Open')
->assertSee('View restore run');
$response->assertSee((string) $expectedUrl, false);
}
public function test_shows_only_generic_links_for_tenantless_runs_on_canonical_detail(): void
{
[$user, $tenant] = createUserWithTenant(role: 'owner');
$run = OperationRun::factory()->create([
'workspace_id' => (int) $tenant->workspace_id,
'tenant_id' => null,
'type' => 'restore.execute',
'context' => [
'restore_run_id' => 999,
],
]);
$this->actingAs($user)
->withSession([WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id])
->get(route('admin.operations.view', ['run' => (int) $run->getKey()]))
->assertOk()
->assertSee('Operations')
->assertSee(route('admin.operations.index'), false)
->assertDontSee('View restore run');
}
public function test_does_not_show_legacy_admin_details_cta_and_keeps_canonical_view_run_label(): void
{
[$user, $tenant] = createUserWithTenant(role: 'owner');
$run = OperationRun::factory()->create([
'workspace_id' => (int) $tenant->workspace_id,
'tenant_id' => (int) $tenant->getKey(),
'type' => 'policy.sync',
]);
$this->actingAs($user)
->withSession([WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id])
->get(route('admin.operations.view', ['run' => (int) $run->getKey()]))
->assertOk()
->assertDontSee('Admin details')
->assertDontSee('/admin/t/'.$tenant->external_id.'/operations/r/'.$run->getKey(), false);
Filament::setTenant($tenant, true);
$this->actingAs($user)
->withSession([WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id])
->get(route('admin.operations.index'))
->assertOk()
->assertSee('Open operation');
}
public function test_hides_tenant_scoped_follow_up_links_when_the_run_tenant_is_not_selector_eligible(): void
{
$activeTenant = Tenant::factory()->active()->create([
'name' => 'Viewer Active Tenant',
]);
[$user, $activeTenant] = createUserWithTenant(tenant: $activeTenant, role: 'owner');
$onboardingTenant = Tenant::factory()->onboarding()->create([
'workspace_id' => (int) $activeTenant->workspace_id,
'name' => 'Viewer Onboarding Tenant',
]);
createUserWithTenant(
tenant: $onboardingTenant,
user: $user,
role: 'owner',
workspaceRole: 'owner',
ensureDefaultMicrosoftProviderConnection: false,
);
$run = OperationRun::factory()->create([
'workspace_id' => (int) $activeTenant->workspace_id,
'tenant_id' => (int) $onboardingTenant->getKey(),
'type' => 'inventory_sync',
]);
$this->actingAs($user)
->withSession([WorkspaceContext::SESSION_KEY => (int) $activeTenant->workspace_id])
->get(route('admin.operations.view', ['run' => (int) $run->getKey()]))
->assertOk()
->assertSee('Open')
->assertSee('Operations')
->assertDontSee(InventoryItemResource::getUrl('index', panel: 'tenant', tenant: $onboardingTenant), false)
->assertSee('Some tenant follow-up actions may be unavailable from this canonical workspace view.');
}
}