actingAs($user); Filament::setTenant($tenant, true); $backupSet = BackupSet::factory()->create([ 'managed_environment_id' => (int) $tenant->getKey(), ]); $operationRun = OperationRun::factory()->forTenant($tenant)->create([ 'type' => OperationRunType::RestoreExecute->value, 'status' => OperationRunStatus::Completed->value, 'outcome' => OperationRunOutcome::Succeeded->value, 'completed_at' => now(), ]); $restoreRun = RestoreRun::factory()->for($tenant, 'tenant')->for($backupSet)->create([ 'status' => 'completed', 'operation_run_id' => (int) $operationRun->getKey(), 'metadata' => [ 'total' => 1, 'succeeded' => 1, 'failed' => 0, 'skipped' => 0, 'partial' => 0, 'non_applied' => 0, ], ]); $presenter = app(RestoreRunDetailPresenter::class); $first = $presenter->forRun($restoreRun->fresh(['backupSet', 'operationRun', 'tenant'])); expect(data_get($first, 'decision.state'))->toBe('completed_proof_incomplete') ->and(data_get($first, 'operationProof.state'))->toBe('available') ->and(data_get($first, 'postRunEvidence.state'))->toBe('unavailable'); EvidenceSnapshot::query()->create([ 'managed_environment_id' => (int) $tenant->getKey(), 'workspace_id' => (int) $tenant->workspace_id, 'operation_run_id' => (int) $operationRun->getKey(), 'status' => EvidenceSnapshotStatus::Active->value, 'completeness_state' => EvidenceCompletenessState::Complete->value, 'summary' => ['finding_count' => 0], 'generated_at' => now(), ]); $second = $presenter->forRun($restoreRun->fresh(['backupSet', 'operationRun', 'tenant'])); expect(data_get($second, 'decision.state'))->toBe('completed_with_evidence') ->and(data_get($second, 'postRunEvidence.state'))->toBe('available') ->and(data_get($second, 'postRunEvidence.identifier'))->toContain('Evidence snapshot #'); }); it('does not expose operation proof from another workspace or environment', function (): void { [$user, $tenant] = createUserWithTenant(role: 'owner'); $this->actingAs($user); Filament::setTenant($tenant, true); $backupSet = BackupSet::factory()->create([ 'managed_environment_id' => (int) $tenant->getKey(), ]); $foreignTenant = \App\Models\ManagedEnvironment::factory()->create(); $foreignOperationRun = OperationRun::factory()->forTenant($foreignTenant)->create([ 'type' => OperationRunType::RestoreExecute->value, 'status' => OperationRunStatus::Completed->value, 'outcome' => OperationRunOutcome::Succeeded->value, 'completed_at' => now(), ]); $restoreRun = RestoreRun::factory()->for($tenant, 'tenant')->for($backupSet)->create([ 'status' => 'completed', 'operation_run_id' => (int) $foreignOperationRun->getKey(), ]); $surface = app(RestoreRunDetailPresenter::class) ->forRun($restoreRun->fresh(['backupSet', 'operationRun', 'tenant'])); expect(data_get($surface, 'operationProof.state'))->toBe('unavailable') ->and(data_get($surface, 'operationProof.url'))->toBeNull() ->and(data_get($surface, 'postRunEvidence.state'))->toBe('unavailable'); });