feat(flow-debugger): predict the reset write + echo wait of the reset-aware handshake (#36)
Claude-Session: https://claude.ai/code/session_01XPsuy2ZZ5Gbyfpt8PrK5BV
This commit is contained in:
@@ -313,4 +313,46 @@ public class FlowShapePredictorTests
|
||||
Assert.True(write.InputDependent);
|
||||
Assert.Equal("name", write.Title);
|
||||
}
|
||||
|
||||
/// <summary>Gitea #36: the reset-aware overload predicts the reset write + echo wait ahead of the batch.</summary>
|
||||
[Fact]
|
||||
public void ResetAwareWriteBatchAndWait_PredictsResetWriteAndEchoWaitBeforeTheBatch()
|
||||
{
|
||||
const string body = """
|
||||
var data = new System.Collections.Generic.Dictionary<string, object?> { { "MoveOutBatchID", 1 } };
|
||||
var hs = await Children["RightMESReceiver"].Attributes.WriteBatchAndWaitAsync(
|
||||
data, "MoveOutFlag", true, "MoveOutCompleteFlag", true, System.TimeSpan.FromSeconds(25),
|
||||
"MoveOutCompleteFlag", false, System.TimeSpan.FromSeconds(10));
|
||||
if (hs.ResetFailed) return new { WasSuccessful = false };
|
||||
""";
|
||||
|
||||
var flow = FlowShapePredictor.PredictSiteScript("MesMoveOut", body);
|
||||
|
||||
Assert.Equal(
|
||||
[
|
||||
(FlowStepKind.ScriptRun, FlowLane.Site, "MesMoveOut"),
|
||||
(FlowStepKind.AttributeWrite, FlowLane.Tags, "MoveOutCompleteFlag"),
|
||||
(FlowStepKind.AttributeWait, FlowLane.Site, "MoveOutCompleteFlag"),
|
||||
(FlowStepKind.AttributeWrite, FlowLane.Tags, "batch + MoveOutFlag"),
|
||||
(FlowStepKind.AttributeWait, FlowLane.Site, "MoveOutCompleteFlag"),
|
||||
], flow.Nodes.Select(n => (n.Kind, n.Lane, n.Title)).ToList());
|
||||
Assert.Equal("reset", flow.Nodes[1].Note);
|
||||
Assert.Equal("reset echo", flow.Nodes[2].Note);
|
||||
}
|
||||
|
||||
/// <summary>Named reset arguments resolve by name, not position.</summary>
|
||||
[Fact]
|
||||
public void ResetAwareWriteBatchAndWait_NamedArguments_ResolveTheResetKey()
|
||||
{
|
||||
const string body = """
|
||||
var hs = await Attributes.WriteBatchAndWaitAsync(data, "Trig", true, "Done", true, t,
|
||||
resetKey: "Done", resetValue: false);
|
||||
""";
|
||||
|
||||
var flow = FlowShapePredictor.PredictSiteScript("S", body);
|
||||
|
||||
Assert.Equal("Done", flow.Nodes[1].Title);
|
||||
Assert.Equal(FlowStepKind.AttributeWrite, flow.Nodes[1].Kind);
|
||||
Assert.Equal(5, flow.Nodes.Count);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user