-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add transaction flow and details sections (#27654)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Adds two new sections for the wallet initiated ERC20 token transfer redesigned confirmation. <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27654?quickstart=1) ## **Related issues** Fixes: MetaMask/MetaMask-planning#3220 ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> <img width="368" alt="Screenshot 2024-10-07 at 11 04 58" src="https://github.com/user-attachments/assets/3e160876-be5c-46d2-b03a-b841f93b08d1"> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
- Loading branch information
1 parent
f58d598
commit dc48117
Showing
36 changed files
with
1,200 additions
and
207 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
test/e2e/page-objects/pages/confirmations/legacy/watch-asset-confirmation.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,20 @@ | ||
import { Driver } from '../../../../webdriver/driver'; | ||
import { RawLocator } from '../../../common'; | ||
|
||
class WatchAssetConfirmation { | ||
private driver: Driver; | ||
|
||
private footerConfirmButton: RawLocator; | ||
|
||
constructor(driver: Driver) { | ||
this.driver = driver; | ||
|
||
this.footerConfirmButton = '[data-testid="page-container-footer-next"]'; | ||
} | ||
|
||
async clickFooterConfirmButton() { | ||
await this.driver.clickElement(this.footerConfirmButton); | ||
} | ||
} | ||
|
||
export default WatchAssetConfirmation; |
4 changes: 2 additions & 2 deletions
4
test/e2e/page-objects/pages/confirmation.ts → ...es/confirmations/redesign/confirmation.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
6 changes: 3 additions & 3 deletions
6
...roval-for-all-transaction-confirmation.ts → ...roval-for-all-transaction-confirmation.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
45 changes: 45 additions & 0 deletions
45
test/e2e/page-objects/pages/confirmations/redesign/token-transfer-confirmation.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,45 @@ | ||
import { tEn } from '../../../../../lib/i18n-helpers'; | ||
import { Driver } from '../../../../webdriver/driver'; | ||
import { RawLocator } from '../../../common'; | ||
import TransactionConfirmation from './transaction-confirmation'; | ||
|
||
class TokenTransferTransactionConfirmation extends TransactionConfirmation { | ||
private networkParagraph: RawLocator; | ||
|
||
private interactingWithParagraph: RawLocator; | ||
|
||
private networkFeeParagraph: RawLocator; | ||
|
||
constructor(driver: Driver) { | ||
super(driver); | ||
|
||
this.driver = driver; | ||
|
||
this.networkParagraph = { | ||
css: 'p', | ||
text: tEn('transactionFlowNetwork') as string, | ||
}; | ||
this.interactingWithParagraph = { | ||
css: 'p', | ||
text: tEn('interactingWith') as string, | ||
}; | ||
this.networkFeeParagraph = { | ||
css: 'p', | ||
text: tEn('networkFee') as string, | ||
}; | ||
} | ||
|
||
async check_networkParagraph() { | ||
await this.driver.waitForSelector(this.networkParagraph); | ||
} | ||
|
||
async check_interactingWithParagraph() { | ||
await this.driver.waitForSelector(this.interactingWithParagraph); | ||
} | ||
|
||
async check_networkFeeParagraph() { | ||
await this.driver.waitForSelector(this.networkFeeParagraph); | ||
} | ||
} | ||
|
||
export default TokenTransferTransactionConfirmation; |
25 changes: 25 additions & 0 deletions
25
test/e2e/page-objects/pages/confirmations/redesign/transaction-confirmation.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 { tEn } from '../../../../../lib/i18n-helpers'; | ||
import { Driver } from '../../../../webdriver/driver'; | ||
import { RawLocator } from '../../../common'; | ||
import Confirmation from './confirmation'; | ||
|
||
class TransactionConfirmation extends Confirmation { | ||
private walletInitiatedHeadingTitle: RawLocator; | ||
|
||
constructor(driver: Driver) { | ||
super(driver); | ||
|
||
this.driver = driver; | ||
|
||
this.walletInitiatedHeadingTitle = { | ||
css: 'h3', | ||
text: tEn('review') as string, | ||
}; | ||
} | ||
|
||
async check_walletInitiatedHeadingTitle() { | ||
await this.driver.waitForSelector(this.walletInitiatedHeadingTitle); | ||
} | ||
} | ||
|
||
export default TransactionConfirmation; |
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 was deleted.
Oops, something went wrong.
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
115 changes: 115 additions & 0 deletions
115
test/e2e/tests/confirmations/transactions/erc20-token-send-redesign.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,115 @@ | ||
/* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ | ||
import { TransactionEnvelopeType } from '@metamask/transaction-controller'; | ||
import { DAPP_URL } from '../../../constants'; | ||
import { unlockWallet, WINDOW_TITLES } from '../../../helpers'; | ||
import { Mockttp } from '../../../mock-e2e'; | ||
import WatchAssetConfirmation from '../../../page-objects/pages/confirmations/legacy/watch-asset-confirmation'; | ||
import TokenTransferTransactionConfirmation from '../../../page-objects/pages/confirmations/redesign/token-transfer-confirmation'; | ||
import HomePage from '../../../page-objects/pages/homepage'; | ||
import SendTokenPage from '../../../page-objects/pages/send/send-token-page'; | ||
import TestDapp from '../../../page-objects/pages/test-dapp'; | ||
import GanacheContractAddressRegistry from '../../../seeder/ganache-contract-address-registry'; | ||
import { Driver } from '../../../webdriver/driver'; | ||
import { withRedesignConfirmationFixtures } from '../helpers'; | ||
import { TestSuiteArguments } from './shared'; | ||
|
||
const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); | ||
|
||
describe('Confirmation Redesign ERC20 Token Send @no-mmi', function () { | ||
it('Sends a type 0 transaction (Legacy)', async function () { | ||
await withRedesignConfirmationFixtures( | ||
this.test?.fullTitle(), | ||
TransactionEnvelopeType.legacy, | ||
async ({ driver, contractRegistry }: TestSuiteArguments) => { | ||
await createTransactionAndAssertDetails(driver, contractRegistry); | ||
}, | ||
mocks, | ||
SMART_CONTRACTS.HST, | ||
); | ||
}); | ||
|
||
it('Sends a type 2 transaction (EIP1559)', async function () { | ||
await withRedesignConfirmationFixtures( | ||
this.test?.fullTitle(), | ||
TransactionEnvelopeType.feeMarket, | ||
async ({ driver, contractRegistry }: TestSuiteArguments) => { | ||
await createTransactionAndAssertDetails(driver, contractRegistry); | ||
}, | ||
mocks, | ||
SMART_CONTRACTS.HST, | ||
); | ||
}); | ||
}); | ||
|
||
async function mocks(server: Mockttp) { | ||
return [await mockedSourcifyTokenSend(server)]; | ||
} | ||
|
||
export async function mockedSourcifyTokenSend(mockServer: Mockttp) { | ||
return await mockServer | ||
.forGet('https://www.4byte.directory/api/v1/signatures/') | ||
.withQuery({ hex_signature: '0xa9059cbb' }) | ||
.always() | ||
.thenCallback(() => ({ | ||
statusCode: 200, | ||
json: { | ||
count: 1, | ||
next: null, | ||
previous: null, | ||
results: [ | ||
{ | ||
bytes_signature: '©\u0005»', | ||
created_at: '2016-07-09T03:58:28.234977Z', | ||
hex_signature: '0xa9059cbb', | ||
id: 145, | ||
text_signature: 'transfer(address,uint256)', | ||
}, | ||
], | ||
}, | ||
})); | ||
} | ||
|
||
async function createTransactionAndAssertDetails( | ||
driver: Driver, | ||
contractRegistry?: GanacheContractAddressRegistry, | ||
) { | ||
await unlockWallet(driver); | ||
|
||
const contractAddress = await ( | ||
contractRegistry as GanacheContractAddressRegistry | ||
).getContractAddress(SMART_CONTRACTS.HST); | ||
|
||
const testDapp = new TestDapp(driver); | ||
|
||
await testDapp.openTestDappPage({ contractAddress, url: DAPP_URL }); | ||
|
||
await testDapp.clickERC20WatchAssetButton(); | ||
|
||
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
|
||
const watchAssetConfirmation = new WatchAssetConfirmation(driver); | ||
await watchAssetConfirmation.clickFooterConfirmButton(); | ||
|
||
await driver.switchToWindowWithTitle(WINDOW_TITLES.ExtensionInFullScreenView); | ||
|
||
const homePage = new HomePage(driver); | ||
await homePage.startSendFlow(); | ||
|
||
const sendToPage = new SendTokenPage(driver); | ||
await sendToPage.check_pageIsLoaded(); | ||
await sendToPage.fillRecipient('0x2f318C334780961FB129D2a6c30D0763d9a5C970'); | ||
await sendToPage.fillAmount('1'); | ||
|
||
await sendToPage.click_assetPickerButton(); | ||
await sendToPage.click_secondTokenListButton(); | ||
await sendToPage.goToNextScreen(); | ||
|
||
const tokenTransferTransactionConfirmation = | ||
new TokenTransferTransactionConfirmation(driver); | ||
await tokenTransferTransactionConfirmation.check_walletInitiatedHeadingTitle(); | ||
await tokenTransferTransactionConfirmation.check_networkParagraph(); | ||
await tokenTransferTransactionConfirmation.check_interactingWithParagraph(); | ||
await tokenTransferTransactionConfirmation.check_networkFeeParagraph(); | ||
|
||
await tokenTransferTransactionConfirmation.clickFooterConfirmButton(); | ||
} |
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
Oops, something went wrong.