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