fix(centralui): Deploy all runs in its own DI scope, live tick/Refresh/loaders pause during actions, dialog wording, failure/saved-state tests (Gitea #40)

This commit is contained in:
Joseph Doherty
2026-10-22 14:22:47 -04:00
parent bcd087efe8
commit e029dc1ccb
4 changed files with 56 additions and 11 deletions
@@ -318,6 +318,42 @@ public class TopologyPageTests : BunitContext
_repo.DidNotReceive().GetAreaByIdAsync(Arg.Any<int>(), Arg.Any<CancellationToken>());
}
/// <summary>A failing instance yields an error toast listing the failure, not the success toast.</summary>
[Fact]
public void DeployAll_FailedInstance_ShowsErrorToastWithFailureList()
{
var host = SeedDeployAllTopology();
var failing = new Instance("Pump-001") { Id = 101, SiteId = 1, AreaId = 10, State = InstanceState.NotDeployed };
_siteRepo.GetInstancesBySiteIdAsync(1, Arg.Any<CancellationToken>())
.Returns(Task.FromResult<IReadOnlyList<Instance>>(new List<Instance> { failing }));
_pipeline.FlattenAndValidateAsync(Arg.Any<int>(), Arg.Any<CancellationToken>(), Arg.Any<bool>())
.Returns(Task.FromResult(Result<FlatteningPipelineResult>.Failure("flatten boom")));
var cut = RenderLoadedTopology();
OpenMenu(cut, "Plant-A");
cut.FindAll("button.dropdown-item").First(b => b.TextContent.Trim() == "Deploy all…").Click();
host.Render();
host.WaitForElement("[data-test='deploy-all-confirm']").Click();
cut.WaitForAssertion(() =>
{
var toast = cut.Find(".toast-body").TextContent;
Assert.Contains("0 deployed, 0 skipped, 1 failed", toast);
Assert.Contains("Pump-001", toast);
});
}
/// <summary>A saved (collapsed) expansion state wins over InitiallyExpanded for sites.</summary>
[Fact]
public void InitialLoad_SavedCollapsedState_WinsOverInitiallyExpanded()
{
SeedRepos(sites: [new Site("Plant", "plant") { Id = 1 }],
areasBySite: new() { [1] = new List<Area> { new("Line A") { Id = 10, SiteId = 1 } } });
JSInterop.Setup<string?>("treeviewStorage.load", _ => true).SetResult("[]");
var cut = Render<TopologyPage>();
cut.WaitForAssertion(() => Assert.Contains("Plant", cut.Markup));
var siteLi = cut.FindAll("li[role='treeitem']").First(li => li.QuerySelector(".tv-label")?.TextContent == "Plant");
Assert.Equal("false", siteLi.GetAttribute("aria-expanded"));
}
/// <summary>Cancel performs no deploy (only the preview read happened).</summary>
[Fact]
public void DeployAll_Cancel_DoesNothing()