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: add Asset watch e2e #12720

Merged
merged 3 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const WatchAssetRequest = ({
const { address, symbol, decimals, standard } = asset;

return (
<View style={styles.root}>
<View style={styles.root} testID={AssetWatcherSelectorsIDs.CONTAINER}>
cortisiko marked this conversation as resolved.
Show resolved Hide resolved
<View style={styles.approveTransactionHeaderWrapper}>
<ApproveTransactionHeader
origin={currentPageInformation?.url}
Expand Down
10 changes: 10 additions & 0 deletions e2e/pages/Browser/TestDApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ class TestDApp {
);
}

get addTokensToWalletButton() {
cortisiko marked this conversation as resolved.
Show resolved Hide resolved
return Matchers.getElementByWebID(
BrowserViewSelectorsIDs.BROWSER_WEBVIEW_ID,
TestDappSelectorsWebIDs.ADD_TOKENS_TO_WALLET_BUTTON,
);
}

async connect() {
await this.tapButton(this.DappConnectButton);
}
Expand All @@ -98,6 +105,9 @@ class TestDApp {
async tapIncreaseAllowanceButton() {
await this.tapButton(this.increaseAllowanceButton);
}
async tapAddERCTokenToWalletButton() {
cortisiko marked this conversation as resolved.
Show resolved Hide resolved
NicolasMassart marked this conversation as resolved.
Show resolved Hide resolved
await this.tapButton(this.addTokensToWalletButton);
}

async tapPersonalSignButton() {
await this.tapButton(this.personalSignButton);
Expand Down
12 changes: 12 additions & 0 deletions e2e/pages/Transactions/AssetWatchBottomSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,25 @@ import Matchers from '../../utils/Matchers';
import Gestures from '../../utils/Gestures';

class AssetWatchBottomSheet {
cortisiko marked this conversation as resolved.
Show resolved Hide resolved
get container() {
return Matchers.getElementByID(AssetWatcherSelectorsIDs.CONTAINER);
}

get cancelButton() {
return Matchers.getElementByID(AssetWatcherSelectorsIDs.CANCEL_BUTTON);
}
get confirmButton() {
return device.getPlatform() === 'android'
? Matchers.getElementByLabel(AssetWatcherSelectorsIDs.CONFIRM_BUTTON)
: Matchers.getElementByID(AssetWatcherSelectorsIDs.CONFIRM_BUTTON);
}

async tapCancelButton() {
await Gestures.waitAndTap(this.cancelButton);
}
async tapAddTokenButton() {
await Gestures.waitAndTap(this.confirmButton);
}
}

export default new AssetWatchBottomSheet();
1 change: 1 addition & 0 deletions e2e/selectors/Browser/TestDapp.selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export const TestDappSelectorsWebIDs = {
SIGN_TYPE_DATA_V3: 'signTypedDataV3',
SIGN_TYPE_DATA_V4: 'signTypedDataV4',
SIWE: 'siwe',
ADD_TOKENS_TO_WALLET_BUTTON: 'watchAssets',
cortisiko marked this conversation as resolved.
Show resolved Hide resolved
};
1 change: 1 addition & 0 deletions e2e/selectors/Transactions/AssetWatcher.selectors.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const AssetWatcherSelectorsIDs = {
CANCEL_BUTTON: 'asset-watch-cancel-button',
CONFIRM_BUTTON: 'asset-watch-confirm-button',
CONTAINER: 'asset-watch-container',
};
61 changes: 61 additions & 0 deletions e2e/specs/assets/import-tokens-via-asset-watcher.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
('use strict');
import { SmokeAssets } from '../../tags';
import TestHelpers from '../../helpers';
import { loginToApp } from '../../viewHelper';
import FixtureBuilder from '../../fixtures/fixture-builder';
import {
withFixtures,
defaultGanacheOptions,
} from '../../fixtures/fixture-helper';
import { SMART_CONTRACTS } from '../../../app/util/test/smart-contracts';

import TabBarComponent from '../../pages/wallet/TabBarComponent';
import TestDApp from '../../pages/Browser/TestDApp';
import Assertions from '../../utils/Assertions';
import AssetWatchBottomSheet from '../../pages/Transactions/AssetWatchBottomSheet';
import WalletView from '../../pages/wallet/WalletView';

const ERC20_CONTRACT = SMART_CONTRACTS.HST;

describe(SmokeAssets('Asset Watch:'), () => {
beforeAll(async () => {
jest.setTimeout(170000);
await TestHelpers.reverseServerPort();
});

it('Should Import ERC20 Token via Dapp', async () => {
await withFixtures(
{
dapp: true,
fixture: new FixtureBuilder()
.withGanacheNetwork()
.withPermissionControllerConnectedToTestDapp()
.build(),
restartDevice: true,
ganacheOptions: defaultGanacheOptions,
smartContract: ERC20_CONTRACT,
},
async ({ contractRegistry }) => {
const hstAddress = await contractRegistry.getContractAddress(
ERC20_CONTRACT,
);
await loginToApp();

// Navigate to the browser screen
await TabBarComponent.tapBrowser();
await TestDApp.navigateToTestDappWithContract({
contractAddress: hstAddress,
});
await TestHelpers.delay(3000); // Because loading the dapp is slow on CI
cortisiko marked this conversation as resolved.
Show resolved Hide resolved

await TestDApp.tapAddERCTokenToWalletButton();
await Assertions.checkIfVisible(AssetWatchBottomSheet.container);
await AssetWatchBottomSheet.tapAddTokenButton();
await Assertions.checkIfNotVisible(AssetWatchBottomSheet.container);

await TabBarComponent.tapWallet();
await Assertions.checkIfVisible(WalletView.tokenInWallet('100 TST'));
},
);
});
});
2 changes: 1 addition & 1 deletion e2e/specs/wallet/incoming-transactions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe(SmokeCore('Incoming Transactions'), () => {
await TestHelpers.reverseServerPort();
});

it('displays standard incoming transaction', async () => {
xit('displays standard incoming transaction', async () => {
cortisiko marked this conversation as resolved.
Show resolved Hide resolved
await withFixtures(
{
fixture: new FixtureBuilder().build(),
Expand Down
Loading