makePortfolioTriageActor('Anchor Tenant'); $weakenedTenant = $this->makePortfolioTriagePeer($user, $anchorTenant, 'Weakened Tenant'); $backupSet = $this->seedPortfolioBackupConcern($weakenedTenant, TenantBackupHealthAssessment::POSTURE_STALE); $this->seedPortfolioRecoveryConcern($weakenedTenant, RestoreResultAttention::STATE_COMPLETED_WITH_FOLLOW_UP, $backupSet); $triageState = [ 'backup_posture' => [TenantBackupHealthAssessment::POSTURE_STALE], 'recovery_evidence' => [TenantRecoveryTriagePresentation::RECOVERY_EVIDENCE_WEAKENED], 'triage_sort' => TenantRecoveryTriagePresentation::TRIAGE_SORT_WORST_FIRST, ]; $this->usePortfolioTriageWorkspace($user, $anchorTenant); $expectedUrl = TenantResource::tenantDashboardOpenUrl($weakenedTenant, $triageState); $this->portfolioTriageRegistryList($user, $anchorTenant, $triageState) ->assertTableActionHasUrl('openTenant', $expectedUrl, $weakenedTenant); expect(tenantRegistryArrivalStateFromUrl($expectedUrl))->toMatchArray([ 'sourceSurface' => PortfolioArrivalContextToken::SOURCE_TENANT_REGISTRY, 'tenantRouteKey' => (string) $weakenedTenant->external_id, 'workspaceId' => (int) $weakenedTenant->workspace_id, 'concernFamily' => PortfolioArrivalContextToken::FAMILY_RECOVERY_EVIDENCE, 'concernState' => TenantRecoveryTriagePresentation::RECOVERY_EVIDENCE_WEAKENED, 'concernReason' => RestoreResultAttention::STATE_COMPLETED_WITH_FOLLOW_UP, 'returnFilters' => [ 'backup_posture' => [TenantBackupHealthAssessment::POSTURE_STALE], 'recovery_evidence' => [TenantRecoveryTriagePresentation::RECOVERY_EVIDENCE_WEAKENED], 'triage_sort' => TenantRecoveryTriagePresentation::TRIAGE_SORT_WORST_FIRST, ], ]); }); it('keeps generic registry opens free of arrival context when triage intent is not active', function (): void { [$user, $tenant] = $this->makePortfolioTriageActor('Generic Registry Tenant'); $expectedUrl = TenantDashboard::getUrl(panel: 'tenant', tenant: $tenant); $this->usePortfolioTriageWorkspace($user, $tenant); $this->get(TenantResource::getUrl('index', panel: 'admin')) ->assertOk() ->assertSee($expectedUrl, false); expect($expectedUrl)->not->toContain(PortfolioArrivalContextToken::QUERY_PARAMETER.'='); }); it('chooses the leading visible concern when worst-first triage is active without explicit family filters', function (): void { [$user, $anchorTenant] = $this->makePortfolioTriageActor('Worst First Anchor'); $priorityTenant = $this->makePortfolioTriagePeer($user, $anchorTenant, 'Priority Tenant'); $this->seedPortfolioBackupConcern($priorityTenant, TenantBackupHealthAssessment::POSTURE_STALE); $this->seedPortfolioRecoveryConcern($priorityTenant, RestoreResultAttention::STATE_PARTIAL); $this->usePortfolioTriageWorkspace($user, $anchorTenant); $expectedUrl = TenantResource::tenantDashboardOpenUrl($priorityTenant, [ 'triage_sort' => TenantRecoveryTriagePresentation::TRIAGE_SORT_WORST_FIRST, ]); $this->portfolioTriageRegistryList($user, $anchorTenant, [ 'triage_sort' => TenantRecoveryTriagePresentation::TRIAGE_SORT_WORST_FIRST, ]) ->assertTableActionHasUrl('openTenant', $expectedUrl, $priorityTenant); expect(tenantRegistryArrivalStateFromUrl($expectedUrl))->toMatchArray([ 'sourceSurface' => PortfolioArrivalContextToken::SOURCE_TENANT_REGISTRY, 'concernFamily' => PortfolioArrivalContextToken::FAMILY_RECOVERY_EVIDENCE, 'concernState' => TenantRecoveryTriagePresentation::RECOVERY_EVIDENCE_WEAKENED, 'concernReason' => RestoreResultAttention::STATE_PARTIAL, ]); });