Skip to content

Commit 3e0d5fa

Browse files
author
Natallia Harshunova
committed
Move extension test to fixtures
1 parent f53cc90 commit 3e0d5fa

5 files changed

Lines changed: 22 additions & 14 deletions

File tree

docs/tool-reference.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,12 @@ so returned values have to JSON-serializable.
283283
**Parameters:**
284284

285285
- **function** (string) **(required)**: A JavaScript function declaration to be executed by the tool in the currently selected page.
286-
Example without arguments: `() => {
286+
Example without arguments: `() => {
287287
return document.title
288288
}` or `async () => {
289289
return await fetch("example.com")
290290
}`.
291-
Example with arguments: `(el) => {
291+
Example with arguments: `(el) => {
292292
return el.innerText;
293293
}`
294294

scripts/generate-docs.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,15 @@ async function generateToolDocumentation(): Promise<void> {
278278
// Convert ToolDefinitions to ToolWithAnnotations
279279
const toolsWithAnnotations: ToolWithAnnotations[] = tools
280280
.filter(tool => {
281-
if (!tool.annotations.conditions) {
282-
return true;
283-
}
284-
285281
// Filter out extension tools
286282
if (tool.name === 'install_extension') {
287283
return false;
288284
}
289-
285+
286+
if (!tool.annotations.conditions) {
287+
return true;
288+
}
289+
290290
// Only include unconditional tools.
291291
return tool.annotations.conditions.length === 0;
292292
})

src/tools/extensions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const installExtension = defineTool({
2222
.describe('Absolute path to the unpacked extension folder.'),
2323
},
2424
handler: async (request, response, context) => {
25-
const { path } = request.params;
25+
const {path} = request.params;
2626
const id = await context.installExtension(path);
2727
response.appendResponseLine(`Extension installed. Id: ${id}`);
2828
},

tests/tools/extensions.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@
66

77
import assert from 'node:assert';
88
import path from 'node:path';
9-
import { describe, it } from 'node:test';
9+
import {describe, it} from 'node:test';
1010

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

14-
const EXTENSION_PATH = path.join(import.meta.dirname, '../../../tests/tools/fixtures/extension');
14+
const EXTENSION_PATH = path.join(
15+
import.meta.dirname,
16+
'../../../tests/tools/fixtures/extension',
17+
);
1518

1619
describe('extension', () => {
1720
it('installs an extension and verifies it is listed in chrome://extensions', async () => {
1821
await withMcpContext(async (response, context) => {
1922
await installExtension.handler(
20-
{ params: { path: EXTENSION_PATH } },
23+
{params: {path: EXTENSION_PATH}},
2124
response,
2225
context,
2326
);
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
<!DOCTYPE html><html><body><h1>Test Popup</h1></body></html>
1+
<!doctype html>
2+
<html
3+
><body
4+
><h1>Test Popup</h1></body
5+
></html
6+
>

0 commit comments

Comments
 (0)