Chrome DevTools for coding agents
test: retry transient navigation and dialog setup timeouts (#2890)
Alex Rudenkoed82e418f6a7
diff --git a/tests/index.test.ts b/tests/index.test.tsindex 22e827b1..32d5184e 100644--- a/tests/index.test.ts+++ b/tests/index.test.ts@@ -436,14 +436,28 @@ describe('e2e', () => {});describe('Dialogs', () => {+ function getFirstText(+ result: Awaited<ReturnType<Client['callTool']>>,+ ): string {+ const first = Array.isArray(result.content)+ ? result.content[0]+ : undefined;+ return first && 'text' in first && typeof first.text === 'string'+ ? first.text+ : '';+ }+async function createNewPageAndTriggerDialog(client: Client) {// Navigate to a page with a button that triggers a dialog on click- await client.callTool({+ const newPageResult = await client.callTool({name: 'new_page',arguments: {url: `data:text/html,<button id="test" onclick="alert('test dialog')">Click me</button>`,},});+ if (newPageResult.isError) {+ throw new Error(getFirstText(newPageResult));+ }const snapshotResult = await client.callTool({name: 'take_snapshot',@@ -451,8 +465,11 @@ describe('e2e', () => {pageId: 2,},});+ if (snapshotResult.isError) {+ throw new Error(getFirstText(snapshotResult));+ }- const snapshotText = (snapshotResult.content as TextContent[])[0].text;+ const snapshotText = getFirstText(snapshotResult);const match = snapshotText.match(/uid=(\d+_\d+)\s+button "Click me"/);const uid = match ? match[1] : '1_1';@@ -464,6 +481,9 @@ describe('e2e', () => {uid,},});+ if (result.isError) {+ throw new Error(getFirstText(result));+ }return result;}diff --git a/tests/utils.ts b/tests/utils.tsindex 60d8b336..09be5388 100644--- a/tests/utils.ts+++ b/tests/utils.ts@@ -148,6 +148,8 @@ export async function withBrowser(const isRetryable =error instanceof Error &&(error.message === 'withBrowser timeout exceeded' ||+ error.message.includes('Navigation timeout') ||+ error.message.includes("Couldn't fetch install info") ||error.message.includes('closed') ||error.message.includes('crash') ||error.message.includes('hang'));