refactor(centralui): complete cycle fallback + polish in ExecutionTree
This commit is contained in:
@@ -184,6 +184,49 @@ public class ExecutionTreeTests : BunitContext
|
||||
Assert.Equal(1, CountOccurrences(cut.Markup, $"data-test=\"tree-node-{b}\""));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToggleExpand_CollapsesAndReExpandsChildSubtree()
|
||||
{
|
||||
// root → child → grandchild. Clicking the root's toggle collapses its
|
||||
// subtree (the child node disappears); clicking it again re-expands.
|
||||
var root = Guid.Parse("aaaaaaaa-3333-3333-3333-333333333333");
|
||||
var child = Guid.Parse("bbbbbbbb-3333-3333-3333-333333333333");
|
||||
var grandchild = Guid.Parse("cccccccc-3333-3333-3333-333333333333");
|
||||
var nodes = new List<ExecutionTreeNode>
|
||||
{
|
||||
Node(root, null),
|
||||
Node(child, root),
|
||||
Node(grandchild, child),
|
||||
};
|
||||
|
||||
var cut = Render<ExecutionTree>(p => p
|
||||
.Add(c => c.Nodes, nodes)
|
||||
.Add(c => c.ArrivedFromExecutionId, root));
|
||||
|
||||
// All nodes start expanded — the whole chain is visible on arrival.
|
||||
Assert.Contains($"data-test=\"tree-node-{child}\"", cut.Markup);
|
||||
Assert.Contains($"data-test=\"tree-node-{grandchild}\"", cut.Markup);
|
||||
|
||||
var toggle = cut.Find($"[data-test=\"tree-toggle-{root}\"]");
|
||||
Assert.Equal("true", toggle.GetAttribute("aria-expanded"));
|
||||
|
||||
// Collapse: the child (and its descendants) must disappear.
|
||||
toggle.Click();
|
||||
Assert.DoesNotContain($"data-test=\"tree-node-{child}\"", cut.Markup);
|
||||
Assert.DoesNotContain($"data-test=\"tree-node-{grandchild}\"", cut.Markup);
|
||||
Assert.Equal(
|
||||
"false",
|
||||
cut.Find($"[data-test=\"tree-toggle-{root}\"]").GetAttribute("aria-expanded"));
|
||||
|
||||
// Re-expand: the child subtree reappears.
|
||||
cut.Find($"[data-test=\"tree-toggle-{root}\"]").Click();
|
||||
Assert.Contains($"data-test=\"tree-node-{child}\"", cut.Markup);
|
||||
Assert.Contains($"data-test=\"tree-node-{grandchild}\"", cut.Markup);
|
||||
Assert.Equal(
|
||||
"true",
|
||||
cut.Find($"[data-test=\"tree-toggle-{root}\"]").GetAttribute("aria-expanded"));
|
||||
}
|
||||
|
||||
private static int CountOccurrences(string haystack, string needle)
|
||||
{
|
||||
int count = 0, idx = 0;
|
||||
|
||||
Reference in New Issue
Block a user