feat(adminui): B2-WP3 driver/device config modals + page-to-form refactor
Extract the 8 typed driver pages into embeddable <Driver>DriverForm bodies (channel/protocol config) and add per-driver <Driver>DeviceForm bodies (connection endpoint -> Device.DeviceConfig, v3 endpoint split). New DriverConfigModal + DeviceModal dispatch by DriverType (DriverTypeNames) for the /raw tree; Test-connect inside DeviceModal builds the merged Driver+Device config transiently via DriverDeviceConfigMerger. Routed pages now host the form bodies and keep working. Round-trip + enum-serialization guard tests for the Modbus driver form + Modbus device model; retargeted the existing page-form serialization tests + the _jsonOpts converter guard to the forms. Claude-Session: https://claude.ai/code/session_01LVneM3eh1UtJxEisFXgmox
This commit is contained in:
+7
-46
@@ -2,7 +2,7 @@ using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Pages.Clusters.Drivers;
|
||||
using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers.Forms;
|
||||
using ZB.MOM.WW.OtOpcUa.Driver.AbCip;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests;
|
||||
@@ -79,59 +79,20 @@ public sealed class AbCipDriverPageFormSerializationTests
|
||||
back.ProbeTimeoutSeconds.ShouldBe(10);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DeviceRow_round_trips_through_definition()
|
||||
{
|
||||
var row = new AbCipDriverPage.AbCipDeviceRow
|
||||
{
|
||||
HostAddress = "ab://10.0.0.1/1,0", PlcFamily = AbCipPlcFamily.CompactLogix, DeviceName = "PLC-A",
|
||||
};
|
||||
var def = row.ToDefinition();
|
||||
var back = AbCipDriverPage.AbCipDeviceRow.FromDefinition(def);
|
||||
|
||||
back.HostAddress.ShouldBe("ab://10.0.0.1/1,0");
|
||||
back.PlcFamily.ShouldBe(AbCipPlcFamily.CompactLogix);
|
||||
back.DeviceName.ShouldBe("PLC-A");
|
||||
}
|
||||
// v3 Batch-2 (WP3): the embedded-Devices CollectionEditor + AbCipDeviceRow retired — devices are now
|
||||
// separate Device entities authored via the raw-tree DeviceModal (AbCipDeviceModel, HostAddress/PlcFamily
|
||||
// into DeviceConfig). The former DeviceRow_* / ValidateDeviceRow_* tests were removed. The channel-config
|
||||
// FormModel now lives in AbCipDriverForm; the multi-device Devices array it preserves is covered below.
|
||||
|
||||
[Fact]
|
||||
public void DeviceRow_preserves_unedited_fields()
|
||||
{
|
||||
var original = new AbCipDeviceOptions(
|
||||
"ab://10.0.0.1/1,0", AbCipPlcFamily.ControlLogix, "PLC-A",
|
||||
AllowPacking: true, ConnectionSize: 4002);
|
||||
var row = AbCipDriverPage.AbCipDeviceRow.FromDefinition(original);
|
||||
row.HostAddress = "ab://10.0.0.2/1,0";
|
||||
|
||||
var back = row.ToDefinition();
|
||||
back.HostAddress.ShouldBe("ab://10.0.0.2/1,0");
|
||||
back.AllowPacking.ShouldBe(true);
|
||||
back.ConnectionSize.ShouldBe(4002);
|
||||
}
|
||||
|
||||
// v3 Batch-1 migration: the pre-declared Tags editor (AbCipDriverPage.AbCipTagRow +
|
||||
// AbCipDriverOptions.Tags) was retired — tags moved to the Raw tree (/raw, Batch 2). The former
|
||||
// TagRow_* / ValidateTagRow_* tests and the tag leg of the list-serialization test were removed.
|
||||
// The multi-device Devices editor is RETAINED, so its coverage (DeviceRow_* + ValidateDeviceRow_*
|
||||
// + the device-list serialization below, all carrying the AbCipPlcFamily enum) stays.
|
||||
|
||||
[Fact]
|
||||
public void ValidateDeviceRow_rejects_duplicate_host()
|
||||
{
|
||||
var rows = new List<AbCipDriverPage.AbCipDeviceRow> { new() { HostAddress = "ab://10.0.0.1/1,0" } };
|
||||
AbCipDriverPage.AbCipDeviceRow.ValidateRow(new() { HostAddress = "ab://10.0.0.1/1,0" }, rows, null)
|
||||
.ShouldNotBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Device_list_survives_options_serialize_round_trip()
|
||||
public void Device_list_survives_form_serialize_round_trip()
|
||||
{
|
||||
var devices = new List<AbCipDeviceOptions>
|
||||
{
|
||||
new("ab://10.0.0.1/1,0", AbCipPlcFamily.ControlLogix, "PLC-1"),
|
||||
new("ab://10.0.0.2/1,0", AbCipPlcFamily.CompactLogix, "PLC-2"),
|
||||
};
|
||||
var opts = new AbCipDriverPage.FormModel().ToOptions(devices);
|
||||
var opts = new AbCipDriverForm.FormModel().ToOptions(devices);
|
||||
var json = JsonSerializer.Serialize(opts, TestJsonOpts);
|
||||
var back = JsonSerializer.Deserialize<AbCipDriverOptions>(json, TestJsonOpts)!;
|
||||
back.Devices.Count.ShouldBe(2);
|
||||
|
||||
Reference in New Issue
Block a user