diff --git a/e2e/pages/Browser/ContractApprovalBottomSheet.js b/e2e/pages/Browser/ContractApprovalBottomSheet.js index e99985f84c4..489fe6a83c0 100644 --- a/e2e/pages/Browser/ContractApprovalBottomSheet.js +++ b/e2e/pages/Browser/ContractApprovalBottomSheet.js @@ -48,6 +48,10 @@ class ContractApprovalBottomSheet { ); } + get confirmButton() { + return Matchers.getElementByText(ContractApprovalBottomSheetSelectorsText.CONFIRM); + } + async tapAddNickName() { await Gestures.waitAndTap(this.addNickName); } @@ -63,6 +67,10 @@ class ContractApprovalBottomSheet { await Gestures.waitAndTap(this.approveButton); } + async tapConfirmButton() { + await Gestures.waitAndTap(this.confirmButton); + } + async tapToCopyContractAddress() { await Gestures.waitAndTap(this.contractAddress); } diff --git a/e2e/pages/Browser/TestDApp.js b/e2e/pages/Browser/TestDApp.js index ab411415955..a9bc65d01d6 100644 --- a/e2e/pages/Browser/TestDApp.js +++ b/e2e/pages/Browser/TestDApp.js @@ -119,6 +119,13 @@ class TestDApp { ); } + get erc1155BatchTransferButton() { + return Matchers.getElementByWebID( + BrowserViewSelectorsIDs.BROWSER_WEBVIEW_ID, + TestDappSelectorsWebIDs.BATCH_TRANSFER_ERC1155_BUTTON_ID, + ); + } + async connect() { await this.tapButton(this.DappConnectButton); } @@ -181,6 +188,10 @@ class TestDApp { await Gestures.tap(this.approveButtonText, 0); } + async tapERC1155BatchTransferButton() { + await this.tapButton(this.erc1155BatchTransferButton); + } + async tapButton(elementId) { await Gestures.scrollToWebViewPort(elementId); await Gestures.tapWebElement(elementId); diff --git a/e2e/selectors/Browser/ContractApprovalBottomSheet.selectors.js b/e2e/selectors/Browser/ContractApprovalBottomSheet.selectors.js index 39ee13229f7..d469fbfed79 100644 --- a/e2e/selectors/Browser/ContractApprovalBottomSheet.selectors.js +++ b/e2e/selectors/Browser/ContractApprovalBottomSheet.selectors.js @@ -6,6 +6,7 @@ export const ContractApprovalBottomSheetSelectorsText = { APPROVE: enContent.transactions.tx_review_approve, REJECT: enContent.transaction.reject, NEXT: enContent.transaction.next, + CONFIRM: enContent.transaction.confirm, }; export const ContractApprovalBottomSheetSelectorsIDs = { diff --git a/e2e/selectors/Browser/TestDapp.selectors.js b/e2e/selectors/Browser/TestDapp.selectors.js index 4725a436c92..e0995aa10f0 100644 --- a/e2e/selectors/Browser/TestDapp.selectors.js +++ b/e2e/selectors/Browser/TestDapp.selectors.js @@ -13,4 +13,5 @@ export const TestDappSelectorsWebIDs = { SIGN_TYPE_DATA_V4: 'signTypedDataV4', ETHEREUM_SIGN: 'siwe', ADD_TOKENS_TO_WALLET_BUTTON: 'watchAssets', + BATCH_TRANSFER_ERC1155_BUTTON_ID: 'batchTransferFromButton', }; diff --git a/e2e/specs/confirmations/batch-transfer-erc1155.spec.js b/e2e/specs/confirmations/batch-transfer-erc1155.spec.js new file mode 100644 index 00000000000..b7ed8494d16 --- /dev/null +++ b/e2e/specs/confirmations/batch-transfer-erc1155.spec.js @@ -0,0 +1,73 @@ +'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'; +import { ContractApprovalBottomSheetSelectorsText } from '../../selectors/Browser/ContractApprovalBottomSheet.selectors'; +import ContractApprovalBottomSheet from '../../pages/Browser/ContractApprovalBottomSheet'; + +describe(SmokeConfirmations('ERC1155 token'), () => { + const ERC1155_CONTRACT = SMART_CONTRACTS.ERC1155; + + beforeAll(async () => { + await TestHelpers.reverseServerPort(); + }); + + it('batch transfer ERC1155 tokens', async () => { + await withFixtures( + { + dapp: true, + fixture: new FixtureBuilder() + .withGanacheNetwork() + .withPermissionControllerConnectedToTestDapp() + .build(), + restartDevice: true, + ganacheOptions: defaultGanacheOptions, + smartContract: ERC1155_CONTRACT, + }, + async ({ contractRegistry }) => { + const erc1155Address = await contractRegistry.getContractAddress( + ERC1155_CONTRACT, + ); + await loginToApp(); + + // Navigate to the browser screen + await TabBarComponent.tapBrowser(); + await TestDApp.navigateToTestDappWithContract({ + contractAddress: erc1155Address, + }); + + // Send batch transfer for ERC1155 tokens + await TestDApp.tapERC1155BatchTransferButton(); + await Assertions.checkIfTextIsDisplayed( + ContractApprovalBottomSheetSelectorsText.CONFIRM, + ); + + // Tap confirm button + await ContractApprovalBottomSheet.tapConfirmButton(); + + // Navigate to the activity screen + await TabBarComponent.tapActivity(); + + // Assert that the ERC1155 activity is an smart contract interaction and it is confirmed + await Assertions.checkIfTextIsDisplayed( + ActivitiesViewSelectorsText.SMART_CONTRACT_INTERACTION, + ); + await Assertions.checkIfTextIsDisplayed( + ActivitiesViewSelectorsText.CONFIRM_TEXT, + ); + }, + ); + }); +});