Elffuss BraidHub

kikocis/continue public

fc89067dc2f1 · 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 });
44
45 it("should show available commands", async () => {
46 const result = await runCLI(context, { args: ["--help"] });
47
48 expect(result.stdout).toContain("Commands:");
49 expect(result.stdout).toContain("login");
50 expect(result.stdout).toContain("logout");
51 });
52 });
53
54 describe("subcommand help", () => {
55 it("should show help for login command", async () => {
56 const result = await runCLI(context, { args: ["login", "--help"] });
57
58 expect(result.exitCode).toBe(0);
59 expect(result.stdout).toContain("Authenticate with Continue");
60 });
61
62 it("should show help for logout command", async () => {
63 const result = await runCLI(context, { args: ["logout", "--help"] });
64
65 expect(result.exitCode).toBe(0);
66 expect(result.stdout).toContain("Log out from Continue");
67 });
68 });
69
70 describe("invalid commands", () => {
71 it("should show error for invalid flag", async () => {
72 const result = await runCLI(context, {
73 args: ["--invalid-flag"],
74 expectError: true,
75 });
76
77 expect(result.exitCode).not.toBe(0);
78 expect(result.stderr || result.stdout).toContain("error");
79 });
80 });
81});