From 48090f52ae7c26905698a1e50e96b248458e06bf Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 19 Jul 2025 20:22:22 -0700 Subject: [PATCH] try to fix windows tests --- src/e2e/headless-dynamic-responses.test.ts | 12 ++++++------ src/e2e/headless-minimal.test.ts | 2 +- src/e2e/headless-mock-llm.test.ts | 6 +++--- src/e2e/headless-simple.test.ts | 2 +- src/e2e/resume-flag.test.ts | 6 +++--- src/test-helpers/cli-helpers.ts | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/e2e/headless-dynamic-responses.test.ts b/src/e2e/headless-dynamic-responses.test.ts index 04ab47b81..207a6d27b 100644 --- a/src/e2e/headless-dynamic-responses.test.ts +++ b/src/e2e/headless-dynamic-responses.test.ts @@ -65,21 +65,21 @@ describe("E2E: Headless Mode with Dynamic Responses", () => { // Test weather query const weatherResult = await runCLI(context, { - args: ["-p", "What's the weather like?", "--config", context.configPath], + args: ["-p", "--config", context.configPath, "What's the weather like?"], timeout: 15000, }); expect(weatherResult.stdout).toContain("It's sunny and 72°F today!"); // Test time query const timeResult = await runCLI(context, { - args: ["-p", "What time is it?", "--config", context.configPath], + args: ["-p", "--config", context.configPath, "What time is it?"], timeout: 15000, }); expect(timeResult.stdout).toContain("The current time is 3:30 PM."); // Test unknown query const unknownResult = await runCLI(context, { - args: ["-p", "Tell me about quantum physics", "--config", context.configPath], + args: ["-p", "--config", context.configPath, "Tell me about quantum physics"], timeout: 15000, }); expect(unknownResult.stdout).toContain("I don't understand your question."); @@ -97,7 +97,7 @@ describe("E2E: Headless Mode with Dynamic Responses", () => { }); const result = await runCLI(context, { - args: ["-p", "Test non-streaming", "--config", context.configPath], + args: ["-p", "--config", context.configPath, "Test non-streaming"], timeout: 15000, }); @@ -149,7 +149,7 @@ models: // Test with the first model (GPT-4 should be default) const result = await runCLI(context, { - args: ["-p", "Hello", "--config", context.configPath], + args: ["-p", "--config", context.configPath, "Hello"], timeout: 15000, }); @@ -202,7 +202,7 @@ models: // Make multiple requests for (let i = 0; i < 3; i++) { const result = await runCLI(context, { - args: ["-p", `Request ${i + 1}`, "--config", context.configPath], + args: ["-p", "--config", context.configPath, `Request ${i + 1}`], timeout: 15000, }); expect(result.stdout).toContain(responses[i]); diff --git a/src/e2e/headless-minimal.test.ts b/src/e2e/headless-minimal.test.ts index 80efbac49..48a7929ef 100644 --- a/src/e2e/headless-minimal.test.ts +++ b/src/e2e/headless-minimal.test.ts @@ -49,7 +49,7 @@ provider: openai` // For now, just test that it tries to load the config // Without proper mocking, it will fail to connect to OpenAI const result = await runCLI(context, { - args: ["-p", "Hello", "--config", configPath], + args: ["-p", "--config", configPath, "Hello"], env: { OPENAI_API_KEY: "test-key" }, expectError: true, }); diff --git a/src/e2e/headless-mock-llm.test.ts b/src/e2e/headless-mock-llm.test.ts index 71a36ea83..c6480e0dd 100644 --- a/src/e2e/headless-mock-llm.test.ts +++ b/src/e2e/headless-mock-llm.test.ts @@ -27,7 +27,7 @@ describe("E2E: Headless Mode with Mock Server", () => { it('should output "Hello World!" when using cn -p "Hi"', async () => { const result = await runCLI(context, { - args: ["-p", "Hi", "--config", context.configPath], + args: ["-p", "--config", context.configPath, "Hi"], timeout: 15000, }); @@ -38,7 +38,7 @@ describe("E2E: Headless Mode with Mock Server", () => { it("should handle streaming responses correctly", async () => { const result = await runCLI(context, { - args: ["-p", "Say hello", "--config", context.configPath], + args: ["-p", "--config", context.configPath, "Say hello"], timeout: 15000, }); @@ -52,7 +52,7 @@ describe("E2E: Headless Mode with Mock Server", () => { it("should work with longer prompts", async () => { const result = await runCLI(context, { - args: ["-p", "Please respond with exactly 'Hello World!' and nothing else", "--config", context.configPath], + args: ["-p", "--config", context.configPath, "Please respond with exactly 'Hello World!' and nothing else"], timeout: 15000, }); diff --git a/src/e2e/headless-simple.test.ts b/src/e2e/headless-simple.test.ts index b44c715e0..20a5fa82b 100644 --- a/src/e2e/headless-simple.test.ts +++ b/src/e2e/headless-simple.test.ts @@ -27,7 +27,7 @@ describe("E2E: Headless Mode (Simple)", () => { no models here`); const result = await runCLI(context, { - args: ["-p", "Test", "--config", context.configPath], + args: ["-p", "--config", context.configPath, "Test"], expectError: true, }); diff --git a/src/e2e/resume-flag.test.ts b/src/e2e/resume-flag.test.ts index 725441935..bed9432d8 100644 --- a/src/e2e/resume-flag.test.ts +++ b/src/e2e/resume-flag.test.ts @@ -30,7 +30,7 @@ describe("E2E: Resume Flag", () => { it("should resume from previous session when using --resume flag", async () => { // First, run a chat session with a single message const firstResult = await runCLI(context, { - args: ["-p", "hello", "--config", context.configPath], + args: ["-p", "--config", context.configPath, "hello"], env: { // Use a fixed session ID so both CLI calls use the same session CONTINUE_CLI_TEST_SESSION_ID: "test-session-123" @@ -119,7 +119,7 @@ describe("E2E: Resume Flag", () => { // First session const firstResult = await runCLI(context, { - args: ["-p", "first message", "--config", context.configPath], + args: ["-p", "--config", context.configPath, "first message"], env: { CONTINUE_CLI_TEST_SESSION_ID: sessionId }, @@ -141,7 +141,7 @@ describe("E2E: Resume Flag", () => { // Resume and add a new message with the SAME session ID const resumeResult = await runCLI(context, { - args: ["--resume", "-p", "second message", "--config", context.configPath], + args: ["--resume", "-p", "--config", context.configPath, "second message"], env: { CONTINUE_CLI_TEST_SESSION_ID: sessionId }, diff --git a/src/test-helpers/cli-helpers.ts b/src/test-helpers/cli-helpers.ts index 4a6261cc4..74bdb5ece 100644 --- a/src/test-helpers/cli-helpers.ts +++ b/src/test-helpers/cli-helpers.ts @@ -84,12 +84,12 @@ export async function runCLI( timeout, reject: false, input, - // Force Windows to use the correct stdout/stderr handling - windowsVerbatimArguments: true, // Ensure proper encoding encoding: 'utf8' as const, // Increase buffer size for Windows maxBuffer: 10 * 1024 * 1024, // 10MB + // Let execa handle Windows argument escaping automatically + windowsHide: true, }; try {