create(['name' => 'Spec349 Blocked']); [$user, $environment] = createUserWithTenant(tenant: $environment, role: 'owner', workspaceRole: 'manager'); $snapshot = seedPartialEnvironmentReviewEvidence($environment, findingCount: 0, driftCount: 0); $review = composeEnvironmentReviewForTest($environment, $user, $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) $user->getKey(), 'summary' => $summary, ])->save(); Storage::disk('exports')->put('review-packs/spec349-blocked.zip', 'PK-spec349-blocked'); $pack = ReviewPack::factory()->ready()->create([ 'managed_environment_id' => (int) $environment->getKey(), 'workspace_id' => (int) $environment->workspace_id, 'environment_review_id' => (int) $review->getKey(), 'evidence_snapshot_id' => (int) $snapshot->getKey(), 'initiated_by_user_id' => (int) $user->getKey(), 'options' => [ 'include_pii' => true, 'include_operations' => true, ], 'file_path' => 'review-packs/spec349-blocked.zip', 'file_disk' => 'exports', 'generated_at' => now()->subMinutes(3), ]); $review->forceFill(['current_export_review_pack_id' => (int) $pack->getKey()])->save(); $component = spec349WorkspaceComponent($user, $environment) ->assertSee('Output not customer-ready') ->assertSee('Create next review') ->assertSee('Inspect review blockers') ->assertSee('Evidence basis incomplete') ->assertSee('Required review sections missing') ->assertSee('Internal package includes PII') ->assertSee('Create the next review cycle from the latest eligible evidence basis.') ->assertSee('Technical details'); $html = $component->html(); expect(substr_count($html, 'data-testid="customer-review-primary-action"'))->toBe(1) ->and($html)->toContain('data-testid="customer-review-output-limitations"') ->and($html)->not->toContain('data-testid="customer-review-output-limitations" open') ->and($html)->toContain('data-testid="customer-review-action-help"') ->and($html)->toContain('data-testid="customer-review-technical-details"') ->and($html)->not->toContain('data-testid="customer-review-technical-details" open') ->and($html)->not->toContain('Ready to share'); }); it('keeps the visible environment_id workspace filter contract while qualifying the internal download label', function (): void { $environment = ManagedEnvironment::factory()->create(['name' => 'Spec349 Internal']); [$user, $environment] = createUserWithTenant(tenant: $environment, role: 'readonly'); $snapshot = seedEnvironmentReviewEvidence($environment, findingCount: 0, driftCount: 0); $review = composeEnvironmentReviewForTest($environment, $user, $snapshot); $review->forceFill([ 'status' => EnvironmentReviewStatus::Published->value, 'published_at' => now(), 'published_by_user_id' => (int) $user->getKey(), ])->save(); $review = markEnvironmentReviewCustomerSafeReady($review); Storage::disk('exports')->put('review-packs/spec349-internal.zip', 'PK-spec349-internal'); $pack = ReviewPack::factory()->ready()->create([ 'managed_environment_id' => (int) $environment->getKey(), 'workspace_id' => (int) $environment->workspace_id, 'environment_review_id' => (int) $review->getKey(), 'evidence_snapshot_id' => (int) $snapshot->getKey(), 'initiated_by_user_id' => (int) $user->getKey(), 'options' => [ 'include_pii' => true, 'include_operations' => true, ], 'file_path' => 'review-packs/spec349-internal.zip', 'file_disk' => 'exports', 'generated_at' => now()->subMinutes(3), ]); $review->forceFill(['current_export_review_pack_id' => (int) $pack->getKey()])->save(); Livewire::withQueryParams([ 'environment_id' => (int) $environment->getKey(), ]) ->actingAs($user) ->test(CustomerReviewWorkspace::class) ->assertSee('Environment filter:') ->assertSee('Spec349 Internal') ->assertSee('Internal review package available') ->assertSee('Download internal review pack') ->assertDontSee('Download governance package') ->assertDontSee('Ready to share'); }); function spec349WorkspaceComponent(User $user, ManagedEnvironment $environment): mixed { session()->put(WorkspaceContext::SESSION_KEY, (int) $environment->workspace_id); setAdminPanelContext(); return Livewire::actingAs($user) ->test(CustomerReviewWorkspace::class); }