@@ -12,7 +12,7 @@ import {listWebMcpTools} from '../../src/tools/webmcp.js';
1212import { getTextContent , html , withMcpContext } from '../utils.js' ;
1313
1414describe ( 'webmcp' , ( ) => {
15- it ( 'list webmcp tools' , async ( ) => {
15+ it ( 'list webmcp tools successfully ' , async ( ) => {
1616 await withMcpContext (
1717 async ( response , context ) => {
1818 const page = context . getSelectedMcpPage ( ) . pptrPage ;
@@ -36,30 +36,53 @@ describe('webmcp', () => {
3636 / 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 " / ,
3737 ) ;
3838 } ,
39- { } ,
39+ { args : [ '--enable-features=WebMCPTesting,DevToolsWebMCPSupport' ] } ,
40+ { experimentalWebmcp : true } as ParsedArguments ,
41+ ) ;
42+ } ) ;
43+
44+ it ( 'list no webmcp tools if there are none' , async ( ) => {
45+ await withMcpContext (
46+ async ( response , context ) => {
47+ const page = context . getSelectedMcpPage ( ) . pptrPage ;
48+
49+ await listWebMcpTools . handler (
50+ { params : { } , page : context . getSelectedMcpPage ( ) } ,
51+ response ,
52+ context ,
53+ ) ;
54+
55+ const formattedResponse = await response . handle ( 'test' , context ) ;
56+ const textContent = getTextContent ( formattedResponse . content [ 0 ] ) ;
57+ assert . match ( textContent , / N o W e b M C P t o o l s a v a i l a b l e / ) ;
58+ } ,
59+ { args : [ '--enable-features=WebMCPTesting,DevToolsWebMCPSupport' ] } ,
4060 { experimentalWebmcp : true } as ParsedArguments ,
4161 ) ;
4262 } ) ;
4363
4464 it ( 'does not list webmcp tools if not enabled' , async ( ) => {
45- await withMcpContext ( async ( response , context ) => {
46- const page = context . getSelectedMcpPage ( ) . pptrPage ;
47- await page . setContent (
48- html `< form
49- toolname ="test_tool "
50- tooldescription ="A test tool "
51- > </ form > ` ,
52- ) ;
65+ await withMcpContext (
66+ async ( response , context ) => {
67+ const page = context . getSelectedMcpPage ( ) . pptrPage ;
68+ await page . setContent (
69+ html `< form
70+ toolname ="test_tool "
71+ tooldescription ="A test tool "
72+ > </ form > ` ,
73+ ) ;
5374
54- await listWebMcpTools . handler (
55- { params : { } , page : context . getSelectedMcpPage ( ) } ,
56- response ,
57- context ,
58- ) ;
75+ await listWebMcpTools . handler (
76+ { params : { } , page : context . getSelectedMcpPage ( ) } ,
77+ response ,
78+ context ,
79+ ) ;
5980
60- const formattedResponse = await response . handle ( 'test' , context ) ;
61- const textContent = getTextContent ( formattedResponse . content [ 0 ] ) ;
62- assert . ok ( ! textContent . includes ( 'name="test_tool"' ) ) ;
63- } , { } ) ;
81+ const formattedResponse = await response . handle ( 'test' , context ) ;
82+ const textContent = getTextContent ( formattedResponse . content [ 0 ] ) ;
83+ assert . ok ( ! textContent . includes ( 'name="test_tool"' ) ) ;
84+ } ,
85+ { args : [ '--enable-features=WebMCPTesting,DevToolsWebMCPSupport' ] } ,
86+ ) ;
6487 } ) ;
6588} ) ;
0 commit comments