create(['name' => 'Spec347 Ready']); [$user, $environment] = createUserWithTenant(tenant: $environment, role: 'owner', workspaceRole: 'manager'); $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); $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' => false, 'include_operations' => true, ], ]); $review->forceFill(['current_export_review_pack_id' => (int) $pack->getKey()])->save(); spec347WorkspaceComponent($user, $environment) ->assertSee('What is the current review pack output state?') ->assertSee('Customer-safe review pack ready') ->assertSee('Customer-safe') ->assertSee('Download customer-safe review pack') ->assertSee('PII excluded') ->assertDontSee('Ready to share'); }); it('shows blocked output guidance when evidence is incomplete and review blockers remain recorded', function (): void { $environment = ManagedEnvironment::factory()->create(['name' => 'Spec347 Limitations']); [$user, $environment] = createUserWithTenant(tenant: $environment, role: 'readonly'); $snapshot = seedPartialEnvironmentReviewEvidence($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(); $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' => false, 'include_operations' => true, ], ]); $review->forceFill(['current_export_review_pack_id' => (int) $pack->getKey()])->save(); spec347WorkspaceComponent($user, $environment) ->assertSee('Output not customer-ready') ->assertSee('Review blockers are still recorded for this output.') ->assertSee('Requires review') ->assertSee('Download review pack with limitations') ->assertDontSee('Ready to share'); }); it('shows the internal-only workspace state when the export contains pii', function (): void { $environment = ManagedEnvironment::factory()->create(['name' => 'Spec347 Internal']); [$user, $environment] = createUserWithTenant(tenant: $environment, role: 'owner', workspaceRole: 'manager'); $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); $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, ], ]); $review->forceFill(['current_export_review_pack_id' => (int) $pack->getKey()])->save(); spec347WorkspaceComponent($user, $environment) ->assertSee('Internal review package available') ->assertSee('Internal only') ->assertSee('Contains PII') ->assertSee('Review PII/redaction state') ->assertSee('Download internal review pack') ->assertDontSee('Customer-safe review pack ready'); }); function spec347WorkspaceComponent(User $user, ManagedEnvironment $environment): mixed { session()->put(WorkspaceContext::SESSION_KEY, (int) $environment->workspace_id); setAdminPanelContext(); return Livewire::actingAs($user) ->test(CustomerReviewWorkspace::class); }