mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-12 20:37:08 -07:00
test(cli): update config tests for default topic tool exclusion
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
EDIT_TOOL_NAME,
|
||||
WEB_FETCH_TOOL_NAME,
|
||||
ASK_USER_TOOL_NAME,
|
||||
CREATE_NEW_TOPIC_TOOL_NAME,
|
||||
type ExtensionLoader,
|
||||
debugLogger,
|
||||
ApprovalMode,
|
||||
@@ -1082,16 +1083,18 @@ describe('mergeExcludeTools', () => {
|
||||
]);
|
||||
process.argv = ['node', 'script.js'];
|
||||
const argv = await parseArguments(createTestMergedSettings());
|
||||
const config = await loadCliConfig(
|
||||
settings,
|
||||
|
||||
'test-session',
|
||||
argv,
|
||||
);
|
||||
const config = await loadCliConfig(settings, 'test-session', argv);
|
||||
expect(config.getExcludeTools()).toEqual(
|
||||
new Set(['tool1', 'tool2', 'tool3', 'tool4', 'tool5']),
|
||||
new Set([
|
||||
'tool1',
|
||||
'tool2',
|
||||
'tool3',
|
||||
'tool4',
|
||||
'tool5',
|
||||
CREATE_NEW_TOPIC_TOOL_NAME,
|
||||
]),
|
||||
);
|
||||
expect(config.getExcludeTools()).toHaveLength(5);
|
||||
expect(config.getExcludeTools()).toHaveLength(6);
|
||||
});
|
||||
|
||||
it('should handle overlapping excludeTools between settings and extensions', async () => {
|
||||
@@ -1113,9 +1116,9 @@ describe('mergeExcludeTools', () => {
|
||||
const argv = await parseArguments(createTestMergedSettings());
|
||||
const config = await loadCliConfig(settings, 'test-session', argv);
|
||||
expect(config.getExcludeTools()).toEqual(
|
||||
new Set(['tool1', 'tool2', 'tool3']),
|
||||
new Set(['tool1', 'tool2', 'tool3', CREATE_NEW_TOPIC_TOOL_NAME]),
|
||||
);
|
||||
expect(config.getExcludeTools()).toHaveLength(3);
|
||||
expect(config.getExcludeTools()).toHaveLength(4);
|
||||
});
|
||||
|
||||
it('should handle overlapping excludeTools between extensions', async () => {
|
||||
@@ -1146,9 +1149,9 @@ describe('mergeExcludeTools', () => {
|
||||
const argv = await parseArguments(createTestMergedSettings());
|
||||
const config = await loadCliConfig(settings, 'test-session', argv);
|
||||
expect(config.getExcludeTools()).toEqual(
|
||||
new Set(['tool1', 'tool2', 'tool3', 'tool4']),
|
||||
new Set(['tool1', 'tool2', 'tool3', 'tool4', CREATE_NEW_TOPIC_TOOL_NAME]),
|
||||
);
|
||||
expect(config.getExcludeTools()).toHaveLength(4);
|
||||
expect(config.getExcludeTools()).toHaveLength(5);
|
||||
});
|
||||
|
||||
it('should return an empty array when no excludeTools are specified and it is interactive', async () => {
|
||||
@@ -1157,7 +1160,9 @@ describe('mergeExcludeTools', () => {
|
||||
process.argv = ['node', 'script.js'];
|
||||
const argv = await parseArguments(createTestMergedSettings());
|
||||
const config = await loadCliConfig(settings, 'test-session', argv);
|
||||
expect(config.getExcludeTools()).toEqual(new Set([]));
|
||||
expect(config.getExcludeTools()).toEqual(
|
||||
new Set([CREATE_NEW_TOPIC_TOOL_NAME]),
|
||||
);
|
||||
});
|
||||
|
||||
it('should return default excludes when no excludeTools are specified and it is not interactive', async () => {
|
||||
@@ -1166,7 +1171,9 @@ describe('mergeExcludeTools', () => {
|
||||
process.argv = ['node', 'script.js', '-p', 'test'];
|
||||
const argv = await parseArguments(createTestMergedSettings());
|
||||
const config = await loadCliConfig(settings, 'test-session', argv);
|
||||
expect(config.getExcludeTools()).toEqual(new Set([ASK_USER_TOOL_NAME]));
|
||||
expect(config.getExcludeTools()).toEqual(
|
||||
new Set([ASK_USER_TOOL_NAME, CREATE_NEW_TOPIC_TOOL_NAME]),
|
||||
);
|
||||
});
|
||||
|
||||
it('should handle settings with excludeTools but no extensions', async () => {
|
||||
@@ -1177,8 +1184,10 @@ describe('mergeExcludeTools', () => {
|
||||
});
|
||||
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
|
||||
const config = await loadCliConfig(settings, 'test-session', argv);
|
||||
expect(config.getExcludeTools()).toEqual(new Set(['tool1', 'tool2']));
|
||||
expect(config.getExcludeTools()).toHaveLength(2);
|
||||
expect(config.getExcludeTools()).toEqual(
|
||||
new Set(['tool1', 'tool2', CREATE_NEW_TOPIC_TOOL_NAME]),
|
||||
);
|
||||
expect(config.getExcludeTools()).toHaveLength(3);
|
||||
});
|
||||
|
||||
it('should handle extensions with excludeTools but no settings', async () => {
|
||||
@@ -1197,8 +1206,10 @@ describe('mergeExcludeTools', () => {
|
||||
process.argv = ['node', 'script.js'];
|
||||
const argv = await parseArguments(createTestMergedSettings());
|
||||
const config = await loadCliConfig(settings, 'test-session', argv);
|
||||
expect(config.getExcludeTools()).toEqual(new Set(['tool1', 'tool2']));
|
||||
expect(config.getExcludeTools()).toHaveLength(2);
|
||||
expect(config.getExcludeTools()).toEqual(
|
||||
new Set(['tool1', 'tool2', CREATE_NEW_TOPIC_TOOL_NAME]),
|
||||
);
|
||||
expect(config.getExcludeTools()).toHaveLength(3);
|
||||
});
|
||||
|
||||
it('should not modify the original settings object', async () => {
|
||||
|
||||
Reference in New Issue
Block a user