Skip to content

Chrome DevTools for coding agents

chore(tests): migrate list_webmcp_tools tests to use mocks (#3037)

Prakhar Pathaka65f09e9da07
diff --git a/tests/tools/webmcp.test.ts b/tests/tools/webmcp.test.ts
index 0040bf37..c5df6a29 100644
--- a/tests/tools/webmcp.test.ts
+++ b/tests/tools/webmcp.test.ts
@@ -18,32 +18,36 @@ import {html, withMcpContext} from '../utils.js';
describe('webmcp', () => {
describe('list_webmcp_tools', () => {
it('list webmcp tools in navigate_page response', async () => {
- await withMcpContext(async (response, context, args) => {
- await navigatePage(args).handler(
- {
- params: {url: 'data:text/html,<html></html>'},
- page: context.getSelectedMcpPage(),
- },
- response,
- context,
- );
- assert.ok(response.listWebMcpTools);
- });
+ const {page, context, response, args} = createHandlerMocks();
+ page.pptrPage.goto.resolves(null);
+
+ await navigatePage(args).handler(
+ {
+ params: {url: 'data:text/html,<html></html>'},
+ page,
+ },
+ response,
+ context,
+ );
+
+ sinon.assert.calledOnceWithExactly(response.setListWebMcpTools);
});
it('list webmcp tools in list_pages response', async () => {
- await withMcpContext(async (response, context, args) => {
- await listPages(args).handler({params: {}}, response, context);
- assert.ok(response.listWebMcpTools);
- });
+ const {context, response, args} = createHandlerMocks();
+
+ await listPages(args).handler({params: {}}, response, context);
+
+ sinon.assert.calledOnceWithExactly(response.setListWebMcpTools);
});
it('list webmcp tools in select_page response', async () => {
- await withMcpContext(async (response, context, args) => {
- const pageId = context.getSelectedMcpPage().id ?? 1;
- await selectPage(args).handler({params: {pageId}}, response, context);
- assert.ok(response.listWebMcpTools);
- });
+ const {context, response, args, page} = createHandlerMocks();
+ context.getPageById.returns(page);
+
+ await selectPage(args).handler({params: {pageId: 1}}, response, context);
+
+ sinon.assert.calledOnceWithExactly(response.setListWebMcpTools);
});
});