Skip to content

Commit

Permalink
✨ feat(metamask): Add getNotificationPageAndWaitForLoad util (#992)
Browse files Browse the repository at this point in the history
  • Loading branch information
duckception authored Nov 11, 2023
1 parent f6005c5 commit 1efba09
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { BrowserContext } from '@playwright/test'
import { getNotificationPage } from '../../../utils/getNotificationPage'
import { getNotificationPageAndWaitForLoad } from '../../../utils/getNotificationPageAndWaitForLoad'

export async function connectToDapp(context: BrowserContext, extensionId: string) {
const notificationPage = await getNotificationPage(context, extensionId)
const notificationPage = await getNotificationPageAndWaitForLoad(context, extensionId)

// Click `Next`.
await notificationPage.getByRole('button').nth(1).click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import type { BrowserContext } from '@playwright/test'
import { getNotificationPage } from '../../../utils/getNotificationPage'
import { getNotificationPageAndWaitForLoad } from '../../../utils/getNotificationPageAndWaitForLoad'
import Selectors from '../selectors'

const signMessage = async (context: BrowserContext, extensionId: string) => {
const notificationPage = await getNotificationPage(context, extensionId)
const notificationPage = await getNotificationPageAndWaitForLoad(context, extensionId)

await notificationPage.locator(Selectors.SignaturePage.signButton).click()
}

const rejectMessage = async (context: BrowserContext, extensionId: string) => {
const notificationPage = await getNotificationPage(context, extensionId)
const notificationPage = await getNotificationPageAndWaitForLoad(context, extensionId)

await notificationPage.locator(Selectors.SignaturePage.rejectButton).click()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { BrowserContext, Page } from '@playwright/test'

export async function getNotificationPage(context: BrowserContext, extensionId: string) {
export async function getNotificationPageAndWaitForLoad(context: BrowserContext, extensionId: string) {
const notificationPageUrl = `chrome-extension://${extensionId}/notification.html`

const isNotificationPage = (page: Page) => page.url().includes(notificationPageUrl)
Expand All @@ -18,5 +18,7 @@ export async function getNotificationPage(context: BrowserContext, extensionId:
height: 592
})

await notificationPage.waitForLoadState('load')

return notificationPage
}

0 comments on commit 1efba09

Please sign in to comment.