-
-
Notifications
You must be signed in to change notification settings - Fork 196
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
8cb0df5
commit 027966f
Showing
10 changed files
with
98 additions
and
8 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
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
29 changes: 29 additions & 0 deletions
29
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,29 @@ | ||
import type { Page } from '@playwright/test' | ||
import { waitFor } from '../../../utils/waitFor' | ||
import Selectors from '../selectors' | ||
|
||
const openTransactionDetails = async (page: Page, txIndex: number) => { | ||
await page.locator(Selectors.activityTab.activityTabButton).click() | ||
|
||
const visibleTxs = await page.locator(Selectors.activityTab.completedTransactions).count() | ||
|
||
if (txIndex >= visibleTxs) { | ||
throw new Error( | ||
`[OpenTransactionDetails] Transaction with index ${txIndex} is not visible. There are only ${visibleTxs} transactions visible.` | ||
) | ||
} | ||
|
||
await page.locator(Selectors.activityTab.completedTransactions).nth(txIndex).click() | ||
|
||
// TODO: Extract timeout. | ||
await waitFor(() => page.locator(Selectors.popover.closeButton).isVisible(), 3_000) | ||
} | ||
|
||
const closeTransactionDetails = async (page: Page) => { | ||
await page.locator(Selectors.popover.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
18 changes: 18 additions & 0 deletions
18
wallets/metamask/test/e2e/metamask/closeTransactionDetails.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,18 @@ | ||
import { testWithMetaMask } from '../testWithMetaMask' | ||
|
||
const test = testWithMetaMask | ||
|
||
const { expect } = test | ||
|
||
test('should close transaction details', async ({ page, metamask, metamaskPage, connectToAnvil }) => { | ||
await connectToAnvil() | ||
|
||
await page.locator('#sendEIP1559Button').click() | ||
await metamask.experimental.confirmTransactionAndWaitForMining() | ||
|
||
await metamask.experimental.openTransactionDetails(0) | ||
|
||
await metamask.experimental.closeTransactionDetails() | ||
|
||
await expect(metamaskPage.locator(metamask.homePage.selectors.popover.closeButton)).toBeHidden() | ||
}) |
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
22 changes: 22 additions & 0 deletions
22
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,22 @@ | ||
import { testWithMetaMask } from '../testWithMetaMask' | ||
|
||
const test = testWithMetaMask | ||
|
||
const { expect } = test | ||
|
||
test('should open transaction details', async ({ page, metamask, metamaskPage, connectToAnvil }) => { | ||
await connectToAnvil() | ||
|
||
await page.locator('#sendEIP1559Button').click() | ||
await metamask.experimental.confirmTransactionAndWaitForMining() | ||
|
||
await metamask.experimental.openTransactionDetails(0) | ||
|
||
await expect(metamaskPage.locator(metamask.homePage.selectors.popover.closeButton)).toBeVisible() | ||
}) | ||
|
||
test('should throw an error if the passed transaction index is out of bounds', async ({ metamask }) => { | ||
await expect(metamask.experimental.openTransactionDetails(0)).rejects.toThrowError( | ||
'[OpenTransactionDetails] Transaction with index 0 is not visible. There are only 0 transactions visible.' | ||
) | ||
}) |