TenantAtlas/tests/Unit
ahmido bcf4996a1e feat/049-backup-restore-job-orchestration (#56)
Summary

This PR implements Spec 049 – Backup/Restore Job Orchestration: all critical Backup/Restore execution paths are job-only, idempotent, tenant-scoped, and observable via run records + DB notifications (Phase 1). The UI no longer performs heavy Graph work inside request/Filament actions for these flows.

Why

We want predictable UX and operations at MSP scale:
	•	no timeouts / long-running requests
	•	reproducible run state + per-item results
	•	safe error persistence (no secrets / no token leakage)
	•	strict tenant isolation + auditability for write paths

What changed

Foundational (Runs + Idempotency + Observability)
	•	Added a shared RunIdempotency helper (dedupe while queued/running).
	•	Added a read-only BulkOperationRuns surface (list + view) for status/progress.
	•	Added DB notifications for run status changes (with “View run” link).

US1 – Policy “Capture snapshot” is job-only
	•	Policy detail “Capture snapshot” now:
	•	creates/reuses a run (dedupe key: tenant + policy.capture_snapshot + policy DB id)
	•	dispatches a queued job
	•	returns immediately with notification + link to run detail
	•	Graph capture work moved fully into the job; request path stays Graph-free.

US3 – Restore runs orchestration is job-only + safe
	•	Live restore execution is queued and updates RestoreRun status/progress.
	•	Per-item outcomes are persisted deterministically (per internal DB record).
	•	Audit logging is written for live restore.
	•	Preview/dry-run is enforced as read-only (no writes).

Tenant isolation / authorization (non-negotiable)
	•	Run list/view/start are tenant-scoped and policy-guarded (cross-tenant access => 403, not 404).
	•	Explicit Pest tests cover cross-tenant denial and start authorization.

Tests / Verification
	•	./vendor/bin/pint --dirty
	•	Targeted suite (examples):
	•	policy capture snapshot queued + idempotency tests
	•	restore orchestration + audit logging + preview read-only tests
	•	run authorization / tenant isolation tests

Notes / Scope boundaries
	•	Phase 1 UX = DB notifications + run detail page. A global “progress widget” is tracked as Phase 2 and not required for merge.
	•	Resilience/backoff is tracked in tasks but can be iterated further after merge.

Review focus
	•	Dedupe behavior for queued/running runs (reuse vs create-new)
	•	Tenant scoping & policy gates for all run surfaces
	•	Restore safety: audit event + preview no-writes

Co-authored-by: Ahmed Darrazi <ahmeddarrazi@adsmac.local>
Reviewed-on: #56
2026-01-11 15:59:06 +00:00
..
BackupScheduling fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
Inventory feat/040-inventory-core (#43) 2026-01-07 14:54:24 +00:00
AppProtectionPolicyNormalizerTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
AssignmentBackupServiceTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
AssignmentFetcherTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
AssignmentFilterResolverTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
AssignmentRestoreServiceTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
BackupItemTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
BulkActionPermissionTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
BulkBackupSetDeleteJobTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
BulkBackupSetForceDeleteJobTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
BulkBackupSetRestoreJobTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
BulkOperationAbortMethodTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
BulkOperationRunProgressTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
BulkPolicyDeleteJobTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
BulkPolicyExportJobTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
BulkPolicyVersionForceDeleteJobTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
BulkPolicyVersionPruneJobTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
BulkPolicyVersionRestoreJobTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
BulkRestoreRunDeleteJobTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
BulkRestoreRunRestoreJobTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
CircuitBreakerTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
CompliancePolicyNormalizerTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
CoverageCapabilitiesResolverTest.php feat/047-inventory-foundations-nodes (#51) 2026-01-10 20:47:29 +00:00
DefaultPolicyNormalizerDiffTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
DependencyExtractionServiceTest.php feat/042-inventory-dependencies-graph (#50) 2026-01-10 12:50:08 +00:00
DependencyTargetResolverTest.php feat/042-inventory-dependencies-graph (#50) 2026-01-10 12:50:08 +00:00
DeviceConfigurationPolicyNormalizerTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
ExampleTest.php Initial commit from Specify template 2025-12-10 22:27:21 +01:00
FoundationMappingServiceTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
FoundationSnapshotServiceTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
GraphClientEndpointResolutionTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
GraphClientScopeTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
GraphContractFallbackTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
GraphContractRegistryActualDataTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
GraphContractRegistrySettingsApplySanitizerTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
GraphContractRegistrySettingsWriteStrategyTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
GraphContractRegistryTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
GroupResolverTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
InventoryLinkTest.php feat/042-inventory-dependencies-graph (#49) 2026-01-10 00:20:14 +00:00
ManagedDeviceAppConfigurationNormalizerTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
MicrosoftGraphClientListPoliciesSelectTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
MicrosoftGraphClientTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
ODataTypeValidationTest.php feat/011-restore-run-wizard (#37) 2026-01-07 01:40:04 +00:00
PolicyCaptureOrchestratorTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
PolicyNormalizerRoutingTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
PolicyNormalizerSettingsCatalogFlattenTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
PolicyNormalizerSettingsCatalogTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
PolicyNormalizerTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
PolicyPickerOptionLabelTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
PolicySnapshotServiceTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
PolicyVersionEligibilityTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
RbacOnboardingServiceTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
RestoreRunDeletableTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
RestoreRunTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
RunIdempotencyTest.php feat/049-backup-restore-job-orchestration (#56) 2026-01-11 15:59:06 +00:00
ScopeTagResolverTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
ScriptsPolicyNormalizerTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
SettingsCatalogPolicyNormalizerTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
TenantCurrentTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
TenantPermissionServiceTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
TenantResourceConsentUrlTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
TenantScopeTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
VersionDiffTest.php feat: TenantPilot v1 - Complete implementation (Phases 1-12) 2025-12-12 02:27:54 +01:00
WindowsDriverUpdateProfileNormalizerTest.php fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00