Some checks failed
PR Fast Feedback / fast-feedback (pull_request) Failing after 1m0s
## Summary - productize the customer review workspace and released-review drilldown into a calmer customer-safe governance flow - make review-pack and evidence-proof access explicit, capability-aware, and auditable in the shared Filament resources - add focused Pest coverage, browser smoke coverage, and the full Spec 258 artifact package ## Notes - Filament stays on v5 with Livewire v4 surfaces; no provider registration changes were introduced - no new global-search scope, destructive action surface, or asset registration was added - bounded additive audit action IDs were added for workspace open and evidence proof open events ## Validation - focused Pest feature suites for workspace, review detail, review-pack, and evidence flows - bounded browser smoke: `tests/Browser/Reviews/CustomerReviewWorkspaceSmokeTest.php` - `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent` Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #310
99 lines
4.0 KiB
PHP
99 lines
4.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Pages\Reviews\ReviewRegister;
|
|
use App\Filament\Pages\Reviews\CustomerReviewWorkspace;
|
|
use App\Filament\Resources\TenantReviewResource;
|
|
use App\Models\Tenant;
|
|
use App\Support\OperationRunLinks;
|
|
use App\Support\ReasonTranslation\ReasonPresenter;
|
|
use App\Support\Ui\GovernanceArtifactTruth\ArtifactTruthPresenter;
|
|
use App\Support\Ui\GovernanceArtifactTruth\SurfaceCompressionContext;
|
|
use App\Support\Workspaces\WorkspaceContext;
|
|
use Livewire\Livewire;
|
|
use Tests\Feature\Concerns\BuildsGovernanceArtifactTruthFixtures;
|
|
|
|
uses(BuildsGovernanceArtifactTruthFixtures::class);
|
|
|
|
it('reuses the same operator explanation on tenant review detail and review register surfaces', function (): void {
|
|
$tenant = Tenant::factory()->create();
|
|
[$user, $tenant] = createUserWithTenant(tenant: $tenant, role: 'owner');
|
|
|
|
$snapshot = $this->makeArtifactTruthEvidenceSnapshot($tenant);
|
|
$review = $this->makeArtifactTruthReview(
|
|
tenant: $tenant,
|
|
user: $user,
|
|
snapshot: $snapshot,
|
|
reviewOverrides: [
|
|
'status' => 'draft',
|
|
'completeness_state' => 'complete',
|
|
],
|
|
summaryOverrides: [
|
|
'publish_blockers' => ['Review the missing approval note before publication.'],
|
|
],
|
|
);
|
|
|
|
$presenter = app(ArtifactTruthPresenter::class);
|
|
$truth = $presenter->forTenantReview($review);
|
|
$explanation = $truth->operatorExplanation;
|
|
$detailOutcome = $presenter->compressedOutcomeFor($review, SurfaceCompressionContext::tenantReview());
|
|
$registerOutcome = $presenter->compressedOutcomeFor($review, SurfaceCompressionContext::reviewRegister());
|
|
$reasonSemantics = app(ReasonPresenter::class)->semantics($truth->reason?->toReasonResolutionEnvelope());
|
|
|
|
expect($reasonSemantics)->not->toBeNull();
|
|
|
|
setTenantPanelContext($tenant);
|
|
|
|
$this->actingAs($user)
|
|
->get(TenantReviewResource::tenantScopedUrl('view', ['record' => $review], $tenant))
|
|
->assertOk()
|
|
->assertSee($detailOutcome?->primaryReason ?? '')
|
|
->assertSee($explanation?->nextActionText ?? '')
|
|
->assertSee('Reason owner')
|
|
->assertSee($reasonSemantics['owner_label'])
|
|
->assertSee('Platform reason family')
|
|
->assertSee($reasonSemantics['family_label']);
|
|
|
|
setAdminPanelContext();
|
|
session()->put(WorkspaceContext::SESSION_KEY, (int) $tenant->workspace_id);
|
|
|
|
Livewire::actingAs($user)
|
|
->test(ReviewRegister::class)
|
|
->assertCanSeeTableRecords([$review])
|
|
->assertSee($registerOutcome?->primaryReason ?? '')
|
|
->assertSee($explanation?->nextActionText ?? '');
|
|
});
|
|
|
|
it('keeps customer-workspace review detail customer-readable by hiding internal reason ownership and fingerprints', function (): void {
|
|
$tenant = Tenant::factory()->create();
|
|
[$user, $tenant] = createUserWithTenant(tenant: $tenant, role: 'readonly');
|
|
|
|
$snapshot = seedTenantReviewEvidence($tenant);
|
|
$review = composeTenantReviewForTest($tenant, $user, $snapshot);
|
|
$review->forceFill([
|
|
'status' => 'published',
|
|
'published_at' => now(),
|
|
'published_by_user_id' => (int) $user->getKey(),
|
|
])->save();
|
|
|
|
expect($review->operation_run_id)->not->toBeNull();
|
|
|
|
setTenantPanelContext($tenant);
|
|
|
|
$this->actingAs($user)
|
|
->get(TenantReviewResource::tenantScopedUrl('view', ['record' => $review], $tenant).'?'.http_build_query([
|
|
CustomerReviewWorkspace::DETAIL_CONTEXT_QUERY_KEY => 1,
|
|
]))
|
|
->assertOk()
|
|
->assertSee('Released governance record')
|
|
->assertSee('This released review is available for customer-safe governance consumption.')
|
|
->assertSee('Evidence snapshot')
|
|
->assertSee('source_surface=customer_review_workspace', false)
|
|
->assertDontSee('Reason owner')
|
|
->assertDontSee('Platform reason family')
|
|
->assertDontSee('Fingerprint')
|
|
->assertDontSee(OperationRunLinks::tenantlessView((int) $review->operation_run_id), false)
|
|
->assertDontSee('Inspect the latest review composition or refresh run.');
|
|
});
|