Files
openclaw/extensions/browser/src/browser-tool.schema.test.ts
Peter Steinberger 01d6ea1f0e feat(browser): expose agent download actions (#101369)
* feat(browser): expose agent download actions

Co-authored-by: changcy <742592895@qq.com>

* chore: keep release notes in PR context

---------

Co-authored-by: changcy <742592895@qq.com>
2026-07-07 06:17:52 +01:00

42 lines
1.8 KiB
TypeScript

// Browser tests cover browser tool.schema plugin behavior.
import { describe, expect, it } from "vitest";
import { BrowserToolSchema } from "./browser-tool.schema.js";
import { ACT_MAX_VIEWPORT_DIMENSION } from "./browser/act-policy.js";
type SchemaRecord = Record<string, { maximum?: number; properties?: SchemaRecord }>;
type SchemaProperty = {
description?: string;
enum?: string[];
maximum?: number;
properties?: SchemaRecord;
};
type BrowserSchemaRecord = Record<string, SchemaProperty>;
describe("browser tool schema", () => {
it("advertises the viewport resize maximum on nested and flattened act params", () => {
const properties = BrowserToolSchema.properties as SchemaRecord;
const requestProperties = properties.request.properties ?? {};
expect(properties.width.maximum).toBe(ACT_MAX_VIEWPORT_DIMENSION);
expect(properties.height.maximum).toBe(ACT_MAX_VIEWPORT_DIMENSION);
expect(requestProperties.width.maximum).toBe(ACT_MAX_VIEWPORT_DIMENSION);
expect(requestProperties.height.maximum).toBe(ACT_MAX_VIEWPORT_DIMENSION);
});
it("describes targetId as a compatible tab reference", () => {
const properties = BrowserToolSchema.properties as BrowserSchemaRecord;
const requestProperties = properties.request.properties as BrowserSchemaRecord;
expect(properties.targetId.description).toContain("Prefer suggestedTargetId");
expect(properties.targetId.description).toContain("raw CDP targetId");
expect(requestProperties.targetId.description).toBe(properties.targetId.description);
});
it("exposes explicit download actions and their output path", () => {
const properties = BrowserToolSchema.properties as BrowserSchemaRecord;
expect(properties.action.enum).toEqual(expect.arrayContaining(["download", "waitfordownload"]));
expect(properties.path).toBeDefined();
});
});