Skip to content

Commit

Permalink
test: ERC1155 set approval for all e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Ivan committed Dec 18, 2024
1 parent 9054f70 commit 878444a
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 2 deletions.
13 changes: 12 additions & 1 deletion e2e/pages/Browser/TestDApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}

Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion e2e/selectors/Browser/TestDapp.selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
73 changes: 73 additions & 0 deletions e2e/specs/confirmations/set-approval-for-all-erc1155.spec.js
Original file line number Diff line number Diff line change
@@ -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,
);
},
);
});
});

0 comments on commit 878444a

Please sign in to comment.