-
Notifications
You must be signed in to change notification settings - Fork 5.4k
feat: add e2e tests for trezor ERC721 NFT deployment and management. #35383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b0bab65
feat: consolidate token polling and batch RPC requests
dawnseeker8 2d1cb10
refactor: update test suite description for Trezor hardware
dawnseeker8 d5574bf
Merge branch 'main' into feat/trezor-erc721-e2e
dawnseeker8 15c6edb
Merge branch 'main' into feat/trezor-erc721-e2e
dawnseeker8 2dee941
Merge branch 'main' into feat/trezor-erc721-e2e
dawnseeker8 e4ef478
Merge branch 'main' into feat/trezor-erc721-e2e
dawnseeker8 2f026ff
Merge branch 'main' into feat/trezor-erc721-e2e
dawnseeker8 3f31036
Merge branch 'main' into feat/trezor-erc721-e2e
dawnseeker8 45b4b55
Merge branch 'main' into feat/trezor-erc721-e2e
dawnseeker8 9829447
Merge branch 'main' into feat/trezor-erc721-e2e
dawnseeker8 f73c3a8
Merge branch 'main' into feat/trezor-erc721-e2e
dawnseeker8 9cb02a0
Merge branch 'main' into feat/trezor-erc721-e2e
dawnseeker8 4f1072d
Move trezor erc 721 to trezor folder.
dawnseeker8 0daec3f
Merge branch 'main' into feat/trezor-erc721-e2e
dawnseeker8 88bc948
Merge branch 'main' into feat/trezor-erc721-e2e
dawnseeker8 05e0fdf
Merge branch 'main' into feat/trezor-erc721-e2e
dawnseeker8 736f1f2
Merge branch 'main' into feat/trezor-erc721-e2e
dawnseeker8 1dac0e1
test: Enhance Trezor ERC-721 e2e tests with deployment, minting, and …
dawnseeker8 fc523e9
test: Refactor Trezor ERC-721 e2e tests for contract deployment and N…
dawnseeker8 c01599a
Rewrite NFT approve function tests due to error to run SmartContract.…
dawnseeker8 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
247 changes: 247 additions & 0 deletions
247
test/e2e/tests/hardware-wallets/trezor/trezor-erc721.spec.ts
This file contains hidden or 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,247 @@ | ||
| import { Suite } from 'mocha'; | ||
| import TestDappPage from '../../../page-objects/pages/test-dapp'; | ||
| import FixtureBuilder from '../../../fixture-builder'; | ||
| import { DAPP_URL, WINDOW_TITLES, withFixtures } from '../../../helpers'; | ||
| import { KNOWN_PUBLIC_KEY_ADDRESSES } from '../../../../stub/keyring-bridge'; | ||
| import { loginWithBalanceValidation } from '../../../page-objects/flows/login.flow'; | ||
| import CreateContractModal from '../../../page-objects/pages/dialog/create-contract'; | ||
| import TransactionConfirmation from '../../../page-objects/pages/confirmations/redesign/transaction-confirmation'; | ||
| import HomePage from '../../../page-objects/pages/home/homepage'; | ||
| import NFTListPage from '../../../page-objects/pages/home/nft-list'; | ||
| import SetApprovalForAllTransactionConfirmation from '../../../page-objects/pages/confirmations/redesign/set-approval-for-all-transaction-confirmation'; | ||
| import ActivityListPage from '../../../page-objects/pages/home/activity-list'; | ||
| import { SMART_CONTRACTS } from '../../../seeder/smart-contracts'; | ||
| import ContractAddressRegistry from '../../../seeder/contract-address-registry'; | ||
| import { TestSuiteArguments } from '../../confirmations/transactions/shared'; | ||
| import { Driver } from '../../../webdriver/driver'; | ||
|
|
||
| describe('Trezor Hardware', function (this: Suite) { | ||
| const smartContract = SMART_CONTRACTS.NFTS; | ||
|
|
||
| describe('can perform actions on an ERC-721 token', function () { | ||
| async function deployContract(testDappPage: TestDappPage, driver: Driver) { | ||
| await testDappPage.clickERC721DeployButton(); | ||
| await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
| const createContractModal = new CreateContractModal(driver); | ||
| await createContractModal.checkPageIsLoaded(); | ||
| await createContractModal.clickConfirm(); | ||
| await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp); | ||
| await testDappPage.checkERC721TokenAddressesValue( | ||
| '0xcB17707e0623251182A654BEdaE16429C78A7424', | ||
| ); | ||
| } | ||
|
|
||
| async function mintNft(testDappPage: TestDappPage, driver: Driver) { | ||
| await testDappPage.clickERC721MintButton(); | ||
| await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
| const mintConfirmation = new TransactionConfirmation(driver); | ||
| await mintConfirmation.clickFooterConfirmButton(); | ||
| await driver.switchToWindowWithTitle( | ||
| WINDOW_TITLES.ExtensionInFullScreenView, | ||
| ); | ||
| const homePage = new HomePage(driver); | ||
| await homePage.goToNftTab(); | ||
| const nftListPage = new NFTListPage(driver); | ||
| // Check that NFT image is displayed in NFT tab on homepagexp | ||
| await nftListPage.checkNftImageIsDisplayed(); | ||
| await homePage.goToActivityList(); | ||
| const activityListPage = new ActivityListPage(driver); | ||
| await activityListPage.checkTransactionActivityByText('Deposit'); | ||
| await activityListPage.checkWaitForTransactionStatus('confirmed'); | ||
| } | ||
|
|
||
| it('deploys an ERC-721 token', async function () { | ||
| await withFixtures( | ||
| { | ||
| fixtures: new FixtureBuilder() | ||
| .withTrezorAccount() | ||
| .withPermissionControllerConnectedToTestDapp({ | ||
| account: KNOWN_PUBLIC_KEY_ADDRESSES[0].address, | ||
| }) | ||
| .build(), | ||
| title: this.test?.fullTitle(), | ||
| smartContract, | ||
| dapp: true, | ||
| }, | ||
| async ({ driver, localNodes }) => { | ||
| await localNodes?.[0]?.setAccountBalance( | ||
| KNOWN_PUBLIC_KEY_ADDRESSES[0].address, | ||
| '0x100000000000000000000', | ||
| ); | ||
| await loginWithBalanceValidation( | ||
| driver, | ||
| undefined, | ||
| undefined, | ||
| '1208925.8196', | ||
| ); | ||
|
|
||
| // deploy action | ||
| const testDappPage = new TestDappPage(driver); | ||
| await testDappPage.openTestDappPage(); | ||
| await testDappPage.checkPageIsLoaded(); | ||
| await deployContract(testDappPage, driver); | ||
| }, | ||
| ); | ||
| }); | ||
|
|
||
| it('mints an ERC-721 token', async function () { | ||
| await withFixtures( | ||
| { | ||
| fixtures: new FixtureBuilder() | ||
| .withTrezorAccount() | ||
| .withPermissionControllerConnectedToTestDapp({ | ||
| account: KNOWN_PUBLIC_KEY_ADDRESSES[0].address, | ||
| }) | ||
| .build(), | ||
| title: this.test?.fullTitle(), | ||
| smartContract, | ||
| dapp: true, | ||
| }, | ||
| async ({ | ||
| driver, | ||
| localNodes, | ||
| contractRegistry, | ||
| }: TestSuiteArguments) => { | ||
| await localNodes?.[0]?.setAccountBalance( | ||
| KNOWN_PUBLIC_KEY_ADDRESSES[0].address as `0x${string}`, | ||
| '0x100000000000000000000', | ||
| ); | ||
| await loginWithBalanceValidation( | ||
| driver, | ||
| undefined, | ||
| undefined, | ||
| '1208925.8196', | ||
| ); | ||
|
|
||
| const contractAddress = await ( | ||
| contractRegistry as ContractAddressRegistry | ||
| ).getContractAddress(smartContract); | ||
|
|
||
| const testDappPage = new TestDappPage(driver); | ||
| await testDappPage.openTestDappPage({ | ||
| contractAddress, | ||
| url: DAPP_URL, | ||
| }); | ||
| await testDappPage.checkPageIsLoaded(); | ||
|
|
||
| await mintNft(testDappPage, driver); | ||
| }, | ||
| ); | ||
| }); | ||
|
|
||
| it('approves an ERC-721 token', async function () { | ||
| // Approve function is difference since caller must be owner of contract, | ||
| // so we need to deploy and mint token first to make sure contract belong to caller. | ||
| await withFixtures( | ||
| { | ||
| fixtures: new FixtureBuilder() | ||
| .withTrezorAccount() | ||
| .withPermissionControllerConnectedToTestDapp({ | ||
| account: KNOWN_PUBLIC_KEY_ADDRESSES[0].address, | ||
| }) | ||
| .build(), | ||
| title: this.test?.fullTitle(), | ||
| dapp: true, | ||
| }, | ||
| async ({ driver, localNodes }: TestSuiteArguments) => { | ||
| await localNodes?.[0]?.setAccountBalance( | ||
| KNOWN_PUBLIC_KEY_ADDRESSES[0].address as `0x${string}`, | ||
| '0x100000000000000000000', | ||
| ); | ||
| await loginWithBalanceValidation( | ||
| driver, | ||
| undefined, | ||
| undefined, | ||
| '1208925.8196', | ||
| ); | ||
|
|
||
| const testDappPage = new TestDappPage(driver); | ||
| await testDappPage.openTestDappPage(); | ||
| await testDappPage.checkPageIsLoaded(); | ||
| await deployContract(testDappPage, driver); | ||
|
|
||
| await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp); | ||
| await mintNft(testDappPage, driver); | ||
|
|
||
| await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp); | ||
| await testDappPage.clickERC721ApproveButton(); | ||
| await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
| const approveConfirmation = new TransactionConfirmation(driver); | ||
| await approveConfirmation.clickFooterConfirmButton(); | ||
| await driver.switchToWindowWithTitle( | ||
| WINDOW_TITLES.ExtensionInFullScreenView, | ||
| ); | ||
|
|
||
| const homePage = new HomePage(driver); | ||
| const activityListPage = new ActivityListPage(driver); | ||
| await homePage.goToActivityList(); | ||
| await activityListPage.checkTransactionActivityByText( | ||
| 'Approve TDN spending cap', | ||
| ); | ||
| await activityListPage.checkWaitForTransactionStatus('confirmed'); | ||
| }, | ||
| ); | ||
| }); | ||
dawnseeker8 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| it('sets approval for all an ERC-721 token', async function () { | ||
| await withFixtures( | ||
| { | ||
| fixtures: new FixtureBuilder() | ||
| .withTrezorAccount() | ||
| .withPermissionControllerConnectedToTestDapp({ | ||
| account: KNOWN_PUBLIC_KEY_ADDRESSES[0].address as `0x${string}`, | ||
| }) | ||
| .build(), | ||
| title: this.test?.fullTitle(), | ||
| smartContract, | ||
| dapp: true, | ||
| }, | ||
| async ({ | ||
| driver, | ||
| localNodes, | ||
| contractRegistry, | ||
| }: TestSuiteArguments) => { | ||
| await localNodes?.[0]?.setAccountBalance( | ||
| KNOWN_PUBLIC_KEY_ADDRESSES[0].address as `0x${string}`, | ||
| '0x100000000000000000000', | ||
| ); | ||
| await loginWithBalanceValidation( | ||
| driver, | ||
| undefined, | ||
| undefined, | ||
| '1208925.8196', | ||
| ); | ||
| const contractAddress = await ( | ||
| contractRegistry as ContractAddressRegistry | ||
| ).getContractAddress(smartContract); | ||
| const testDappPage = new TestDappPage(driver); | ||
| await testDappPage.openTestDappPage({ | ||
| contractAddress, | ||
| url: DAPP_URL, | ||
| }); | ||
| await testDappPage.checkPageIsLoaded(); | ||
|
|
||
| await testDappPage.clickERC721SetApprovalForAllButton(); | ||
| await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); | ||
| const setApprovalForAllConfirmation = | ||
| new SetApprovalForAllTransactionConfirmation(driver); | ||
| await setApprovalForAllConfirmation.checkSetApprovalForAllTitle(); | ||
| await setApprovalForAllConfirmation.checkSetApprovalForAllSubHeading(); | ||
| await setApprovalForAllConfirmation.clickScrollToBottomButton(); | ||
| await setApprovalForAllConfirmation.clickFooterConfirmButton(); | ||
| await driver.switchToWindowWithTitle( | ||
| WINDOW_TITLES.ExtensionInFullScreenView, | ||
| ); | ||
|
|
||
| const homePage = new HomePage(driver); | ||
| const activityListPage = new ActivityListPage(driver); | ||
| await homePage.goToActivityList(); | ||
| await activityListPage.checkTransactionActivityByText( | ||
| 'Approve TDN with no spend limit', | ||
| ); | ||
| await activityListPage.checkWaitForTransactionStatus('confirmed'); | ||
| }, | ||
| ); | ||
| }); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, the approve e2e tests are difference due to
approvewill check against the ownership of contract, the SMART_CONTRACTS.NFT contract doesnt belong to ledger account, that is why i need to do deployment, mint and then approve in this tests.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, good point! I think we could enhance our testing framework to support this. I'll open a ticket for that for the QA team. Thank you!!