Elffuss BraidHub

kikocis/continue public

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