fix(tests): enable cyclic schema MCP tool test (#10912)

This commit is contained in:
Sandy Tao
2025-10-14 18:46:54 -07:00
committed by GitHub
parent dabe161a6f
commit 4f5b335792
5 changed files with 41 additions and 23 deletions

View File

@@ -27,15 +27,13 @@ describe.skip('Interactive Mode', () => {
const longPrompt =
'Dont do anything except returning a 1000 token long paragraph with the <name of the scientist who discovered theory of relativity> at the end to indicate end of response. This is a moderately long sentence.';
await run.type(longPrompt);
await run.type('\r');
await run.sendKeys(longPrompt);
await run.sendKeys('\r');
await run.expectText('einstein', 25000);
await run.type('/compress');
// A small delay to allow React to re-render the command list.
await new Promise((resolve) => setTimeout(resolve, 100));
await run.type('\r');
await run.sendKeys('\r');
const foundEvent = await rig.waitForTelemetryEvent(
'chat_compression',
@@ -53,9 +51,7 @@ describe.skip('Interactive Mode', () => {
const run = await rig.runInteractive();
await run.type('/compress');
// A small delay to allow React to re-render the command list.
await new Promise((resolve) => setTimeout(resolve, 100));
await run.type('\r');
await run.sendKeys('\r');
await run.expectText('compression was not beneficial', 25000);
});
});

View File

@@ -16,7 +16,7 @@ describe.skip('Ctrl+C exit', () => {
const run = await rig.runInteractive();
// Send first Ctrl+C
run.type('\x03');
run.sendKeys('\x03');
await run.expectText('Press Ctrl+C again to exit', 5000);
@@ -40,7 +40,7 @@ describe.skip('Ctrl+C exit', () => {
}
// Send second Ctrl+C
run.type('\x03');
run.sendKeys('\x03');
const exitCode = await run.expectExit();
expect(exitCode, `Process exited with code ${exitCode}.`).toBe(0);

View File

@@ -28,7 +28,7 @@ describe.skip('Interactive file system', () => {
// Step 1: Read the file
const readPrompt = `Read the version from ${fileName}`;
await run.type(readPrompt);
await run.type('\r');
await run.sendKeys('\r');
const readCall = await rig.waitForToolCall('read_file', 30000);
expect(readCall, 'Expected to find a read_file tool call').toBe(true);
@@ -38,7 +38,7 @@ describe.skip('Interactive file system', () => {
// Step 2: Write the file
const writePrompt = `now change the version to 1.0.1 in the file`;
await run.type(writePrompt);
await run.type('\r');
await run.sendKeys('\r');
await rig.expectToolCallSuccess(['write_file', 'replace'], 30000);

View File

@@ -23,7 +23,7 @@
import { writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { beforeAll, describe, expect, it } from 'vitest';
import { beforeAll, describe, it } from 'vitest';
import { TestRig } from './test-helper.js';
// Create a minimal MCP server that doesn't require external dependencies
@@ -192,15 +192,12 @@ describe('mcp server with cyclic tool schema is detected', () => {
}
});
//TODO - https://github.com/google-gemini/gemini-cli/issues/10735
it.skip('mcp tool list should include tool with cyclic tool schema', async () => {
const tool_list_output = await rig.run('/mcp list');
expect(tool_list_output).toContain('tool_with_cyclic_schema');
});
it('mcp tool list should include tool with cyclic tool schema', async () => {
const run = await rig.runInteractive();
it('gemini api call should be successful with cyclic mcp tool schema', async () => {
// Run any command and verify that we get a non-error response from
// the Gemini API.
await rig.run('hello');
await run.type('/mcp list');
await run.sendKeys('\r');
await run.expectText('tool_with_cyclic_schema');
});
});

View File

@@ -195,8 +195,33 @@ export class InteractiveRun {
expect(found, `Did not find expected text: "${text}"`).toBe(true);
}
// Simulates typing a string one character at a time to avoid paste detection.
// This types slowly to make sure command is correct, but only work for short
// commands that are not multi-line, use sendKeys to type long prompts
async type(text: string) {
let typedSoFar = '';
for (const char of text) {
this.ptyProcess.write(char);
typedSoFar += char;
// Wait for the typed sequence so far to be echoed back.
const found = await poll(
() => stripAnsi(this.output).includes(typedSoFar),
5000, // 5s timeout per character (generous for CI)
10, // check frequently
);
if (!found) {
throw new Error(
`Timed out waiting for typed text to appear in output: "${typedSoFar}".\nStripped output:\n${stripAnsi(
this.output,
)}`,
);
}
}
}
// Simulates typing a string one character at a time to avoid paste detection.
async sendKeys(text: string) {
const delay = 5;
for (const char of text) {
this.ptyProcess.write(char);