From 894106e9bf024bc2346786f1e5a9aff97492a67e Mon Sep 17 00:00:00 2001 From: drptbl Date: Thu, 20 Jun 2024 10:33:37 +0100 Subject: [PATCH] =?UTF-8?q?Revert=20"=F0=9F=90=9B=20fix:=20Add=20confirm?= =?UTF-8?q?=20signature=20race=20condition=20handler=20(#1144)"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 5e42b685399797160d3baacdc90afb67a46bfcfd. --- .../src/pages/NotificationPage/page.ts | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/wallets/metamask/src/pages/NotificationPage/page.ts b/wallets/metamask/src/pages/NotificationPage/page.ts index 7ca06f7d2..ebed5cced 100644 --- a/wallets/metamask/src/pages/NotificationPage/page.ts +++ b/wallets/metamask/src/pages/NotificationPage/page.ts @@ -1,5 +1,6 @@ import type { Page } from '@playwright/test' import { getNotificationPageAndWaitForLoad } from '../../utils/getNotificationPageAndWaitForLoad' +import { waitFor } from '../../utils/waitFor' import { type GasSetting, approvePermission, @@ -30,22 +31,17 @@ export class NotificationPage { await connectToDapp(notificationPage, accounts) } + // TODO: Revisit this logic in the future to see if we can increase the performance by utilizing `Promise.race`. private async beforeMessageSignature(extensionId: string) { const notificationPage = await getNotificationPageAndWaitForLoad(this.page.context(), extensionId) - const scrollDownButton = notificationPage.locator(Selectors.SignaturePage.structuredMessage.scrollDownButton) - let isScrollButtonVisible = false - - const scrollButtonPromise = scrollDownButton - .waitFor({ state: 'visible' }) - .then(async () => { - isScrollButtonVisible = true - await scrollDownButton.click() - return true - }) - .catch(() => false) - - await Promise.race([scrollButtonPromise, notificationPage.waitForLoadState('load').then(() => false)]) + // TODO: Make this configurable. + // Most of the time, this function will be used to sign structured messages, so we check for the scroll button first. + const isScrollButtonVisible = await waitFor( + () => notificationPage.locator(Selectors.SignaturePage.structuredMessage.scrollDownButton).isVisible(), + 1_500, + false + ) return { notificationPage,