Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/test/simulation/inlineEdit/inlineEdit.stest.ts
13394 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
import { XtabProvider } from '../../../src/extension/xtab/node/xtabProvider';
6
import { ConfigKey } from '../../../src/platform/configuration/common/configurationService';
7
import { Configuration, ISimulationSuiteDescriptor, ssuite, stest } from '../../base/stest';
8
import { inlineEditsFixture, loadFile } from './fileLoading';
9
import { InlineEditTester } from './inlineEditTester';
10
11
const CompScore1 = 'CompScore1';
12
const CompScore2 = 'CompScore2';
13
const CompScore3 = 'CompScore3';
14
15
function getTester() {
16
return new InlineEditTester();
17
}
18
19
type TestConfiguration = {
20
providerName: string;
21
extensionConfiguration: Configuration<any>[];
22
/**
23
* Default is true.
24
*/
25
shouldBeRun?: boolean;
26
};
27
28
const commonXtabTestConfigurations: Configuration<unknown>[] = [
29
// uncomment to include viewed files
30
// {
31
// key: ConfigKey.Internal.InlineEditsXtabIncludeViewedFiles,
32
// value: true,
33
// },
34
];
35
36
const testConfigs: TestConfiguration[] = [
37
{
38
providerName: 'xtab',
39
extensionConfiguration: [
40
{
41
key: ConfigKey.TeamInternal.InlineEditsProviderId,
42
value: XtabProvider.ID,
43
},
44
...commonXtabTestConfigurations,
45
],
46
}
47
];
48
49
for (const testConfig of testConfigs) {
50
51
const providerName = testConfig.providerName;
52
53
function ssuiteByProvider(descr: ISimulationSuiteDescriptor, testRegistrationFactory: () => void) {
54
if (providerName === 'server') {
55
return ssuite.optional( // remember: optional tests aren't run in CI (which matches current desired behavior but don't be surprised)
56
(opts) => !opts.runServerPoweredNesProvider,
57
descr,
58
testRegistrationFactory
59
);
60
} else {
61
return ssuite(descr, testRegistrationFactory);
62
}
63
}
64
65
ssuiteByProvider({ title: 'InlineEdit GoldenScenario', subtitle: `[${testConfig.providerName}]`, location: 'external', configurations: testConfig.extensionConfiguration }, () => {
66
67
const tester = getTester();
68
69
stest({ description: '[MustHave] 1-point.ts', language: 'typescript', attributes: { [CompScore1]: 1, [CompScore2]: 0.5, [CompScore3]: 0 } }, collection => tester.runAndScoreTestFromRecording(collection,
70
loadFile({ filePath: inlineEditsFixture('1-point.ts/recording.w.json') }),
71
));
72
73
stest({ description: '[NiceToHave] 2-helloworld-sample-remove-generic-parameter', language: 'typescript', attributes: { [CompScore1]: 0 } }, collection => tester.runAndScoreTestFromRecording(collection,
74
loadFile({ filePath: inlineEditsFixture('2-helloworld-sample-remove-generic-parameter/recording.w.json') }),
75
));
76
77
stest({ description: '[MustHave] 6-vscode-remote-try-java-part-1', language: 'java', attributes: { [CompScore1]: 1, [CompScore2]: 1, [CompScore3]: 0.75 } }, collection => tester.runAndScoreTestFromRecording(collection,
78
loadFile({ filePath: inlineEditsFixture('6-vscode-remote-try-java-part-1/recording.w.json') }),
79
));
80
81
// TODO: this test case is weird, it overspecifies like directing via comments
82
stest({ description: '[MustHave] 6-vscode-remote-try-java-part-2', language: 'java', attributes: { [CompScore1]: 1, [CompScore2]: 1, [CompScore3]: 0.75 } }, collection => tester.runAndScoreTestFromRecording(collection,
83
loadFile({ filePath: inlineEditsFixture('6-vscode-remote-try-java-part-2/recording.w.json') })
84
));
85
86
// 7 covered in "From codium"
87
88
stest({ description: '[MustHave] 8-cppIndividual-1-point.cpp', language: 'cpp', attributes: { [CompScore1]: 1, [CompScore2]: 0, [CompScore3]: 1 } }, collection => tester.runAndScoreTestFromRecording(collection,
89
loadFile({ filePath: inlineEditsFixture('8-cppIndividual-1-point.cpp/recording.w.json') }),
90
));
91
92
stest({ description: '[MustHave] 8-cppIndividual-2-collection-farewell', language: 'cpp', attributes: { [CompScore1]: 1, [CompScore2]: 0.5, [CompScore3]: 0.5 } }, collection => tester.runAndScoreTestFromRecording(collection,
93
loadFile({ filePath: inlineEditsFixture('8-cppIndividual-2-collection-farewell/recording.w.json') }),
94
));
95
96
stest({ description: '[MustHave] 9-cppProject-add-header-expect-implementation', language: 'cpp', attributes: { [CompScore1]: 1, [CompScore2]: 0.66, [CompScore3]: 0.5 } }, collection => tester.runAndScoreTestFromRecording(collection,
97
loadFile({ filePath: inlineEditsFixture('9-cppProject-add-header-expect-implementation/recording.w.json') })
98
));
99
100
stest({ description: '[MustHave] 9-cppProject-add-implementation-expect-header', language: 'cpp', attributes: { [CompScore1]: 1, [CompScore2]: 0, [CompScore3]: 1 } }, collection => tester.runAndScoreTestFromRecording(collection,
101
loadFile({ filePath: inlineEditsFixture('9-cppProject-add-implementation-expect-header/recording.w.json') }),
102
));
103
104
stest({ description: 'Notebook 10-update-name-in-same-cell-of-notebook', language: 'python' }, collection => tester.runAndScoreTestFromRecording(collection,
105
loadFile({
106
filePath: inlineEditsFixture('10-update-name-in-same-cell-of-notebook/recording.w.json'),
107
})
108
));
109
110
stest({ description: 'Notebook 11-update-name-in-next-cell-of-notebook', language: 'python' }, collection => tester.runAndScoreTestFromRecording(collection,
111
loadFile({
112
filePath: inlineEditsFixture('11-update-name-in-next-cell-of-notebook/recording.w.json'),
113
})
114
));
115
116
});
117
118
}
119
120