Some checks failed
Main Confidence / confidence (push) Failing after 44s
## Summary - enforce shared operation run link generation across admin and system surfaces - add guard coverage to block new raw operation route bypasses outside explicit exceptions - harden Filament theme asset resolution so stale or wrong-stack hot files fall back to built assets ## Testing - export PATH="/bin:/usr/bin:/usr/local/bin:$PATH" && cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent - export PATH="/bin:/usr/bin:/usr/local/bin:$PATH" && cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/OpsUx/CanonicalViewRunLinksTest.php tests/Feature/Monitoring/OperationsDashboardDrillthroughTest.php tests/Feature/Filament/RecentOperationsSummaryWidgetTest.php tests/Feature/Filament/InventoryCoverageRunContinuityTest.php tests/Feature/ReviewPack/ReviewPackResourceTest.php tests/Feature/144/CanonicalOperationViewerDeepLinkTrustTest.php tests/Feature/078/RelatedLinksOnDetailTest.php tests/Feature/RunAuthorizationTenantIsolationTest.php tests/Feature/System/Spec195/SystemDirectoryResidualSurfaceTest.php tests/Feature/System/Spec113/AuthorizationSemanticsTest.php tests/Feature/Guards/OperationRunLinkContractGuardTest.php tests/Unit/Filament/PanelThemeAssetTest.php Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #268
122 lines
4.8 KiB
PHP
122 lines
4.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\OperationRun;
|
|
use App\Models\Tenant;
|
|
use App\Support\OperationRunLinks;
|
|
use App\Support\OpsUx\OperationRunUrl;
|
|
use App\Support\System\SystemOperationRunLinks;
|
|
use Illuminate\Support\Facades\File;
|
|
|
|
it('routes all OperationRun view links through OperationRunLinks', function (): void {
|
|
$files = File::allFiles(app_path());
|
|
|
|
$violations = [];
|
|
|
|
foreach ($files as $file) {
|
|
$path = $file->getRealPath();
|
|
if (! is_string($path)) {
|
|
continue;
|
|
}
|
|
|
|
// OperationRunLinks is the canonical wrapper.
|
|
if (str_ends_with($path, '/Support/OperationRunLinks.php')) {
|
|
continue;
|
|
}
|
|
|
|
$contents = File::get($path);
|
|
|
|
if (preg_match("/\\bOperationRunResource::getUrl\(\\s*'view'/", $contents) === 1
|
|
|| preg_match("/route\(\s*'filament\.admin\.resources\.operations\.view'/", $contents) === 1) {
|
|
$violations[] = $path;
|
|
}
|
|
}
|
|
|
|
expect($violations)->toBeEmpty();
|
|
})->group('ops-ux');
|
|
|
|
it('resolves tenantless operation run links to the canonical admin.operations.view route', function (): void {
|
|
$run = OperationRun::factory()->create();
|
|
|
|
$expectedUrl = route('admin.operations.view', ['run' => (int) $run->getKey()]);
|
|
|
|
expect(OperationRunLinks::tenantlessView($run))->toBe($expectedUrl);
|
|
expect(OperationRunLinks::tenantlessView((int) $run->getKey()))->toBe($expectedUrl);
|
|
})->group('ops-ux');
|
|
|
|
it('normalizes tenant-scoped callers onto the canonical tenantless run route', function (): void {
|
|
$tenant = Tenant::factory()->create();
|
|
$run = OperationRun::factory()->for($tenant)->create();
|
|
|
|
$expectedUrl = route('admin.operations.view', ['run' => (int) $run->getKey()]);
|
|
|
|
expect(OperationRunLinks::view($run, $tenant))->toBe($expectedUrl)
|
|
->and(OperationRunLinks::view((int) $run->getKey(), $tenant))->toBe($expectedUrl);
|
|
})->group('ops-ux');
|
|
|
|
it('preserves tenant prefilter, requested tab, and problem class on canonical operations collection links', function (): void {
|
|
$tenant = Tenant::factory()->create();
|
|
|
|
expect(OperationRunLinks::index($tenant, activeTab: 'active'))
|
|
->toBe(route('admin.operations.index', [
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'activeTab' => 'active',
|
|
]))
|
|
->and(OperationRunLinks::index(
|
|
$tenant,
|
|
activeTab: OperationRun::PROBLEM_CLASS_ACTIVE_STALE_ATTENTION,
|
|
problemClass: OperationRun::PROBLEM_CLASS_ACTIVE_STALE_ATTENTION,
|
|
))
|
|
->toBe(route('admin.operations.index', [
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'activeTab' => OperationRun::PROBLEM_CLASS_ACTIVE_STALE_ATTENTION,
|
|
'problemClass' => OperationRun::PROBLEM_CLASS_ACTIVE_STALE_ATTENTION,
|
|
]))
|
|
->and(OperationRunLinks::index(
|
|
$tenant,
|
|
activeTab: OperationRun::PROBLEM_CLASS_TERMINAL_FOLLOW_UP,
|
|
problemClass: OperationRun::PROBLEM_CLASS_TERMINAL_FOLLOW_UP,
|
|
))
|
|
->toBe(route('admin.operations.index', [
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'activeTab' => OperationRun::PROBLEM_CLASS_TERMINAL_FOLLOW_UP,
|
|
'problemClass' => OperationRun::PROBLEM_CLASS_TERMINAL_FOLLOW_UP,
|
|
]));
|
|
})->group('ops-ux');
|
|
|
|
it('preserves helper-owned operation type filters on canonical operations collection links', function (): void {
|
|
$tenant = Tenant::factory()->create();
|
|
|
|
expect(OperationRunLinks::index($tenant, operationType: 'inventory_sync'))
|
|
->toBe(route('admin.operations.index', [
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'tableFilters' => [
|
|
'type' => [
|
|
'value' => 'inventory_sync',
|
|
],
|
|
],
|
|
]));
|
|
})->group('ops-ux');
|
|
|
|
it('keeps the thin operation URL delegate on the canonical admin helpers', function (): void {
|
|
$tenant = Tenant::factory()->create();
|
|
$run = OperationRun::factory()->for($tenant)->create();
|
|
|
|
expect(OperationRunUrl::view($run, $tenant))
|
|
->toBe(OperationRunLinks::view($run, $tenant))
|
|
->and(OperationRunUrl::index($tenant))
|
|
->toBe(OperationRunLinks::index($tenant));
|
|
})->group('ops-ux');
|
|
|
|
it('resolves system operation links through the canonical system helper family', function (): void {
|
|
$run = OperationRun::factory()->create();
|
|
|
|
expect(SystemOperationRunLinks::index())
|
|
->toBe(\App\Filament\System\Pages\Ops\Runs::getUrl(panel: 'system'))
|
|
->and(SystemOperationRunLinks::view($run))
|
|
->toBe(\App\Filament\System\Pages\Ops\ViewRun::getUrl(['run' => (int) $run->getKey()], panel: 'system'))
|
|
->and(SystemOperationRunLinks::view((int) $run->getKey()))
|
|
->toBe(\App\Filament\System\Pages\Ops\ViewRun::getUrl(['run' => (int) $run->getKey()], panel: 'system'));
|
|
})->group('ops-ux');
|