diff options
| author | Adam Malczewski <[email protected]> | 2026-10-24 18:05:30 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-10-24 18:05:30 +0900 |
| commit | daefad66bdf8dee132d701a3b43ce0d227dde241 (patch) | |
| tree | 424ac806b3822247c0b835ee38ffabdf87f5016e /src/features/tabs/tab-groups.test.ts | |
| parent | c8b2fb49835bde2f85d99a91b313e6a01ce1359c (diff) | |
| parent | 0ba54b4455cb560cf7a82baf71b31ed129cfc29b (diff) | |
| download | dispatch-web-daefad66bdf8dee132d701a3b43ce0d227dde241.tar.gz dispatch-web-daefad66bdf8dee132d701a3b43ce0d227dde241.zip | |
Merge branch 'feature/close-tab-cascade-subagents' into dev
Diffstat (limited to 'src/features/tabs/tab-groups.test.ts')
| -rw-r--r-- | src/features/tabs/tab-groups.test.ts | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/features/tabs/tab-groups.test.ts b/src/features/tabs/tab-groups.test.ts index a09dbc8..46b04e7 100644 --- a/src/features/tabs/tab-groups.test.ts +++ b/src/features/tabs/tab-groups.test.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { buildTabGroups, + cascadeCloseIds, directGroupChildren, groupBleedPx, groupDescendants, @@ -104,6 +105,43 @@ describe("groupDescendants / directGroupChildren / groupParentCandidates", () => }); }); +describe("cascadeCloseIds (the ids a cascading tab close removes)", () => { + const tabs = [ + tab("p"), + tab("c1", "p"), + tab("c2", "p"), + tab("g", "c1"), // sub-sub-agent: grouped under c1, still cascades from p + tab("solo"), + ]; + + it("returns the tab first, then its transitive descendants in tab order", () => { + expect(cascadeCloseIds(tabs, "p")).toEqual(["p", "c1", "c2", "g"]); + }); + + it("starts the cascade at a mid-level tab, taking only its own subtree", () => { + expect(cascadeCloseIds(tabs, "c1")).toEqual(["c1", "g"]); + }); + + it("returns just the tab itself when it has no subagents (closes without a prompt)", () => { + expect(cascadeCloseIds(tabs, "solo")).toEqual(["solo"]); + expect(cascadeCloseIds(tabs, "c2")).toEqual(["c2"]); + }); + + it("matches the rendered forest for cycles and manual regrouping", () => { + const cycle = [tab("p", "c1"), tab("c1", "p"), tab("g", "c1")]; + expect(cascadeCloseIds(cycle, "p")).toEqual(["p"]); + expect(cascadeCloseIds(cycle, "c1")).toEqual(["c1", "g"]); + const regrouped = [tab("p"), tab("c1", "solo"), tab("g", "c1"), tab("solo")]; + expect(cascadeCloseIds(regrouped, "p")).toEqual(["p"]); + expect(cascadeCloseIds(regrouped, "solo")).toEqual(["solo", "c1", "g"]); + }); + + it("ignores tabs whose group parent is no longer open", () => { + const stale = [tab("p"), tab("orphan", "gone")]; + expect(cascadeCloseIds(stale, "p")).toEqual(["p"]); + }); +}); + describe("groupTone", () => { it("rotates three colours by level, starting at the outermost box", () => { expect([1, 2, 3, 4, 5, 6, 7].map(groupTone)).toEqual([ |
