Skip to content

Commit f53cc90

Browse files
author
Natallia Harshunova
committed
Fix pr comments
1 parent 5b52f35 commit f53cc90

4 files changed

Lines changed: 19 additions & 41 deletions

File tree

src/tools/extensions.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
/**
22
* @license
3-
* Copyright 2025 Google LLC
3+
* Copyright 2026 Google LLC
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
import {logger} from '../logger.js';
87
import {zod} from '../third_party/index.js';
98

109
import {ToolCategory} from './categories.js';
@@ -23,13 +22,8 @@ export const installExtension = defineTool({
2322
.describe('Absolute path to the unpacked extension folder.'),
2423
},
2524
handler: async (request, response, context) => {
26-
const {path} = request.params;
27-
try {
28-
const id = await context.installExtension(path);
29-
response.appendResponseLine(`Extension installed. Id: ${id}`);
30-
} catch (error) {
31-
logger('Extension installation error: ', error);
32-
throw error;
33-
}
25+
const { path } = request.params;
26+
const id = await context.installExtension(path);
27+
response.appendResponseLine(`Extension installed. Id: ${id}`);
3428
},
3529
});

tests/tools/extensions.test.ts

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,19 @@
55
*/
66

77
import assert from 'node:assert';
8-
import fs from 'node:fs';
9-
import os from 'node:os';
108
import path from 'node:path';
11-
import {describe, it, after} from 'node:test';
9+
import { describe, it } from 'node:test';
1210

13-
import {installExtension} from '../../src/tools/extensions.js';
14-
import {withMcpContext} from '../utils.js';
11+
import { installExtension } from '../../src/tools/extensions.js';
12+
import { withMcpContext } from '../utils.js';
1513

16-
describe('extension', () => {
17-
let tmpDir: string;
14+
const EXTENSION_PATH = path.join(import.meta.dirname, '../../../tests/tools/fixtures/extension');
1815

16+
describe('extension', () => {
1917
it('installs an extension and verifies it is listed in chrome://extensions', async () => {
20-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'extension-test-'));
21-
fs.writeFileSync(
22-
path.join(tmpDir, 'manifest.json'),
23-
JSON.stringify({
24-
manifest_version: 3,
25-
name: 'Test Extension',
26-
version: '1.0',
27-
action: {
28-
default_popup: 'popup.html',
29-
},
30-
}),
31-
);
32-
fs.writeFileSync(
33-
path.join(tmpDir, 'popup.html'),
34-
'<!DOCTYPE html><html><body><h1>Test Popup</h1></body></html>',
35-
);
36-
3718
await withMcpContext(async (response, context) => {
3819
await installExtension.handler(
39-
{params: {path: tmpDir}},
20+
{ params: { path: EXTENSION_PATH } },
4021
response,
4122
context,
4223
);
@@ -59,10 +40,4 @@ describe('extension', () => {
5940
);
6041
});
6142
});
62-
63-
after(() => {
64-
if (tmpDir) {
65-
fs.rmSync(tmpDir, {recursive: true, force: true});
66-
}
67-
});
6843
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"manifest_version": 3,
3+
"name": "Test Extension",
4+
"version": "1.0",
5+
"action": {
6+
"default_popup": "popup.html"
7+
}
8+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!DOCTYPE html><html><body><h1>Test Popup</h1></body></html>

0 commit comments

Comments
 (0)