mirror of
https://github.com/merlinhu1/truthmark.git
synced 2026-08-25 07:53:25 +02:00
* feat: harden init routing and generated lifecycle * test: align restored coverage with platform routing * docs: translate localized uninstall guidance * test: complete init routing and lifecycle coverage * docs: record completed OpenSpec tasks * chore: archive implemented init lifecycle OpenSpec change * chore: remove OpenSpec configuration * docs: clarify platform omission reconciliation --------- Co-authored-by: MerlinH <merlinh221@gmail.com>
95 lines
2.8 KiB
TypeScript
95 lines
2.8 KiB
TypeScript
import { describe, it } from "node:test";
|
|
import { expect } from "expect";
|
|
|
|
import { runCli } from "../helpers/run-cli.js";
|
|
|
|
const forbiddenCommands = [
|
|
"packet",
|
|
"review",
|
|
"scan",
|
|
"doctor",
|
|
"build",
|
|
"realize",
|
|
];
|
|
|
|
describe("truthmark CLI", () => {
|
|
it("lists config, init, and check in top-level help", async () => {
|
|
const result = await runCli(["--help"]);
|
|
|
|
expect(result.exitCode).toBe(0);
|
|
expect(result.stdout).toContain("config");
|
|
expect(result.stdout).toContain("init");
|
|
expect(result.stdout).toContain("uninstall");
|
|
expect(result.stdout).toContain("check");
|
|
expect(result.stdout).toContain("index");
|
|
expect(result.stdout).toContain("impact");
|
|
expect(result.stdout).not.toContain("context");
|
|
|
|
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");
|
|
});
|
|
|
|
it("shows config help", async () => {
|
|
const result = await runCli(["config", "--help"]);
|
|
|
|
expect(result.exitCode).toBe(0);
|
|
expect(result.stdout).toContain("Usage: truthmark config");
|
|
expect(result.stdout).toContain("--json");
|
|
expect(result.stdout).toContain("--stdout");
|
|
expect(result.stdout).toContain("--force");
|
|
});
|
|
|
|
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");
|
|
});
|
|
|
|
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");
|
|
});
|
|
|
|
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[];
|
|
data?: {
|
|
scorecard?: {
|
|
schemaVersion?: string;
|
|
};
|
|
};
|
|
};
|
|
|
|
expect(payload.command).toBe("check");
|
|
expect(typeof payload.summary).toBe("string");
|
|
expect(payload.summary.length).toBeGreaterThan(0);
|
|
expect(Array.isArray(payload.diagnostics)).toBe(true);
|
|
expect(payload.data?.scorecard?.schemaVersion).toBe(
|
|
"truthmark-scorecard/v0",
|
|
);
|
|
});
|
|
});
|