Skip to content

Commit b61593f

Browse files
committed
fix(insert-from-url): correct the NoInteract <-> WithDialog inversion
NoInteract state='True' means 'suppress the dialog' = 'With dialog: Off'. The ToXml and FromXml were mapping 'WithDialog=true' to state='True' (semantically backwards); round-trips were byte-intact but the display text said 'With dialog: On' for steps that FM Pro authored with the dialog suppressed and vice versa. Also added regression tests that pin both directions of the mapping so the invariant can't silently invert again.
1 parent 69fe485 commit b61593f

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

src/SharpFM.Model/Scripting/Steps/InsertFromUrlStep.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ public override XElement ToXml()
4444
new XAttribute("enable", Enabled ? "True" : "False"),
4545
new XAttribute("id", XmlId),
4646
new XAttribute("name", XmlName),
47-
new XElement("NoInteract", new XAttribute("state", WithDialog ? "True" : "False")),
47+
// NoInteract is inverted: state="True" suppresses the dialog
48+
// (= With dialog: Off). state="False" shows it.
49+
new XElement("NoInteract", new XAttribute("state", WithDialog ? "False" : "True")),
4850
new XElement("DontEncodeURL", new XAttribute("state", DontEncodeUrl ? "True" : "False")),
4951
new XElement("SelectAll", new XAttribute("state", SelectAll ? "True" : "False")),
5052
new XElement("VerifySSLCertificates", new XAttribute("state", VerifySslCertificates ? "True" : "False")));
@@ -75,7 +77,8 @@ public override string ToDisplayLine()
7577
public static new ScriptStep FromXml(XElement step)
7678
{
7779
var enabled = step.Attribute("enable")?.Value != "False";
78-
var withDialog = step.Element("NoInteract")?.Attribute("state")?.Value == "True";
80+
// NoInteract inverted: state="True" = dialog suppressed = WithDialog: Off.
81+
var withDialog = step.Element("NoInteract")?.Attribute("state")?.Value != "True";
7982
var dontEncode = step.Element("DontEncodeURL")?.Attribute("state")?.Value == "True";
8083
var selectAll = step.Element("SelectAll")?.Attribute("state")?.Value == "True";
8184
var verify = step.Element("VerifySSLCertificates")?.Attribute("state")?.Value == "True";

tests/SharpFM.Tests/Scripting/Steps/InsertFromUrlStepTests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,34 @@ public void RealWorldShapes_RoundTrip(
6363
$"Round-trip mismatch.\nSource:\n{source}\n\nOutput:\n{step.ToXml()}");
6464
}
6565

66+
[Fact]
67+
public void NoInteract_True_RendersAsWithDialogOff()
68+
{
69+
// FM Pro semantics: NoInteract state="True" suppresses the dialog.
70+
// Display must say "With dialog: Off".
71+
var source = XElement.Parse(
72+
"<Step enable=\"True\" id=\"160\" name=\"Insert from URL\">"
73+
+ "<NoInteract state=\"True\" /><DontEncodeURL state=\"False\" />"
74+
+ "<SelectAll state=\"True\" /><VerifySSLCertificates state=\"False\" />"
75+
+ "</Step>");
76+
var step = (InsertFromUrlStep)InsertFromUrlStep.Metadata.FromXml!(source);
77+
Assert.False(step.WithDialog);
78+
Assert.Contains("With dialog: Off", step.ToDisplayLine());
79+
}
80+
81+
[Fact]
82+
public void NoInteract_False_RendersAsWithDialogOn()
83+
{
84+
var source = XElement.Parse(
85+
"<Step enable=\"True\" id=\"160\" name=\"Insert from URL\">"
86+
+ "<NoInteract state=\"False\" /><DontEncodeURL state=\"False\" />"
87+
+ "<SelectAll state=\"True\" /><VerifySSLCertificates state=\"False\" />"
88+
+ "</Step>");
89+
var step = (InsertFromUrlStep)InsertFromUrlStep.Metadata.FromXml!(source);
90+
Assert.True(step.WithDialog);
91+
Assert.Contains("With dialog: On", step.ToDisplayLine());
92+
}
93+
6694
[Fact]
6795
public void Display_BaseShape_IsValidatorClean()
6896
{

0 commit comments

Comments
 (0)