fix(centralui): enable Test Bindings for MxGateway connections
The Test Bindings button was disabled (greyed out) for any attribute bound to a non-OPC-UA connection. BuildTestableRows() filtered to protocol == "OpcUa", a stale gate left over from when OPC UA was the only protocol. ReadTagValuesCommand is protocol-agnostic (routes through IDataConnection.ReadBatchAsync, which MxGatewayDataConnection implements), so the filter only blocked the UI — mirroring the already-fixed IsBrowsable. Remove the OPC-UA-only filter and update the stale comments. Add a bUnit regression test (theory over MxGateway + OpcUa) asserting the button is enabled for a readable-protocol binding. Verified live: dialog opens for an MxGateway binding and returns a Good-quality read.
This commit is contained in:
+59
@@ -104,4 +104,63 @@ public class InstanceConfigureAuditDrillinTests : BunitContext
|
||||
Assert.Contains("Recent audit activity", link.TextContent);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Regression: the Test Bindings button must be enabled for an attribute
|
||||
/// bound to an MxGateway connection. The site-side ReadTagValuesCommand
|
||||
/// path is protocol-agnostic (routes through IDataConnection.ReadBatchAsync,
|
||||
/// which MxGateway implements), so the UI must not gate the button on
|
||||
/// protocol == "OpcUa". Previously BuildTestableRows filtered to OPC UA
|
||||
/// only, leaving the button greyed for MxGateway bindings.
|
||||
/// </summary>
|
||||
[Theory]
|
||||
[InlineData("MxGateway")]
|
||||
[InlineData("OpcUa")]
|
||||
public void TestBindingsButton_Enabled_ForReadableProtocol(string protocol)
|
||||
{
|
||||
var instance = new Instance("Pump-42")
|
||||
{
|
||||
Id = 42,
|
||||
TemplateId = 1,
|
||||
SiteId = 1,
|
||||
State = ZB.MOM.WW.ScadaBridge.Commons.Types.Enums.InstanceState.NotDeployed,
|
||||
};
|
||||
|
||||
_templateRepo.GetInstanceByIdAsync(42, Arg.Any<CancellationToken>()).Returns(instance);
|
||||
_templateRepo.GetTemplateByIdAsync(1, Arg.Any<CancellationToken>())
|
||||
.Returns(new Template("Pump") { Id = 1 });
|
||||
_siteRepo.GetAllSitesAsync(Arg.Any<CancellationToken>())
|
||||
.Returns(new List<Site> { new("Plant A", "plant-a") { Id = 1 } });
|
||||
_templateRepo.GetAreasBySiteIdAsync(1, Arg.Any<CancellationToken>())
|
||||
.Returns(new List<Area>());
|
||||
// One data-sourced attribute (non-empty DataSourceReference => testable row).
|
||||
_templateRepo.GetAttributesByTemplateIdAsync(1, Arg.Any<CancellationToken>())
|
||||
.Returns(new List<TemplateAttribute>
|
||||
{
|
||||
new("Speed") { Id = 1, DataSourceReference = "TestMachine_001.TestHistoryValue" },
|
||||
});
|
||||
// A connection on the attribute's chosen protocol.
|
||||
_siteRepo.GetDataConnectionsBySiteIdAsync(1, Arg.Any<CancellationToken>())
|
||||
.Returns(new List<DataConnection> { new("Shared", protocol, 1) { Id = 7 } });
|
||||
_templateRepo.GetBindingsByInstanceIdAsync(42, Arg.Any<CancellationToken>())
|
||||
.Returns(new List<InstanceConnectionBinding>
|
||||
{
|
||||
new("Speed") { Id = 1, InstanceId = 42, DataConnectionId = 7 },
|
||||
});
|
||||
_templateRepo.GetOverridesByInstanceIdAsync(42, Arg.Any<CancellationToken>())
|
||||
.Returns(new List<InstanceAttributeOverride>());
|
||||
_templateRepo.GetAlarmsByTemplateIdAsync(1, Arg.Any<CancellationToken>())
|
||||
.Returns(new List<TemplateAlarm>());
|
||||
_templateRepo.GetAlarmOverridesByInstanceIdAsync(42, Arg.Any<CancellationToken>())
|
||||
.Returns(new List<InstanceAlarmOverride>());
|
||||
|
||||
var cut = Render<InstanceConfigurePage>(p => p.Add(c => c.Id, 42));
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
var testButton = cut.FindAll("button").Single(b => b.TextContent.Trim() == "Test Bindings");
|
||||
Assert.False(testButton.HasAttribute("disabled"),
|
||||
$"Test Bindings should be enabled for a {protocol} binding.");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user