(
t: it.TestContext,
parseArguments: ParsedArguments,
handlerAction: (
response: McpResponse,
context: McpContext,
) => Promise<void>,
toolName: string,
)
| 1461 | |
| 1462 | describe('webmcp', () => { |
| 1463 | async function testIncludesWebmcpTools( |
| 1464 | t: it.TestContext, |
| 1465 | parseArguments: ParsedArguments, |
| 1466 | handlerAction: ( |
| 1467 | response: McpResponse, |
| 1468 | context: McpContext, |
| 1469 | ) => Promise<void>, |
| 1470 | toolName: string, |
| 1471 | ) { |
| 1472 | await withMcpContext( |
| 1473 | async (response, context) => { |
| 1474 | response.setListWebMcpTools(); |
| 1475 | |
| 1476 | await handlerAction(response, context); |
| 1477 | |
| 1478 | const page = context.getSelectedMcpPage().pptrPage; |
| 1479 | const {resolve, promise} = Promise.withResolvers(); |
| 1480 | page.webmcp.once('toolsadded', () => { |
| 1481 | resolve(undefined); |
| 1482 | }); |
| 1483 | await page.setContent( |
| 1484 | html`<form |
| 1485 | toolname="test_tool" |
| 1486 | tooldescription="A test tool" |
| 1487 | ></form>`, |
| 1488 | ); |
| 1489 | await promise; |
| 1490 | |
| 1491 | const {content, structuredContent} = await response.handle( |
| 1492 | toolName, |
| 1493 | context, |
| 1494 | ); |
| 1495 | assert.ok(getTextContent(content[0])); |
| 1496 | t.assert.snapshot(getTextContent(content[0])); |
| 1497 | t.assert.snapshot( |
| 1498 | JSON.stringify( |
| 1499 | stabilizeStructuredContent(structuredContent), |
| 1500 | null, |
| 1501 | 2, |
| 1502 | ), |
| 1503 | ); |
| 1504 | }, |
| 1505 | {args: ['--enable-features=WebMCP,DevToolsWebMCPSupport']}, |
| 1506 | parseArguments, |
| 1507 | ); |
| 1508 | } |
| 1509 | |
| 1510 | it('includes webmcp tools in list_pages response', async t => { |
| 1511 | await testIncludesWebmcpTools( |
no test coverage detected