Skip to content

Commit 718daf4

Browse files
srousseyclaude
andcommitted
test(cli-v2): add CLI integration smoke test
Verifies the command hierarchy works end-to-end by spawning the CLI as a subprocess and checking help output for all command groups, global options, version, and subcommands (bootstrap, query, fetch, update, db). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 08b47f9 commit 718daf4

1 file changed

Lines changed: 91 additions & 0 deletions

File tree

src/cli/cli.integration.test.ts

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import { describe, it, expect } from "bun:test";
2+
3+
const ENV = {
4+
...process.env,
5+
SEC_DB_FOLDER: "/tmp/sec-cli-integration-test",
6+
SEC_DB_NAME: "edgar",
7+
SEC_RAW_DATA_FOLDER: "/tmp/sec-cli-integration-test-raw",
8+
};
9+
10+
const SEC_TS = new URL("../sec.ts", import.meta.url).pathname;
11+
12+
async function runCli(...args: string[]): Promise<string> {
13+
const proc = Bun.spawn(["bun", "run", SEC_TS, ...args], {
14+
env: ENV,
15+
stdout: "pipe",
16+
stderr: "pipe",
17+
});
18+
const stdout = await new Response(proc.stdout).text();
19+
const stderr = await new Response(proc.stderr).text();
20+
await proc.exited;
21+
return stdout + stderr;
22+
}
23+
24+
describe("CLI v2 integration", () => {
25+
it("should show help with all command groups", async () => {
26+
const output = await runCli("--help");
27+
expect(output).toContain("bootstrap");
28+
expect(output).toContain("sync");
29+
expect(output).toContain("update");
30+
expect(output).toContain("fetch");
31+
expect(output).toContain("query");
32+
expect(output).toContain("db");
33+
expect(output).toContain("init");
34+
});
35+
36+
it("should show global options", async () => {
37+
const output = await runCli("--help");
38+
expect(output).toContain("--json");
39+
expect(output).toContain("--verbose");
40+
expect(output).toContain("--dry-run");
41+
expect(output).toContain("--no-color");
42+
expect(output).toContain("--concurrency");
43+
});
44+
45+
it("should show version 2.0.0", async () => {
46+
const output = await runCli("--version");
47+
expect(output.trim()).toBe("2.0.0");
48+
});
49+
50+
it("should show bootstrap subcommands", async () => {
51+
const output = await runCli("bootstrap", "--help");
52+
expect(output).toContain("download");
53+
expect(output).toContain("ingest");
54+
expect(output).toContain("--skip-download");
55+
expect(output).toContain("--skip-ingest");
56+
expect(output).toContain("--skip-forms");
57+
});
58+
59+
it("should show query subcommands", async () => {
60+
const output = await runCli("query", "--help");
61+
expect(output).toContain("entities");
62+
expect(output).toContain("filings");
63+
expect(output).toContain("offerings");
64+
expect(output).toContain("crowdfunding");
65+
expect(output).toContain("facts");
66+
expect(output).toContain("persons");
67+
});
68+
69+
it("should show fetch subcommands", async () => {
70+
const output = await runCli("fetch", "--help");
71+
expect(output).toContain("submissions");
72+
expect(output).toContain("facts");
73+
expect(output).toContain("form");
74+
expect(output).toContain("doc");
75+
});
76+
77+
it("should show update subcommands", async () => {
78+
const output = await runCli("update", "--help");
79+
expect(output).toContain("submissions");
80+
expect(output).toContain("facts");
81+
expect(output).toContain("forms");
82+
});
83+
84+
it("should show db subcommands", async () => {
85+
const output = await runCli("db", "--help");
86+
expect(output).toContain("setup");
87+
expect(output).toContain("status");
88+
expect(output).toContain("stats");
89+
expect(output).toContain("reset");
90+
});
91+
});

0 commit comments

Comments
 (0)