Some checks failed
PR Fast Feedback / fast-feedback (pull_request) Failing after 3m45s
Implemented the first version of review output resolve actions. Included a ReviewOutputResolveActionMapper, commands to seed browser fixtures, updated CustomerReviewWorkspace, EnvironmentReviewResource, UI enforcement, and related views. Also added extensive unit, feature, and browser tests, and updated the design coverage matrix.
122 lines
5.4 KiB
PHP
122 lines
5.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Pages\Reviews\CustomerReviewWorkspace;
|
|
use App\Filament\Resources\EnvironmentReviewResource;
|
|
use App\Models\ManagedEnvironment;
|
|
use App\Models\ReviewPack;
|
|
use App\Support\EnvironmentReviewStatus;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
beforeEach(function (): void {
|
|
Storage::fake('exports');
|
|
});
|
|
|
|
it('adds the shared resolution case to the environment review output guidance state', function (): void {
|
|
$tenant = ManagedEnvironment::factory()->create(['name' => 'Spec350 Detail Blocked']);
|
|
[$owner, $tenant] = createUserWithTenant(tenant: $tenant, role: 'owner');
|
|
$snapshot = seedPartialEnvironmentReviewEvidence($tenant, findingCount: 0, driftCount: 0);
|
|
$review = composeEnvironmentReviewForTest($tenant, $owner, $snapshot);
|
|
$summary = array_replace_recursive(is_array($review->summary) ? $review->summary : [], [
|
|
'publish_blockers' => ['Operator approval note is still missing.'],
|
|
]);
|
|
|
|
$review->forceFill([
|
|
'status' => EnvironmentReviewStatus::Published->value,
|
|
'published_at' => now(),
|
|
'published_by_user_id' => (int) $owner->getKey(),
|
|
'summary' => $summary,
|
|
])->save();
|
|
|
|
Storage::disk('exports')->put('review-packs/spec350-detail-blocked.zip', 'PK-spec350-detail-blocked');
|
|
|
|
$pack = ReviewPack::factory()->ready()->create([
|
|
'managed_environment_id' => (int) $tenant->getKey(),
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'environment_review_id' => (int) $review->getKey(),
|
|
'evidence_snapshot_id' => (int) $snapshot->getKey(),
|
|
'initiated_by_user_id' => (int) $owner->getKey(),
|
|
'options' => [
|
|
'include_pii' => false,
|
|
'include_operations' => true,
|
|
],
|
|
'file_path' => 'review-packs/spec350-detail-blocked.zip',
|
|
'file_disk' => 'exports',
|
|
'generated_at' => now()->subMinutes(3),
|
|
]);
|
|
|
|
$review->forceFill(['current_export_review_pack_id' => (int) $pack->getKey()])->save();
|
|
|
|
setAdminEnvironmentContext($tenant);
|
|
$this->actingAs($owner);
|
|
|
|
$state = EnvironmentReviewResource::outputGuidanceState($review->fresh(['tenant', 'evidenceSnapshot', 'currentExportReviewPack.operationRun', 'operationRun']));
|
|
|
|
expect(data_get($state, 'resolution_case.key'))->toBe('review_output.publication_blocked')
|
|
->and(data_get($state, 'resolution_case.primary_action.key'))->toBe('create_next_review')
|
|
->and(data_get($state, 'resolution_case.primary_action.action_name'))->toBe('create_next_review')
|
|
->and(data_get($state, 'resolution_case.source_refs'))->toContainEqual(['type' => 'environment_review', 'id' => (int) $review->getKey()])
|
|
->and(data_get($state, 'resolution_case.source_refs'))->toContainEqual(['type' => 'review_pack', 'id' => (int) $pack->getKey()])
|
|
->and(data_get($state, 'resolution_case.evidence_refs'))->toHaveCount(1);
|
|
|
|
$this->actingAs($owner)
|
|
->get(EnvironmentReviewResource::environmentScopedUrl('view', ['record' => $review], $tenant))
|
|
->assertOk()
|
|
->assertSee('Output not customer-ready')
|
|
->assertSee('Create next review');
|
|
});
|
|
|
|
it('keeps the customer-workspace detail mode action suppression while retaining the shared case payload', function (): void {
|
|
$tenant = ManagedEnvironment::factory()->create(['name' => 'Spec350 Detail Context']);
|
|
[$owner, $tenant] = createUserWithTenant(tenant: $tenant, role: 'owner');
|
|
$snapshot = seedPartialEnvironmentReviewEvidence($tenant, findingCount: 0, driftCount: 0);
|
|
$review = composeEnvironmentReviewForTest($tenant, $owner, $snapshot);
|
|
$summary = array_replace_recursive(is_array($review->summary) ? $review->summary : [], [
|
|
'publish_blockers' => ['Operator approval note is still missing.'],
|
|
]);
|
|
|
|
$review->forceFill([
|
|
'status' => EnvironmentReviewStatus::Published->value,
|
|
'published_at' => now(),
|
|
'published_by_user_id' => (int) $owner->getKey(),
|
|
'summary' => $summary,
|
|
])->save();
|
|
|
|
Storage::disk('exports')->put('review-packs/spec350-detail-context.zip', 'PK-spec350-detail-context');
|
|
|
|
$pack = ReviewPack::factory()->ready()->create([
|
|
'managed_environment_id' => (int) $tenant->getKey(),
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'environment_review_id' => (int) $review->getKey(),
|
|
'evidence_snapshot_id' => (int) $snapshot->getKey(),
|
|
'initiated_by_user_id' => (int) $owner->getKey(),
|
|
'options' => [
|
|
'include_pii' => false,
|
|
'include_operations' => true,
|
|
],
|
|
'file_path' => 'review-packs/spec350-detail-context.zip',
|
|
'file_disk' => 'exports',
|
|
'generated_at' => now()->subMinutes(3),
|
|
]);
|
|
|
|
$review->forceFill(['current_export_review_pack_id' => (int) $pack->getKey()])->save();
|
|
|
|
setAdminEnvironmentContext($tenant);
|
|
|
|
$this->actingAs($owner)
|
|
->get(EnvironmentReviewResource::environmentScopedUrl('view', [
|
|
'record' => $review,
|
|
CustomerReviewWorkspace::DETAIL_CONTEXT_QUERY_KEY => 1,
|
|
], $tenant))
|
|
->assertOk()
|
|
->assertSee('Output not customer-ready')
|
|
->assertSee('Review limitations below')
|
|
->assertSee('You are already on the review detail for this output.')
|
|
->assertDontSee('Open evidence basis')
|
|
->assertDontSee('Open operation proof');
|
|
});
|