From 62d1fae96a915b7164c7255dc321b775e684aaef Mon Sep 17 00:00:00 2001 From: Taneja Hriday Date: Mon, 6 Oct 2025 12:44:09 +0000 Subject: [PATCH 1/6] test: enable interactive integration tests for windows --- .../context-compress-interactive.test.ts | 170 +++++++++--------- .../file-system-interactive.test.ts | 121 ++++++------- 2 files changed, 139 insertions(+), 152 deletions(-) diff --git a/integration-tests/context-compress-interactive.test.ts b/integration-tests/context-compress-interactive.test.ts index 3a626150f87..e27041509f2 100644 --- a/integration-tests/context-compress-interactive.test.ts +++ b/integration-tests/context-compress-interactive.test.ts @@ -18,93 +18,85 @@ describe('Interactive Mode', () => { await rig.cleanup(); }); - it.skipIf(process.platform === 'win32')( - 'should trigger chat compression with /compress command', - async () => { - await rig.setup('interactive-compress-test'); - - const { ptyProcess } = rig.runInteractive(); - - let fullOutput = ''; - ptyProcess.onData((data) => (fullOutput += data)); - - const authDialogAppeared = await rig.waitForText( - 'How would you like to authenticate', - 5000, - ); - - // select the second option if auth dialog come's up - if (authDialogAppeared) { - ptyProcess.write('2'); - } - - // Wait for the app to be ready - const isReady = await rig.waitForText('Type your message', 15000); - expect( - isReady, - 'CLI did not start up in interactive mode correctly', - ).toBe(true); - - const longPrompt = - 'Dont do anything except returning a 1000 token long paragragh with the at the end to indicate end of response. This is a moderately long sentence.'; - - await type(ptyProcess, longPrompt); - await type(ptyProcess, '\r'); - - await rig.waitForText('einstein', 25000); - - await type(ptyProcess, '/compress'); - // A small delay to allow React to re-render the command list. - await new Promise((resolve) => setTimeout(resolve, 100)); - await type(ptyProcess, '\r'); - - const foundEvent = await rig.waitForTelemetryEvent( - 'chat_compression', - 90000, - ); - expect(foundEvent, 'chat_compression telemetry event was not found').toBe( - true, - ); - }, - ); - - it.skipIf(process.platform === 'win32')( - 'should handle compression failure on token inflation', - async () => { - await rig.setup('interactive-compress-test'); - - const { ptyProcess } = rig.runInteractive(); - - let fullOutput = ''; - ptyProcess.onData((data) => (fullOutput += data)); - - const authDialogAppeared = await rig.waitForText( - 'How would you like to authenticate', - 5000, - ); - - // select the second option if auth dialog come's up - if (authDialogAppeared) { - ptyProcess.write('2'); - } - - // Wait for the app to be ready - const isReady = await rig.waitForText('Type your message', 25000); - expect( - isReady, - 'CLI did not start up in interactive mode correctly', - ).toBe(true); - - await type(ptyProcess, '/compress'); - await new Promise((resolve) => setTimeout(resolve, 100)); - await type(ptyProcess, '\r'); - - const compressionFailed = await rig.waitForText( - 'compression was not beneficial', - 25000, - ); - - expect(compressionFailed).toBe(true); - }, - ); + it('should trigger chat compression with /compress command', async () => { + await rig.setup('interactive-compress-test'); + + const { ptyProcess } = rig.runInteractive(); + + let fullOutput = ''; + ptyProcess.onData((data) => (fullOutput += data)); + + const authDialogAppeared = await rig.waitForText( + 'How would you like to authenticate', + 5000, + ); + + // select the second option if auth dialog come's up + if (authDialogAppeared) { + ptyProcess.write('2'); + } + + // Wait for the app to be ready + const isReady = await rig.waitForText('Type your message', 15000); + expect(isReady, 'CLI did not start up in interactive mode correctly').toBe( + true, + ); + + const longPrompt = + 'Dont do anything except returning a 1000 token long paragragh with the at the end to indicate end of response. This is a moderately long sentence.'; + + await type(ptyProcess, longPrompt); + await type(ptyProcess, '\r'); + + await rig.waitForText('einstein', 25000); + + await type(ptyProcess, '/compress'); + // A small delay to allow React to re-render the command list. + await new Promise((resolve) => setTimeout(resolve, 100)); + await type(ptyProcess, '\r'); + + const foundEvent = await rig.waitForTelemetryEvent( + 'chat_compression', + 90000, + ); + expect(foundEvent, 'chat_compression telemetry event was not found').toBe( + true, + ); + }); + + it('should handle compression failure on token inflation', async () => { + await rig.setup('interactive-compress-test'); + + const { ptyProcess } = rig.runInteractive(); + + let fullOutput = ''; + ptyProcess.onData((data) => (fullOutput += data)); + + const authDialogAppeared = await rig.waitForText( + 'How would you like to authenticate', + 5000, + ); + + // select the second option if auth dialog come's up + if (authDialogAppeared) { + ptyProcess.write('2'); + } + + // Wait for the app to be ready + const isReady = await rig.waitForText('Type your message', 25000); + expect(isReady, 'CLI did not start up in interactive mode correctly').toBe( + true, + ); + + await type(ptyProcess, '/compress'); + await new Promise((resolve) => setTimeout(resolve, 100)); + await type(ptyProcess, '\r'); + + const compressionFailed = await rig.waitForText( + 'compression was not beneficial', + 25000, + ); + + expect(compressionFailed).toBe(true); + }); }); diff --git a/integration-tests/file-system-interactive.test.ts b/integration-tests/file-system-interactive.test.ts index ea231155396..be5f9fd2b29 100644 --- a/integration-tests/file-system-interactive.test.ts +++ b/integration-tests/file-system-interactive.test.ts @@ -18,69 +18,64 @@ describe('Interactive file system', () => { await rig.cleanup(); }); - it.skipIf(process.platform === 'win32')( - 'should perform a read-then-write sequence', - async () => { - const fileName = 'version.txt'; - await rig.setup('interactive-read-then-write'); - rig.createFile(fileName, '1.0.0'); - - const { ptyProcess } = rig.runInteractive(); - - const authDialogAppeared = await rig.waitForText( - 'How would you like to authenticate', - 5000, - ); - - // select the second option if auth dialog come's up - if (authDialogAppeared) { - ptyProcess.write('2'); - } - - // Wait for the app to be ready - const isReady = await rig.waitForText('Type your message', 15000); - expect( - isReady, - 'CLI did not start up in interactive mode correctly', - ).toBe(true); - - // Step 1: Read the file - const readPrompt = `Read the version from ${fileName}`; - await type(ptyProcess, readPrompt); - await type(ptyProcess, '\r'); - - const readCall = await rig.waitForToolCall('read_file', 30000); - expect(readCall, 'Expected to find a read_file tool call').toBe(true); - - const containsExpectedVersion = await rig.waitForText('1.0.0', 15000); - expect( - containsExpectedVersion, - 'Expected to see version "1.0.0" in output', - ).toBe(true); - - // Step 2: Write the file - const writePrompt = `now change the version to 1.0.1 in the file`; - await type(ptyProcess, writePrompt); - await type(ptyProcess, '\r'); - - const toolCall = await rig.waitForAnyToolCall( - ['write_file', 'replace'], - 30000, - ); - - if (!toolCall) { - printDebugInfo(rig, rig._interactiveOutput, { - toolCall, - }); - } - - expect( + it('should perform a read-then-write sequence', async () => { + const fileName = 'version.txt'; + await rig.setup('interactive-read-then-write'); + rig.createFile(fileName, '1.0.0'); + + const { ptyProcess } = rig.runInteractive(); + + const authDialogAppeared = await rig.waitForText( + 'How would you like to authenticate', + 5000, + ); + + // select the second option if auth dialog come's up + if (authDialogAppeared) { + ptyProcess.write('2'); + } + + // Wait for the app to be ready + const isReady = await rig.waitForText('Type your message', 15000); + expect(isReady, 'CLI did not start up in interactive mode correctly').toBe( + true, + ); + + // Step 1: Read the file + const readPrompt = `Read the version from ${fileName}`; + await type(ptyProcess, readPrompt); + await type(ptyProcess, '\r'); + + const readCall = await rig.waitForToolCall('read_file', 30000); + expect(readCall, 'Expected to find a read_file tool call').toBe(true); + + const containsExpectedVersion = await rig.waitForText('1.0.0', 15000); + expect( + containsExpectedVersion, + 'Expected to see version "1.0.0" in output', + ).toBe(true); + + // Step 2: Write the file + const writePrompt = `now change the version to 1.0.1 in the file`; + await type(ptyProcess, writePrompt); + await type(ptyProcess, '\r'); + + const toolCall = await rig.waitForAnyToolCall( + ['write_file', 'replace'], + 30000, + ); + + if (!toolCall) { + printDebugInfo(rig, rig._interactiveOutput, { toolCall, - 'Expected to find a write_file or replace tool call', - ).toBe(true); + }); + } - const newFileContent = rig.readFile(fileName); - expect(newFileContent).toBe('1.0.1'); - }, - ); + expect(toolCall, 'Expected to find a write_file or replace tool call').toBe( + true, + ); + + const newFileContent = rig.readFile(fileName); + expect(newFileContent).toBe('1.0.1'); + }); }); From 16a0902a496bd13a51317b7d107c0b0a81f2504b Mon Sep 17 00:00:00 2001 From: Taneja Hriday Date: Mon, 6 Oct 2025 18:49:00 +0000 Subject: [PATCH 2/6] preselect auth --- integration-tests/context-compress-interactive.test.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/integration-tests/context-compress-interactive.test.ts b/integration-tests/context-compress-interactive.test.ts index e27041509f2..c7662683788 100644 --- a/integration-tests/context-compress-interactive.test.ts +++ b/integration-tests/context-compress-interactive.test.ts @@ -65,7 +65,15 @@ describe('Interactive Mode', () => { }); it('should handle compression failure on token inflation', async () => { - await rig.setup('interactive-compress-test'); + await rig.setup('interactive-compress-test', { + settings: { + security: { + auth: { + selectedType: 'gemini-api-key', + }, + }, + }, + }); const { ptyProcess } = rig.runInteractive(); From 169dfe5199cdcf3d94e594c5fc32ce90e3a93d42 Mon Sep 17 00:00:00 2001 From: Taneja Hriday Date: Mon, 6 Oct 2025 20:07:46 +0000 Subject: [PATCH 3/6] added a timeout after initialization --- integration-tests/context-compress-interactive.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/integration-tests/context-compress-interactive.test.ts b/integration-tests/context-compress-interactive.test.ts index c7662683788..5ebc553ca5d 100644 --- a/integration-tests/context-compress-interactive.test.ts +++ b/integration-tests/context-compress-interactive.test.ts @@ -96,8 +96,10 @@ describe('Interactive Mode', () => { true, ); + await new Promise((resolve) => setTimeout(resolve, 5000)); + await type(ptyProcess, '/compress'); - await new Promise((resolve) => setTimeout(resolve, 100)); + await new Promise((resolve) => setTimeout(resolve, 1000)); await type(ptyProcess, '\r'); const compressionFailed = await rig.waitForText( From 213c08c8ae0aaf70e6bfb559da2cc1cd442e2ccb Mon Sep 17 00:00:00 2001 From: Taneja Hriday Date: Mon, 6 Oct 2025 20:37:51 +0000 Subject: [PATCH 4/6] added a confirmation after initialization --- .../context-compress-interactive.test.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/integration-tests/context-compress-interactive.test.ts b/integration-tests/context-compress-interactive.test.ts index 5ebc553ca5d..6c95f8ba29b 100644 --- a/integration-tests/context-compress-interactive.test.ts +++ b/integration-tests/context-compress-interactive.test.ts @@ -96,9 +96,17 @@ describe('Interactive Mode', () => { true, ); - await new Promise((resolve) => setTimeout(resolve, 5000)); + await type(ptyProcess, '/co'); - await type(ptyProcess, '/compress'); + const suggestionsReady = await rig.waitForText( + 'Compresses the context by replacing it with a summary.', + 15000, + ); + expect(suggestionsReady, 'Command suggestions did not appear in time').toBe( + true, + ); + + await type(ptyProcess, 'mpress'); await new Promise((resolve) => setTimeout(resolve, 1000)); await type(ptyProcess, '\r'); From b0df0db6a1b41936781a8655866956c61c0ad31c Mon Sep 17 00:00:00 2001 From: Taneja Hriday Date: Tue, 7 Oct 2025 05:41:20 +0000 Subject: [PATCH 5/6] removed rig setting for one of the tests --- integration-tests/context-compress-interactive.test.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/integration-tests/context-compress-interactive.test.ts b/integration-tests/context-compress-interactive.test.ts index 6c95f8ba29b..f577277ed9f 100644 --- a/integration-tests/context-compress-interactive.test.ts +++ b/integration-tests/context-compress-interactive.test.ts @@ -65,15 +65,7 @@ describe('Interactive Mode', () => { }); it('should handle compression failure on token inflation', async () => { - await rig.setup('interactive-compress-test', { - settings: { - security: { - auth: { - selectedType: 'gemini-api-key', - }, - }, - }, - }); + await rig.setup('interactive-compress-test'); const { ptyProcess } = rig.runInteractive(); From 13b304fe843bd5e28d11af693ef083463715256c Mon Sep 17 00:00:00 2001 From: Taneja Hriday Date: Wed, 8 Oct 2025 11:13:29 +0000 Subject: [PATCH 6/6] updated wait for /compress command from list --- integration-tests/context-compress-interactive.test.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/integration-tests/context-compress-interactive.test.ts b/integration-tests/context-compress-interactive.test.ts index f577277ed9f..f0e0a3937fc 100644 --- a/integration-tests/context-compress-interactive.test.ts +++ b/integration-tests/context-compress-interactive.test.ts @@ -88,7 +88,7 @@ describe('Interactive Mode', () => { true, ); - await type(ptyProcess, '/co'); + await type(ptyProcess, '/compress'); const suggestionsReady = await rig.waitForText( 'Compresses the context by replacing it with a summary.', @@ -97,9 +97,6 @@ describe('Interactive Mode', () => { expect(suggestionsReady, 'Command suggestions did not appear in time').toBe( true, ); - - await type(ptyProcess, 'mpress'); - await new Promise((resolve) => setTimeout(resolve, 1000)); await type(ptyProcess, '\r'); const compressionFailed = await rig.waitForText(