diff --git a/services/nginx/app/modules/selfserve/classes/selfserve_studio_graph.php b/services/nginx/app/modules/selfserve/classes/selfserve_studio_graph.php index ae64b78c..142cc9ff 100644 --- a/services/nginx/app/modules/selfserve/classes/selfserve_studio_graph.php +++ b/services/nginx/app/modules/selfserve/classes/selfserve_studio_graph.php @@ -4319,8 +4319,10 @@ class selfserve_studio_graph int $terminalPathCount, array $questionIds, array $progress = [], - array $confirmationRows = [] + ?array $confirmationRows = null ): array { + $confirmationRows = $confirmationRows ?? []; + usort($outcomes, static fn(array $left, array $right): int => ((int)($right['path_count'] ?? 0) <=> (int)($left['path_count'] ?? 0)) ?: strcmp((string)($left['summary'] ?? ''), (string)($right['summary'] ?? ''))); foreach ($outcomes as $index => &$outcome) { diff --git a/services/nginx/app/tests/Unit/Selfserve/SelfserveStudioGraphTest.php b/services/nginx/app/tests/Unit/Selfserve/SelfserveStudioGraphTest.php index b09e2bb2..d07611a7 100644 --- a/services/nginx/app/tests/Unit/Selfserve/SelfserveStudioGraphTest.php +++ b/services/nginx/app/tests/Unit/Selfserve/SelfserveStudioGraphTest.php @@ -1265,6 +1265,29 @@ it('marks projected path confirmations confirmed or stale by stable signatures', ->and($changed['summary']['confirmations']['stale'])->toBe(1); }); +it('treats null path confirmation rows as an empty confirmation set', function (): void { + $service = selfserve_studio_graph_without_constructor(); + $method = new ReflectionMethod(selfserve_studio_graph::class, 'pathOutcomesPayload'); + + $payload = $method->invoke( + $service, + ['department_id' => 6, 'lane_id' => 7], + [], + [], + [], + false, + null, + 0, + 0, + [], + [], + null + ); + + expect($payload['summary']['confirmations']['total'])->toBe(0) + ->and($payload['confirmations']['removed'])->toBe([]); +}); + it('truncates path outcome projection when the state cap is reached', function (): void { $service = selfserve_studio_graph_without_constructor(); $simulate = function (array $overrides): array {