a7bd746f21
* Restructure dash * WIP * WIP * refactor trigger UI: extract PR summary card, add mentions section, rename labels Co-authored-by: Cursor <cursoragent@cursor.com> * clean up console UI: remove info icons from section descriptions, rename mentions trigger Co-authored-by: Cursor <cursoragent@cursor.com> * fix review feedback: layout, terminology, form scope - extract console sidebar sections to module-level constant - align three-column layout breakpoints to xl (match sidebar visibility) - fix mixed shell/bash terminology in beta page - scope FormProvider to trigger sections only, restore autoComplete="off" Co-authored-by: Cursor <cursoragent@cursor.com> * Bump --------- Co-authored-by: Cursor <cursoragent@cursor.com>
92 lines
2.7 KiB
TypeScript
92 lines
2.7 KiB
TypeScript
import { Inputs, JsonPayload } from "./payload.ts";
|
|
|
|
describe("Inputs schema", () => {
|
|
it("only prompt is required", () => {
|
|
const result = Inputs.assert({ prompt: "test prompt" });
|
|
expect(result).toEqual({ prompt: "test prompt" });
|
|
expect(() => Inputs.assert({})).toThrow();
|
|
});
|
|
|
|
it.each([
|
|
["web", "enabled"],
|
|
["web", "disabled"],
|
|
["web", undefined],
|
|
["search", "enabled"],
|
|
["search", "disabled"],
|
|
["search", undefined],
|
|
["push", "enabled"],
|
|
["push", "disabled"],
|
|
["push", undefined],
|
|
["shell", "enabled"],
|
|
["shell", "restricted"],
|
|
["shell", "disabled"],
|
|
["shell", undefined],
|
|
["effort", "mini"],
|
|
["effort", "auto"],
|
|
["effort", "max"],
|
|
["timeout", "10m"],
|
|
["timeout", "1h30m"],
|
|
["timeout", "30s"],
|
|
["timeout", undefined],
|
|
["agent", "claude"],
|
|
["agent", "codex"],
|
|
["agent", "cursor"],
|
|
["agent", "gemini"],
|
|
["agent", "opencode"],
|
|
// ['agent', null],
|
|
] as const)("should accept %s for %s", (prop, value) => {
|
|
const input = { prompt: "test", [prop]: value };
|
|
expect(() => Inputs.assert(input)).not.toThrow();
|
|
});
|
|
|
|
it.each([["web"], ["search"], ["push"], ["shell"], ["effort"], ["agent"]] as const)(
|
|
"should reject invalid %s values",
|
|
(prop) => {
|
|
const input = { prompt: "test", [prop]: "invalid" as any };
|
|
expect(() => Inputs.assert(input)).toThrow();
|
|
}
|
|
);
|
|
});
|
|
|
|
describe("JsonPayload schema", () => {
|
|
it("requires ~pullfrog and version and prompt", () => {
|
|
const result = JsonPayload.assert({
|
|
"~pullfrog": true,
|
|
version: "1.2.3",
|
|
prompt: "test prompt",
|
|
});
|
|
expect(result).toMatchObject({ "~pullfrog": true, version: "1.2.3", prompt: "test prompt" });
|
|
expect(() => JsonPayload.assert({})).toThrow();
|
|
expect(() => JsonPayload.assert({ "~pullfrog": true })).toThrow();
|
|
expect(() => JsonPayload.assert({ version: "1.2.3" })).toThrow();
|
|
});
|
|
|
|
it.each([
|
|
["agent", "claude"],
|
|
["agent", "codex"],
|
|
["agent", "cursor"],
|
|
["agent", "gemini"],
|
|
["agent", "opencode"],
|
|
["effort", "mini"],
|
|
["effort", "auto"],
|
|
["effort", "max"],
|
|
["timeout", "10m"],
|
|
["timeout", "1h30m"],
|
|
["timeout", "30s"],
|
|
["event", { trigger: "unknown" }],
|
|
] as const)("should accept optional %s with value %s", (prop, value) => {
|
|
const input = { "~pullfrog": true, version: "1.2.3", prompt: "test prompt", [prop]: value };
|
|
expect(() => JsonPayload.assert(input)).not.toThrow();
|
|
});
|
|
|
|
it.each([["agent"], ["effort"]] as const)("should reject invalid %s values", (prop) => {
|
|
const input = {
|
|
"~pullfrog": true,
|
|
version: "1.2.3",
|
|
prompt: "test prompt",
|
|
[prop]: "invalid" as any,
|
|
};
|
|
expect(() => JsonPayload.assert(input)).toThrow();
|
|
});
|
|
});
|