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:
+8
-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.FOCAS;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests;
|
||||
@@ -119,8 +119,7 @@ public sealed class FocasDriverPageFormSerializationTests
|
||||
},
|
||||
};
|
||||
|
||||
var form = ZB.MOM.WW.OtOpcUa.AdminUI.Components.Pages.Clusters.Drivers
|
||||
.FocasDriverPage.FormModel.FromOptions(opts);
|
||||
var form = FocasDriverForm.FormModel.FromOptions(opts);
|
||||
var roundTripped = form.ToOptions([]);
|
||||
|
||||
roundTripped.Timeout.ShouldBe(TimeSpan.FromSeconds(4));
|
||||
@@ -138,57 +137,20 @@ public sealed class FocasDriverPageFormSerializationTests
|
||||
roundTripped.FixedTree.TimerPollInterval.ShouldBe(TimeSpan.FromSeconds(45));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DeviceRow_round_trips_through_definition()
|
||||
{
|
||||
var row = new FocasDriverPage.FocasDeviceRow
|
||||
{
|
||||
HostAddress = "192.168.0.10:8193", Series = FocasCncSeries.Thirty_i, DeviceName = "CNC1",
|
||||
};
|
||||
var def = row.ToDefinition();
|
||||
var back = FocasDriverPage.FocasDeviceRow.FromDefinition(def);
|
||||
|
||||
back.HostAddress.ShouldBe("192.168.0.10:8193");
|
||||
back.Series.ShouldBe(FocasCncSeries.Thirty_i);
|
||||
back.DeviceName.ShouldBe("CNC1");
|
||||
}
|
||||
// v3 Batch-2 (WP3): the embedded-Devices CollectionEditor + FocasDeviceRow retired — devices are now
|
||||
// separate Device entities authored via the raw-tree DeviceModal (FocasDeviceModel, HostAddress/Series
|
||||
// into DeviceConfig). The former DeviceRow_* / ValidateDeviceRow_* tests were removed. The channel-config
|
||||
// FormModel now lives in FocasDriverForm; the multi-device Devices array it preserves is covered below.
|
||||
|
||||
[Fact]
|
||||
public void DeviceRow_preserves_unedited_fields()
|
||||
{
|
||||
var original = new FocasDeviceOptions("192.168.0.10:8193", "CNC1", FocasCncSeries.Thirty_i);
|
||||
var row = FocasDriverPage.FocasDeviceRow.FromDefinition(original);
|
||||
row.HostAddress = "192.168.0.20:8193";
|
||||
|
||||
var back = row.ToDefinition();
|
||||
back.HostAddress.ShouldBe("192.168.0.20:8193");
|
||||
back.DeviceName.ShouldBe("CNC1");
|
||||
back.Series.ShouldBe(FocasCncSeries.Thirty_i);
|
||||
}
|
||||
|
||||
// v3 Batch-1 migration: the pre-declared Tags editor (FocasDriverPage.FocasTagRow +
|
||||
// FocasDriverOptions.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 FocasCncSeries enum) stays.
|
||||
|
||||
[Fact]
|
||||
public void ValidateDeviceRow_rejects_duplicate_host()
|
||||
{
|
||||
var rows = new List<FocasDriverPage.FocasDeviceRow> { new() { HostAddress = "192.168.0.10:8193" } };
|
||||
FocasDriverPage.FocasDeviceRow.ValidateRow(new() { HostAddress = "192.168.0.10:8193" }, 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<FocasDeviceOptions>
|
||||
{
|
||||
new("192.168.0.10:8193", "CNC1", FocasCncSeries.Thirty_i),
|
||||
new("192.168.0.20:8193", "CNC2", FocasCncSeries.Zero_i_F),
|
||||
};
|
||||
var opts = new FocasDriverPage.FormModel().ToOptions(devices);
|
||||
var opts = new FocasDriverForm.FormModel().ToOptions(devices);
|
||||
var json = JsonSerializer.Serialize(opts, TestJsonOpts);
|
||||
var back = JsonSerializer.Deserialize<FocasDriverOptions>(json, TestJsonOpts)!;
|
||||
back.Devices.Count.ShouldBe(2);
|
||||
|
||||
Reference in New Issue
Block a user