Merge branch 'worktree-agent-a9d87141c744e7733' into feat/instance-picker

This commit is contained in:
Joseph Doherty
2026-09-08 09:48:25 -04:00
2 changed files with 37 additions and 12 deletions
@@ -83,7 +83,7 @@
<div class="col-md-4">
<label class="form-label small">Instance</label>
<InstancePicker Areas="_siteAreas" Instances="_siteInstances"
ItemLabel="@(i => $"{i.UniqueName} ({i.State})")"
ItemLabel="InstanceLabel"
SelectedInstanceId="_selectedInstanceId" SelectedInstanceIdChanged="OnInstancePicked"
Disabled="@_connected" DataTestPrefix="debug-instance" />
</div>
@@ -455,17 +455,22 @@
}
}
/// <summary>Handles a pick from the <c>InstancePicker</c> combobox.</summary>
private void OnInstancePicked(int id)
{
_selectedInstanceId = id;
OnInstanceSelectionChanged();
}
/// <summary>
/// The label the <c>InstancePicker</c> renders on a row and in its field:
/// the instance's unique name with its lifecycle state.
/// </summary>
/// <param name="instance">The instance to label.</param>
/// <returns>The display label, e.g. <c>Line1.Mixer (Enabled)</c>.</returns>
private static string InstanceLabel(Instance instance) =>
$"{instance.UniqueName} ({instance.State})";
private void OnInstanceSelectionChanged()
{
// No-op; selection is tracked via _selectedInstanceId binding
}
/// <summary>
/// Records the instance the operator picked in the <c>InstancePicker</c>.
/// Everything downstream (the Connect button's enablement, <c>Connect()</c>
/// itself) reads <c>_selectedInstanceId</c>, so there is nothing else to do.
/// </summary>
/// <param name="id">Id of the picked instance.</param>
private void OnInstancePicked(int id) => _selectedInstanceId = id;
/// <summary>
/// When the attribute filter changes, expand the tree so any branches holding
@@ -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;
/// <c>&lt;select&gt;</c> to the shared <c>InstancePicker</c> 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 <em>Connect</em>.
/// that the selection still enables <em>Connect</em>, and that a live connection
/// locks the picker down.
/// </summary>
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<DebugViewPage>();
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"));
}
}