Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/test/inline/agent.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
7
import * as assert from 'assert';
8
import { CHAT_MODEL } from '../../src/platform/configuration/common/configurationService';
9
import { TestingServiceCollection } from '../../src/platform/test/node/services';
10
import { ssuite, stest } from '../base/stest';
11
import { assertFileContent, assertNoElidedCodeComments, getWorkspaceDiagnostics } from '../simulation/outcomeValidators';
12
import { EditTestStrategyPanel, simulatePanelCodeMapper } from '../simulation/panelCodeMapperSimulator';
13
import { assertWorkspaceEdit, fromFixture } from '../simulation/stestUtil';
14
import { EditTestStrategy, IScenario } from '../simulation/types';
15
16
function executeEditTest(
17
strategy: EditTestStrategyPanel,
18
testingServiceCollection: TestingServiceCollection,
19
scenario: IScenario
20
): Promise<void> {
21
return simulatePanelCodeMapper(testingServiceCollection, scenario, strategy);
22
}
23
24
function forAgent(callback: (model: string | undefined) => void): void {
25
callback(undefined);
26
callback(CHAT_MODEL.CLAUDE_SONNET);
27
}
28
29
const skipAgentTests = true;
30
31
forAgent((model) => {
32
const title = model ? `edit-agent-${model}` : 'edit-agent';
33
ssuite.optional(() => skipAgentTests, { title, location: 'panel' }, () => {
34
stest({ description: 'issue #8098: extract function to unseen file', language: 'typescript', model }, (testingServiceCollection) => {
35
return executeEditTest(EditTestStrategy.Agent, testingServiceCollection, {
36
files: [
37
fromFixture('multiFileEdit/issue-8098/debugUtils.ts'),
38
fromFixture('multiFileEdit/issue-8098/debugTelemetry.ts'),
39
],
40
queries: [
41
{
42
query: 'Extract filterExceptionsFromTelemetry to debugTelemetry.ts',
43
validate: async (outcome, workspace, accessor) => {
44
assertWorkspaceEdit(outcome);
45
assert.ok(outcome.files.length === 2, 'Expected two files to be edited');
46
47
const utilsTs = assertFileContent(outcome.files, 'debugUtils.ts');
48
assert.ok(!utilsTs.includes('function filterExceptionsFromTelemetry'), 'Expected filterExceptionsFromTelemetry to be extracted');
49
const telemetryFile = assertFileContent(outcome.files, 'debugTelemetry.ts');
50
assert.ok(telemetryFile.includes('filterExceptionsFromTelemetry'), 'Expected filterExceptionsFromTelemetry to be extracted');
51
52
assert.strictEqual((await getWorkspaceDiagnostics(accessor, workspace, 'tsc')).filter(d => d.kind === 'syntactic').length, 0);
53
assertNoElidedCodeComments(outcome);
54
}
55
}
56
]
57
});
58
});
59
});
60
});
61
62