Path: blob/main/extensions/copilot/test/intent/panelChatIntent.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 fs from 'fs';5import '../../src/extension/intents/node/allIntents'; // make sure all intents are registered6import { ChatLocation } from '../../src/platform/chat/common/commonTypes';7import { join } from '../../src/util/vs/base/common/path';8import { ssuite } from '../base/stest';9import { generateIntentTest } from './intentTest';1011ssuite({ title: 'intent', location: 'panel' }, () => {12runAdditionalCases(join(__dirname, '../test/intent/panel-chat.json'));13// Uncomment this line to run additional intent detection tests14// runAdditionalCases(join(__dirname, '../test/intent/panel-chat-github.json'));15// runAdditionalCases(join(__dirname, '../test/intent/panel-chat-unknown.json'));16});1718function runAdditionalCases(sourceFile: string) {19const additionalCases = JSON.parse(fs.readFileSync(sourceFile, { encoding: 'utf8' }));20if (additionalCases && Array.isArray(additionalCases)) {21additionalCases.forEach((testCase: any) => {22if (typeof testCase === 'object' && !!testCase && testCase['Location'] === 'panel') {23const query = testCase['Request'];24const expectedIntent = testCase['Intent'];25for (const strictMode of [true, false]) {26generateIntentTest({27location: ChatLocation.Panel,28name: (strictMode ? '[strict] ' : '[relaxed] ') + `[${expectedIntent === 'github' ? 'github' : 'builtin'}] ` + query,29query,30expectedIntent: (['workspace', 'vscode', 'new', 'newNotebook', 'unknown', 'tests', 'setupTests', 'terminalExplain', 'github.copilot-dynamic.platform'].includes(expectedIntent)31? (strictMode ? expectedIntent : [expectedIntent, 'unknown'])32: 'unknown'),33});34}35}36});37}38}394041