Skip to content

Commit

Permalink
♻️ refactor(metamask): Move and update getNotificationPage (#986)
Browse files Browse the repository at this point in the history
  • Loading branch information
duckception authored Nov 11, 2023
1 parent 28d1339 commit 6ad9a81
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import type { BrowserContext } from '@playwright/test'
import { getNotificationPage } from '../utils'
import { getNotificationPage } from '../../../utils/getNotificationPage'

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

if (!process.env.HEADLESS) {
// Set pop-up window viewport size to resemble the actual MetaMask pop-up window.
await notificationPage.setViewportSize({
width: 360,
height: 592
})
}

// Click `Next`.
await notificationPage.getByRole('button').nth(1).click()

Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion wallets/metamask/src/pages/NotificationPage/utils/index.ts

This file was deleted.

22 changes: 22 additions & 0 deletions wallets/metamask/src/utils/getNotificationPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { BrowserContext, Page } from '@playwright/test'

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

const isNotificationPage = (page: Page) => page.url().includes(notificationPageUrl)

// Check if notification page is already open.
let notificationPage = context.pages().find(isNotificationPage)

if (!notificationPage) {
notificationPage = await context.waitForEvent('page', { predicate: isNotificationPage })
}

// Set pop-up window viewport size to resemble the actual MetaMask pop-up window.
await notificationPage.setViewportSize({
width: 360,
height: 592
})

return notificationPage
}

0 comments on commit 6ad9a81

Please sign in to comment.