fix(sidebar): expand collapsed groups when locating tab

Closes #7387
This commit is contained in:
t8y2 committed 2026-08-27 16:33:23 +08:00
1 parent e4dc5bace8
commit 4eeeafa858
4 files changed
+120 -2

No files matched your search

@@ -0,0 +1,20 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
const connectionTreeSource = readFileSync(new URL("../ConnectionTree.vue", import.meta.url), "utf8");
describe("ConnectionTree locate in collapsed groups", () => {
it("reopens collapsed connection groups on the node path through the persisted layout op", () => {
// Group expansion must flow through store.expandConnectionGroups so
// layout.collapsed is flipped and the next layout rebuild keeps the group
// open; flipping isExpanded directly would be reverted by that rebuild.
expect(connectionTreeSource).toMatch(/const collapsedGroupIds = nodePath\s*\.filter\(\(node\) => node\.type === "connection-group" && !node\.isExpanded\)\s*\.map\(\(node\) => node\.id\);/);
// The expansion happens before the flat-tree match that drives selection,
// scrolling and flashing, so the reopened groups are visible to it.
expect(connectionTreeSource).toMatch(/store\.expandConnectionGroups\(collapsedGroupIds\);\s*\}\s*\n\s*await nextTick\(\);\s*\n\s*const match = target \? findSidebarNodeForTarget\(target, flatNodes\.value\) : null;/);
});
it("still gates generic ancestor expansion on loaded children only (#5850)", () => {
expect(connectionTreeSource).toMatch(/if \(!ancestor\.isExpanded && store\.canUseLoadedTreeNodeToggle\(ancestor\)\) \{\s*ancestor\.isExpanded = true;\s*\}/);
});
});