Skip to content

Commit

Permalink
Merge branch 'new-dawn' into feat/add-rename-account-test
Browse files Browse the repository at this point in the history
  • Loading branch information
Seroxdesign authored Jun 13, 2024
2 parents 01249ec + 5e42b68 commit bf512da
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions wallets/metamask/src/pages/NotificationPage/page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Page } from '@playwright/test'
import { getNotificationPageAndWaitForLoad } from '../../utils/getNotificationPageAndWaitForLoad'
import { waitFor } from '../../utils/waitFor'
import {
type GasSetting,
approvePermission,
Expand Down Expand Up @@ -31,17 +30,22 @@ 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)

// 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
)
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)])

return {
notificationPage,
Expand Down

0 comments on commit bf512da

Please sign in to comment.