fix(adminui): S7 typed page no longer wipes Tags on save
- S7DriverPage.FormModel now preserves Tags through Form ↔ Options translation (was hard-coding Tags = [] on every save, silently destroying any tag list that operators had configured). - Add FormModel_RoundTrip tests for OpcUaClient and Historian mirror classes — both were translating Options ↔ form-model entirely untested. - Surface S7 Tags in the round-trip test so this regression can't reach merge again.
This commit is contained in:
@@ -69,6 +69,12 @@ public sealed class S7DriverPageFormSerializationTests
|
||||
[Fact]
|
||||
public void FormModel_RoundTrip_PreservesEditableFields()
|
||||
{
|
||||
var tags = new[]
|
||||
{
|
||||
new S7TagDefinition("Speed", "DB1.DBD0", S7DataType.Float32, Writable: true),
|
||||
new S7TagDefinition("Status", "DB1.DBW4", S7DataType.Int16, Writable: false),
|
||||
};
|
||||
|
||||
var opts = new S7DriverOptions
|
||||
{
|
||||
Host = "192.168.1.50",
|
||||
@@ -84,6 +90,7 @@ public sealed class S7DriverPageFormSerializationTests
|
||||
Timeout = TimeSpan.FromSeconds(4),
|
||||
},
|
||||
ProbeTimeoutSeconds = 20,
|
||||
Tags = tags,
|
||||
};
|
||||
|
||||
var form = ZB.MOM.WW.OtOpcUa.AdminUI.Components.Pages.Clusters.Drivers
|
||||
@@ -100,5 +107,14 @@ public sealed class S7DriverPageFormSerializationTests
|
||||
roundTripped.Probe.Interval.ShouldBe(TimeSpan.FromSeconds(8));
|
||||
roundTripped.Probe.Timeout.ShouldBe(TimeSpan.FromSeconds(4));
|
||||
roundTripped.ProbeTimeoutSeconds.ShouldBe(20);
|
||||
|
||||
// Tags must survive the FormModel round-trip unchanged (regression guard for the
|
||||
// Tags = [] data-loss bug fixed in this PR).
|
||||
roundTripped.Tags.Count.ShouldBe(2);
|
||||
roundTripped.Tags[0].Name.ShouldBe("Speed");
|
||||
roundTripped.Tags[0].Address.ShouldBe("DB1.DBD0");
|
||||
roundTripped.Tags[0].DataType.ShouldBe(S7DataType.Float32);
|
||||
roundTripped.Tags[1].Name.ShouldBe("Status");
|
||||
roundTripped.Tags[1].Writable.ShouldBeFalse();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user