| 264 | |
| 265 | describe('Dialogs', () => { |
| 266 | async function createNewPageAndTriggerDialog(client: Client) { |
| 267 | // Navigate to a page with a button that triggers a dialog on click |
| 268 | await client.callTool({ |
| 269 | name: 'new_page', |
| 270 | arguments: { |
| 271 | url: `data:text/html,<button id="test" onclick="alert('test dialog')">Click me</button>`, |
| 272 | }, |
| 273 | }); |
| 274 | |
| 275 | const snapshotResult = await client.callTool({ |
| 276 | name: 'take_snapshot', |
| 277 | arguments: {}, |
| 278 | }); |
| 279 | |
| 280 | const snapshotText = (snapshotResult.content as TextContent[])[0].text; |
| 281 | const match = snapshotText.match(/uid=(\d+_\d+)\s+button "Click me"/); |
| 282 | const uid = match ? match[1] : '1_1'; |
| 283 | |
| 284 | // Trigger the dialog |
| 285 | const result = await client.callTool({ |
| 286 | name: 'click', |
| 287 | arguments: { |
| 288 | uid, |
| 289 | }, |
| 290 | }); |
| 291 | |
| 292 | return result; |
| 293 | } |
| 294 | |
| 295 | it('returns blocked message when dialog is opened during tool execution', async t => { |
| 296 | await withClient(async client => { |