2026-06-30 20:57:55 +10:00
|
|
|
import { describe, it } from "node:test";
|
|
|
|
|
import { expect } from "expect";
|
2026-05-09 17:58:44 +10:00
|
|
|
|
|
|
|
|
import { runCli } from "../helpers/run-cli.js";
|
|
|
|
|
|
|
|
|
|
const forbiddenCommands = [
|
|
|
|
|
"packet",
|
|
|
|
|
"review",
|
|
|
|
|
"scan",
|
|
|
|
|
"doctor",
|
|
|
|
|
"build",
|
|
|
|
|
"realize",
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
describe("truthmark CLI", () => {
|
2026-07-31 18:54:10 +10:00
|
|
|
it("lists init and omits the retired config command in top-level help", async () => {
|
2026-05-09 17:58:44 +10:00
|
|
|
const result = await runCli(["--help"]);
|
|
|
|
|
|
|
|
|
|
expect(result.exitCode).toBe(0);
|
2026-07-31 18:54:10 +10:00
|
|
|
expect(result.stdout).not.toContain("\n config ");
|
2026-05-09 17:58:44 +10:00
|
|
|
expect(result.stdout).toContain("init");
|
2026-07-12 20:48:09 +10:00
|
|
|
expect(result.stdout).toContain("uninstall");
|
2026-05-09 17:58:44 +10:00
|
|
|
expect(result.stdout).toContain("check");
|
2026-05-16 03:55:55 +10:00
|
|
|
expect(result.stdout).toContain("index");
|
|
|
|
|
expect(result.stdout).toContain("impact");
|
2026-06-16 11:03:04 +10:00
|
|
|
expect(result.stdout).not.toContain("context");
|
2026-05-09 17:58:44 +10:00
|
|
|
|
|
|
|
|
for (const command of forbiddenCommands) {
|
|
|
|
|
expect(result.stdout).not.toContain(command);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("shows init help", async () => {
|
|
|
|
|
const result = await runCli(["init", "--help"]);
|
|
|
|
|
|
|
|
|
|
expect(result.exitCode).toBe(0);
|
|
|
|
|
expect(result.stdout).toContain("Usage: truthmark init");
|
|
|
|
|
expect(result.stdout).toContain("--json");
|
2026-07-31 18:54:10 +10:00
|
|
|
expect(result.stdout).toContain("--platform <id>");
|
|
|
|
|
expect(result.stdout).toContain("--clear-platforms");
|
2026-05-09 17:58:44 +10:00
|
|
|
});
|
|
|
|
|
|
2026-07-31 18:54:10 +10:00
|
|
|
it("rejects the removed config command", async () => {
|
|
|
|
|
const result = await runCli(["config"]);
|
2026-05-09 17:58:44 +10:00
|
|
|
|
2026-07-31 18:54:10 +10:00
|
|
|
expect(result.exitCode).not.toBe(0);
|
|
|
|
|
expect(result.stderr).toContain("unknown command 'config'");
|
2026-05-09 17:58:44 +10:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("shows check help", async () => {
|
|
|
|
|
const result = await runCli(["check", "--help"]);
|
|
|
|
|
|
|
|
|
|
expect(result.exitCode).toBe(0);
|
|
|
|
|
expect(result.stdout).toContain("Usage: truthmark check");
|
|
|
|
|
expect(result.stdout).toContain("--json");
|
|
|
|
|
expect(result.stdout).not.toContain("--workflow");
|
|
|
|
|
});
|
|
|
|
|
|
2026-07-12 20:48:09 +10:00
|
|
|
it("shows uninstall help with JSON and execution mode options", async () => {
|
|
|
|
|
const result = await runCli(["uninstall", "--help"]);
|
|
|
|
|
|
|
|
|
|
expect(result.exitCode).toBe(0);
|
|
|
|
|
expect(result.stdout).toContain("Usage: truthmark uninstall");
|
|
|
|
|
expect(result.stdout).toContain("--dry-run");
|
|
|
|
|
expect(result.stdout).toContain("--apply");
|
|
|
|
|
expect(result.stdout).toContain("--json");
|
|
|
|
|
});
|
|
|
|
|
|
2026-05-09 17:58:44 +10:00
|
|
|
it("returns valid JSON for check", async () => {
|
|
|
|
|
const result = await runCli(["check", "--json"]);
|
|
|
|
|
|
|
|
|
|
expect(result.exitCode).toBe(0);
|
|
|
|
|
|
|
|
|
|
const payload = JSON.parse(result.stdout) as {
|
|
|
|
|
command: string;
|
|
|
|
|
summary: string;
|
|
|
|
|
diagnostics: unknown[];
|
2026-06-13 04:09:45 +10:00
|
|
|
data?: {
|
|
|
|
|
scorecard?: {
|
|
|
|
|
schemaVersion?: string;
|
|
|
|
|
};
|
|
|
|
|
};
|
2026-05-09 17:58:44 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
expect(payload.command).toBe("check");
|
|
|
|
|
expect(typeof payload.summary).toBe("string");
|
|
|
|
|
expect(payload.summary.length).toBeGreaterThan(0);
|
|
|
|
|
expect(Array.isArray(payload.diagnostics)).toBe(true);
|
2026-06-30 20:57:55 +10:00
|
|
|
expect(payload.data?.scorecard?.schemaVersion).toBe(
|
|
|
|
|
"truthmark-scorecard/v0",
|
|
|
|
|
);
|
2026-05-09 17:58:44 +10:00
|
|
|
});
|
|
|
|
|
});
|