Path: blob/main/extensions/copilot/test/e2e/edit.stest.ts
13388 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import assert from 'assert';6import path from 'path';7import { ToolName } from '../../src/extension/tools/common/toolNames';8import { ICodebaseToolParams } from '../../src/extension/tools/node/codebaseTool';9import { IReadFileParamsV1 } from '../../src/extension/tools/node/readFileTool';10import { deserializeWorkbenchState } from '../../src/platform/test/node/promptContextModel';11import { ssuite, stest } from '../base/stest';12import { generateToolTestRunner } from './toolSimTest';13import { shouldSkipAgentTests } from './tools.stest';141516ssuite.optional(shouldSkipAgentTests, { title: 'edit', subtitle: 'toolCalling', location: 'panel' }, () => {17const scenarioFolder = path.join(__dirname, '..', 'test/scenarios/test-tools');18const getState = () => deserializeWorkbenchState(scenarioFolder, path.join(scenarioFolder, 'chatSetup.state.json'));1920stest('does not read', generateToolTestRunner({21question: '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',22scenarioFolderPath: '',23getState,24tools: {25},26}, {27allowParallelToolCalls: true,28toolCallValidators: {29[ToolName.ReadFile]: (toolCalls) => {30assert.ok(!toolCalls.some(tc => (tc.input as IReadFileParamsV1).filePath.endsWith('chatSetup.ts')), 'Should not read_file the attached file');31},32[ToolName.Codebase]: (toolCalls) => {33assert.ok(!toolCalls.some(tc => {34const query = (tc.input as ICodebaseToolParams).query;35return query.includes('doForwardRequestToCopilotWhenReady') || query.includes('whenLanguageModelReady');36}), 'Should not do semantic_search for something that is in the attached file');37}38}39}));40});414243