Skip to content

Commit 2d464fc

Browse files
committed
add test
1 parent 452490d commit 2d464fc

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

tests/index.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,38 @@ describe('e2e', () => {
245245
},
246246
);
247247
});
248+
249+
it('returns blocked message when dialog is opened during tool execution', async () => {
250+
await withClient(async client => {
251+
// Navigate to a page with a button that triggers a dialog on click
252+
await client.callTool({
253+
name: 'new_page',
254+
arguments: {
255+
url: `data:text/html,<button id="test" onclick="alert('test dialog')">Click me</button>`,
256+
},
257+
});
258+
259+
const snapshotResult = await client.callTool({
260+
name: 'take_snapshot',
261+
arguments: {},
262+
});
263+
264+
const snapshotText = (snapshotResult.content as TextContent[])[0].text;
265+
const match = snapshotText.match(/uid=(\d+_\d+)\s+button "Click me"/);
266+
const uid = match ? match[1] : '1_1';
267+
268+
// Trigger the dialog
269+
const result = await client.callTool({
270+
name: 'click',
271+
arguments: {
272+
uid
273+
},
274+
});
275+
276+
const content = result.content as TextContent[];
277+
assert.match(content[0].text, /\[Blocked\] Action triggered a dialog\./);
278+
});
279+
});
248280
});
249281

250282
async function getToolsWithFilteredCategories(

0 commit comments

Comments
 (0)