mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-08-06 15:25:34 +00:00
fix: resolve acpConnection test failure and ESLint warning
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
parent
b1e29a1aa7
commit
004baaebcc
2 changed files with 23 additions and 20 deletions
15
package-lock.json
generated
15
package-lock.json
generated
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue