Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/test/e2e/system.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 * as path from 'path';
6
import { ssuite, stest } from '../base/stest';
7
import { validate } from '../base/validate';
8
import { fetchConversationScenarios } from './scenarioLoader';
9
import { generateScenarioTestRunner } from './scenarioTest';
10
11
ssuite({ title: 'system', subtitle: 'identity', location: 'panel' }, (inputPath) => {
12
13
const scenarioFolder = inputPath ?? path.join(__dirname, '..', 'test/scenarios/test-system');
14
const scenarios = fetchConversationScenarios(scenarioFolder);
15
16
for (const scenario of scenarios) {
17
stest({ description: scenario[0].question, language: undefined }, generateScenarioTestRunner(
18
scenario,
19
async (accessor, question, answer) => {
20
const expectedKeywords = scenario.find((s) => s.question === question)?.json.keywords;
21
if (expectedKeywords !== undefined) {
22
const err = validate(answer, expectedKeywords);
23
if (err) {
24
return { success: false, errorMessage: err };
25
}
26
27
return { success: true, errorMessage: answer };
28
}
29
30
return { success: true, errorMessage: 'No requirements set for test.' };
31
}
32
));
33
}
34
});
35
36