Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/test/e2e/edit.stest.ts
13388 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import assert from 'assert';
7
import path from 'path';
8
import { ToolName } from '../../src/extension/tools/common/toolNames';
9
import { ICodebaseToolParams } from '../../src/extension/tools/node/codebaseTool';
10
import { IReadFileParamsV1 } from '../../src/extension/tools/node/readFileTool';
11
import { deserializeWorkbenchState } from '../../src/platform/test/node/promptContextModel';
12
import { ssuite, stest } from '../base/stest';
13
import { generateToolTestRunner } from './toolSimTest';
14
import { shouldSkipAgentTests } from './tools.stest';
15
16
17
ssuite.optional(shouldSkipAgentTests, { title: 'edit', subtitle: 'toolCalling', location: 'panel' }, () => {
18
const scenarioFolder = path.join(__dirname, '..', 'test/scenarios/test-tools');
19
const getState = () => deserializeWorkbenchState(scenarioFolder, path.join(scenarioFolder, 'chatSetup.state.json'));
20
21
stest('does not read', generateToolTestRunner({
22
question: 'This code fails because whenLanguageModelReady waits for any model, not the correct model. From doInvokeWithoutSetup, wait for the model with id IChatAgentRequest.userSelectedModelId to be registered',
23
scenarioFolderPath: '',
24
getState,
25
tools: {
26
},
27
}, {
28
allowParallelToolCalls: true,
29
toolCallValidators: {
30
[ToolName.ReadFile]: (toolCalls) => {
31
assert.ok(!toolCalls.some(tc => (tc.input as IReadFileParamsV1).filePath.endsWith('chatSetup.ts')), 'Should not read_file the attached file');
32
},
33
[ToolName.Codebase]: (toolCalls) => {
34
assert.ok(!toolCalls.some(tc => {
35
const query = (tc.input as ICodebaseToolParams).query;
36
return query.includes('doForwardRequestToCopilotWhenReady') || query.includes('whenLanguageModelReady');
37
}), 'Should not do semantic_search for something that is in the attached file');
38
}
39
}
40
}));
41
});
42
43