From 30de51c48a1c33a9acf69436d95e1bce375be64c Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Tue, 8 Sep 2026 01:08:39 -0400 Subject: [PATCH] =?UTF-8?q?test(commons):=20FlowGraphBuilder=20=E2=80=94?= =?UTF-8?q?=20a=20RouteCall=20root=20(flow=20debugger=20direct=20script=20?= =?UTF-8?q?call)=20builds=20Central=20=E2=86=92=20Site?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Claude-Session: https://claude.ai/code/session_01NcMG6xXdsJbmD2wYAgkK29 --- .../Debugging/FlowGraphBuilderTests.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/ZB.MOM.WW.ScadaBridge.Commons.Tests/Debugging/FlowGraphBuilderTests.cs b/tests/ZB.MOM.WW.ScadaBridge.Commons.Tests/Debugging/FlowGraphBuilderTests.cs index bfd3f478..9cf23c47 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.Commons.Tests/Debugging/FlowGraphBuilderTests.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.Commons.Tests/Debugging/FlowGraphBuilderTests.cs @@ -588,4 +588,34 @@ public class FlowGraphBuilderTests var into = Assert.Single(graph.Edges, e => e.ToEventId == graph.Steps[2].EventId); Assert.Equal(graph.Steps[1].EventId, into.FromEventId); } + + // ---- Script entry point (2026-09-08 plan, Task 6) ----------------------------------------- + + [Fact] + public void RouteCallRoot_WithoutInboundRow_BuildsCentralToSite_AndNoResponse() + { + // Flow Debugger script entry (design 2026-09-08 §4): a direct script call's root is an + // operator-attributed RouteCall row — there is no InboundRequest and no Response. + var root = Guid.NewGuid(); + var run = Guid.NewGuid(); + var events = new List + { + ScadaBridgeAuditEventFactory.Create(AuditChannel.ScriptTrace, AuditKind.RouteCall, AuditStatus.Delivered, + occurredAtUtc: T0, actor: "ops", target: "M1.Manual", sourceNode: "central-a", executionId: root, + sourceSiteId: "site-a", sourceInstanceId: "M1", durationMs: 50, requestSummary: "{\"n\":3}", responseSummary: "42", + extra: new ScriptTraceExtra { Source = "flow-debugger", ChildExecutionId = run }.ToJson()), + ScadaBridgeAuditEventFactory.Create(AuditChannel.ScriptTrace, AuditKind.ScriptRun, AuditStatus.Delivered, + occurredAtUtc: T0.AddMilliseconds(5), actor: "Manual", target: "Manual", sourceNode: "node-a", + executionId: run, parentExecutionId: root, sourceSiteId: "site-a", sourceInstanceId: "M1", durationMs: 40, + extra: new ScriptTraceExtra { TriggerKind = "call" }.ToJson()), + }; + + var graph = FlowGraphBuilder.Build(events); + + Assert.Equal([FlowStepKind.RouteCall, FlowStepKind.ScriptRun], graph.Steps.Select(s => s.Kind).ToList()); + Assert.Equal([FlowLane.Central, FlowLane.Site], graph.Steps.Select(s => s.Lane).ToList()); + var edge = Assert.Single(graph.Edges); + Assert.Equal((graph.Steps[0].EventId, graph.Steps[1].EventId, true), (edge.FromEventId, edge.ToEventId, edge.CrossesBoundary)); + Assert.DoesNotContain(graph.Steps, s => s.Kind == FlowStepKind.Response); + } }