Complete protocol field associations and verify rendered inventory

This commit is contained in:
Joseph Doherty
2026-11-13 21:29:03 -05:00
parent ee8ac73e8c
commit 27bca683c1
23 changed files with 11500 additions and 32 deletions
@@ -13,3 +13,7 @@ Batch3: MQTT, MTConnect and OPC UA Client driver fields:98focused checks passed.
Batch4: S7, SQL and TwinCAT driver fields:115focused/serialization/parity cases pass. The named-queries textarea was the one remaining rendered name failure after initial association; its existing visible panel heading now supplies the name, and existing connection-ref/queries errors have persistent correctly scoped feedback targets. Raw initial failure is retained. Protocol C# and existing event/bind expressions remain unchanged.
Tag batch1: AB CIP, AB Legacy and FOCAS editors retain defaults and callbacks while receiving unique native labels/IDs;154focused field/model/authoring parity checks pass. FOCAS’s existing address/data-type mismatch now has one persistent linked feedback target for exactly those two fields, preserving its original refusal predicate.
Final root-owned field checkpoint: all12driver/13tag bodies and8editable device bodies plus2intentional informational device views retain existing models, JSON serialization and callbacks.89rendered cases pass (35two-instance,35standalone,12invalid numeric parser/config preservation,7conditional MQTT/SQL/Heidenhain/FOCAS branches). Every label target and description resolves; the FOCAS existing mismatch connects exactly the address/type fields. Calculation source passes a human AriaLabel to the separately verified Monaco component.
Actual local browser4cases1440/390:370root-owned driver controls and124tag controls per viewport,50real label-click focus checks,unique IDs/resolved help and zero document overflow/errors. Common resilience is explicitly excluded from root-owned browser field assertions and remains the common-component owner's scope. Actual screenshots preserve the incumbent compact field geometry. The pure Razor host refuses all backend operations and exposes only a synthetic empty script catalog; it has no connection/save service. Conditional branches have rendered unit coverage here; no successful protocol connection or backend mutation is claimed. Source guard verifies all35inventory bodies/event/bind expressions against the GB baseline.
@@ -0,0 +1,22 @@
"""Actual root-owned driver/tag labels, help and label click focus; common resilience is separately owned."""
import json
from pathlib import Path
from playwright.sync_api import sync_playwright,expect
OUT=Path(__file__).resolve().parent/'protocol-browser';OUT.mkdir(exist_ok=True)
results=[]
with sync_playwright() as p:
b=p.chromium.launch()
for kind in ['drivers','tags']:
for w,h in [(1440,900),(390,844)]:
page=b.new_page(viewport={'width':w,'height':h});errors=[];page.on('pageerror',lambda e:errors.append(str(e)))
page.goto('http://127.0.0.1:18137/protocols?kind='+kind);expect(page.locator('#interactive')).to_have_text('True')
data=page.evaluate('''()=>{const owned=e=>!e.closest('section.panel')?.querySelector('.panel-head')?.textContent.includes('Resilience');const inputs=[...document.querySelectorAll('section[data-protocol] input,section[data-protocol] select,section[data-protocol] textarea')].filter(owned);const ids=[...document.querySelectorAll('[id]')].map(e=>e.id);return {controls:inputs.length,uniqueIds:new Set(ids).size===ids.length,fields:inputs.map(e=>({id:e.id,name:e.getAttribute('aria-label')||[...e.labels].map(l=>l.textContent.trim()).join(' ')||(e.getAttribute('aria-labelledby')||'').split(' ').map(id=>document.getElementById(id)?.textContent||'').join(' ').trim(),descriptions:(e.getAttribute('aria-describedby')||'').split(' ').filter(Boolean).map(id=>({id,present:!!document.getElementById(id),text:document.getElementById(id)?.textContent}))})),width:innerWidth,scrollWidth:document.documentElement.scrollWidth}}''')
assert data['controls']>0 and data['uniqueIds'];assert data['width']==data['scrollWidth'];assert all(f['name'] and all(d['present'] for d in f['descriptions']) for f in data['fields']),data
clicked=[]
for region in page.locator('section[data-protocol][data-copy="0"]').all():
family=region.get_attribute('data-protocol');label=region.locator('label[for]').first;ident=label.get_attribute('for');control=region.locator('[id="'+ident+'"]');label.click();expect(control).to_be_focused();clicked.append(family)
for family in (['SqlDriverForm','MqttDriverForm'] if kind=='drivers' else ['CalculationTagConfigEditor','NativeAlarmEditor','SqlTagConfigEditor']):
page.locator('[data-protocol="'+family+'"][data-copy="0"]').screenshot(path=str(OUT/(family+'-'+str(w)+'.png')))
results.append({'kind':kind,'width':w,'inventory':data,'labelClickFocus':clicked,'errors':errors});assert not errors;page.close()
b.close()
(OUT/'results.json').write_text(json.dumps({'boundary':'Whitelisted real component drafts; empty script catalog; all backend operations refused. Common resilience fields excluded from root-owned assertions.','results':results},indent=2)+'\n');print('PASS4 cases; all root-owned rendered fields named/ID/help resolved and50 real label focus clicks')
@@ -0,0 +1,27 @@
@page "/protocols"
@rendermode InteractiveServer
@using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers.Forms
@using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Uns.TagEditors
<main class="container-fluid p-3"><h1>Protocol field fixture</h1><p>Synthetic drafts only; no device or backend operations.</p><output id="interactive">@_ready</output>
<EditForm EditContext="_context" OnSubmit="IgnoreSubmit">
@foreach (var type in Types)
{
@for (int copy = 0; copy < 2; copy++)
{
var key = type.Name + copy;
<section data-protocol="@type.Name" data-copy="@copy" @key="key"><h2>@type.Name · instance @copy</h2><DynamicComponent Type="type" Parameters="Values(type)" /></section>
}
}
</EditForm></main>
@code {
[SupplyParameterFromQuery] public string? Kind { get; set; }
private readonly EditContext _context = new(new object());
private bool _ready;
protected override void OnAfterRender(bool firstRender) { if (firstRender) { _ready = true; StateHasChanged(); } }
private static readonly Type[] Drivers = [typeof(AbCipDriverForm), typeof(AbLegacyDriverForm), typeof(FocasDriverForm), typeof(GalaxyDriverForm), typeof(HeidenhainDriverForm), typeof(MTConnectDriverForm), typeof(ModbusDriverForm), typeof(MqttDriverForm), typeof(OpcUaClientDriverForm), typeof(S7DriverForm), typeof(SqlDriverForm), typeof(TwinCATDriverForm)];
private static readonly Type[] Tags = [typeof(AbCipTagConfigEditor), typeof(AbLegacyTagConfigEditor), typeof(CalculationTagConfigEditor), typeof(FocasTagConfigEditor), typeof(HeidenhainTagConfigEditor), typeof(MTConnectTagConfigEditor), typeof(ModbusTagConfigEditor), typeof(MqttTagConfigEditor), typeof(NativeAlarmEditor), typeof(OpcUaClientTagConfigEditor), typeof(S7TagConfigEditor), typeof(SqlTagConfigEditor), typeof(TwinCATTagConfigEditor)];
private Type[] Types => Kind == "drivers" ? Drivers : Tags;
private static Dictionary<string, object> Values(Type type) => type == typeof(NativeAlarmEditor)
? new() { ["DriverType"] = "AbCip", ["ConfigJson"] = "{\"alarm\":{\"severity\":500}}" } : new();
private void IgnoreSubmit(EditContext context) { }
}
@@ -1,6 +1,7 @@
using DeviceFormCanary.Components;
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseStaticWebAssets();
builder.Services.AddSingleton(System.Reflection.DispatchProxy.Create<ZB.MOM.WW.OtOpcUa.AdminUI.Uns.IUnsTreeService, ProtocolReadOnlyProxy>());
builder.Services.AddRazorComponents().AddInteractiveServerComponents();
var app = builder.Build();
app.UseAntiforgery();
@@ -0,0 +1,9 @@
using System.Reflection;
using ZB.MOM.WW.OtOpcUa.AdminUI.Uns;
/// <summary>Read-only empty script catalog; every backend operation is refused.</summary>
public class ProtocolReadOnlyProxy : DispatchProxy
{
protected override object? Invoke(MethodInfo? method, object?[]? args) => method?.Name == nameof(IUnsTreeService.LoadScriptsAsync)
? Task.FromResult<IReadOnlyList<(string ScriptId, string Display)>>([])
: throw new NotSupportedException("No backend operations in protocol fixture: " + method?.Name);
}
@@ -0,0 +1,52 @@
ZB.MOM.WW.OtOpcUa.Analyzers -> /Users/dohertj2/Desktop/OtOpcUa/src/Tooling/ZB.MOM.WW.OtOpcUa.Analyzers/bin/Debug/netstandard2.0/ZB.MOM.WW.OtOpcUa.Analyzers.dll
ZB.MOM.WW.OtOpcUa.Core.Abstractions -> /Users/dohertj2/Desktop/OtOpcUa/src/Core/ZB.MOM.WW.OtOpcUa.Core.Abstractions/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Core.Abstractions.dll
ZB.MOM.WW.OtOpcUa.Core.Scripting.Abstractions -> /Users/dohertj2/Desktop/OtOpcUa/src/Core/ZB.MOM.WW.OtOpcUa.Core.Scripting.Abstractions/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Core.Scripting.Abstractions.dll
ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Contracts/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Contracts.dll
ZB.MOM.WW.OtOpcUa.Commons -> /Users/dohertj2/Desktop/OtOpcUa/src/Core/ZB.MOM.WW.OtOpcUa.Commons/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Commons.dll
ZB.MOM.WW.OtOpcUa.Driver.MTConnect.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.MTConnect.Contracts/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.MTConnect.Contracts.dll
ZB.MOM.WW.OtOpcUa.Driver.Ab.Transport -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Ab.Transport/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.Ab.Transport.dll
ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Contracts/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Contracts.dll
ZB.MOM.WW.OtOpcUa.Core.AlarmHistorian -> /Users/dohertj2/Desktop/OtOpcUa/src/Core/ZB.MOM.WW.OtOpcUa.Core.AlarmHistorian/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Core.AlarmHistorian.dll
ZB.MOM.WW.OtOpcUa.Driver.AbCip.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbCip.Contracts/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.AbCip.Contracts.dll
ZB.MOM.WW.OtOpcUa.Driver.Heidenhain.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Heidenhain.Contracts/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.Heidenhain.Contracts.dll
ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Contracts/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Contracts.dll
ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Contracts/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Contracts.dll
ZB.MOM.WW.OtOpcUa.Driver.Sql.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Sql.Contracts/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.Sql.Contracts.dll
ZB.MOM.WW.OtOpcUa.Driver.Calculation.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Calculation.Contracts/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.Calculation.Contracts.dll
ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Contracts/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Contracts.dll
ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Contracts/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.Contracts.dll
ZB.MOM.WW.OtOpcUa.Cluster -> /Users/dohertj2/Desktop/OtOpcUa/src/Core/ZB.MOM.WW.OtOpcUa.Cluster/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Cluster.dll
ZB.MOM.WW.OtOpcUa.Driver.S7.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.S7.Contracts/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.S7.Contracts.dll
ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Transport -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Transport/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Transport.dll
ZB.MOM.WW.OtOpcUa.Driver.Modbus.Addressing -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Modbus.Addressing/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.Modbus.Addressing.dll
ZB.MOM.WW.OtOpcUa.Core.Scripting -> /Users/dohertj2/Desktop/OtOpcUa/src/Core/ZB.MOM.WW.OtOpcUa.Core.Scripting/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Core.Scripting.dll
ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Session -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Session/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Session.dll
ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Browser -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Browser/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Browser.dll
ZB.MOM.WW.OtOpcUa.Core.ScriptedAlarms -> /Users/dohertj2/Desktop/OtOpcUa/src/Core/ZB.MOM.WW.OtOpcUa.Core.ScriptedAlarms/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Core.ScriptedAlarms.dll
ZB.MOM.WW.OtOpcUa.Driver.Sql.Dialect -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Sql.Dialect/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.Sql.Dialect.dll
ZB.MOM.WW.OtOpcUa.Core.VirtualTags -> /Users/dohertj2/Desktop/OtOpcUa/src/Core/ZB.MOM.WW.OtOpcUa.Core.VirtualTags/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Core.VirtualTags.dll
ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Browser -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Browser/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Browser.dll
ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Browser -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Browser/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Browser.dll
ZB.MOM.WW.OtOpcUa.Driver.Sql.Browser -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Sql.Browser/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.Sql.Browser.dll
ZB.MOM.WW.OtOpcUa.Configuration -> /Users/dohertj2/Desktop/OtOpcUa/src/Core/ZB.MOM.WW.OtOpcUa.Configuration/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Configuration.dll
ZB.MOM.WW.OtOpcUa.Driver.Modbus.Contracts -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Modbus.Contracts/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.Modbus.Contracts.dll
ZB.MOM.WW.OtOpcUa.Core -> /Users/dohertj2/Desktop/OtOpcUa/src/Core/ZB.MOM.WW.OtOpcUa.Core/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Core.dll
ZB.MOM.WW.OtOpcUa.Security -> /Users/dohertj2/Desktop/OtOpcUa/src/Server/ZB.MOM.WW.OtOpcUa.Security/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Security.dll
ZB.MOM.WW.OtOpcUa.Driver.Galaxy -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Galaxy/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.Galaxy.dll
ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.dll
ZB.MOM.WW.OtOpcUa.Driver.Heidenhain -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Heidenhain/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.Heidenhain.dll
ZB.MOM.WW.OtOpcUa.Driver.Sql -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Sql/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.Sql.dll
ZB.MOM.WW.OtOpcUa.Driver.AbCip -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbCip/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.AbCip.dll
ZB.MOM.WW.OtOpcUa.Driver.FOCAS -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.dll
ZB.MOM.WW.OtOpcUa.Driver.AbLegacy -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.dll
ZB.MOM.WW.OtOpcUa.Driver.MTConnect -> /Users/dohertj2/Desktop/OtOpcUa/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.MTConnect/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Driver.MTConnect.dll
ZB.MOM.WW.OtOpcUa.OpcUaServer -> /Users/dohertj2/Desktop/OtOpcUa/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.OpcUaServer.dll
ZB.MOM.WW.OtOpcUa.ControlPlane -> /Users/dohertj2/Desktop/OtOpcUa/src/Server/ZB.MOM.WW.OtOpcUa.ControlPlane/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.ControlPlane.dll
ZB.MOM.WW.OtOpcUa.Runtime -> /Users/dohertj2/Desktop/OtOpcUa/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.Runtime.dll
ZB.MOM.WW.OtOpcUa.AdminUI -> /Users/dohertj2/Desktop/OtOpcUa/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.AdminUI.dll
ZB.MOM.WW.OtOpcUa.AdminUI.Tests -> /Users/dohertj2/Desktop/OtOpcUa/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.AdminUI.Tests.dll
Test run for /Users/dohertj2/Desktop/OtOpcUa/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/bin/Debug/net10.0/ZB.MOM.WW.OtOpcUa.AdminUI.Tests.dll (.NETCoreApp,Version=v10.0)
A total of 1 test files matched the specified pattern.
Passed! - Failed: 0, Passed: 89, Skipped: 0, Total: 89, Duration: 860 ms - ZB.MOM.WW.OtOpcUa.AdminUI.Tests.dll (net10.0)
@@ -0,0 +1,212 @@
[
{
"component": "TwinCATDriverForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "MqttDriverForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "SqlDriverForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "GalaxyDriverForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "ModbusDriverForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "OpcUaClientDriverForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "MTConnectDriverForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "S7DriverForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "HeidenhainDriverForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "FocasDriverForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "AbLegacyDriverForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "AbCipDriverForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "S7DeviceForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "HeidenhainDeviceForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "FocasDeviceForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "AbLegacyDeviceForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "AbCipDeviceForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "TwinCATDeviceForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "MqttDeviceForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": false
},
{
"component": "GalaxyDeviceForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": false
},
{
"component": "OpcUaClientDeviceForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "ModbusDeviceForm",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "CalculationTagConfigEditor",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "FocasTagConfigEditor",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "OpcUaClientTagConfigEditor",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "AbLegacyTagConfigEditor",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "MTConnectTagConfigEditor",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "ModbusTagConfigEditor",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "TwinCATTagConfigEditor",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "HeidenhainTagConfigEditor",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "AbCipTagConfigEditor",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "NativeAlarmEditor",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "SqlTagConfigEditor",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "MqttTagConfigEditor",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
},
{
"component": "S7TagConfigEditor",
"protocolCSharpUnchanged": true,
"eventAndBindExpressionsUnchanged": true,
"migrated": true
}
]
Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

