refactor(adminui): B2-WP8 DriverTypeNames rewire + retire routed driver-authoring flow

Part 1 — rewire the three DriverType dispatch maps from hand-authored string
literals to the canonical DriverTypeNames constants (single source of truth):
- TagConfigEditorMap, TagConfigValidator (AdminUI)
- EquipmentTagConfigInspector (ControlPlane)
This FIXES the live drift ("TwinCat"->TwinCAT, "Focas"->FOCAS). The maps are
OrdinalIgnoreCase so behavior is identical; the value is no future drift.
Calculation is not added to the inspector (no CalculationTagDefinitionFactory.Inspect).
Added TagConfigDriverTypeNameGuardTests pinning the maps to the constants.

Part 2 — retire the routed /clusters/{id}/drivers driver-authoring flow (/raw
Waves A-C now cover driver/device/tag authoring end-to-end):
- Deleted DriverTypePicker, DriverEditRouter, the 8 *DriverPage shells, and the
  ClusterDrivers list page.
- Removed the "Drivers" tab from ClusterNav. Routes /clusters/{id}/drivers* now
  simply do not exist -> clean 404.
- The Forms/DeviceForms bodies, shared driver sections, and address pickers used
  by the /raw modals are untouched.

Part 3 — updated PageAuthorizationGuardTests census: removed the 10 deleted
ConfigEditor pages + ClusterDrivers, updated group-count comments (ConfigEditor
21->11, AuthenticatedRead 17->16). Removed the now-dead Clusters.Drivers usings
from the 4 *DriverPageFormSerializationTests + the guard test.

Claude-Session: https://claude.ai/code/session_01LVneM3eh1UtJxEisFXgmox
This commit is contained in:
Joseph Doherty
2026-07-16 04:39:22 -04:00
parent dc80a3b4f6
commit 96471d2345
21 changed files with 103 additions and 1927 deletions
@@ -0,0 +1,65 @@
using Shouldly;
using Xunit;
using ZB.MOM.WW.OtOpcUa.AdminUI.Uns.TagEditors;
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.Uns;
/// <summary>
/// B2-WP8 drift guard: asserts the tag-config dispatch maps (<see cref="TagConfigEditorMap"/> and
/// <see cref="TagConfigValidator"/>) are keyed by the canonical <see cref="DriverTypeNames"/>
/// constants. Because the maps are <c>OrdinalIgnoreCase</c>, a drifted literal (e.g. the historical
/// <c>"TwinCat"</c>/<c>"Focas"</c>) still matched case-insensitively — so a plain lookup test cannot
/// catch drift. These tests resolve <em>through the constants themselves</em>, so if a map key ever
/// stops matching its <see cref="DriverTypeNames"/> constant (a rename on either side) the dispatch
/// goes dark and the test fails.
/// </summary>
public sealed class TagConfigDriverTypeNameGuardTests
{
// Every DriverTypeNames constant that has a typed editor registered.
public static TheoryData<string> EditorMappedDriverTypes() =>
[
DriverTypeNames.Modbus,
DriverTypeNames.S7,
DriverTypeNames.AbCip,
DriverTypeNames.AbLegacy,
DriverTypeNames.TwinCAT,
DriverTypeNames.FOCAS,
DriverTypeNames.OpcUaClient,
DriverTypeNames.Calculation,
];
[Theory]
[MemberData(nameof(EditorMappedDriverTypes))]
public void EditorMap_resolves_every_mapped_DriverTypeNames_constant(string driverType)
=> TagConfigEditorMap.Resolve(driverType).ShouldNotBeNull(
$"TagConfigEditorMap must dispatch DriverTypeNames.{driverType} — key/constant drift.");
// Drivers whose typed model has a required field: a REGISTERED validator returns a non-null error for
// the empty config, whereas an unmapped/drifted key falls through to the null "unmapped ⇒ valid" branch.
// So a non-null result here unambiguously proves the constant is still keyed in the validator map.
public static TheoryData<string> ValidatorRequiredFieldDriverTypes() =>
[
DriverTypeNames.S7,
DriverTypeNames.AbCip,
DriverTypeNames.AbLegacy,
DriverTypeNames.TwinCAT,
DriverTypeNames.FOCAS,
DriverTypeNames.OpcUaClient,
];
[Theory]
[MemberData(nameof(ValidatorRequiredFieldDriverTypes))]
public void Validator_dispatches_every_required_field_DriverTypeNames_constant(string driverType)
=> TagConfigValidator.Validate(driverType, "{}").ShouldNotBeNullOrEmpty(
$"TagConfigValidator must dispatch DriverTypeNames.{driverType} — key/constant drift.");
// The drift the WP8 rewire fixed: these two constants differ in case from the retired literals
// ("TwinCat"/"Focas"). Pin them explicitly.
[Fact]
public void TwinCAT_and_FOCAS_constants_resolve_their_editors()
{
TagConfigEditorMap.Resolve(DriverTypeNames.TwinCAT).ShouldNotBeNull();
TagConfigEditorMap.Resolve(DriverTypeNames.FOCAS).ShouldNotBeNull();
}
}