Skip to content

Commit 78328fe

Browse files
committed
update unit tests
1 parent 4404a4a commit 78328fe

File tree

3 files changed

+43
-18
lines changed

3 files changed

+43
-18
lines changed

src/vs/platform/prompts/test/common/config.test.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ import { IConfigurationOverrides, IConfigurationService } from '../../../configu
1616
const createMock = <T>(value: T): IConfigurationService => {
1717
return mockService<IConfigurationService>({
1818
getValue(key?: string | IConfigurationOverrides) {
19-
assert.strictEqual(
20-
key,
21-
PromptsConfig.CONFIG_KEY,
22-
`Mocked service supports only one configuration key: '${PromptsConfig.CONFIG_KEY}'.`,
19+
assert(
20+
typeof key === 'string',
21+
`Expected string configuration key, got '${typeof key}'.`,
22+
);
23+
24+
assert(
25+
[PromptsConfig.CONFIG_KEY, PromptsConfig.LOCATIONS_CONFIG_KEY].includes(key),
26+
`Unsupported configuration key '${key}'.`,
2327
);
2428

2529
return value;
@@ -35,7 +39,7 @@ suite('PromptsConfig', () => {
3539
const configService = createMock(undefined);
3640

3741
assert.strictEqual(
38-
PromptsConfig.getValue(configService),
42+
PromptsConfig.getLocationsValue(configService),
3943
undefined,
4044
'Must read correct value.',
4145
);
@@ -45,7 +49,7 @@ suite('PromptsConfig', () => {
4549
const configService = createMock(null);
4650

4751
assert.strictEqual(
48-
PromptsConfig.getValue(configService),
52+
PromptsConfig.getLocationsValue(configService),
4953
undefined,
5054
'Must read correct value.',
5155
);
@@ -54,15 +58,15 @@ suite('PromptsConfig', () => {
5458
suite('• object', () => {
5559
test('• empty', () => {
5660
assert.deepStrictEqual(
57-
PromptsConfig.getValue(createMock({})),
61+
PromptsConfig.getLocationsValue(createMock({})),
5862
{},
5963
'Must read correct value.',
6064
);
6165
});
6266

6367
test('• only valid strings', () => {
6468
assert.deepStrictEqual(
65-
PromptsConfig.getValue(createMock({
69+
PromptsConfig.getLocationsValue(createMock({
6670
'/root/.bashrc': true,
6771
'../../folder/.hidden-folder/config.xml': true,
6872
'/srv/www/Public_html/.htaccess': true,
@@ -96,7 +100,7 @@ suite('PromptsConfig', () => {
96100

97101
test('• filters out non valid entries', () => {
98102
assert.deepStrictEqual(
99-
PromptsConfig.getValue(createMock({
103+
PromptsConfig.getLocationsValue(createMock({
100104
'/etc/hosts.backup': '\t\n\t',
101105
'./run.tests.sh': '\v',
102106
'../assets/img/logo.v2.png': true,
@@ -135,7 +139,7 @@ suite('PromptsConfig', () => {
135139

136140
test('• only invalid or false values', () => {
137141
assert.deepStrictEqual(
138-
PromptsConfig.getValue(createMock({
142+
PromptsConfig.getLocationsValue(createMock({
139143
'/etc/hosts.backup': '\t\n\t',
140144
'./run.tests.sh': '\v',
141145
'../assets/IMG/logo.v2.png': '',

src/vs/workbench/contrib/chat/browser/chat.contribution.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,19 +200,36 @@ configurationRegistry.registerConfiguration({
200200
tags: ['experimental', 'onExp']
201201
},
202202
[PromptsConfig.CONFIG_KEY]: {
203+
type: 'boolean',
204+
title: nls.localize(
205+
'chat.reusablePrompts.config.enabled.title',
206+
"Reusable Prompts",
207+
),
208+
markdownDescription: nls.localize(
209+
'chat.reusablePrompts.config.enabled.description',
210+
"Enable reusable prompts (`*{0}`) in Chat, Edits, and Inline Chat sessions. [Learn More]({0}).",
211+
PROMPT_FILE_EXTENSION,
212+
DOCUMENTATION_URL,
213+
),
214+
default: true,
215+
restricted: true,
216+
disallowConfigurationDefault: true,
217+
tags: ['experimental'],
218+
},
219+
[PromptsConfig.LOCATIONS_CONFIG_KEY]: {
203220
type: 'object',
204221
title: nls.localize(
205-
'chat.promptFiles.config.title',
206-
"Prompt Files",
222+
'chat.reusablePrompts.config.locations.title',
223+
"Reusable Prompt Locations",
207224
),
208225
markdownDescription: nls.localize(
209-
'chat.promptFiles.config.description',
226+
'chat.reusablePrompts.config.locations.description',
210227
"Specify location(s) of reusable prompt files (`*{0}`) that can be attached in Chat, Edits, and Inline Chat sessions. [Learn More]({1}).\n\nRelative paths are resolved from the root folder(s) of your workspace.",
211228
PROMPT_FILE_EXTENSION,
212229
DOCUMENTATION_URL,
213230
),
214231
default: {
215-
[PromptsConfig.DEFAULT_SOURCE_FOLDER]: false,
232+
[PromptsConfig.DEFAULT_SOURCE_FOLDER]: true,
216233
},
217234
required: [PromptsConfig.DEFAULT_SOURCE_FOLDER],
218235
additionalProperties: { type: 'boolean' },

src/vs/workbench/contrib/chat/test/common/promptSyntax/utils/promptFilesLocator.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ import { IWorkspace, IWorkspaceContextService, IWorkspaceFolder } from '../../..
2727
const mockConfigService = <T>(value: T): IConfigurationService => {
2828
return mockService<IConfigurationService>({
2929
getValue(key?: string | IConfigurationOverrides) {
30-
assert.strictEqual(
31-
key,
32-
PromptsConfig.CONFIG_KEY,
33-
`Mocked service supports only one configuration key: '${PromptsConfig.CONFIG_KEY}'.`,
30+
assert(
31+
typeof key === 'string',
32+
`Expected string configuration key, got '${typeof key}'.`,
33+
);
34+
35+
assert(
36+
[PromptsConfig.CONFIG_KEY, PromptsConfig.LOCATIONS_CONFIG_KEY].includes(key),
37+
`Unsupported configuration key '${key}'.`,
3438
);
3539

3640
return value;

0 commit comments

Comments
 (0)