test(client): cover observationTabOpen without a right-column tree

Fixes the typecheck failure introduced by marking `splits` optional: withTabOpened keeps a missing `splits` as-is instead of feeding it to the walker, and a regression test asserts observationTabOpen does not dereference an absent right-column tree (DSH 0.1.5 / better-sidebar 0.19+).
This commit is contained in:
hZsFN
2026-09-11 17:57:28 +08:00
parent dd4e60d77e
commit 7bf0cdf5a0
@@ -117,7 +117,7 @@ function withTabOpened(state: SidebarStateLike, type: string): SidebarStateLike
}
return { ...node, children: node.children.map(walk) };
};
return { ...state, splits: walk(state.splits) };
return { ...state, splits: state.splits === undefined ? undefined : walk(state.splits) };
}
function makeSidebar(
@@ -280,6 +280,16 @@ describe("observationTabOpen", () => {
};
expect(observationTabOpen(inBottom)).toBe(true);
});
it("does not crash when the right-column tree is absent (DSH 0.1.5+)", () => {
// better-sidebar 0.19+ no longer emits `splits` (the right column moved to
// dsh's native Sidebar); the walk must skip absent roots, not dereference.
const noSplits: SidebarStateLike = {
bottomSplits: { kind: "leaf", id: "p2", active: null, tabs: [] },
};
expect(() => observationTabOpen(noSplits)).not.toThrow();
expect(observationTabOpen(noSplits)).toBe(false);
});
});
describe("ObservationSidebarTab", () => {