Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/test/e2e/vscode.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
import { ssuite, stest } from '../base/stest';
6
import { validate } from '../base/validate';
7
import { discoverScenarios } from './scenarioLoader';
8
import { generateScenarioTestRunner } from './scenarioTest';
9
10
ssuite({ title: '@vscode', location: 'panel' }, (inputPath) => {
11
if (!inputPath) {
12
return;
13
}
14
15
const scenarios = discoverScenarios(inputPath);
16
17
for (const scenario of scenarios) {
18
const fileName = scenario[0].name;
19
const testName = inputPath ? fileName.substring(0, fileName.indexOf('.')) : scenario[0].question.replace('@vscode', '');
20
stest({ description: testName }, generateScenarioTestRunner(
21
scenario,
22
async (accessor, question, answer, rawResponse, turn, scenarioIndex, commands) => {
23
if (scenario[0].json.keywords !== undefined) {
24
const err = validate(rawResponse, scenario[0].json.keywords);
25
if (err) {
26
return { success: false, errorMessage: err };
27
}
28
const showCommands = scenario[0].json.showCommand as boolean ?? true;
29
if (showCommands && commands.length === 0) {
30
return { success: false, errorMessage: 'Response is missing required commands.' };
31
} else if (!showCommands && commands.length > 0) {
32
return { success: false, errorMessage: 'Response includes commands that should not be present.' };
33
}
34
return { success: true, errorMessage: answer };
35
}
36
37
return { success: true, errorMessage: 'No requirements set for test.' };
38
}
39
));
40
}
41
});
42
43