Files
bot/test/cli-json-stdout.e2e.test.ts
zooqueen adb8e1f802 feat: merge upstream improvements via rebrand bridge
Squash merge of 1,462 upstream commits with openclaw→hanzo-bot
naming transforms applied. Conflicts resolved favoring our main
branch to preserve existing customizations.

Key upstream additions:
- iOS Security Stack (concurrency locks, runtime guards, TTS fallback)
- Discord CDN hostname allowlisting for SSRF protection
- Discord mention handling improvements
- Various bug fixes and stability improvements
2026-03-03 09:38:30 -08:00

45 lines
1.5 KiB
TypeScript

import { spawnSync } from "node:child_process";
import fs from "node:fs/promises";
import path from "node:path";
import { describe, expect, it } from "vitest";
import { withTempHome } from "./helpers/temp-home.ts";
describe("cli json stdout contract", () => {
it("keeps `update status --json` stdout parseable even with legacy doctor preflight inputs", async () => {
await withTempHome(
async (tempHome) => {
const legacyDir = path.join(tempHome, ".clawdbot");
await fs.mkdir(legacyDir, { recursive: true });
await fs.writeFile(path.join(legacyDir, "clawdbot.json"), "{}", "utf8");
const env = {
...process.env,
HOME: tempHome,
USERPROFILE: tempHome,
BOT_TEST_FAST: "1",
};
delete env.BOT_HOME;
delete env.BOT_STATE_DIR;
delete env.BOT_CONFIG_PATH;
delete env.VITEST;
const entry = path.resolve(process.cwd(), "bot.mjs");
const result = spawnSync(
process.execPath,
[entry, "update", "status", "--json", "--timeout", "1"],
{ cwd: process.cwd(), env, encoding: "utf8" },
);
expect(result.status).toBe(0);
const stdout = result.stdout.trim();
expect(stdout.length).toBeGreaterThan(0);
expect(() => JSON.parse(stdout)).not.toThrow();
expect(stdout).not.toContain("Doctor warnings");
expect(stdout).not.toContain("Doctor changes");
expect(stdout).not.toContain("Config invalid");
},
{ prefix: "bot-json-e2e-" },
);
});
});