Path: blob/main/extensions/copilot/test/e2e/variables.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 * as path from 'path';5import { getLanguage } from '../../src/util/common/languages';6import { ssuite, stest } from '../base/stest';7import { validate } from '../base/validate';8import { fetchConversationScenarios } from './scenarioLoader';9import { generateScenarioTestRunner } from './scenarioTest';1011ssuite({ title: 'variables', location: 'panel' }, (inputPath) => {1213const scenarioFolder = inputPath ?? path.join(__dirname, '..', 'test/scenarios/test-variables');14const scenarios = fetchConversationScenarios(scenarioFolder);1516for (const scenario of scenarios) {17const language = scenario[0].getState?.().activeTextEditor?.document.languageId;18stest({ description: scenario[0].json.description ?? scenario[0].question, language: language ? getLanguage(language).languageId : undefined }, generateScenarioTestRunner(19scenario,20async (accessor, question, answer) => {21if (scenario[0].json.keywords !== undefined) {22const err = validate(answer, scenario[0].json.keywords);23if (err) {24return { success: false, errorMessage: err };25}2627return { success: true };28}2930return { success: true, errorMessage: 'No requirements set for test.' };31}32));33}34});353637