Skip to content

Commit

Permalink
add error page handling
Browse files Browse the repository at this point in the history
  • Loading branch information
r3kt-eth committed May 4, 2023
1 parent 8011acc commit 761ae0f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
20 changes: 17 additions & 3 deletions commands/playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,28 @@ module.exports = {
async fixCriticalError(page = metamaskWindow) {
for (let times = 0; times < 5; times++) {
if ((await page.locator(pageElements.criticalError).count()) > 0) {
if (times < 3) {
if (times <= 3) {
await page.reload();
} else {
await module.exports.waitUntilMetamaskWindowIsStable();
} else if (times === 4) {
await module.exports.waitAndClick(
pageElements.criticalErrorRestartButton,
);
await module.exports.waitUntilMetamaskWindowIsStable();
} else {
throw new Error(
'[fixCriticalError] Max amount of retries to fix critical metamask error has been reached.',
);
}
} else if ((await page.locator(pageElements.errorPage).count()) > 0) {
if (times <= 4) {
await page.reload();
await module.exports.waitUntilMetamaskWindowIsStable();
} else {
throw new Error(
'[fixCriticalError] Max amount of retries to fix critical metamask error has been reached.',
);
}
await module.exports.waitUntilMetamaskWindowIsStable();
} else {
break;
}
Expand Down
3 changes: 3 additions & 0 deletions pages/metamask/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const loadingOverlayErrorButtonsRetryButton =
const criticalError = '.critical-error';
const criticalErrorRestartButton = '#critical-error-button';

const errorPage = '.error-page';

module.exports.pageElements = {
loadingLogo,
loadingSpinner,
Expand All @@ -18,4 +20,5 @@ module.exports.pageElements = {
loadingOverlayErrorButtonsRetryButton,
criticalError,
criticalErrorRestartButton,
errorPage,
};

0 comments on commit 761ae0f

Please sign in to comment.