Elffuss BraidHub

kikocis/continue public

main · 2.5 KiBRawPermalink
1import {
2 cleanupTestContext,
3 createTestContext,
4 runCLI,
5} from "../test-helpers/cli-helpers.js";
6import { getVersion } from "../version.js";
7
8describe("E2E: Basic Commands", () => {
9 let context: any;
10
11 beforeEach(async () => {
12 context = await createTestContext();
13 });
14
15 afterEach(async () => {
16 await cleanupTestContext(context);
17 });
18
19 describe("--version flag", () => {
20 it("should display version information", async () => {
21 const result = await runCLI(context, { args: ["--version"] });
22
23 expect(result.exitCode).toBe(0);
24 expect(result.stdout).toBe(getVersion());
25 expect(result.stderr).toBe("");
26 });
27 });
28
29 describe("--help flag", () => {
30 it("should display help information", async () => {
31 const result = await runCLI(context, { args: ["--help"] });
32
33 expect(result.exitCode).toBe(0);
34 expect(result.stdout).toContain("Continue CLI");
35 expect(result.stdout).toContain("AI-powered development assistant");
36 expect(result.stdout).toContain("Options:");
37 expect(result.stdout).toContain("-p, --print");
38 expect(result.stdout).toContain("--config <path>");
39 expect(result.stdout).toContain("--resume");
40 expect(result.stdout).toContain("--readonly");
41 expect(result.stdout).toContain("--auto");
42 expect(result.stdout).toContain("--rule <rule>");
43 expect(result.stdout).toContain("--prompt <prompt>");
44 });
45
46 it("should show available commands", async () => {
47 const result = await runCLI(context, { args: ["--help"] });
48
49 expect(result.stdout).toContain("Commands:");
50 expect(result.stdout).toContain("login");
51 expect(result.stdout).toContain("logout");
52 });
53 });
54
55 describe("subcommand help", () => {
56 it("should show help for login command", async () => {
57 const result = await runCLI(context, { args: ["login", "--help"] });
58
59 expect(result.exitCode).toBe(0);
60 expect(result.stdout).toContain("Authenticate with Continue");
61 });
62
63 it("should show help for logout command", async () => {
64 const result = await runCLI(context, { args: ["logout", "--help"] });
65
66 expect(result.exitCode).toBe(0);
67 expect(result.stdout).toContain("Log out from Continue");
68 });
69 });
70
71 describe("invalid commands", () => {
72 it("should show error for invalid flag", async () => {
73 const result = await runCLI(context, {
74 args: ["--invalid-flag"],
75 expectError: true,
76 });
77
78 expect(result.exitCode).not.toBe(0);
79 expect(result.stderr || result.stdout).toContain("error");
80 });
81 });
82});