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