TenantAtlas/tests/Unit
ahmido 30ad57baab feat/053-unify-runs-monitoring (#60)
Summary

This PR introduces Unified Operations Runs + Monitoring Hub (053).

Goal: Standardize how long-running operations are tracked and monitored using the existing tenant-scoped run record (BulkOperationRun) as the canonical “operation run”, and surface it in a single Monitoring → Operations hub (view-only, tenant-scoped, role-aware).

Phase 1 adoption scope (per spec):
	•	Drift generation (drift.generate)
	•	Backup Set “Add Policies” (backup_set.add_policies)

Note: This PR does not convert every run type yet (e.g. GroupSyncRuns / InventorySyncRuns remain separate for now). This is intentionally incremental.

⸻

What changed

Monitoring / Operations hub
	•	Moved/organized run monitoring under Monitoring → Operations
	•	Added:
	•	status buckets (queued / running / succeeded / partially succeeded / failed)
	•	filters (run type, status bucket, time range)
	•	run detail “Related” links (e.g. Drift findings, Backup Set context)
	•	All hub pages are DB-only and view-only (no rerun/cancel/delete actions)

Canonical run semantics
	•	Added canonical helpers on BulkOperationRun:
	•	runType() (resource.action)
	•	statusBucket() derived from status + counts (testable semantics)

Drift integration (Phase 1)
	•	Drift generation start behavior now:
	•	creates/reuses a BulkOperationRun with drift context payload (scope_key + baseline/current run ids)
	•	dispatches generation job
	•	emits DB notifications including “View run” link
	•	On generation failure: stores sanitized failure entries + sends failure notification

Permissions / tenant isolation
	•	Monitoring run list/view is tenant-scoped and returns 403 for cross-tenant access
	•	Readonly can view runs but cannot start drift generation

⸻

Tests

Added/updated Pest coverage:
	•	BulkOperationRunStatusBucketTest.php
	•	DriftGenerationDispatchTest.php
	•	GenerateDriftFindingsJobNotificationTest.php
	•	RunAuthorizationTenantIsolationTest.php

Validation run locally:
	•	./vendor/bin/pint --dirty
	•	targeted tests from feature quickstart / drift monitoring tests

⸻

Manual QA
	1.	Go to Monitoring → Operations
	•	verify filters (run type / status / time range)
	•	verify run detail shows counts + sanitized failures + “Related” links
	2.	Open Drift Landing
	•	with >=2 successful inventory runs for scope: should queue drift generation + show notification with “View run”
	•	as readonly: should not start generation
	3.	Run detail
	•	drift.generate runs show “Drift findings” related link
	•	failure entries are sanitized (no secrets/tokens/raw payload dumps)

⸻

Notes / Ops
	•	Queue workers must be restarted after deploy so they load the new code:
	•	php artisan queue:restart (or Sail equivalent)
	•	This PR standardizes monitoring for Phase 1 producers only; follow-ups will migrate additional run types into the unified pattern.

⸻

Spec / Docs
	•	SpecKit artifacts added under specs/053-unify-runs-monitoring/
	•	Checklists are complete:
	•	requirements checklist PASS
	•	writing checklist PASS

Co-authored-by: Ahmed Darrazi <ahmeddarrazi@adsmac.local>
Reviewed-on: #60
2026-01-16 15:10:31 +00:00
..
BackupScheduling fix(tests): remove per-file TestCase uses (#45) 2026-01-08 00:41:46 +00:00
DirectoryGroups 051-entra-group-directory-cache (#57) 2026-01-11 23:24:12 +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 feat/052-async-add-policies (#59) 2026-01-15 22:20:16 +00:00
BulkOperationRunStatusBucketTest.php feat/053-unify-runs-monitoring (#60) 2026-01-16 15:10:31 +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