Skip to content
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

test: send failing contract #12802

Merged
merged 4 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions e2e/pages/Browser/TestDApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ class TestDApp {
);
}

get sendFailingTransactionButton() {
return Matchers.getElementByWebID(
BrowserViewSelectorsIDs.BROWSER_WEBVIEW_ID,
TestDappSelectorsWebIDs.SEND_FAILING_TRANSACTION_BUTTON_ID,
);
}

get erc1155BatchTransferButton() {
return Matchers.getElementByWebID(
BrowserViewSelectorsIDs.BROWSER_WEBVIEW_ID,
Expand Down Expand Up @@ -188,6 +195,10 @@ class TestDApp {
await Gestures.tap(this.approveButtonText, 0);
}

async tapSendFailingTransactionButton() {
await this.tapButton(this.sendFailingTransactionButton);
}

async tapERC1155BatchTransferButton() {
await this.tapButton(this.erc1155BatchTransferButton);
}
Expand Down
1 change: 1 addition & 0 deletions e2e/selectors/Browser/TestDapp.selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ export const TestDappSelectorsWebIDs = {
SIGN_TYPE_DATA_V4: 'signTypedDataV4',
ETHEREUM_SIGN: 'siwe',
ADD_TOKENS_TO_WALLET_BUTTON: 'watchAssets',
SEND_FAILING_TRANSACTION_BUTTON_ID: 'sendFailingButton',
BATCH_TRANSFER_ERC1155_BUTTON_ID: 'batchTransferFromButton',
};
1 change: 1 addition & 0 deletions e2e/selectors/Transactions/ActivitiesView.selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const ActivitiesViewSelectorsIDs = {

export const ActivitiesViewSelectorsText = {
CONFIRM_TEXT: enContent.transaction.confirmed,
FAILED_TEXT: enContent.transaction.failed,
SMART_CONTRACT_INTERACTION: enContent.transactions.smart_contract_interaction,
INCREASE_ALLOWANCE_METHOD: enContent.transactions.increase_allowance,
SENT_COLLECTIBLE_MESSAGE_TEXT: enContent.transactions.sent_collectible,
Expand Down
77 changes: 77 additions & 0 deletions e2e/specs/confirmations/send-failing-contract.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
'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 { mockEvents } from '../../api-mocking/mock-config/mock-events';

describe(SmokeConfirmations('Failing contracts'), () => {
const FAILING_CONTRACT = SMART_CONTRACTS.FAILING;

beforeAll(async () => {
jest.setTimeout(150000);
await TestHelpers.reverseServerPort();
});

it('sends a failing contract transaction', async () => {

const testSpecificMock = {
GET: [
mockEvents.GET.suggestedGasFeesApiGanache
],
};
await withFixtures(
{
dapp: true,
fixture: new FixtureBuilder()
.withGanacheNetwork()
.withPermissionControllerConnectedToTestDapp()
.build(),
restartDevice: true,
ganacheOptions: defaultGanacheOptions,
smartContract: FAILING_CONTRACT,
testSpecificMock,
},
async ({ contractRegistry }) => {
const failingAddress = await contractRegistry.getContractAddress(
FAILING_CONTRACT,
);
await loginToApp();

// Navigate to the browser screen
await TabBarComponent.tapBrowser();
await TestDApp.navigateToTestDappWithContract({
contractAddress: failingAddress,
});

// Send a failing transaction
await TestDApp.tapSendFailingTransactionButton();
await TestHelpers.delay(3000);

await TestDApp.tapConfirmButton();

// Navigate to the activity screen
await TabBarComponent.tapActivity();

// Assert the failed transaction is displayed
await Assertions.checkIfTextIsDisplayed(
ActivitiesViewSelectorsText.SMART_CONTRACT_INTERACTION
);
await Assertions.checkIfTextIsDisplayed(
ActivitiesViewSelectorsText.FAILED_TEXT
);
},
);
});
});
Loading