diff --git a/e2e/pages/Browser/TestDApp.js b/e2e/pages/Browser/TestDApp.js index cdf89c571f8..425aab18602 100644 --- a/e2e/pages/Browser/TestDApp.js +++ b/e2e/pages/Browser/TestDApp.js @@ -89,7 +89,7 @@ class TestDApp { get nftSetApprovalForAllButton() { return Matchers.getElementByWebID( BrowserViewSelectorsIDs.BROWSER_WEBVIEW_ID, - TestDappSelectorsWebIDs.SET_APPROVAL_FOR_ALL_BUTTON_ID, + TestDappSelectorsWebIDs.SET_APPROVAL_FOR_ALL_NFT_BUTTON_ID, ); } @@ -100,6 +100,13 @@ class TestDApp { ); } + get erc1155SetApprovalForAllButton() { + return Matchers.getElementByWebID( + BrowserViewSelectorsIDs.BROWSER_WEBVIEW_ID, + TestDappSelectorsWebIDs.SET_APPROVAL_FOR_ALL_ERC1155_BUTTON_ID, + ); + } + async connect() { await this.tapButton(this.DappConnectButton); } @@ -146,6 +153,10 @@ class TestDApp { await this.tapButton(this.nftSetApprovalForAllButton); } + async tapERC1155SetApprovalForAllButton() { + await this.tapButton(this.erc1155SetApprovalForAllButton); + } + async tapConfirmButton() { await Gestures.tap(this.confirmButtonText, 0); } diff --git a/e2e/selectors/Browser/TestDapp.selectors.js b/e2e/selectors/Browser/TestDapp.selectors.js index 0f2b7cad254..e072905b426 100644 --- a/e2e/selectors/Browser/TestDapp.selectors.js +++ b/e2e/selectors/Browser/TestDapp.selectors.js @@ -5,7 +5,8 @@ export const TestDappSelectorsWebIDs = { INCREASE_ALLOWANCE_BUTTON_ID: 'increaseTokenAllowance', NFT_TRANSFER_FROM_BUTTON_ID: 'transferFromButton', PERSONAL_SIGN: 'personalSign', - SET_APPROVAL_FOR_ALL_BUTTON_ID: 'setApprovalForAllButton', + SET_APPROVAL_FOR_ALL_NFT_BUTTON_ID: 'setApprovalForAllButton', + SET_APPROVAL_FOR_ALL_ERC1155_BUTTON_ID: 'setApprovalForAllERC1155Button', SIGN_TYPE_DATA: 'signTypedData', SIGN_TYPE_DATA_V3: 'signTypedDataV3', SIGN_TYPE_DATA_V4: 'signTypedDataV4', diff --git a/e2e/specs/confirmations/set-approval-for-all-erc1155.spec.js b/e2e/specs/confirmations/set-approval-for-all-erc1155.spec.js new file mode 100644 index 00000000000..8e646db9efd --- /dev/null +++ b/e2e/specs/confirmations/set-approval-for-all-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('approve all 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, + }); + + // Set approval for all ERC1155 tokens + await TestDApp.tapERC1155SetApprovalForAllButton(); + await Assertions.checkIfTextIsDisplayed( + ContractApprovalBottomSheetSelectorsText.APPROVE, + ); + + // Tap approve button + await ContractApprovalBottomSheet.tapApproveButton(); + + // Navigate to the activity screen + await TabBarComponent.tapActivity(); + + // Assert that the ERC1155 activity is an set approve for all and it is confirmed + await Assertions.checkIfTextIsDisplayed( + ActivitiesViewSelectorsText.SET_APPROVAL_FOR_ALL_METHOD, + ); + await Assertions.checkIfTextIsDisplayed( + ActivitiesViewSelectorsText.CONFIRM_TEXT, + ); + }, + ); + }); +});