fix(central-ui): Debug View reconnect guards the stored instance; drop select-era sort; deep-link-in-area test
Three final-review findings on the two picker pages: 1. DebugView's localStorage auto-reconnect restored the stored instance id with no membership check, where the ?instanceId= path has one — a stored instance that is no longer Enabled (or was deleted, or moved sites) is filtered out of the list the picker is handed, so the field rendered blank while the page held a non-zero id and auto-connected to it anyway. The guard now mirrors the deep-link path: forget the stored instance id, tell the operator, and leave the site selected and loaded so they can pick again. 2. FlowDebugger's _instances kept an OrderBy(UniqueName) from the flat <select> era; InstanceTreeBuilder sorts areas and instances itself. 3. The deep-link test is joined by one where the instance sits two areas deep, so the field text is pinned to resolve from the flat list with the panel never opened. Claude-Session: https://claude.ai/code/session_01NcMG6xXdsJbmD2wYAgkK29
This commit is contained in:
@@ -816,6 +816,37 @@ public class FlowDebuggerPageTests : BunitContext
|
||||
Assert.Equal("Sim01", cut.Find("[data-test='flow-instance-input']").GetAttribute("value")));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The same deep link, but the instance sits two areas deep. The picker resolves the field
|
||||
/// text from <c>SelectedInstanceId</c> against the flat instance list, not by walking the
|
||||
/// tree — so a nested instance must show its name with the panel never opened (and therefore
|
||||
/// with Line1 / Cell A never expanded).
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void ScriptEntry_DeepLink_InstanceIdInsideAnArea_ShowsItsNameWithoutOpeningThePanel()
|
||||
{
|
||||
RegisterServices();
|
||||
WireInstance();
|
||||
_templates.GetAreasBySiteIdAsync(1, Arg.Any<CancellationToken>())
|
||||
.Returns(Task.FromResult<IReadOnlyList<Area>>(
|
||||
[new Area("Line1") { Id = 1, SiteId = 1 }, new Area("Cell A") { Id = 2, SiteId = 1, ParentAreaId = 1 }]));
|
||||
var nested = new Instance("Sim01") { Id = 7, SiteId = 1, TemplateId = 10, AreaId = 2 };
|
||||
_templates.GetInstancesBySiteIdAsync(1, Arg.Any<CancellationToken>())
|
||||
.Returns(Task.FromResult<IReadOnlyList<Instance>>([nested]));
|
||||
_templates.GetInstanceByIdAsync(7, Arg.Any<CancellationToken>()).Returns(nested);
|
||||
|
||||
var nav = Services.GetRequiredService<NavigationManager>();
|
||||
nav.NavigateTo("/deployment/flow-debugger?instanceId=7");
|
||||
|
||||
var cut = Render<FlowDebuggerPage>();
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
Assert.Equal("Sim01", cut.Find("[data-test='flow-instance-input']").GetAttribute("value")));
|
||||
// The panel was never opened, so nothing of the tree is rendered.
|
||||
Assert.Empty(cut.FindAll("[data-test='flow-instance-panel']"));
|
||||
Assert.Empty(cut.FindAll("[data-test='flow-instance-row']"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The picker must stay disabled for the WHOLE site load, not just until the site id lands.
|
||||
/// Blazor renders as soon as <c>OnSiteChangedAsync</c> hits its first await, and at that point
|
||||
|
||||
Reference in New Issue
Block a user