-
-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat(metamask): Add support for opening transaction details
- Loading branch information
1 parent
96a413e
commit 877acc9
Showing
8 changed files
with
99 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
wallets/metamask/src/pages/HomePage/actions/transactionDetails.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { Page } from '@playwright/test' | ||
import { waitFor } from '../../../utils/waitFor' | ||
import Selectors from '../selectors' | ||
|
||
const openTransactionDetails = async (page: Page, txIndex: number) => { | ||
let visibleTxs = await page.locator(Selectors.activityTab.completedTransactions).count() | ||
|
||
while (txIndex >= visibleTxs) { | ||
try { | ||
await page.locator(Selectors.activityTab.viewMoreButton).click({ | ||
timeout: 3_000 // TODO: Extract timeout. | ||
}) | ||
} catch (e) { | ||
console.log(e) | ||
throw new Error(`Transaction with index ${txIndex} not found. There are only ${visibleTxs} transactions visible.`) | ||
} | ||
|
||
visibleTxs = await page.locator(Selectors.activityTab.completedTransactions).count() | ||
} | ||
|
||
await page.locator(Selectors.activityTab.completedTransactions).nth(txIndex).click() | ||
|
||
// TODO: Extract timeout. | ||
await waitFor(() => page.locator(Selectors.transactionPopover.closeButton).isVisible(), 3_000) | ||
} | ||
|
||
const closeTransactionDetails = async (page: Page) => { | ||
await page.locator(Selectors.transactionPopover.closeButton).click() | ||
} | ||
|
||
export const transactionDetails = { | ||
open: openTransactionDetails, | ||
close: closeTransactionDetails | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
wallets/metamask/test/e2e/metamask/openTransactionDetails.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { waitFor } from '../../../src/utils/waitFor' | ||
import { testWithMetaMask } from '../testWithMetaMask' | ||
|
||
const test = testWithMetaMask | ||
|
||
const { expect } = test | ||
|
||
test('should open transaction details', async ({ page, metamask, metamaskPage }) => { | ||
await page.locator('#addEthereumChain').click() | ||
|
||
const isPopperVisible = await waitFor(() => metamaskPage.locator('.tippy-popper button').isVisible(), 1000, false) | ||
if (isPopperVisible) { | ||
await metamaskPage.locator('.tippy-popper button').click() | ||
} | ||
|
||
await metamask.approveNewNetwork() | ||
await metamask.approveSwitchNetwork() | ||
|
||
await page.locator('#sendEIP1559Button').click() | ||
await metamask.experimental.confirmTransactionAndWaitForMining() | ||
|
||
await metamask.experimental.openTransactionDetails(0) | ||
|
||
await expect(metamaskPage.locator(metamask.homePage.selectors.transactionPopover.closeButton)).toBeVisible() | ||
}) |