diff --git a/e2e/pages/Browser/TestDApp.js b/e2e/pages/Browser/TestDApp.js index 56f846e6942..e824b816787 100644 --- a/e2e/pages/Browser/TestDApp.js +++ b/e2e/pages/Browser/TestDApp.js @@ -12,6 +12,7 @@ import Matchers from '../../utils/Matchers'; export const TEST_DAPP_LOCAL_URL = `http://localhost:${getLocalTestDappPort()}`; const CONFIRM_BUTTON_TEXT = enContent.confirmation_modal.confirm_cta; +const APPROVE_BUTTON_TEXT = enContent.transactions.tx_review_approve; class TestDApp { get androidContainer() { @@ -22,6 +23,10 @@ class TestDApp { return Matchers.getElementByText(CONFIRM_BUTTON_TEXT); } + get approveButtonText() { + return Matchers.getElementByText(APPROVE_BUTTON_TEXT); + } + get DappConnectButton() { return Matchers.getElementByWebID( BrowserViewSelectorsIDs.BROWSER_WEBVIEW_ID, @@ -29,10 +34,17 @@ class TestDApp { ); } - get ApproveButton() { + get ApproveERC20TokensButton() { + return Matchers.getElementByWebID( + BrowserViewSelectorsIDs.BROWSER_WEBVIEW_ID, + TestDappSelectorsWebIDs.APPROVE_ERC_20_TOKENS_BUTTON_ID, + ); + } + + get ApproveERC721TokenButton() { return Matchers.getElementByWebID( BrowserViewSelectorsIDs.BROWSER_WEBVIEW_ID, - TestDappSelectorsWebIDs.APPROVE_TOKENS_BUTTON_ID, + TestDappSelectorsWebIDs.APPROVE_ERC_721_TOKEN_BUTTON_ID, ); } // This taps on the transfer tokens button under the "SEND TOKENS section" @@ -98,8 +110,12 @@ class TestDApp { await this.tapButton(this.DappConnectButton); } - async tapApproveButton() { - await this.tapButton(this.ApproveButton); + async tapApproveERC20TokensButton() { + await this.tapButton(this.ApproveERC20TokensButton); + } + + async tapApproveERC721TokenButton() { + await this.tapButton(this.ApproveERC721TokenButton); } async tapIncreaseAllowanceButton() { @@ -139,6 +155,10 @@ class TestDApp { await Gestures.tap(this.confirmButtonText, 0); } + async tapApproveButton() { + await Gestures.tap(this.approveButtonText, 0); + } + async tapButton(elementId) { await Gestures.scrollToWebViewPort(elementId); await Gestures.tapWebElement(elementId); diff --git a/e2e/selectors/Browser/TestDapp.selectors.js b/e2e/selectors/Browser/TestDapp.selectors.js index 8b2649767ab..b08ca367e39 100644 --- a/e2e/selectors/Browser/TestDapp.selectors.js +++ b/e2e/selectors/Browser/TestDapp.selectors.js @@ -1,5 +1,6 @@ export const TestDappSelectorsWebIDs = { - APPROVE_TOKENS_BUTTON_ID: 'approveTokens', + APPROVE_ERC_20_TOKENS_BUTTON_ID: 'approveTokens', + APPROVE_ERC_721_TOKEN_BUTTON_ID: 'approveButton', CONNECT_BUTTON: 'connectButton', ERC_20_SEND_TOKENS_TRANSFER_TOKENS_BUTTON_ID: 'transferTokens', INCREASE_ALLOWANCE_BUTTON_ID: 'increaseTokenAllowance', diff --git a/e2e/selectors/Transactions/ActivitiesView.selectors.js b/e2e/selectors/Transactions/ActivitiesView.selectors.js index 50a3cb95384..4327c397700 100644 --- a/e2e/selectors/Transactions/ActivitiesView.selectors.js +++ b/e2e/selectors/Transactions/ActivitiesView.selectors.js @@ -16,4 +16,5 @@ export const ActivitiesViewSelectorsText = { SET_APPROVAL_FOR_ALL_METHOD: enContent.transactions.set_approval_for_all, SWAP: enContent.swaps.transaction_label.swap, TITLE: enContent.transactions_view.title, + }; diff --git a/e2e/specs/confirmations/approve-custom-erc20.spec.js b/e2e/specs/confirmations/approve-custom-erc20.spec.js index 1c8d9e96383..ed24c9c3c6a 100644 --- a/e2e/specs/confirmations/approve-custom-erc20.spec.js +++ b/e2e/specs/confirmations/approve-custom-erc20.spec.js @@ -48,7 +48,7 @@ describe(SmokeConfirmations('ERC20 tokens'), () => { await TestDApp.navigateToTestDappWithContract({ contractAddress: hstAddress, }); - await TestDApp.tapApproveButton(); + await TestDApp.tapApproveERC20TokensButton(); //Input custom token amount await Assertions.checkIfVisible( diff --git a/e2e/specs/confirmations/approve-default-erc20.spec.js b/e2e/specs/confirmations/approve-default-erc20.spec.js index ed9c02188c5..ca7a2889a0f 100644 --- a/e2e/specs/confirmations/approve-default-erc20.spec.js +++ b/e2e/specs/confirmations/approve-default-erc20.spec.js @@ -50,7 +50,7 @@ describe(SmokeConfirmations('ERC20 tokens'), () => { await TestDApp.navigateToTestDappWithContract({ contractAddress: hstAddress, }); - await TestDApp.tapApproveButton(); + await TestDApp.tapApproveERC20TokensButton(); await Assertions.checkIfVisible( ContractApprovalBottomSheet.approveTokenAmount, diff --git a/e2e/specs/confirmations/approve-erc721.spec.js b/e2e/specs/confirmations/approve-erc721.spec.js new file mode 100644 index 00000000000..d06a16d4909 --- /dev/null +++ b/e2e/specs/confirmations/approve-erc721.spec.js @@ -0,0 +1,61 @@ +'use strict'; + +import { SmokeConfirmations } from '../../tags'; +import TestHelpers from '../../helpers'; +import { loginToApp } from '../../viewHelper'; + +import TabBarComponent from '../../pages/wallet/TabBarComponent'; +import TestDApp from '../../pages/Browser/TestDApp'; +import FixtureBuilder from '../../fixtures/fixture-builder'; +import { + withFixtures, + defaultGanacheOptions, +} from '../../fixtures/fixture-helper'; +import { SMART_CONTRACTS } from '../../../app/util/test/smart-contracts'; +import { ActivitiesViewSelectorsText } from '../../selectors/Transactions/ActivitiesView.selectors'; +import Assertions from '../../utils/Assertions'; + +describe(SmokeConfirmations('ERC721 tokens'), () => { + const NFT_CONTRACT = SMART_CONTRACTS.NFTS; + + beforeAll(async () => { + jest.setTimeout(150000); + await TestHelpers.reverseServerPort(); + }); + + it('approve an ERC721 token from a dapp', async () => { + await withFixtures( + { + dapp: true, + fixture: new FixtureBuilder() + .withGanacheNetwork() + .withPermissionControllerConnectedToTestDapp() + .build(), + restartDevice: true, + ganacheOptions: defaultGanacheOptions, + smartContract: NFT_CONTRACT, + }, + async ({ contractRegistry }) => { + const nftsAddress = await contractRegistry.getContractAddress( + NFT_CONTRACT, + ); + await loginToApp(); + // Navigate to the browser screen + await TabBarComponent.tapBrowser(); + await TestDApp.navigateToTestDappWithContract({ + contractAddress: nftsAddress, + }); + // Approve NFT + await TestDApp.tapApproveERC721TokenButton(); + await TestHelpers.delay(3000); + await TestDApp.tapApproveButton(); + // Navigate to the activity screen + await TabBarComponent.tapActivity(); + // Assert NFT is approved + await Assertions.checkIfTextIsDisplayed( + ActivitiesViewSelectorsText.CONFIRM_TEXT, + ); + }, + ); + }); +});