From c6a32e8fefb0a7180be1fe23051490c9d00781bb Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sat, 27 Jun 2026 13:48:58 -0400 Subject: [PATCH] test(central-ui): cover tree-select path for OnNodeSelected DataType --- .../NodeBrowserDialogSelectionTests.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.Tests/Components/NodeBrowserDialogSelectionTests.cs b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.Tests/Components/NodeBrowserDialogSelectionTests.cs index 3ecf52a3..4947259b 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.Tests/Components/NodeBrowserDialogSelectionTests.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.Tests/Components/NodeBrowserDialogSelectionTests.cs @@ -66,4 +66,36 @@ public class NodeBrowserDialogSelectionTests : BunitContext Assert.Empty(cut.FindAll("[data-test=node-search-input]")); } + + // The Secured Writes page browses MxGateway with ShowSearch=false, so the + // ONLY user-reachable selection path in production is the tree (Select(TreeNode) + // → _selectedNode = node.Source). This guards that path end-to-end: a tree-node + // click must carry the node's DataType through Confirm → OnNodeSelected. + [Fact] + public void TreeSelect_emits_full_node_with_datatype_on_OnNodeSelected() + { + _browse.BrowseChildrenAsync( + Arg.Any(), Arg.Any(), Arg.Any(), + Arg.Any(), Arg.Any()) + .Returns(new BrowseNodeResult( + new[] { new BrowseNode("Area1.Pump.Speed", "Speed", BrowseNodeClass.Variable, HasChildren: false, DataType: "Float") }, + Truncated: false, Failure: null)); + + BrowseNode? captured = null; + var cut = Render(p => p + .Add(c => c.SiteId, "plant-a") + .Add(c => c.ConnectionName, "PLC-MX") + .Add(c => c.ShowSearch, false) + .Add(c => c.OnNodeSelected, EventCallback.Factory.Create(this, n => captured = n))); + cut.InvokeAsync(() => cut.Instance.ShowAsync("plant-a", "PLC-MX", null)); + cut.Render(); + + // Click the tree node's select link (tree path, not search). + cut.Find(".node-browser-tree a").Click(); + cut.Find(".modal-footer .btn-primary").Click(); + + Assert.NotNull(captured); + Assert.Equal("Area1.Pump.Speed", captured!.NodeId); + Assert.Equal("Float", captured.DataType); + } }