Path: blob/main/extensions/copilot/test/e2e/vscode.stest.ts
13388 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/4import { ssuite, stest } from '../base/stest';5import { validate } from '../base/validate';6import { discoverScenarios } from './scenarioLoader';7import { generateScenarioTestRunner } from './scenarioTest';89ssuite({ title: '@vscode', location: 'panel' }, (inputPath) => {10if (!inputPath) {11return;12}1314const scenarios = discoverScenarios(inputPath);1516for (const scenario of scenarios) {17const fileName = scenario[0].name;18const testName = inputPath ? fileName.substring(0, fileName.indexOf('.')) : scenario[0].question.replace('@vscode', '');19stest({ description: testName }, generateScenarioTestRunner(20scenario,21async (accessor, question, answer, rawResponse, turn, scenarioIndex, commands) => {22if (scenario[0].json.keywords !== undefined) {23const err = validate(rawResponse, scenario[0].json.keywords);24if (err) {25return { success: false, errorMessage: err };26}27const showCommands = scenario[0].json.showCommand as boolean ?? true;28if (showCommands && commands.length === 0) {29return { success: false, errorMessage: 'Response is missing required commands.' };30} else if (!showCommands && commands.length > 0) {31return { success: false, errorMessage: 'Response includes commands that should not be present.' };32}33return { success: true, errorMessage: answer };34}3536return { success: true, errorMessage: 'No requirements set for test.' };37}38));39}40});414243