Skip to content

Commit 98011ce

Browse files
Update tests
1 parent 2971fec commit 98011ce

2 files changed

Lines changed: 45 additions & 20 deletions

File tree

tests/tools/webmcp.test.ts

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {listWebMcpTools} from '../../src/tools/webmcp.js';
1212
import {getTextContent, html, withMcpContext} from '../utils.js';
1313

1414
describe('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
/name="test_tool", description="A test tool"/,
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, /No WebMCP tools available/);
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
});

tests/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export async function withBrowser(
6464
debug?: boolean;
6565
autoOpenDevTools?: boolean;
6666
executablePath?: string;
67+
args?: string[];
6768
} = {},
6869
) {
6970
const launchOptions: LaunchOptions = {
@@ -74,7 +75,7 @@ export async function withBrowser(
7475
devtools: options.autoOpenDevTools ?? false,
7576
pipe: true,
7677
handleDevToolsAsPage: true,
77-
args: ['--screen-info={3840x2160}'],
78+
args: [...options.args || [], '--screen-info={3840x2160}'],
7879
enableExtensions: true,
7980
};
8081
const key = JSON.stringify(launchOptions);
@@ -104,6 +105,7 @@ export async function withMcpContext(
104105
autoOpenDevTools?: boolean;
105106
performanceCrux?: boolean;
106107
executablePath?: string;
108+
args?: string[];
107109
} = {},
108110
args: ParsedArguments = {} as ParsedArguments,
109111
) {

0 commit comments

Comments
 (0)