

























@@ -18,43 +18,51 @@ describe("mantis desktop browser smoke runtime", () => {
1818it("leases a desktop box, runs a visible browser, copies artifacts, and stops on pass", async () => {
1919await fs.mkdir(path.join(repoRoot, "qa-artifacts"), { recursive: true });
2020await fs.writeFile(path.join(repoRoot, "qa-artifacts", "timeline.html"), "<h1>Mantis</h1>");
21-const commands: { args: readonly string[]; command: string }[] = [];
22-const runner = vi.fn(async (command: string, args: readonly string[]) => {
23-commands.push({ command, args });
24-if (command === "/tmp/crabbox" && args[0] === "warmup") {
25-return { stdout: "ready lease cbx_abc123\n", stderr: "" };
26-}
27-if (command === "/tmp/crabbox" && args[0] === "inspect") {
28-return {
29-stdout: `${JSON.stringify({
30- host: "203.0.113.10",
31- id: "cbx_abc123",
32- provider: "hetzner",
33- slug: "brisk-mantis",
34- sshKey: "/tmp/key",
35- sshPort: "2222",
36- sshUser: "crabbox",
37- state: "active",
38- })}\n`,
39-stderr: "",
40-};
41-}
42-if (command === "rsync") {
43-const outputDir = args.at(-1);
44-expect(outputDir).toBeTypeOf("string");
45-await fs.mkdir(outputDir as string, { recursive: true });
46-await fs.writeFile(path.join(outputDir as string, "desktop-browser-smoke.png"), "png");
47-await fs.writeFile(path.join(outputDir as string, "remote-metadata.json"), "{}\n");
48-await fs.writeFile(path.join(outputDir as string, "chrome.log"), "chrome\n");
21+const commands: { args: readonly string[]; command: string; env?: NodeJS.ProcessEnv }[] = [];
22+const runtimeEnv = {
23+PATH: process.env.PATH,
24+CRABBOX_COORDINATOR_TOKEN: "runtime-token",
25+OPENCLAW_MANTIS_CRABBOX_PROVIDER: "hetzner",
26+};
27+const runner = vi.fn(
28+async (command: string, args: readonly string[], options: { env?: NodeJS.ProcessEnv }) => {
29+commands.push({ command, args, env: options.env });
30+if (command === "/tmp/crabbox" && args[0] === "warmup") {
31+return { stdout: "ready lease cbx_abc123\n", stderr: "" };
32+}
33+if (command === "/tmp/crabbox" && args[0] === "inspect") {
34+return {
35+stdout: `${JSON.stringify({
36+ host: "203.0.113.10",
37+ id: "cbx_abc123",
38+ provider: "hetzner",
39+ slug: "brisk-mantis",
40+ sshKey: "/tmp/key",
41+ sshPort: "2222",
42+ sshUser: "crabbox",
43+ state: "active",
44+ })}\n`,
45+stderr: "",
46+};
47+}
48+if (command === "rsync") {
49+const outputDir = args.at(-1);
50+expect(outputDir).toBeTypeOf("string");
51+await fs.mkdir(outputDir as string, { recursive: true });
52+await fs.writeFile(path.join(outputDir as string, "desktop-browser-smoke.png"), "png");
53+await fs.writeFile(path.join(outputDir as string, "remote-metadata.json"), "{}\n");
54+await fs.writeFile(path.join(outputDir as string, "chrome.log"), "chrome\n");
55+return { stdout: "", stderr: "" };
56+}
4957return { stdout: "", stderr: "" };
50-}
51-return { stdout: "", stderr: "" };
52-});
58+},
59+);
53605461const result = await runMantisDesktopBrowserSmoke({
5562browserUrl: "https://openclaw.ai/docs",
5663commandRunner: runner,
5764crabboxBin: "/tmp/crabbox",
65+env: runtimeEnv,
5866htmlFile: "qa-artifacts/timeline.html",
5967now: () => new Date("2026-05-04T12:00:00.000Z"),
6068outputDir: ".artifacts/qa-e2e/mantis/desktop-browser-test",
@@ -69,6 +77,7 @@ describe("mantis desktop browser smoke runtime", () => {
6977["rsync", "-az"],
7078["/tmp/crabbox", "stop"],
7179]);
80+expect(commands.every((entry) => entry.env === runtimeEnv)).toBe(true);
7281const rsyncArgs = commands.find((entry) => entry.command === "rsync")?.args ?? [];
7382expect(rsyncArgs).not.toContain("--delete");
7483expect(rsyncArgs).toEqual(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。