Skip to content

Commit 71fc5d8

Browse files
Dismiss unexpected dialogs that block a tutorial step click
When a click is intercepted by a dialog that does not contain the element the tutorial points to (e.g. an error alert opened above the object editor on CI), close it like a user would and log its content. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 069921d commit 71fc5d8

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

‎e2e/lib/tutorialPlayer.js‎

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,39 @@ const playTutorial = async ({ page, context, tutorial, log = () => {} }) => {
547547
});
548548
} catch (error) {
549549
actionError = error;
550-
log(`Action failed: ${error.message}`);
550+
log(`Action failed: ${error.message.split('\n')[0]}`);
551+
if (error.message.includes('intercepts pointer events')) {
552+
// An unexpected dialog (e.g. an error alert) opened above the current
553+
// one and blocks the click: dismiss any dialog that does not contain
554+
// the element the tutorial points to, like a user would.
555+
const dismissedDialogs = await page
556+
.evaluate((selector) => {
557+
const target = selector ? document.querySelector(selector) : null;
558+
const dismissed = [];
559+
for (const dialog of document.querySelectorAll('[role="dialog"]')) {
560+
if (target && dialog.contains(target)) continue;
561+
const closeButton = [...dialog.querySelectorAll('button')].find(
562+
(button) =>
563+
/^(close|ok|cancel|got it)$/i.test(
564+
(button.textContent || '').trim()
565+
)
566+
);
567+
if (closeButton) {
568+
dismissed.push((dialog.textContent || '').trim().slice(0, 120));
569+
closeButton.click();
570+
}
571+
}
572+
return dismissed;
573+
}, state.elementToHighlightId || null)
574+
.catch(() => []);
575+
if (dismissedDialogs.length) {
576+
log(
577+
`Dismissed unexpected dialog(s): ${JSON.stringify(
578+
dismissedDialogs
579+
)}`
580+
);
581+
}
582+
}
551583
}
552584

553585
const advanced = await waitForStepChange(page, state.stepIndex);

0 commit comments

Comments
 (0)