Files
vscode/extensions/copilot/test/inline/slashDoc.java.stest.ts
Johannes Rieken fcbff5831a InlineChatIntent (#1549)
* remove references to old setting `github.copilot.chat.advanced.inlineChat2`

* play with `InlineChatIntent`

* wip

* move things, better/simpler prompt

* cleanup, renames, stuff

* more wip

* done after tool call

* edit and generate stest for new InlineChatIntent

* use codebook for diagnostics

* inline chat fixing stests

* stest run

* remove old Inline2 tests

* remove slash commands for v2, remove the editCodeIntent path for v2

* 💄

* 💄

* Don't use `diagnosticsTimeout` when with inline chat because the new diagnostics will never be read but slow down the result

* fix compile error

* stest run

* update baseline

* prevent some JSON errors from empty output

* unfresh baseline.json

* use `MockGithubAvailableEmbeddingTypesService` in stests

* back to hamfisted skipping of stests

* send telemetry from inline chat intent

* tweak some stests
2025-10-29 10:44:00 +00:00

77 lines
2.8 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { InlineDocIntent } from '../../src/extension/intents/node/docIntent';
import { ssuite, stest } from '../base/stest';
import { forInline, simulateInlineChatWithStrategy } from '../simulation/inlineChatSimulator';
import { assertInlineEdit, fromFixture } from '../simulation/stestUtil';
import { assertDocLines } from './slashDoc.util';
forInline((strategy, nonExtensionConfigurations, suffix) => {
ssuite({ title: `/doc${suffix}`, language: 'java', location: 'inline' }, () => {
stest({ description: 'class', nonExtensionConfigurations }, (testingServiceCollection) => {
return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {
files: [
fromFixture('tlaplus/toolbox/org.lamport.tla.toolbox.doc/src/org/lamport/tla/toolbox/doc/HelpActivator.java'),
],
queries: [
{
file: 'HelpActivator.java',
selection: [30, 21],
query: '/doc',
expectedIntent: InlineDocIntent.ID,
validate: async (outcome, workspace, accessor) => {
assertInlineEdit(outcome);
const fileContents = outcome.fileContents;
// no duplication of declaration
assert.strictEqual([...fileContents.matchAll(/class HelpActivator/g)].length, 1);
// no block bodies with a single comment
assert.strictEqual([...fileContents.matchAll(/\/\/ \.\.\./g)].length, 0, 'no // ...');
assert.strictEqual([...fileContents.matchAll(/details|implementation/g)].length, 1);
// assert it contains doc comments above
const lineWithCursor = 'public class HelpActivator';
assertDocLines(fileContents, lineWithCursor);
}
}
],
});
});
stest({ description: 'method', nonExtensionConfigurations }, (testingServiceCollection) => {
return simulateInlineChatWithStrategy(strategy, testingServiceCollection, {
files: [
fromFixture('tlaplus/toolbox/org.lamport.tla.toolbox.doc/src/org/lamport/tla/toolbox/doc/HelpActivator.java'),
],
queries: [
{
file: 'HelpActivator.java',
selection: [40, 0, 43, 1],
query: '/doc',
expectedIntent: InlineDocIntent.ID,
validate: async (outcome, workspace, accessor) => {
assertInlineEdit(outcome);
const fileContents = outcome.fileContents;
// assert it contains doc comments above
const lineWithCursor = ' public void start(BundleContext context) throws Exception {';
assertDocLines(fileContents, lineWithCursor);
}
}
],
});
});
});
});