diff --git a/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Deployment/DebugView.razor b/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Deployment/DebugView.razor index 6a20f5ff..5b0b00ae 100644 --- a/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Deployment/DebugView.razor +++ b/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Deployment/DebugView.razor @@ -83,7 +83,7 @@
@@ -455,17 +455,22 @@ } } - /// Handles a pick from the InstancePicker combobox. - private void OnInstancePicked(int id) - { - _selectedInstanceId = id; - OnInstanceSelectionChanged(); - } + /// + /// The label the InstancePicker renders on a row and in its field: + /// the instance's unique name with its lifecycle state. + /// + /// The instance to label. + /// The display label, e.g. Line1.Mixer (Enabled). + private static string InstanceLabel(Instance instance) => + $"{instance.UniqueName} ({instance.State})"; - private void OnInstanceSelectionChanged() - { - // No-op; selection is tracked via _selectedInstanceId binding - } + /// + /// Records the instance the operator picked in the InstancePicker. + /// Everything downstream (the Connect button's enablement, Connect() + /// itself) reads _selectedInstanceId, so there is nothing else to do. + /// + /// Id of the picked instance. + private void OnInstancePicked(int id) => _selectedInstanceId = id; /// /// When the attribute filter changes, expand the tree so any branches holding diff --git a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.Tests/Deployment/DebugViewInstancePickerTests.cs b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.Tests/Deployment/DebugViewInstancePickerTests.cs index 43cee11c..99486101 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.Tests/Deployment/DebugViewInstancePickerTests.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.Tests/Deployment/DebugViewInstancePickerTests.cs @@ -1,3 +1,4 @@ +using System.Reflection; using System.Security.Claims; using Bunit; using Microsoft.AspNetCore.Components.Authorization; @@ -21,7 +22,8 @@ namespace ZB.MOM.WW.ScadaBridge.CentralUI.Tests.Deployment; /// <select> to the shared InstancePicker area-tree combobox /// (design 2026-09-08). Pins that the page hands the picker the site's areas and /// its Enabled-only instance list, that drilling down the tree selects an instance, -/// and that the selection still enables Connect. +/// that the selection still enables Connect, and that a live connection +/// locks the picker down. /// public class DebugViewInstancePickerTests : BunitContext { @@ -153,4 +155,22 @@ public class DebugViewInstancePickerTests : BunitContext .First(b => b.TextContent.Contains("Connect")); Assert.False(connect.HasAttribute("disabled")); } + + [Fact] + public void WhileConnected_ThePickerIsDisabled() + { + RegisterServices(); + var cut = Render(); + cut.Find("[data-test='debug-site-select']").Change(SiteId.ToString()); + + // Mark the page connected the way the other DebugView page tests do — + // driving the real gRPC stream is not available to a bUnit render. + cut.InvokeAsync(() => typeof(DebugViewPage) + .GetField("_connected", BindingFlags.Instance | BindingFlags.NonPublic)! + .SetValue(cut.Instance, true)); + cut.Render(); + + Assert.True(cut.Find("[data-test='debug-instance-input']").HasAttribute("disabled")); + Assert.True(cut.Find("[data-test='debug-instance-toggle']").HasAttribute("disabled")); + } }