Elffuss BraidHub

kikocis/continue public

main · 2.6 KiBRawPermalink
1import {
2 createTestContext,
3 cleanupTestContext,
4 runCLI,
5 createTestConfig,
6} from "../test-helpers/cli-helpers.js";
7
8describe("E2E: Headless Mode with --org flag", () => {
9 let context: any;
10
11 const testConfig = `name: Test Assistant
12version: 1.0.0
13schema: v1
14models:
15 - name: test-model
16 model: gpt-4
17 provider: openai
18 apiKey: test-key`;
19
20 const testEnv = {
21 OPENAI_API_KEY: "test-key",
22 CONTINUE_API_KEY: "test-api-key",
23 };
24
25 beforeEach(async () => {
26 context = await createTestContext();
27 });
28
29 afterEach(async () => {
30 await cleanupTestContext(context);
31 });
32
33 describe("--org flag mode restriction", () => {
34 it("should fail when --org is used without -p flag (interactive mode)", async () => {
35 await createTestConfig(context, testConfig);
36
37 const result = await runCLI(context, {
38 args: [
39 "--config",
40 context.configPath,
41 "--org",
42 "my-org",
43 "Test prompt",
44 ],
45 env: testEnv,
46 expectError: true,
47 });
48
49 expect(result.exitCode).not.toBe(0);
50 expect(result.stderr).toContain(
51 "--org flag is only supported in headless mode (with -p/--print flag)",
52 );
53 });
54
55 it("should accept --org flag with -p flag (headless mode)", async () => {
56 await createTestConfig(context, testConfig);
57
58 // This will fail due to missing actual auth, but should get past the flag validation
59 const result = await runCLI(context, {
60 args: [
61 "-p",
62 "--config",
63 context.configPath,
64 "--org",
65 "my-org",
66 "Test prompt",
67 ],
68 env: testEnv,
69 expectError: true,
70 });
71
72 // Should fail for a different reason (no actual auth/API), not because of flag validation
73 expect(result.stderr).not.toContain(
74 "--org flag is only supported in headless mode (with -p/--print flag)",
75 );
76 });
77 });
78
79 describe("--org flag inheritance", () => {
80 it("should inherit --org flag from parent command", async () => {
81 await createTestConfig(context, testConfig);
82
83 // Test with chat subcommand
84 const result = await runCLI(context, {
85 args: [
86 "--org",
87 "test-org",
88 "chat",
89 "-p",
90 "--config",
91 context.configPath,
92 "Test prompt",
93 ],
94 env: testEnv,
95 expectError: true,
96 });
97
98 // The org flag should be inherited and work in headless mode
99 expect(result.stderr).not.toContain(
100 "--org flag is only supported in headless mode (with -p/--print flag)",
101 );
102 });
103 });
104});