Conditionally use consent flow (#8551)

This commit is contained in:
christine betts
2025-09-17 09:24:38 -04:00
committed by GitHub
parent 1a6e4a119e
commit 0403375799
3 changed files with 47 additions and 27 deletions
+21 -3
View File
@@ -596,7 +596,7 @@ describe('extension tests', () => {
mockQuestion.mockImplementation((_query, callback) => callback('y'));
await expect(
installExtension({ source: sourceExtDir, type: 'local' }),
installExtension({ source: sourceExtDir, type: 'local' }, true),
).resolves.toBe('my-local-extension');
expect(consoleInfoSpy).toHaveBeenCalledWith(
@@ -629,7 +629,7 @@ describe('extension tests', () => {
mockQuestion.mockImplementation((_query, callback) => callback('y'));
await expect(
installExtension({ source: sourceExtDir, type: 'local' }),
installExtension({ source: sourceExtDir, type: 'local' }, true),
).resolves.toBe('my-local-extension');
expect(mockQuestion).toHaveBeenCalledWith(
@@ -654,7 +654,7 @@ describe('extension tests', () => {
mockQuestion.mockImplementation((_query, callback) => callback('n'));
await expect(
installExtension({ source: sourceExtDir, type: 'local' }),
installExtension({ source: sourceExtDir, type: 'local' }, true),
).rejects.toThrow('Installation cancelled by user.');
expect(mockQuestion).toHaveBeenCalledWith(
@@ -662,6 +662,24 @@ describe('extension tests', () => {
expect.any(Function),
);
});
it('should ignore consent flow if not required', async () => {
const sourceExtDir = createExtension({
extensionsDir: tempHomeDir,
name: 'my-local-extension',
version: '1.0.0',
mcpServers: {
'test-server': {
command: 'node',
args: ['server.js'],
},
},
});
await expect(
installExtension({ source: sourceExtDir, type: 'local' }, false),
).resolves.toBe('my-local-extension');
});
});
describe('uninstallExtension', () => {