123 lines
3.5 KiB
TypeScript
123 lines
3.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { parseWorkflowArgs } from "./workflow-args.js";
|
|
|
|
describe("workflow start arguments", () => {
|
|
it("accepts an explicit new task boundary", () => {
|
|
expect(parseWorkflowArgs([
|
|
"start",
|
|
"--plan", "plan.json",
|
|
"--executor", "reasonix",
|
|
"--new-task",
|
|
])).toEqual({
|
|
sub: "start",
|
|
planInput: "plan.json",
|
|
executor: "reasonix",
|
|
vcs: undefined,
|
|
maxCycles: undefined,
|
|
newTask: true,
|
|
reviewer: undefined,
|
|
});
|
|
});
|
|
|
|
it("accepts a valid reviewer", () => {
|
|
expect(parseWorkflowArgs([
|
|
"start",
|
|
"--plan", "plan.json",
|
|
"--executor", "reasonix",
|
|
"--reviewer", "claude"
|
|
])).toEqual({
|
|
sub: "start",
|
|
planInput: "plan.json",
|
|
executor: "reasonix",
|
|
vcs: undefined,
|
|
maxCycles: undefined,
|
|
newTask: false,
|
|
reviewer: "claude",
|
|
});
|
|
});
|
|
|
|
it("throws on invalid reviewer", () => {
|
|
expect(() => parseWorkflowArgs([
|
|
"start",
|
|
"--plan", "plan.json",
|
|
"--executor", "reasonix",
|
|
"--reviewer", "invalid"
|
|
])).toThrow(/must be codex or claude/);
|
|
});
|
|
});
|
|
|
|
describe("workflow advancing arguments", () => {
|
|
it("review requires reviewer", () => {
|
|
expect(() => parseWorkflowArgs(["review", "--run", "run-123"])).toThrow(/--reviewer is required/);
|
|
expect(parseWorkflowArgs(["review", "--run", "run-123", "--reviewer", "codex"])).toEqual({
|
|
sub: "review",
|
|
runId: "run-123",
|
|
reviewer: "codex"
|
|
});
|
|
});
|
|
|
|
it("decide requires reviewer", () => {
|
|
expect(() => parseWorkflowArgs(["decide", "--run", "run-123", "--input", "decision.json"])).toThrow(/--reviewer is required/);
|
|
expect(parseWorkflowArgs(["decide", "--run", "run-123", "--input", "decision.json", "--reviewer", "claude"])).toEqual({
|
|
sub: "decide",
|
|
runId: "run-123",
|
|
decisionInput: "decision.json",
|
|
reviewer: "claude"
|
|
});
|
|
});
|
|
|
|
it("retry-review requires reviewer", () => {
|
|
expect(() => parseWorkflowArgs(["retry-review", "--run", "run-123"])).toThrow(/--reviewer is required/);
|
|
expect(parseWorkflowArgs(["retry-review", "--run", "run-123", "--reviewer", "codex"])).toEqual({
|
|
sub: "retry-review",
|
|
runId: "run-123",
|
|
reviewer: "codex"
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("workflow retry-execute arguments", () => {
|
|
it("accepts an explicit Claude session ID", () => {
|
|
expect(parseWorkflowArgs([
|
|
"retry-execute",
|
|
"--run", "run-123",
|
|
"--session", "22778b47-e4f3-4645-84cd-1c6a74a912d8",
|
|
])).toEqual({
|
|
sub: "retry-execute",
|
|
runId: "run-123",
|
|
sessionId: "22778b47-e4f3-4645-84cd-1c6a74a912d8",
|
|
});
|
|
});
|
|
|
|
it("preserves retry without a session override", () => {
|
|
expect(parseWorkflowArgs(["retry-execute", "--run", "run-123"])).toEqual({
|
|
sub: "retry-execute",
|
|
runId: "run-123",
|
|
sessionId: undefined,
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("workflow web arguments", () => {
|
|
it("accepts no options", () => {
|
|
expect(parseWorkflowArgs(["web"])).toEqual({
|
|
sub: "web",
|
|
port: undefined,
|
|
});
|
|
});
|
|
|
|
it("accepts a custom port", () => {
|
|
expect(parseWorkflowArgs(["web", "--port", "8080"])).toEqual({
|
|
sub: "web",
|
|
port: 8080,
|
|
});
|
|
});
|
|
|
|
it("throws on invalid port", () => {
|
|
expect(() => parseWorkflowArgs(["web", "--port", "abc"])).toThrow();
|
|
expect(() => parseWorkflowArgs(["web", "--port", "-1"])).toThrow();
|
|
expect(() => parseWorkflowArgs(["web", "--port", "0"])).toThrow();
|
|
expect(() => parseWorkflowArgs(["web", "--port", "70000"])).toThrow();
|
|
});
|
|
});
|