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

This commit is contained in:
Joseph Doherty
2026-09-08 09:49:19 -04:00
2 changed files with 33 additions and 2 deletions
@@ -815,4 +815,31 @@ public class FlowDebuggerPageTests : BunitContext
cut.WaitForAssertion(() =>
Assert.Equal("Sim01", cut.Find("[data-test='flow-instance-input']").GetAttribute("value")));
}
[Fact]
public void ScriptEntry_SiteChange_ClearsThePickedInstance()
{
RegisterServices();
WireInstance();
// A second site the operator can switch to, with no instances of its own.
_sites.GetAllSitesAsync(Arg.Any<CancellationToken>()).Returns(Task.FromResult<IReadOnlyList<Site>>(
[new Site("Plant A", "site-a") { Id = 1 }, new Site("Plant B", "site-b") { Id = 2 }]));
_templates.GetInstancesBySiteIdAsync(2, Arg.Any<CancellationToken>())
.Returns(Task.FromResult<IReadOnlyList<Instance>>([]));
_templates.GetAreasBySiteIdAsync(2, Arg.Any<CancellationToken>())
.Returns(Task.FromResult<IReadOnlyList<Area>>([]));
var cut = Render<FlowDebuggerPage>();
cut.Find("button[data-test='flow-entry-script']").Click();
cut.Find("select[data-test='flow-site-select']").Change("1");
PickInstance(cut, 7);
Assert.Equal("Sim01", cut.Find("[data-test='flow-instance-input']").GetAttribute("value"));
cut.Find("select[data-test='flow-site-select']").Change("2");
// The pick is dropped on both sides: the page's id and the picker's field text, which
// it re-derives because the new site handed it a different instance list.
Assert.Equal(string.Empty, cut.Find("[data-test='flow-instance-input']").GetAttribute("value"));
Assert.Equal(["— choose —"], cut.FindAll("select[data-test='flow-script-select'] option").Select(o => o.TextContent.Trim()).ToList());
}
}