test(adminui): migrate AdminUI.Tests to v3 greenfield schema + Batch-1 stubs

Migrate tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests (was 358 build errors) to
the v3 Raw-only Tag schema and the Batch-1 AdminUI stubs. Production untouched.

- Driver-page serialization tests: drop the retired pre-declared Tags editor
  (page *TagRow types + DriverOptions.Tags); multi-device pages keep their
  Devices editor (ToOptions(devices)). Enum-serialization round-trip coverage
  (CpuType/ModbusFamily/MelsecFamily/AbCipPlcFamily/AbLegacyPlcFamily/FocasCncSeries)
  preserved intact.
- UnsTreeTestDb: reseed to v3 (Device->Tag raw slice, no EquipmentId/DriverInstanceId
  on Tag, no Namespace).
- UnsTreeService tag tests: assert Batch-1 stubs (CreateTag/UpdateTag refusal,
  empty tag/tag-driver lists); DeleteTag stays live against a raw Tag.
- Equipment #122 guard retained (validates input driver vs line cluster); drop the
  retired persisted-binding assertions + NamespaceId seeds. Area/Line #122 driver-
  orphan guard retired -> assert cross-cluster move now succeeds.
- DeleteCluster: drop the deleted-Namespace child-check test.
- OpcUaClientTagConfigModel/TagConfigValidator: address key FullName -> nodeId.
- ScriptTagCatalog: project surviving Name/DataType/TagConfig; DriverInstanceId null.
- VirtualTag {{equip}} equipment-tag-derived base is dark -> 3 tests skipped (Batch-3).

Result: build green; 507 passed / 3 skipped / 0 failed.
This commit is contained in:
Joseph Doherty
2026-07-15 21:50:48 -04:00
parent aaba2ebd66
commit 6a616a1ab2
22 changed files with 266 additions and 1029 deletions
@@ -52,7 +52,6 @@ public sealed class FocasDriverPageFormSerializationTests
TimerPollInterval = TimeSpan.FromSeconds(60),
},
Devices = [],
Tags = [],
};
var json = JsonSerializer.Serialize(original, _opts);
@@ -73,7 +72,6 @@ public sealed class FocasDriverPageFormSerializationTests
back.FixedTree.ProgramPollInterval.ShouldBe(TimeSpan.FromSeconds(2));
back.FixedTree.TimerPollInterval.ShouldBe(TimeSpan.FromSeconds(60));
back.Devices.ShouldBeEmpty();
back.Tags.ShouldBeEmpty();
}
[Fact]
@@ -123,7 +121,7 @@ public sealed class FocasDriverPageFormSerializationTests
var form = ZB.MOM.WW.OtOpcUa.AdminUI.Components.Pages.Clusters.Drivers
.FocasDriverPage.FormModel.FromOptions(opts);
var roundTripped = form.ToOptions([], []);
var roundTripped = form.ToOptions([]);
roundTripped.Timeout.ShouldBe(TimeSpan.FromSeconds(4));
roundTripped.Probe.Enabled.ShouldBeTrue();
@@ -168,37 +166,11 @@ public sealed class FocasDriverPageFormSerializationTests
back.Series.ShouldBe(FocasCncSeries.Thirty_i);
}
[Fact]
public void TagRow_round_trips_through_definition()
{
var row = new FocasDriverPage.FocasTagRow
{
Name = "MacroVar", DeviceHostAddress = "192.168.0.10:8193", Address = "MACRO:500",
DataType = FocasDataType.Float64, Writable = true,
};
var def = row.ToDefinition();
var back = FocasDriverPage.FocasTagRow.FromDefinition(def);
back.Name.ShouldBe("MacroVar");
back.DeviceHostAddress.ShouldBe("192.168.0.10:8193");
back.Address.ShouldBe("MACRO:500");
back.DataType.ShouldBe(FocasDataType.Float64);
back.Writable.ShouldBeTrue();
}
[Fact]
public void TagRow_preserves_unedited_fields()
{
var original = new FocasTagDefinition(
"MacroVar", "192.168.0.10:8193", "MACRO:500", FocasDataType.Float64,
Writable: true, WriteIdempotent: true);
var row = FocasDriverPage.FocasTagRow.FromDefinition(original);
row.Name = "Renamed";
var back = row.ToDefinition();
back.Name.ShouldBe("Renamed");
back.WriteIdempotent.ShouldBeTrue();
}
// 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()
@@ -209,34 +181,19 @@ public sealed class FocasDriverPageFormSerializationTests
}
[Fact]
public void ValidateTagRow_rejects_duplicate_name()
{
var rows = new List<FocasDriverPage.FocasTagRow> { new() { Name = "MacroVar" } };
FocasDriverPage.FocasTagRow.ValidateRow(new() { Name = "MacroVar" }, rows, null)
.ShouldNotBeNull();
}
[Fact]
public void Device_and_tag_lists_survive_options_serialize_round_trip()
public void Device_list_survives_options_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 tags = new List<FocasTagDefinition>
{
new("MacroVar", "192.168.0.10:8193", "MACRO:500", FocasDataType.Float64),
new("Flag", "192.168.0.20:8193", "X0.0", FocasDataType.Bit),
};
var opts = new FocasDriverPage.FormModel().ToOptions(devices, tags);
var opts = new FocasDriverPage.FormModel().ToOptions(devices);
var json = JsonSerializer.Serialize(opts, TestJsonOpts);
var back = JsonSerializer.Deserialize<FocasDriverOptions>(json, TestJsonOpts)!;
back.Devices.Count.ShouldBe(2);
back.Devices[0].HostAddress.ShouldBe("192.168.0.10:8193");
back.Devices[0].Series.ShouldBe(FocasCncSeries.Thirty_i);
back.Tags.Count.ShouldBe(2);
back.Tags[0].Name.ShouldBe("MacroVar");
back.Tags[0].Address.ShouldBe("MACRO:500");
back.Devices[1].Series.ShouldBe(FocasCncSeries.Zero_i_F);
}
}