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:
Joseph Doherty
2026-07-16 03:26:24 -04:00
parent 54ab413396
commit 844f93f64f
44 changed files with 3728 additions and 2474 deletions
@@ -2,6 +2,7 @@ using System.Text.Json;
using System.Text.Json.Serialization;
using Shouldly;
using Xunit;
using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers.Forms;
using ZB.MOM.WW.OtOpcUa.Driver.TwinCAT;
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests;
@@ -80,8 +81,7 @@ public sealed class TwinCATDriverPageFormSerializationTests
ProbeTimeoutSeconds = 15,
};
var form = ZB.MOM.WW.OtOpcUa.AdminUI.Components.Pages.Clusters.Drivers
.TwinCATDriverPage.FormModel.FromOptions(opts);
var form = TwinCATDriverForm.FormModel.FromOptions(opts);
var roundTripped = form.ToOptions([]);
roundTripped.Timeout.ShouldBe(TimeSpan.FromSeconds(3));
@@ -94,60 +94,15 @@ public sealed class TwinCATDriverPageFormSerializationTests
roundTripped.ProbeTimeoutSeconds.ShouldBe(15);
}
[Fact]
public void DeviceRow_RoundTrip_PreservesEditableFields()
{
var def = new TwinCATDeviceOptions("192.168.0.1.1.1:851", "PLC1");
var row = ZB.MOM.WW.OtOpcUa.AdminUI.Components.Pages.Clusters.Drivers
.TwinCATDriverPage.TwinCATDeviceRow.FromDefinition(def);
var back = row.ToDefinition();
back.HostAddress.ShouldBe("192.168.0.1.1.1:851");
back.DeviceName.ShouldBe("PLC1");
}
[Fact]
public void DeviceRow_CarriesThroughUneditedSourceFields()
{
// Edit only DeviceName; HostAddress on the source must survive the round-trip via _source.
var def = new TwinCATDeviceOptions("10.0.0.5.1.1:851", "Original");
var row = ZB.MOM.WW.OtOpcUa.AdminUI.Components.Pages.Clusters.Drivers
.TwinCATDriverPage.TwinCATDeviceRow.FromDefinition(def);
row.DeviceName = "Renamed";
var back = row.ToDefinition();
back.HostAddress.ShouldBe("10.0.0.5.1.1:851");
back.DeviceName.ShouldBe("Renamed");
}
[Fact]
public void DeviceRow_ValidateRow_RejectsDuplicateHostAddress()
{
var existing = ZB.MOM.WW.OtOpcUa.AdminUI.Components.Pages.Clusters.Drivers
.TwinCATDriverPage.TwinCATDeviceRow.FromDefinition(new TwinCATDeviceOptions("192.168.0.1.1.1:851"));
var dup = new ZB.MOM.WW.OtOpcUa.AdminUI.Components.Pages.Clusters.Drivers
.TwinCATDriverPage.TwinCATDeviceRow { HostAddress = "192.168.0.1.1.1:851" };
var all = new[] { existing, dup };
var error = ZB.MOM.WW.OtOpcUa.AdminUI.Components.Pages.Clusters.Drivers
.TwinCATDriverPage.TwinCATDeviceRow.ValidateRow(dup, all, editIndex: 1);
error.ShouldNotBeNull();
error.ShouldContain("Duplicate");
}
// v3 Batch-1 migration: the pre-declared Tags editor (TwinCATDriverPage.TwinCATTagRow +
// TwinCATDriverOptions.Tags) was retired — tags moved to the Raw tree (/raw, Batch 2). The former
// TagRow_* tests and the tag leg of FormModel_ToOptions_* were removed. The multi-device Devices
// editor is RETAINED, so its coverage (DeviceRow_* + the device-list serialization below) stays.
// v3 Batch-2 (WP3): the embedded-Devices CollectionEditor + TwinCATDeviceRow retired — devices are now
// separate Device entities authored via the raw-tree DeviceModal (TwinCATDeviceModel, HostAddress into
// DeviceConfig). The former DeviceRow_* tests were removed. The channel-config FormModel now lives in
// TwinCATDriverForm; the multi-device Devices array it preserves is covered below.
[Fact]
public void FormModel_ToOptions_SerializesDeviceList()
{
var form = ZB.MOM.WW.OtOpcUa.AdminUI.Components.Pages.Clusters.Drivers
.TwinCATDriverPage.FormModel.FromOptions(new TwinCATDriverOptions());
var form = TwinCATDriverForm.FormModel.FromOptions(new TwinCATDriverOptions());
var devices = new[] { new TwinCATDeviceOptions("192.168.0.1.1.1:851", "PLC1") };