mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 03:00:43 +00:00
test: tighten tool planner hidden assertions
This commit is contained in:
@@ -16,6 +16,16 @@ function descriptor(name: string, overrides: Partial<ToolDescriptor> = {}): Tool
|
||||
};
|
||||
}
|
||||
|
||||
type ToolPlan = ReturnType<typeof buildToolPlan>;
|
||||
|
||||
function expectHiddenTool(plan: ToolPlan, index: number): ToolPlan["hidden"][number] {
|
||||
const entry = plan.hidden[index];
|
||||
if (!entry) {
|
||||
throw new Error(`Expected hidden tool at index ${index}`);
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
describe("buildToolPlan", () => {
|
||||
it("sorts visible and hidden tools deterministically", () => {
|
||||
const plan = buildToolPlan({
|
||||
@@ -32,7 +42,9 @@ describe("buildToolPlan", () => {
|
||||
|
||||
expect(plan.visible.map((entry) => entry.descriptor.name)).toEqual(["alpha", "zeta"]);
|
||||
expect(plan.hidden.map((entry) => entry.descriptor.name)).toEqual(["hidden"]);
|
||||
expect(plan.hidden[0]?.diagnostics.map((entry) => entry.reason)).toEqual(["env-missing"]);
|
||||
expect(expectHiddenTool(plan, 0).diagnostics.map((entry) => entry.reason)).toEqual([
|
||||
"env-missing",
|
||||
]);
|
||||
});
|
||||
|
||||
it("fails deterministically on duplicate tool names", () => {
|
||||
@@ -81,8 +93,9 @@ describe("buildToolPlan", () => {
|
||||
});
|
||||
|
||||
expect(plan.visible).toEqual([]);
|
||||
expect(plan.hidden[0]?.descriptor.name).toBe("plugin_tool");
|
||||
expect(plan.hidden[0]?.diagnostics[0]?.reason).toBe("plugin-disabled");
|
||||
const hiddenTool = expectHiddenTool(plan, 0);
|
||||
expect(hiddenTool.descriptor.name).toBe("plugin_tool");
|
||||
expect(hiddenTool.diagnostics.map((entry) => entry.reason)).toEqual(["plugin-disabled"]);
|
||||
});
|
||||
|
||||
it("hides descriptors with malformed empty allOf availability", () => {
|
||||
@@ -91,8 +104,9 @@ describe("buildToolPlan", () => {
|
||||
});
|
||||
|
||||
expect(plan.visible).toEqual([]);
|
||||
expect(plan.hidden[0]?.descriptor.name).toBe("malformed");
|
||||
expect(plan.hidden[0]?.diagnostics).toEqual([
|
||||
const hiddenTool = expectHiddenTool(plan, 0);
|
||||
expect(hiddenTool.descriptor.name).toBe("malformed");
|
||||
expect(hiddenTool.diagnostics).toEqual([
|
||||
{
|
||||
reason: "unsupported-signal",
|
||||
message: "Empty availability allOf group",
|
||||
|
||||
Reference in New Issue
Block a user