@@ -9,26 +9,19 @@ import {describe, it} from 'node:test';
99
1010import type { ParsedArguments } from '../../src/bin/chrome-devtools-mcp-cli-options.js' ;
1111import { listWebMcpTools } from '../../src/tools/webmcp.js' ;
12- import { getTextContent , withMcpContext } from '../utils.js' ;
12+ import { getTextContent , html , withMcpContext } from '../utils.js' ;
1313
1414describe ( 'webmcp' , ( ) => {
1515 it ( 'list webmcp tools' , async ( ) => {
1616 await withMcpContext (
1717 async ( response , context ) => {
1818 const page = context . getSelectedMcpPage ( ) . pptrPage ;
19- // @ts -expect-error internal API
20- const client = page . _client ( ) ;
21-
22- client . emit ( 'WebMCP.toolsAdded' , {
23- tools : [
24- {
25- name : 'test_tool' ,
26- description : 'A test tool' ,
27- inputSchema : { type : 'object' } ,
28- frameId : '1' ,
29- } ,
30- ] ,
31- } ) ;
19+ await page . setContent (
20+ html `< form
21+ toolname ="test_tool "
22+ tooldescription ="A test tool "
23+ > </ form > ` ,
24+ ) ;
3225
3326 await listWebMcpTools . handler (
3427 { params : { } , page : context . getSelectedMcpPage ( ) } ,
@@ -38,7 +31,10 @@ describe('webmcp', () => {
3831
3932 const formattedResponse = await response . handle ( 'test' , context ) ;
4033 const textContent = getTextContent ( formattedResponse . content [ 0 ] ) ;
41- assert . match ( textContent , / n a m e = " t e s t _ t o o l " , d e s c r i p t i o n = " A t e s t t o o l " / ) ;
34+ assert . match (
35+ textContent ,
36+ / n a m e = " t e s t _ t o o l " , d e s c r i p t i o n = " A t e s t t o o l " / ,
37+ ) ;
4238 } ,
4339 { } ,
4440 { experimentalWebmcp : true } as ParsedArguments ,
@@ -48,19 +44,12 @@ describe('webmcp', () => {
4844 it ( 'does not list webmcp tools if not enabled' , async ( ) => {
4945 await withMcpContext ( async ( response , context ) => {
5046 const page = context . getSelectedMcpPage ( ) . pptrPage ;
51- // @ts -expect-error internal API
52- const client = page . _client ( ) ;
53-
54- client . emit ( 'WebMCP.toolsAdded' , {
55- tools : [
56- {
57- name : 'test_tool' ,
58- description : 'A test tool' ,
59- inputSchema : { type : 'object' } ,
60- frameId : '1' ,
61- } ,
62- ] ,
63- } ) ;
47+ await page . setContent (
48+ html `< form
49+ toolname ="test_tool "
50+ tooldescription ="A test tool "
51+ > </ form > ` ,
52+ ) ;
6453
6554 await listWebMcpTools . handler (
6655 { params : { } , page : context . getSelectedMcpPage ( ) } ,
0 commit comments