Files
gitea-axi/test/help.test.ts
alexion 38026f963d feat: scaffold CLI and minimal issue list (task 0001)
Tracer bullet for gitea-axi: runnable npm package on axi-sdk-js with
gitea-js as the sole HTTP layer, ESM on Node 20+.

- issue list with --state/--limit, default fields, count line from
  X-Total-Count, type=issues guard, explicit empty state, and next-step
  suggestions
- repo context detection from the git origin remote (SSH/scp/HTTPS),
  tea credential discovery with the three-way login-matching split, and
  -R/--repo and --login overrides (flag > env > auto)
- token retrieval via tea login helper get: tea's login list JSON
  carries no token (ADR 0001 amended)
- full AxiError classification table with path-based 404 split, TOON
  errors on stdout, exit codes 0/1/2
- test mode (GITEA_AXI_API_URL/TOKEN/REPO) suppressing subprocesses,
  fixture server, and vitest suites driving the CLI seam (50 tests)
2026-07-11 07:11:07 -04:00

47 lines
1.5 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { runCliTest } from "./harness.js";
describe("--help", () => {
it("prints a top-level flag reference and exits 0", async () => {
const { stdout, exitCode } = await runCliTest(["--help"]);
expect(exitCode).toBe(0);
expect(stdout).toContain("usage: gitea-axi");
expect(stdout).toContain("issue list");
expect(stdout).toContain("-R, --repo");
expect(stdout).toContain("--login");
});
it("prints the issue list flag reference and exits 0", async () => {
const { stdout, exitCode } = await runCliTest(["issue", "list", "--help"]);
expect(exitCode).toBe(0);
expect(stdout).toContain("usage: gitea-axi issue list");
expect(stdout).toContain("--state");
expect(stdout).toContain("--limit");
});
it("prints the issue group help and exits 0", async () => {
const { stdout, exitCode } = await runCliTest(["issue", "--help"]);
expect(exitCode).toBe(0);
expect(stdout).toContain("usage: gitea-axi issue");
expect(stdout).toContain("list");
});
it("prints the version for --version", async () => {
const { stdout, exitCode } = await runCliTest(["--version"]);
expect(exitCode).toBe(0);
expect(stdout.trim()).toMatch(/^\d+\.\d+\.\d+$/);
});
it("rejects unknown commands with exit code 2", async () => {
const { stdout, exitCode } = await runCliTest(["frobnicate"]);
expect(exitCode).toBe(2);
expect(stdout).toContain("code: VALIDATION_ERROR");
expect(stdout).toContain("frobnicate");
});
});