mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 03:15:46 -06:00
c70aee247e
* refactor(scripts): migrate JavaScript tools to TypeScript * fix(ci): keep changed-scope preflight zero-install * fix(ci): preserve zero-install script owners * fix(ci): complete script migration follow-through * fix(release): keep stable closeout zero-install * fix(scripts): preserve standalone execution boundaries * fix(scripts): repair standalone loader boundaries * fix(scripts): normalize gateway observation ids * fix(scripts): keep Docker packager standalone * test(scripts): preserve rebase cleanup helpers * test(sessions): use tracked temp directory
103 lines
3.3 KiB
TypeScript
103 lines
3.3 KiB
TypeScript
// Mantis Web UI Chat Proof Workflow tests cover mantis web ui chat proof workflow behavior.
|
|
import { readFileSync } from "node:fs";
|
|
import { describe, expect, it } from "vitest";
|
|
import { parse } from "yaml";
|
|
|
|
const WORKFLOW = ".github/workflows/mantis-web-ui-chat-proof.yml";
|
|
|
|
type WorkflowStep = {
|
|
name?: string;
|
|
run?: string;
|
|
uses?: string;
|
|
with?: Record<string, string>;
|
|
};
|
|
|
|
type WorkflowJob = {
|
|
permissions?: Record<string, string>;
|
|
steps?: WorkflowStep[];
|
|
};
|
|
|
|
type Workflow = {
|
|
jobs?: Record<string, WorkflowJob>;
|
|
};
|
|
|
|
function resolveRequestScript(): string {
|
|
const workflow = parse(readFileSync(WORKFLOW, "utf8")) as Workflow;
|
|
const steps = workflow.jobs?.resolve_request?.steps ?? [];
|
|
const step = steps.find((candidate) => candidate.name === "Resolve ref and target PR");
|
|
if (!step?.with?.script) {
|
|
throw new Error("Missing Resolve ref and target PR script");
|
|
}
|
|
return step.with.script;
|
|
}
|
|
|
|
function workflowJob(name: string): WorkflowJob {
|
|
const workflow = parse(readFileSync(WORKFLOW, "utf8")) as Workflow;
|
|
const job = workflow.jobs?.[name];
|
|
if (!job) {
|
|
throw new Error(`Missing ${name} job`);
|
|
}
|
|
return job;
|
|
}
|
|
|
|
function candidateOverridePattern(): RegExp {
|
|
const script = resolveRequestScript();
|
|
const match = script.match(/const candidateMatch = body\.match\((\/.*\/i)\);/);
|
|
if (!match) {
|
|
throw new Error("Missing candidate override regex");
|
|
}
|
|
const literal = match[1];
|
|
if (!literal) {
|
|
throw new Error("Missing candidate override regex literal");
|
|
}
|
|
const flagsStart = literal.lastIndexOf("/");
|
|
return new RegExp(literal.slice(1, flagsStart), literal.slice(flagsStart + 1));
|
|
}
|
|
|
|
describe("Mantis Web UI chat proof workflow", () => {
|
|
it("keeps candidate execution read-only and installs dependencies only in the candidate", () => {
|
|
const job = workflowJob("run_web_ui_chat");
|
|
const setup = job.steps?.find((step) => step.name === "Setup Node environment");
|
|
|
|
expect(job.permissions).toEqual({ contents: "read" });
|
|
expect(setup?.with).toMatchObject({
|
|
"install-bun": "false",
|
|
"install-deps": "false",
|
|
});
|
|
});
|
|
|
|
it("publishes evidence with plain Node and no dependency setup", () => {
|
|
const job = workflowJob("publish_evidence");
|
|
const publish = job.steps?.find((step) => step.name === "Comment PR with inline QA evidence");
|
|
|
|
expect(job.steps?.some((step) => step.name === "Setup Node environment")).toBe(false);
|
|
expect(publish?.run).toContain("node scripts/mantis/publish-pr-evidence.mjs");
|
|
expect(publish?.run).not.toContain("--import tsx");
|
|
});
|
|
|
|
it("only treats explicit candidate assignments as PR head overrides", () => {
|
|
const pattern = candidateOverridePattern();
|
|
|
|
expect(
|
|
"verify this PR head produces a redacted Control UI chat transcript artifact".match(
|
|
pattern,
|
|
)?.[1],
|
|
).toBeUndefined();
|
|
expect(
|
|
"@openclaw-mantis web ui chat proof: verify candidate=e63393c publishes evidence".match(
|
|
pattern,
|
|
)?.[1],
|
|
).toBe("e63393c");
|
|
expect(
|
|
"@openclaw-mantis web ui chat proof: verify head: e63393c publishes evidence".match(
|
|
pattern,
|
|
)?.[1],
|
|
).toBe("e63393c");
|
|
expect(
|
|
"@openclaw-mantis web ui chat proof: verify candidate=`e63393c` publishes evidence".match(
|
|
pattern,
|
|
)?.[1],
|
|
).toBe("e63393c");
|
|
});
|
|
});
|