mirror of
https://github.com/Tencent/BrowserSkill.git
synced 2026-10-02 07:34:35 +08:00
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:
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user