## Summary - add a request-scoped derived-state store with deterministic keying and freshness controls - adopt the shared contract in ArtifactTruthPresenter, OperationUxPresenter, and RelatedNavigationResolver plus the covered Filament consumers - add spec, plan, contracts, guardrails, and focused memoization and freshness test coverage for spec 167 ## Verification - vendor/bin/sail artisan test --compact tests/Feature/078/RelatedLinksOnDetailTest.php - vendor/bin/sail artisan test --compact tests/Feature/078/ tests/Feature/Operations/TenantlessOperationRunViewerTest.php tests/Feature/Monitoring/OperationsCanonicalUrlsTest.php tests/Feature/Monitoring/OperationsTenantScopeTest.php tests/Feature/Verification/VerificationAuthorizationTest.php tests/Feature/Verification/VerificationReportViewerDbOnlyTest.php tests/Feature/Verification/VerificationReportRedactionTest.php tests/Feature/Verification/VerificationReportMissingOrMalformedTest.php tests/Feature/OpsUx/FailureSanitizationTest.php tests/Feature/OpsUx/CanonicalViewRunLinksTest.php - vendor/bin/sail bin pint --dirty --format agent ## Notes - Livewire v4.0+ compliance preserved - provider registration remains in bootstrap/providers.php - no Filament assets or panel registration changes - no global-search behavior changes - no destructive action behavior changes in this PR Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #198
72 lines
2.8 KiB
PHP
72 lines
2.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Pages\Operations\TenantlessOperationRunViewer;
|
|
use App\Models\OperationRun;
|
|
use App\Support\OperationRunOutcome;
|
|
use App\Support\OperationRunStatus;
|
|
use App\Support\OpsUx\OperationUxPresenter;
|
|
use App\Support\Ui\DerivedState\DerivedStateFamily;
|
|
use App\Support\Ui\DerivedState\RequestScopedDerivedStateStore;
|
|
use App\Support\Workspaces\WorkspaceContext;
|
|
use Filament\Facades\Filament;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Livewire\Livewire;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('reuses operation guidance and explanation state on the canonical run detail surface', function (): void {
|
|
$tenant = \App\Models\Tenant::factory()->create();
|
|
[$user, $tenant] = createUserWithTenant(tenant: $tenant, role: 'owner');
|
|
|
|
$run = OperationRun::factory()->create([
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'user_id' => (int) $user->getKey(),
|
|
'type' => 'baseline_compare',
|
|
'status' => OperationRunStatus::Completed->value,
|
|
'outcome' => OperationRunOutcome::Blocked->value,
|
|
'context' => [
|
|
'reason_code' => 'missing_capability',
|
|
'blocked_by' => 'queued_execution_legitimacy',
|
|
'execution_legitimacy' => [
|
|
'reason_code' => 'missing_capability',
|
|
],
|
|
],
|
|
'failure_summary' => [[
|
|
'code' => 'operation.blocked',
|
|
'reason_code' => 'missing_capability',
|
|
'message' => 'Operation blocked because the initiating actor no longer has the required capability.',
|
|
]],
|
|
]);
|
|
|
|
Filament::setTenant(null, true);
|
|
$this->actingAs($user)->withSession([WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id]);
|
|
session([WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id]);
|
|
|
|
Livewire::actingAs($user)
|
|
->test(TenantlessOperationRunViewer::class, ['run' => $run])
|
|
->assertSee('Blocked by prerequisite')
|
|
->assertSee('Execution legitimacy revalidation');
|
|
|
|
$guidance = OperationUxPresenter::surfaceGuidance($run->fresh());
|
|
$operatorExplanation = OperationUxPresenter::governanceOperatorExplanation($run->fresh());
|
|
$store = app(RequestScopedDerivedStateStore::class);
|
|
|
|
expect($store->countStored(
|
|
DerivedStateFamily::OperationUxGuidance,
|
|
OperationRun::class,
|
|
(string) $run->getKey(),
|
|
'surface_guidance',
|
|
))->toBe(1)
|
|
->and($store->countStored(
|
|
DerivedStateFamily::OperationUxExplanation,
|
|
OperationRun::class,
|
|
(string) $run->getKey(),
|
|
'governance_operator_explanation',
|
|
))->toBe(1)
|
|
->and($guidance)->toBe('Review workspace or tenant access before retrying.')
|
|
->and($operatorExplanation?->headline)->not->toBe('');
|
|
});
|