fix: browser_tabs select action with index 0 failing due to falsy check (#964)

This commit is contained in:
Sangjin Park
2025-08-29 07:36:31 +09:00
committed by GitHub
parent fc04de2be5
commit 7fb8b0dc3a
2 changed files with 14 additions and 1 deletions

View File

@@ -49,7 +49,7 @@ const browserTabs = defineTool({
return;
}
case 'select': {
if (!params.index)
if (params.index === undefined)
throw new Error('Tab index is required');
await context.selectTab(params.index);
response.setIncludeSnapshot();

View File

@@ -103,6 +103,19 @@ test('select tab', async ({ client }) => {
- generic [active] [ref=e1]: Body one
\`\`\``),
});
expect(await client.callTool({
name: 'browser_tabs',
arguments: {
action: 'select',
index: 0,
},
})).toHaveResponse({
tabs: `- 0: (current) [] (about:blank)
- 1: [Tab one] (data:text/html,<title>Tab one</title><body>Body one</body>)
- 2: [Tab two] (data:text/html,<title>Tab two</title><body>Body two</body>)`,
pageState: expect.stringContaining(`- Page URL: about:blank`),
});
});
test('close tab', async ({ client }) => {