fix: resolve acpConnection test failure and ESLint warning

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
wenshao 2026-03-21 00:52:41 +08:00
parent b1e29a1aa7
commit 004baaebcc
2 changed files with 23 additions and 20 deletions

15
package-lock.json generated
View file

@ -1536,10 +1536,6 @@
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
}
},
"node_modules/@google/gemini-cli-test-utils": {
"resolved": "packages/test-utils",
"link": true
},
"node_modules/@grpc/grpc-js": {
"version": "1.13.4",
"resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.13.4.tgz",
@ -18878,6 +18874,16 @@
"@teddyzhu/clipboard-win32-x64-msvc": "0.0.5"
}
},
"packages/cli/node_modules/@google/gemini-cli-test-utils": {
"name": "@qwen-code/qwen-code-test-utils",
"version": "0.13.0",
"resolved": "file:packages/test-utils",
"dev": true,
"license": "Apache-2.0",
"engines": {
"node": ">=20"
}
},
"packages/cli/node_modules/@google/genai": {
"version": "1.30.0",
"resolved": "https://registry.npmjs.org/@google/genai/-/genai-1.30.0.tgz",
@ -22891,7 +22897,6 @@
"packages/test-utils": {
"name": "@qwen-code/qwen-code-test-utils",
"version": "0.13.0",
"dev": true,
"license": "Apache-2.0",
"devDependencies": {
"typescript": "^5.3.3"

View file

@ -69,19 +69,9 @@ describe('AcpConnection readTextFile error mapping', () => {
});
it('passes structured ACP prompt blocks through without wrapping them as text', async () => {
const prompt = vi.fn().mockResolvedValue({});
const promptFn = vi.fn().mockResolvedValue({});
const onEndTurn = vi.fn();
const conn = new AcpConnection() as unknown as {
sdkConnection: {
prompt: (params: {
sessionId: string;
prompt: ContentBlock[];
}) => Promise<unknown>;
};
sessionId: string | null;
onEndTurn: (reason?: string) => void;
sendPrompt: (prompt: string | ContentBlock[]) => Promise<unknown>;
};
const conn = new AcpConnection();
const promptBlocks: ContentBlock[] = [
{ type: 'text', text: 'Inspect this image' },
{
@ -92,13 +82,21 @@ describe('AcpConnection readTextFile error mapping', () => {
},
];
conn.sdkConnection = { prompt };
conn.sessionId = 'session-1';
// Mock ensureConnection to return a mock connection with the prompt function
vi.spyOn(
conn as unknown as { ensureConnection: () => unknown },
'ensureConnection',
).mockReturnValue({
prompt: promptFn,
} as never);
// Set sessionId via the public property
(conn as unknown as { sessionId: string | null }).sessionId = 'session-1';
conn.onEndTurn = onEndTurn;
await conn.sendPrompt(promptBlocks);
expect(prompt).toHaveBeenCalledWith({
expect(promptFn).toHaveBeenCalledWith({
sessionId: 'session-1',
prompt: promptBlocks,
});