fix: browser_tabs select action with index 0 failing due to falsy check (#964)
This commit is contained in:
@@ -49,7 +49,7 @@ const browserTabs = defineTool({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case 'select': {
|
case 'select': {
|
||||||
if (!params.index)
|
if (params.index === undefined)
|
||||||
throw new Error('Tab index is required');
|
throw new Error('Tab index is required');
|
||||||
await context.selectTab(params.index);
|
await context.selectTab(params.index);
|
||||||
response.setIncludeSnapshot();
|
response.setIncludeSnapshot();
|
||||||
|
|||||||
@@ -103,6 +103,19 @@ test('select tab', async ({ client }) => {
|
|||||||
- generic [active] [ref=e1]: Body one
|
- 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 }) => {
|
test('close tab', async ({ client }) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user