Skip to content

Commit

Permalink
fix: get rid of delay for isScrollButtonPresent
Browse files Browse the repository at this point in the history
Signed-off-by: drptbl <[email protected]>
  • Loading branch information
drptbl committed Jun 20, 2024
1 parent c45d1b2 commit bae96af
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 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,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)

// 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
)
const scrollButton = notificationPage.locator(Selectors.SignaturePage.structuredMessage.scrollDownButton)
const isScrollButtonPresent = (await scrollButton.count()) > 0

let isScrollButtonVisible = false
if (isScrollButtonPresent) {
await scrollButton.waitFor({ state: 'visible' })
isScrollButtonVisible = true
}

return {
notificationPage,
Expand Down

0 comments on commit bae96af

Please sign in to comment.