File diff suppressed because it is too large Load Diff
@@ -11,8 +11,8 @@
<div class="row g-2">
<div class="col-md-6">
<label class="form-label">Script</label>
<select class="form-select form-select-sm" value="@_m.ScriptId" @onchange="OnScriptChangedAsync">
<label for="@FieldId("field-01")" class="form-label">Script</label>
<select id="@FieldId("field-01")" class="form-select form-select-sm" value="@_m.ScriptId" @onchange="OnScriptChangedAsync">
<option value="">— pick script —</option>
@foreach (var (id, display) in _scripts)
{
@@ -21,7 +21,7 @@
</select>
</div>
<div class="col-md-3">
<label class="form-label">Change-triggered</label>
<label for="calc-change-@_uid" class="form-label">Change-triggered</label>
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="calc-change-@_uid"
checked="@_m.ChangeTriggered"
@@ -30,11 +30,11 @@
</div>
</div>
<div class="col-md-3">
<label class="form-label">Timer (ms)</label>
<input type="number" min="50" step="1" class="form-control form-control-sm"
<label for="@FieldId("field-03")" class="form-label">Timer (ms)</label>
<input aria-describedby="@FieldIds("field-03-hint")" id="@FieldId("field-03")" type="number" min="50" step="1" class="form-control form-control-sm"
value="@_m.TimerIntervalMs"
@onchange="@(e => Update(() => _m.TimerIntervalMs = ParseTimer(e.Value)))" />
<div class="form-text">Blank = change-trigger only. Min 50 ms.</div>
<div id="@FieldId("field-03-hint")" class="form-text">Blank = change-trigger only. Min 50 ms.</div>
</div>
</div>
@@ -75,7 +75,7 @@
Editing shared script "<span class="mono">@_scriptName</span>" — used by
@_scriptUsageCount virtual tag(s). Changes affect every tag using it.
</div>
<MonacoEditor @bind-Value="_scriptSource" Height="300px" />
<MonacoEditor AriaLabel="Calculation script source" @bind-Value="_scriptSource" Height="300px" />
@if (!string.IsNullOrWhiteSpace(_scriptError))
{
<div class="text-danger small mt-2">@_scriptError</div>
@@ -97,6 +97,10 @@
}
@code {
private readonly string _fieldScope = "calculation-tag-config-editor-" + Guid.NewGuid().ToString("N");
private string FieldIds(params string[] names) => string.Join(" ", names.Select(FieldId));
private string FieldId(string name) => $"{_fieldScope}-{name}";
[Parameter] public string? ConfigJson { get; set; }
[Parameter] public EventCallback<string> ConfigJsonChanged { get; set; }
/// <summary>DriverType of the selected driver — accepted for dispatch uniformity; unused here.</summary>
@@ -19,23 +19,23 @@
This tag carries an <span class="mono">alarm</span> object, but driver type
<span class="mono">@DriverType</span> does not raise native alarms, so it has no effect.
</div>
<button type="button" class="btn btn-sm btn-outline-secondary mt-1" id="native-alarm-remove"
<button type="button" class="btn btn-sm btn-outline-secondary mt-1" id="@FieldId("native-alarm-remove")"
@onclick="@(() => Update(m => m.IsAlarm = false))">Remove alarm object</button>
}
else
{
<div class="form-check form-switch">
<input id="native-alarm-enabled" type="checkbox" class="form-check-input"
<input id="@FieldId("native-alarm-enabled")" type="checkbox" class="form-check-input"
checked="@_m.IsAlarm"
@onchange="@(e => Update(m => m.IsAlarm = e.Value is true))" />
<label class="form-check-label" for="native-alarm-enabled">Native alarm (Part 9 condition)</label>
<label class="form-check-label" for="@FieldId("native-alarm-enabled")">Native alarm (Part 9 condition)</label>
</div>
@if (_m.IsAlarm)
{
<div class="row g-2 mt-1">
<div class="col-md-4">
<label class="form-label" for="native-alarm-type">Alarm type</label>
<select id="native-alarm-type" class="form-select form-select-sm" value="@_m.AlarmType"
<label class="form-label" for="@FieldId("native-alarm-type")">Alarm type</label>
<select id="@FieldId("native-alarm-type")" class="form-select form-select-sm" value="@_m.AlarmType"
@onchange="@(e => Update(m => m.AlarmType = e.Value?.ToString() ?? "AlarmCondition"))">
@foreach (var t in NativeAlarmModel.KnownAlarmTypes) { <option value="@t">@t</option> }
@if (!NativeAlarmModel.KnownAlarmTypes.Contains(_m.AlarmType))
@@ -45,14 +45,14 @@
</select>
</div>
<div class="col-md-4">
<label class="form-label" for="native-alarm-severity">Severity (1..1000)</label>
<input id="native-alarm-severity" type="number" min="1" max="1000" class="form-control form-control-sm"
<label class="form-label" for="@FieldId("native-alarm-severity")">Severity (1..1000)</label>
<input id="@FieldId("native-alarm-severity")" type="number" min="1" max="1000" class="form-control form-control-sm"
value="@_m.Severity"
@onchange="@(e => Update(m => m.Severity = int.TryParse(e.Value?.ToString(), out var s) ? s : 500))" />
</div>
<div class="col-md-4">
<label class="form-label" for="native-alarm-historize">Historize to AVEVA</label>
<select id="native-alarm-historize" class="form-select form-select-sm"
<label class="form-label" for="@FieldId("native-alarm-historize")">Historize to AVEVA</label>
<select id="@FieldId("native-alarm-historize")" class="form-select form-select-sm"
value="@HistorizeValue(_m.HistorizeToAveva)"
@onchange="@(e => Update(m => m.HistorizeToAveva = ParseHistorize(e.Value?.ToString())))">
<option value="default">Default (yes)</option>
@@ -71,6 +71,9 @@
}
@code {
private readonly string _fieldScope = "native-alarm-editor-" + Guid.NewGuid().ToString("N");
private string FieldId(string name) => $"{_fieldScope}-{name}";
/// <summary>The tag's raw TagConfig JSON (supports <c>@bind-ConfigJson</c>).</summary>
[Parameter] public string? ConfigJson { get; set; }
/// <summary>Two-way config callback.</summary>
@@ -5,24 +5,24 @@
<div class="row g-2">
<div class="col-md-5">
<label class="form-label">Address</label>
<label for="@FieldId("field-01")" class="form-label">Address</label>
<div class="input-group input-group-sm">
<input class="form-control form-control-sm mono" value="@_m.Address" placeholder="e.g. DB1.DBW0, M0.0, I0.0, QD4" @onchange="@(e => Update(() => _m.Address = e.Value?.ToString() ?? string.Empty))" />
<input id="@FieldId("field-01")" class="form-control form-control-sm mono" value="@_m.Address" placeholder="e.g. DB1.DBW0, M0.0, I0.0, QD4" @onchange="@(e => Update(() => _m.Address = e.Value?.ToString() ?? string.Empty))" />
<button type="button" class="btn btn-outline-secondary" @onclick="@(() => _showPicker = true)">Build</button>
</div>
</div>
<div class="col-md-4"><label class="form-label">Data type</label>
<select class="form-select form-select-sm" value="@_m.DataType" @onchange="@(e => Update(() => _m.DataType = ParseEnum(e.Value, S7DataType.Int16)))">
<div class="col-md-4"><label for="@FieldId("field-02")" class="form-label">Data type</label>
<select id="@FieldId("field-02")" class="form-select form-select-sm" value="@_m.DataType" @onchange="@(e => Update(() => _m.DataType = ParseEnum(e.Value, S7DataType.Int16)))">
@foreach (var v in Enum.GetValues<S7DataType>()) { <option value="@v">@v</option> }
</select></div>
<div class="col-md-3"><label class="form-label">String len</label>
<input type="number" class="form-control form-control-sm" value="@_m.StringLength" @onchange="@(e => Update(() => _m.StringLength = ParseInt(e.Value)))" /></div>
<div class="col-md-3"><label for="@FieldId("field-03")" class="form-label">String len</label>
<input id="@FieldId("field-03")" type="number" class="form-control form-control-sm" value="@_m.StringLength" @onchange="@(e => Update(() => _m.StringLength = ParseInt(e.Value)))" /></div>
<div class="col-12">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="s7-writable"
<input type="checkbox" class="form-check-input" id="@FieldId("s7-writable")"
checked="@(_m.Writable ?? true)"
@onchange="@(e => Update(() => _m.Writable = e.Value is bool b && b))" />
<label class="form-check-label small" for="s7-writable">Writable (uncheck for a read-only tag)</label>
<label class="form-check-label small" for="@FieldId("s7-writable")">Writable (uncheck for a read-only tag)</label>
</div>
</div>
</div>
@@ -39,6 +39,9 @@
}
@code {
private readonly string _fieldScope = "s7-tag-config-editor-" + Guid.NewGuid().ToString("N");
private string FieldId(string name) => $"{_fieldScope}-{name}";
[Parameter] public string? ConfigJson { get; set; }
[Parameter] public EventCallback<string> ConfigJsonChanged { get; set; }
/// <summary>DriverType of the selected driver — lets browse-capable pickers open a universal session.</summary>
@@ -4,25 +4,25 @@
@using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers.Pickers
<div class="row g-2">
<div class="col-md-4"><label class="form-label">Device host</label>
<input class="form-control form-control-sm mono" value="@_m.DeviceHostAddress" placeholder="AmsNetId[:port]" @onchange="@(e => Update(() => _m.DeviceHostAddress = e.Value?.ToString() ?? string.Empty))" /></div>
<div class="col-md-4"><label for="@FieldId("field-01")" class="form-label">Device host</label>
<input id="@FieldId("field-01")" class="form-control form-control-sm mono" value="@_m.DeviceHostAddress" placeholder="AmsNetId[:port]" @onchange="@(e => Update(() => _m.DeviceHostAddress = e.Value?.ToString() ?? string.Empty))" /></div>
<div class="col-md-5">
<label class="form-label">Symbol path</label>
<label for="@FieldId("field-02")" class="form-label">Symbol path</label>
<div class="input-group input-group-sm">
<input class="form-control form-control-sm mono" value="@_m.SymbolPath" placeholder="e.g. MAIN.bStart, GVL.Counter" @onchange="@(e => Update(() => _m.SymbolPath = e.Value?.ToString() ?? string.Empty))" />
<input id="@FieldId("field-02")" class="form-control form-control-sm mono" value="@_m.SymbolPath" placeholder="e.g. MAIN.bStart, GVL.Counter" @onchange="@(e => Update(() => _m.SymbolPath = e.Value?.ToString() ?? string.Empty))" />
<button type="button" class="btn btn-outline-secondary" @onclick="@(() => _showPicker = true)">Build</button>
</div>
</div>
<div class="col-md-3"><label class="form-label">Data type</label>
<select class="form-select form-select-sm" value="@_m.DataType" @onchange="@(e => Update(() => _m.DataType = ParseEnum(e.Value, TwinCATDataType.DInt)))">
<div class="col-md-3"><label for="@FieldId("field-03")" class="form-label">Data type</label>
<select id="@FieldId("field-03")" class="form-select form-select-sm" value="@_m.DataType" @onchange="@(e => Update(() => _m.DataType = ParseEnum(e.Value, TwinCATDataType.DInt)))">
@foreach (var v in Enum.GetValues<TwinCATDataType>()) { <option value="@v">@v</option> }
</select></div>
<div class="col-12">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="twincat-writable"
<input type="checkbox" class="form-check-input" id="@FieldId("twincat-writable")"
checked="@(_m.Writable ?? true)"
@onchange="@(e => Update(() => _m.Writable = e.Value is bool b && b))" />
<label class="form-check-label small" for="twincat-writable">Writable (uncheck for a read-only tag)</label>
<label class="form-check-label small" for="@FieldId("twincat-writable")">Writable (uncheck for a read-only tag)</label>
</div>
</div>
</div>
@@ -41,6 +41,9 @@
}
@code {
private readonly string _fieldScope = "twin-c-a-t-tag-config-editor-" + Guid.NewGuid().ToString("N");
private string FieldId(string name) => $"{_fieldScope}-{name}";
[Parameter] public string? ConfigJson { get; set; }
[Parameter] public EventCallback<string> ConfigJsonChanged { get; set; }
/// <summary>DriverType of the selected driver — lets browse-capable pickers open a universal session.</summary>
@@ -0,0 +1,201 @@
using System.Reflection;
using AngleSharp.Dom;
using Bunit;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.Extensions.DependencyInjection;
using Shouldly;
using Xunit;
using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers;
using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers.Forms;
using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers.DeviceForms;
using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Uns.TagEditors;
using ZB.MOM.WW.OtOpcUa.AdminUI.Uns;
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.Pages;
/// <summary>Rendered field contracts across real protocol forms, including two simultaneous instances.</summary>
public class ProtocolFormAccessibilityTests : BunitContext
{
/// <summary>Common resilience controls have a separate owner and contract suite.</summary>
public ProtocolFormAccessibilityTests()
{
ComponentFactories.AddStub<DriverResilienceSection>();
Services.AddSingleton(DispatchProxy.Create<IUnsTreeService, ScriptListOnlyProxy>());
}
/// <summary>The verified12 driver,10 device and13 tag-editor surfaces.</summary>
public static IEnumerable<object[]> Forms()
{
yield return [typeof(AbCipDeviceForm)];
yield return [typeof(AbLegacyDeviceForm)];
yield return [typeof(FocasDeviceForm)];
yield return [typeof(GalaxyDeviceForm)];
yield return [typeof(HeidenhainDeviceForm)];
yield return [typeof(ModbusDeviceForm)];
yield return [typeof(MqttDeviceForm)];
yield return [typeof(OpcUaClientDeviceForm)];
yield return [typeof(S7DeviceForm)];
yield return [typeof(TwinCATDeviceForm)];
yield return [typeof(AbCipDriverForm)];
yield return [typeof(AbLegacyDriverForm)];
yield return [typeof(FocasDriverForm)];
yield return [typeof(GalaxyDriverForm)];
yield return [typeof(HeidenhainDriverForm)];
yield return [typeof(MTConnectDriverForm)];
yield return [typeof(ModbusDriverForm)];
yield return [typeof(MqttDriverForm)];
yield return [typeof(OpcUaClientDriverForm)];
yield return [typeof(S7DriverForm)];
yield return [typeof(SqlDriverForm)];
yield return [typeof(TwinCATDriverForm)];
yield return [typeof(AbCipTagConfigEditor)];
yield return [typeof(AbLegacyTagConfigEditor)];
yield return [typeof(CalculationTagConfigEditor)];
yield return [typeof(FocasTagConfigEditor)];
yield return [typeof(HeidenhainTagConfigEditor)];
yield return [typeof(MTConnectTagConfigEditor)];
yield return [typeof(ModbusTagConfigEditor)];
yield return [typeof(MqttTagConfigEditor)];
yield return [typeof(NativeAlarmEditor)];
yield return [typeof(OpcUaClientTagConfigEditor)];
yield return [typeof(S7TagConfigEditor)];
yield return [typeof(SqlTagConfigEditor)];
yield return [typeof(TwinCATTagConfigEditor)];
}
/// <summary>Every native field has a visible label/name and every referenced ID is unique and present.</summary>
[Theory]
[MemberData(nameof(Forms))]
[Trait("Category", "Unit")]
public void ProtocolFields_TwoInstancesHaveUniqueNamesAndResolvedDescriptions(Type type)
{
var cut = Render<CascadingValue<EditContext>>(p => p.Add(x => x.Value, new EditContext(new object()))
.Add(x => x.ChildContent, (RenderFragment)(builder =>
{
for (int i = 0; i < 2; i++)
{
builder.OpenComponent(0, type); builder.SetKey(i);
if (type == typeof(NativeAlarmEditor))
{
builder.AddAttribute(1, "DriverType", "AbCip");
builder.AddAttribute(2, "ConfigJson", "{\"alarm\":{\"alarmType\":\"AlarmCondition\",\"severity\":500}}");
}
builder.CloseComponent();
}
})));
var controls = cut.FindAll("input:not([type=hidden]),select,textarea");
if (type == typeof(GalaxyDeviceForm) || type == typeof(MqttDeviceForm)) controls.ShouldBeEmpty("Galaxy/MQTT devices intentionally have no per-device endpoint");
else controls.ShouldNotBeEmpty(type.Name);
AssertRelationships(cut, type);
}
/// <summary>Embedded driver/device/tag bodies remain usable without an external EditForm.</summary>
[Theory]
[MemberData(nameof(Forms))]
[Trait("Category", "Unit")]
public void ProtocolFields_StandaloneDoesNotRequireEditContext(Type type)
{
Dictionary<string, object> values = type == typeof(NativeAlarmEditor)
? new() { ["DriverType"] = "AbCip", ["ConfigJson"] = "{\"alarm\":{\"severity\":500}}" } : new();
var cut = Render<DynamicComponent>(p => p.Add(x => x.Type, type).Add(x => x.Parameters, values));
if (type == typeof(GalaxyDeviceForm) || type == typeof(MqttDeviceForm)) cut.FindAll("input,select,textarea").ShouldBeEmpty();
else cut.FindAll("input,select,textarea").ShouldNotBeEmpty(type.Name);
}
/// <summary>Existing number parsing stays in Blazor and cannot silently alter emitted protocol JSON.</summary>
[Theory]
[InlineData(typeof(AbCipDriverForm))]
[InlineData(typeof(AbLegacyDriverForm))]
[InlineData(typeof(FocasDriverForm))]
[InlineData(typeof(GalaxyDriverForm))]
[InlineData(typeof(HeidenhainDriverForm))]
[InlineData(typeof(ModbusDriverForm))]
[InlineData(typeof(MqttDriverForm))]
[InlineData(typeof(MTConnectDriverForm))]
[InlineData(typeof(OpcUaClientDriverForm))]
[InlineData(typeof(S7DriverForm))]
[InlineData(typeof(SqlDriverForm))]
[InlineData(typeof(TwinCATDriverForm))]
[Trait("Category", "Unit")]
public void ProtocolFields_InvalidNumberHasLinkedFeedbackAndPreservesConfig(Type type)
{
var cut = Render<CascadingValue<EditContext>>(p => p.Add(x => x.Value, new EditContext(new object()))
.Add(x => x.ChildContent, (RenderFragment)(builder =>
{
builder.OpenComponent<DynamicComponent>(0); builder.AddAttribute(1, "Type", type); builder.CloseComponent();
})));
object instance = cut.FindComponent<DynamicComponent>().Instance.Instance!;
MethodInfo getConfig = type.GetMethod("GetConfigJson")!;
string before = (string)getConfig.Invoke(instance, null)!;
var input = cut.Find("input[type=number]");
input.Change("not-a-number");
input = cut.Find("input[type=number]");
input.GetAttribute("aria-invalid").ShouldBe("true");
string description = string.Join(" ", (input.GetAttribute("aria-describedby") ?? string.Empty)
.Split(' ', StringSplitOptions.RemoveEmptyEntries).Select(id => FindById(cut, id).TextContent));
description.ShouldContain("number");
getConfig.Invoke(instance, null).ShouldBe(before);
}
/// <summary>Conditional protocol branches retain labels and descriptions in simultaneous instances.</summary>
[Theory]
[InlineData(typeof(MqttTagConfigEditor), "{\"groupId\":\"Plant1\",\"edgeNodeId\":\"E1\",\"deviceId\":\"D1\",\"metricName\":\"Temp\"}")]
[InlineData(typeof(SqlTagConfigEditor), "{\"model\":\"Query\",\"queryName\":\"fixture\"}")]
[InlineData(typeof(SqlTagConfigEditor), "{\"model\":\"WideRow\",\"rowSelector\":{\"whereColumn\":\"station\",\"whereValue\":\"1\"}}")]
[InlineData(typeof(SqlTagConfigEditor), "{\"model\":\"WideRow\",\"rowSelector\":{\"topByTimestamp\":\"sample_ts\"}}")]
[InlineData(typeof(HeidenhainTagConfigEditor), "{\"address\":\"Status/ExecutionState\"}")]
[InlineData(typeof(HeidenhainTagConfigEditor), "{\"address\":\"ALARM:*\"}")]
[InlineData(typeof(FocasTagConfigEditor), "{\"address\":\"R100\",\"dataType\":\"String\"}")]
[Trait("Category", "Unit")]
public void ProtocolFields_ConditionalBranchesResolveRelationships(Type type, string config)
{
var cut = Render<CascadingValue<EditContext>>(p => p.Add(x => x.Value, new EditContext(new object()))
.Add(x => x.ChildContent, (RenderFragment)(builder =>
{
for (int i = 0; i < 2; i++)
{
builder.OpenComponent(0, type); builder.SetKey(i);
builder.AddAttribute(1, "ConfigJson", config); builder.CloseComponent();
}
})));
AssertRelationships(cut, type);
if (type == typeof(FocasTagConfigEditor))
{
cut.FindAll("[aria-invalid=true]").Count.ShouldBe(4);
foreach (var input in cut.FindAll("[aria-invalid=true]"))
FindById(cut, input.GetAttribute("aria-describedby")!).TextContent.ShouldNotBeNullOrWhiteSpace();
}
}
private static void AssertRelationships(IRenderedComponent<CascadingValue<EditContext>> cut, Type type)
{
var controls = cut.FindAll("input:not([type=hidden]),select,textarea");
var ids = cut.FindAll("[id]").Select(e => e.Id).ToArray();
ids.Distinct(StringComparer.Ordinal).Count().ShouldBe(ids.Length, type.Name + " repeated IDs");
foreach (IElement input in controls)
{
string label = input.GetAttribute("aria-label") ?? string.Empty;
if (string.IsNullOrWhiteSpace(label) && input.GetAttribute("aria-labelledby") is { } namedBy)
label = string.Join(" ", namedBy.Split(' ', StringSplitOptions.RemoveEmptyEntries).Select(id => FindById(cut, id).TextContent));
if (string.IsNullOrWhiteSpace(label) && !string.IsNullOrEmpty(input.Id))
label = string.Join(" ", cut.FindAll("label").Where(e => e.GetAttribute("for") == input.Id).Select(e => e.TextContent));
if (string.IsNullOrWhiteSpace(label)) label = input.Closest("label")?.TextContent ?? string.Empty;
label.ShouldNotBeNullOrWhiteSpace(type.Name + ": " + input.OuterHtml);
foreach (string id in (input.GetAttribute("aria-describedby") ?? string.Empty).Split(' ', StringSplitOptions.RemoveEmptyEntries))
FindById(cut, id).ShouldNotBeNull();
}
foreach (var label in cut.FindAll("label[for]"))
FindById(cut, label.GetAttribute("for")!).ShouldNotBeNull();
}
private static IElement FindById(IRenderedComponent<CascadingValue<EditContext>> cut, string id) => cut.FindAll("[id]").Single(e => e.Id == id);
/// <summary>The only render-time dependency returns an empty synthetic script list; mutations fail closed.</summary>
public class ScriptListOnlyProxy : DispatchProxy
{
protected override object? Invoke(MethodInfo? method, object?[]? args) => method?.Name == nameof(IUnsTreeService.LoadScriptsAsync)
? Task.FromResult<IReadOnlyList<(string ScriptId, string Display)>>([])
: throw new NotSupportedException("Protocol field fixture does not execute operations: " + method?.Name);
}
}