feat(adminui): link /fleet rows to node diagnostics; show authored driver names (A-F4, A-F5)
/fleet/diagnostics was reachable only by URL: each driver-role row on /fleet now links to it (FleetDiagnosticsLinks.For escapes the host:port node id). The diagnostics table showed the string instance id because the wire carries no display name; the page now joins the authored DriverInstances.Name from the ConfigDb (enrichment only - a failed lookup falls back to the id) and keeps the id beneath the name. Refs #745 Claude-Session: https://claude.ai/code/session_01Ub9hGmYLQvn9XETzw7CMsT
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZB.MOM.WW.OtOpcUa.AdminUI.Clients;
|
||||
using ZB.MOM.WW.OtOpcUa.Configuration;
|
||||
using ZB.MOM.WW.OtOpcUa.Configuration.Entities;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests;
|
||||
|
||||
/// <summary>A-F4 / A-F5: <c>/fleet</c> links to the per-node diagnostics page, which shows authored names.</summary>
|
||||
[Trait("Category", "Unit")]
|
||||
public sealed class FleetDiagnosticsLinksTests
|
||||
{
|
||||
[Fact]
|
||||
public void Link_escapes_the_node_id()
|
||||
=> FleetDiagnosticsLinks.For("host-a:4053").ShouldBe("/fleet/diagnostics?node=host-a%3A4053");
|
||||
|
||||
[Fact]
|
||||
public async Task Display_names_join_from_the_config_db_and_unknown_ids_are_absent()
|
||||
{
|
||||
var name = Guid.NewGuid().ToString("N");
|
||||
var options = new DbContextOptionsBuilder<OtOpcUaConfigDbContext>().UseInMemoryDatabase(name).Options;
|
||||
await using (var seed = new OtOpcUaConfigDbContext(options))
|
||||
{
|
||||
seed.DriverInstances.Add(new DriverInstance
|
||||
{
|
||||
DriverInstanceId = "drv-press-1", ClusterId = "MAIN", Name = "Press line Modbus",
|
||||
DriverType = "Modbus", DriverConfig = "{}",
|
||||
});
|
||||
await seed.SaveChangesAsync();
|
||||
}
|
||||
|
||||
await using var db = new OtOpcUaConfigDbContext(options);
|
||||
var names = await FleetDiagnosticsLinks.LoadDisplayNamesAsync(db, ["drv-press-1", "drv-unknown"]);
|
||||
|
||||
names["DRV-PRESS-1"].ShouldBe("Press line Modbus"); // the returned map is case-insensitive
|
||||
names.ContainsKey("drv-unknown").ShouldBeFalse();
|
||||
|
||||
(await FleetDiagnosticsLinks.LoadDisplayNamesAsync(db, [])).ShouldBeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Fleet_rows_link_driver_nodes_and_the_page_uses_the_names()
|
||||
{
|
||||
AdminUiSource.Read("Components", "Pages", "Fleet.razor")
|
||||
.ShouldContain("href=\"@FleetDiagnosticsLinks.For(r.NodeId)\"");
|
||||
var diag = AdminUiSource.Read("Components", "Pages", "FleetDiagnostics.razor");
|
||||
diag.ShouldContain("FleetDiagnosticsLinks.LoadDisplayNamesAsync(");
|
||||
diag.ShouldContain("@DisplayNameOf(d)");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user