From a0292d3063ea2b0fc17b1c52637246147fad3331 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Tue, 8 Sep 2026 09:48:13 -0400 Subject: [PATCH] =?UTF-8?q?fix(central-ui):=20Debug=20View=20picker=20?= =?UTF-8?q?=E2=80=94=20disabled-while-connected=20test;=20drop=20no-op=20h?= =?UTF-8?q?andler;=20static=20label?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task 5 review follow-ups: - New DebugViewInstancePickerTests.WhileConnected_ThePickerIsDisabled pins that a live connection locks the picker: both the input and the chevron carry `disabled`. It marks the page connected by reflection, the way the other DebugView page tests do (DebugViewAlarmTableTests) — driving the real gRPC stream is not available to a bUnit render. - OnInstanceSelectionChanged() was already a no-op and its comment described the @bind that the picker replaced; deleted, and OnInstancePicked now just records the id (XML-documented). - The ItemLabel lambda is hoisted to a private static InstanceLabel(Instance), passed as a method group. Claude-Session: https://claude.ai/code/session_01NcMG6xXdsJbmD2wYAgkK29 --- .../Pages/Deployment/DebugView.razor | 27 +++++++++++-------- .../DebugViewInstancePickerTests.cs | 22 ++++++++++++++- 2 files changed, 37 insertions(+), 12 deletions(-) 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")); + } }