feat(m9/T24b): move-data-connection UI dialog + action

This commit is contained in:
Joseph Doherty
2026-06-18 11:45:53 -04:00
parent dbe51e5f25
commit 16cb078cd2
7 changed files with 530 additions and 0 deletions
@@ -26,11 +26,17 @@ public class DataConnectionsPageTests : BunitContext
// keeps every existing test green (no badge / unknown state when no report).
private readonly IConnectionHealthQueryService _healthQuery =
Substitute.For<IConnectionHealthQueryService>();
// M9-T24b: the page now opens a Move-to-Site dialog that dispatches the move
// through IDataConnectionMoveService (the guard-running ManagementActor path).
// Substituted so the page renders without a real ManagementActor in scope.
private readonly IDataConnectionMoveService _moveService =
Substitute.For<IDataConnectionMoveService>();
public DataConnectionsPageTests()
{
Services.AddSingleton(_siteRepo);
Services.AddSingleton(_healthQuery);
Services.AddSingleton(_moveService);
// Satisfy the page's [Inject] IDialogService — the host that actually
// renders the dialog lives in MainLayout, not in bUnit's render scope.
Services.AddScoped<IDialogService, DialogService>();
@@ -209,4 +215,52 @@ public class DataConnectionsPageTests : BunitContext
Assert.Contains("bg-danger", disconnectedBadge.GetAttribute("class"));
Assert.Contains("Disconnected", disconnectedBadge.TextContent);
}
[Fact]
public void ConnectionNode_Has_MoveToSiteAction()
{
// M9-T24b: each connection node exposes a "Move to Site…" action alongside
// Edit/Delete.
SeedRepos(
sites: new[]
{
new Site("Plant-A", "plant-a") { Id = 1 },
new Site("Plant-B", "plant-b") { Id = 2 }
},
connections: new[] { new DataConnection("PLC-1", "OpcUa", 1) { Id = 100 } });
var cut = Render<DataConnectionsPage>();
FindToggleForLabel(cut, "Plant-A")!.Click();
Assert.Contains(cut.FindAll("button"),
b => b.TextContent.Contains("Move to Site"));
}
[Fact]
public void MoveToSite_OpensDialog_ExcludingCurrentSite()
{
// M9-T24b: clicking "Move to Site…" opens the move dialog whose target-site
// picker omits the connection's current site (Plant-A) and lists the others.
SeedRepos(
sites: new[]
{
new Site("Plant-A", "plant-a") { Id = 1 },
new Site("Plant-B", "plant-b") { Id = 2 },
new Site("Plant-C", "plant-c") { Id = 3 }
},
connections: new[] { new DataConnection("PLC-1", "OpcUa", 1) { Id = 100 } });
var cut = Render<DataConnectionsPage>();
FindToggleForLabel(cut, "Plant-A")!.Click();
cut.FindAll("button").First(b => b.TextContent.Contains("Move to Site")).Click();
// The dialog renders with a site picker; the current site is excluded.
var dialog = cut.Find(".modal.show");
var optionLabels = dialog.QuerySelectorAll("select option")
.Select(o => o.TextContent).ToList();
Assert.Contains(optionLabels, l => l.Contains("Plant-B"));
Assert.Contains(optionLabels, l => l.Contains("Plant-C"));
Assert.DoesNotContain(optionLabels, l => l.Contains("Plant-A"));
}
}