From b2cce876e06c1475c6f40d597a0ff87d43315f89 Mon Sep 17 00:00:00 2001 From: SamuelSalas Date: Sat, 6 Jul 2024 16:14:02 -0600 Subject: [PATCH] test: Refactor WalletView file (#10225) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Refactor the WalletView screen to follow the page object model as well as the current guidelines establish by the QA mobile team. As well to unify all the testIDs into one single object. ## **Summary** * app/component-library/components/Pickers/PickerAccount/PickerAccount.tsx: Remove previous `generateTestId ` with current testID `WalletViewSelectorsIDs.ACCOUNT_NAME_LABEL_TEXT` * app/component-library/components/Pickers/PickerNetwork/PickerNetwork.tsx: Remove previous `generateTestId ` with current testID `WalletViewSelectorsIDs.NAVBAR_NETWORK_TEXT ` * app/component-library/components/Toast/Toast.tsx: Remove previous `generateTestId ` with current testID `ToastSelectorsIDs.CONTAINER` * app/components/UI/AccountOverview/index.js: Remove `currentCurrency `, `newAssetTransaction `, `toggleReceiveModal ` props causing lint issues. Remove previous `generateTestId ` with current testID `WalletViewSelectorsIDs.ACCOUNT_ICON`, `WalletViewSelectorsIDs. ACCOUNT_NAME_LABEL_INPUT `, `WalletViewSelectorsIDs. ACCOUNT_NAME_LABEL_TEXT ` * app/components/UI/AddressCopy/AddressCopy.tsx: Remove previous `generateTestId ` with current testID `WalletViewSelectorsIDs.ACCOUNT_COPY_BUTTON`, `WalletViewSelectorsIDs. ACCOUNT_ADDRESS ` * app/components/UI/CollectibleContracts/index.js: Remove previous `generateTestId ` with current testID `WalletViewSelectorsIDs. IMPORT_NFT_BUTTON `, `WalletViewSelectorsIDs. NFT_TAB_CONTAINER ` * app/components/UI/Navbar/index.js: Remove previous `generateTestId ` with current testID `AddContactViewSelectorsIDs.EDIT_BUTTON `, `WalletViewSelectorsIDs.NAVBAR_NETWORK_BUTTON ` * app/components/UI/Tokens/index.test.tsx: Update `getByTestId ` with current testID `AddContactViewSelectorsIDs. IMPORT_TOKEN_BUTTON `, `WalletViewSelectorsIDs. TOKENS_CONTAINER ` * app/components/UI/Tokens/index.tsx: Remove previous `generateTestId ` with current testID `AddContactViewSelectorsIDs. IMPORT_TOKEN_BUTTON `, `WalletViewSelectorsIDs. TOKENS_CONTAINER ` * app/components/UI/WalletAccount/WalletAccount.test.tsx: Update `getByTestId ` with current testID `WalletViewSelectorsIDs.ACCOUNT_ADDRESS `, `WalletViewSelectorsIDs. ACCOUNT_COPY_BUTTON `, `WalletViewSelectorsIDs. ACCOUNT_ICON ` * app/components/UI/WalletAccount/WalletAccount.tsx: Remove previous `generateTestId ` with current testID `WalletViewSelectorsIDs.ACCOUNT_ADDRESS `, `WalletViewSelectorsIDs. ACCOUNT_COPY_BUTTON `, `WalletViewSelectorsIDs. ACCOUNT_ICON ` * app/components/Views/AccountActions/AccountActions.constants.ts: File removed * app/components/Views/AccountActions/AccountActions.test.tsx: Update `getByTestId ` with current testIDs from `AccountActionsModalSelectorsIDs` object. * app/components/Views/AccountActions/AccountActions.tsx: Remove previous `generateTestId ` with current testIDs from `AccountActionsModalSelectorsIDs ` object. * app/components/Views/TransactionsView/index.js: Remove `generateTestId` * app/components/Views/Wallet/index.test.tsx: Update `getByTestId ` with current testID `CommonSelectorsIDs.FOX_ICON `, `WalletViewSelectorsIDs.WALLET_SCAN_BUTTON` * app/components/Views/Wallet/index.tsx: Remove `generateTestId` * e2e/pages/Send/TransactionConfirmView.js: Remove `await` inside `Gestures.waitAndTap()` * e2e/pages/WalletView.js: File Relocated * e2e/pages/wallet/WalletView.js: File refactor to POM * e2e/selectors/Common.selectors.js: Add `ANDROID_PROGRESS_BAR` testId * e2e/selectors/Modals/AccountActionsModal.selectors.js: File created with already existing testIDs * e2e/selectors/TransactionConfirmView.selectors.js: Remove `eslint` exception line * e2e/selectors/wallet/WalletView.selectors.js: Added testIDs located in other files. * e2e/specs/accounts/create-wallet-account.spec.js: Update `pages/wallet/WalletView` file path. * e2e/specs/accounts/import-wallet-account.spec.js: Update `pages/wallet/WalletView` file path. Update `WalletView.isVisible()` to `Assertions.checkIfVisible(WalletView.container)`. * e2e/specs/assets/import-tokens.spec.js: Update `pages/wallet/WalletView` file path. Update `WalletView.isVisible()` to `Assertions.checkIfVisible(WalletView.container)`. Implement `WalletView.tokenInWallet()`. * e2e/specs/assets/nft-detection-modal.spec.js: Update `pages/wallet/WalletView` file path. Update `WalletView.isVisible()` to `Assertions.checkIfVisible(WalletView.container)`. * e2e/specs/assets/token-detection-import-all.spec.js: Due to some inconsistencies when importing the wallet not showing the import token button, I decided to implement the fixture steps. * e2e/specs/confirmations/advanced-gas-fees.spec.js: Update `pages/wallet/WalletView` file path. Update `WalletView.isVisible()` to `Assertions.checkIfVisible(WalletView.container)`. Remove await inside `await Assertions.checkIfVisible()` * e2e/specs/confirmations/approve-custom-erc20.spec.js: Update `Assertions. checkIfHasText()` to `Assertions. checkIfElementToHaveText()`. * e2e/specs/confirmations/increase-allowance-erc20.spec.js: Update `WalletView.checkIfHasText()` to `Assertions. checkIfElementToHaveText()`. * e2e/specs/networks/add-custom-rpc.spec.js: * e2e/specs/networks/connect-test-network.spec.js: Update `WalletView.isVisible()` to `Assertions.checkIfVisible(WalletView.container)`. Update `Assertions. checkIfHasText()` to `Assertions. checkIfElementToHaveText()`. * e2e/specs/onboarding/onboarding-wizard-opt-in.spec.js: Update `pages/wallet/WalletView` file path. Update `WalletView.isVisible()` to `Assertions.checkIfVisible(WalletView.container)`. * e2e/specs/permission-systems/permission-system-delete-wallet.spec.js: Update `pages/wallet/WalletView` file path. Update `WalletView.isVisible()` to `Assertions.checkIfVisible(WalletView.container)`. * e2e/specs/quarantine/add-edit-custom-eth-mainnet.failing.js: Implement `Assertions.checkIfVisible(WalletView.container)`. * e2e/specs/quarantine/contract-nickname.failing.js: Update `pages/wallet/WalletView` file path. Update `WalletView.isVisible()` to `Assertions.checkIfVisible(WalletView.container)`. Implement `Assertions.checkIfVisible(WalletView.container)`. * e2e/specs/quarantine/deeplinks.failing.js: * e2e/specs/quarantine/import-nft.failing.js: Implement `Assertions.checkIfVisible()`. * e2e/specs/quarantine/permission-system-removing-imported-account.failing.js: Update `pages/wallet/WalletView` file path. Update `WalletView.isVisible()` to `Assertions.checkIfVisible(WalletView.container)`. * e2e/specs/settings/fiat-on-testnets.spec.js: Update `pages/wallet/WalletView` file path. Create `WalletView.totalBalance`. Update `Assertions. checkIfHasText()` to `Assertions. checkIfElementToHaveText()`. * e2e/specs/swaps/swap-token-chart.spec.js: Update `pages/wallet/WalletView` file path. Update `WalletView.isVisible()` to `Assertions.checkIfVisible(WalletView.container)`. * e2e/specs/swaps/token-details.spec.js: Update `pages/wallet/WalletView` file path. * e2e/specs/wallet/portfolio-connect-account.spec.js: Update `pages/wallet/WalletView` file path. Update `Assertions. checkIfHasText()` to `Assertions. checkIfElementToHaveText()`. * e2e/specs/wallet/request-token-flow.spec.js: Update `pages/wallet/WalletView` file path. Update `WalletView.isVisible()` to `Assertions.checkIfVisible(WalletView.container)`. * e2e/specs/wallet/send-ERC-token.spec.js: Update `pages/wallet/WalletView` file path. Update `WalletView.isVisible()` to `Assertions.checkIfVisible(WalletView.container)`. * e2e/specs/wallet/start-exploring.spec.js: Remove deprecated steps * e2e/utils/Assertions.js: Remove `checkIfHasText ` method. * e2e/viewHelper.js: Implement `Assertions.checkIfVisible()` for `WalletView` and `NetworkEducationModal `. Add `await Assertions.checkIfVisible(ToastModal.container)` steps * wdio/screen-objects/AddContact.js: Update testIDs to current implementation. * wdio/screen-objects/CommonScreen.js: Update testIDs to current implementation. * wdio/screen-objects/Modals/WalletAccountModal.js: Update testIDs to current implementation. * wdio/screen-objects/WalletMainScreen.js: Update testIDs to current implementation, fix naming issues. * wdio/screen-objects/testIDs/Common.testIds.js: File removed * wdio/screen-objects/testIDs/Screens/WalletView.testIds.js: Walletview testIDs moved to unify file ## **Related issues** Fixes: [#1848](https://github.com/MetaMask/mobile-planning/issues/1848) ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** Smoke test: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/558e5890-c45c-4d8f-bba4-f8c0456cb4d1 Regression test: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/01e5fdff-34cf-4956-b54f-1588c4066139 ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- .../Pickers/PickerAccount/PickerAccount.tsx | 7 +- .../Pickers/PickerNetwork/PickerNetwork.tsx | 7 +- .../components/Toast/Toast.tsx | 6 +- app/components/UI/AccountOverview/index.js | 29 +--- app/components/UI/AddressCopy/AddressCopy.tsx | 8 +- .../UI/CollectibleContracts/index.js | 11 +- app/components/UI/Navbar/index.js | 7 +- app/components/UI/Tokens/index.test.tsx | 10 +- app/components/UI/Tokens/index.tsx | 10 +- .../UI/WalletAccount/WalletAccount.test.tsx | 7 +- .../UI/WalletAccount/WalletAccount.tsx | 12 +- .../AccountActions.constants.ts | 5 - .../AccountActions/AccountActions.test.tsx | 33 ++-- .../Views/AccountActions/AccountActions.tsx | 18 +-- .../Views/TransactionsView/index.js | 6 +- app/components/Views/Wallet/index.test.tsx | 8 +- app/components/Views/Wallet/index.tsx | 3 +- e2e/pages/Send/TransactionConfirmView.js | 2 +- e2e/pages/WalletView.js | 144 ----------------- e2e/pages/wallet/WalletView.js | 145 ++++++++++++++++++ e2e/selectors/Common.selectors.js | 1 + .../Modals/AccountActionsModal.selectors.js | 7 + .../TransactionConfirmView.selectors.js | 1 - e2e/selectors/wallet/WalletView.selectors.js | 13 ++ .../accounts/create-wallet-account.spec.js | 2 +- .../accounts/import-wallet-account.spec.js | 10 +- e2e/specs/assets/import-tokens.spec.js | 9 +- e2e/specs/assets/nft-detection-modal.spec.js | 6 +- .../assets/token-detection-import-all.spec.js | 56 ++++--- .../confirmations/advanced-gas-fees.spec.js | 12 +- .../approve-custom-erc20.spec.js | 2 +- .../increase-allowance-erc20.spec.js | 2 +- e2e/specs/networks/add-custom-rpc.spec.js | 47 ++++-- .../networks/connect-test-network.spec.js | 17 +- .../onboarding-wizard-opt-in.spec.js | 8 +- .../permission-system-delete-wallet.spec.js | 4 +- .../add-edit-custom-eth-mainnet.failing.js | 15 +- .../quarantine/contract-nickname.failing.js | 12 +- e2e/specs/quarantine/deeplinks.failing.js | 64 +++++--- e2e/specs/quarantine/import-nft.failing.js | 12 +- ...ystem-removing-imported-account.failing.js | 5 +- e2e/specs/settings/fiat-on-testnets.spec.js | 10 +- e2e/specs/swaps/swap-token-chart.spec.js | 5 +- e2e/specs/swaps/token-details.spec.js | 2 +- .../wallet/portfolio-connect-account.spec.js | 6 +- e2e/specs/wallet/request-token-flow.spec.js | 4 +- e2e/specs/wallet/send-ERC-token.spec.js | 4 +- e2e/specs/wallet/start-exploring.spec.js | 5 - e2e/utils/Assertions.js | 14 -- e2e/viewHelper.js | 16 +- wdio/screen-objects/AddContact.js | 4 +- wdio/screen-objects/CommonScreen.js | 7 +- .../Modals/WalletAccountModal.js | 13 +- wdio/screen-objects/WalletMainScreen.js | 43 ++---- wdio/screen-objects/testIDs/Common.testIds.js | 3 - .../testIDs/Screens/WalletView.testIds.js | 24 --- 56 files changed, 462 insertions(+), 481 deletions(-) delete mode 100644 app/components/Views/AccountActions/AccountActions.constants.ts delete mode 100644 e2e/pages/WalletView.js create mode 100644 e2e/pages/wallet/WalletView.js create mode 100644 e2e/selectors/Modals/AccountActionsModal.selectors.js delete mode 100644 wdio/screen-objects/testIDs/Common.testIds.js diff --git a/app/component-library/components/Pickers/PickerAccount/PickerAccount.tsx b/app/component-library/components/Pickers/PickerAccount/PickerAccount.tsx index 2f6ee293579..29fdaffa08f 100644 --- a/app/component-library/components/Pickers/PickerAccount/PickerAccount.tsx +++ b/app/component-library/components/Pickers/PickerAccount/PickerAccount.tsx @@ -2,7 +2,7 @@ // Third party dependencies. import React, { forwardRef } from 'react'; -import { Platform, TouchableOpacity, View } from 'react-native'; +import { TouchableOpacity, View } from 'react-native'; // External dependencies. import Avatar, { AvatarSize, AvatarVariant } from '../../Avatars/Avatar'; @@ -15,8 +15,7 @@ import { strings } from '../../../../../locales/i18n'; import PickerBase from '../PickerBase'; import { PickerAccountProps } from './PickerAccount.types'; import styleSheet from './PickerAccount.styles'; -import generateTestId from '../../../../../wdio/utils/generateTestId'; -import { WALLET_ACCOUNT_NAME_LABEL_TEXT } from '../../../../../wdio/screen-objects/testIDs/Screens/WalletView.testIds'; +import { WalletViewSelectorsIDs } from '../../../../../e2e/selectors/wallet/WalletView.selectors'; const PickerAccount: React.ForwardRefRenderFunction< TouchableOpacity, @@ -52,7 +51,7 @@ const PickerAccount: React.ForwardRefRenderFunction< {accountName} diff --git a/app/component-library/components/Pickers/PickerNetwork/PickerNetwork.tsx b/app/component-library/components/Pickers/PickerNetwork/PickerNetwork.tsx index 586c53d09fb..9c4dd1f150a 100644 --- a/app/component-library/components/Pickers/PickerNetwork/PickerNetwork.tsx +++ b/app/component-library/components/Pickers/PickerNetwork/PickerNetwork.tsx @@ -2,7 +2,7 @@ // Third party dependencies. import React from 'react'; -import { Platform, TouchableOpacity } from 'react-native'; +import { TouchableOpacity } from 'react-native'; // External dependencies. import Avatar, { AvatarSize, AvatarVariant } from '../../Avatars/Avatar'; @@ -13,8 +13,7 @@ import { useStyles } from '../../../hooks'; // Internal dependencies. import { PickerNetworkProps } from './PickerNetwork.types'; import stylesheet from './PickerNetwork.styles'; -import generateTestId from '../../../../../wdio/utils/generateTestId'; -import { NAVBAR_NETWORK_TEXT } from '../../../../../wdio/screen-objects/testIDs/Screens/WalletView.testIds'; +import { WalletViewSelectorsIDs } from '../../../../../e2e/selectors/wallet/WalletView.selectors'; import { PICKERNETWORK_ARROW_TESTID } from './PickerNetwork.constants'; const PickerNetwork = ({ @@ -38,7 +37,7 @@ const PickerNetwork = ({ style={styles.label} numberOfLines={1} variant={TextVariant.BodyMD} - {...generateTestId(Platform, NAVBAR_NETWORK_TEXT)} + testID={WalletViewSelectorsIDs.NAVBAR_NETWORK_TEXT} > {label} diff --git a/app/component-library/components/Toast/Toast.tsx b/app/component-library/components/Toast/Toast.tsx index e4a37893279..b7916a32b93 100644 --- a/app/component-library/components/Toast/Toast.tsx +++ b/app/component-library/components/Toast/Toast.tsx @@ -10,7 +10,6 @@ import React, { import { Dimensions, LayoutChangeEvent, - Platform, StyleProp, View, ViewStyle, @@ -39,8 +38,7 @@ import { ToastVariants, } from './Toast.types'; import styles from './Toast.styles'; -import generateTestId from '../../../../wdio/utils/generateTestId'; -import { TOAST_ID } from '../../../../wdio/screen-objects/testIDs/Common.testIds'; +import { ToastSelectorsIDs } from '../../../../e2e/selectors/Modals/ToastModal.selectors'; import { ButtonProps } from '../Buttons/Button/Button.types'; const visibilityDuration = 2750; @@ -210,7 +208,7 @@ const Toast = forwardRef((_, ref: React.ForwardedRef) => { {renderAvatar()} {renderLabel(labelOptions)} {renderButtonLink(linkButtonOptions)} diff --git a/app/components/UI/AccountOverview/index.js b/app/components/UI/AccountOverview/index.js index db383ab313f..b844d7ac534 100644 --- a/app/components/UI/AccountOverview/index.js +++ b/app/components/UI/AccountOverview/index.js @@ -2,7 +2,6 @@ import PropTypes from 'prop-types'; import React, { PureComponent } from 'react'; import { InteractionManager, - Platform, ScrollView, StyleSheet, TextInput, @@ -11,12 +10,7 @@ import { } from 'react-native'; import { connect } from 'react-redux'; import { strings } from '../../../../locales/i18n'; -import { - WALLET_ACCOUNT_ICON, - WALLET_ACCOUNT_NAME_LABEL_INPUT, - WALLET_ACCOUNT_NAME_LABEL_TEXT, -} from '../../../../wdio/screen-objects/testIDs/Screens/WalletView.testIds'; -import generateTestId from '../../../../wdio/utils/generateTestId'; +import { WalletViewSelectorsIDs } from '../../../../e2e/selectors/wallet/WalletView.selectors'; import { showAlert } from '../../../actions/alert'; import { toggleReceiveModal } from '../../../actions/modals'; import { newAssetTransaction } from '../../../actions/transaction'; @@ -168,10 +162,6 @@ class AccountOverview extends PureComponent { */ account: PropTypes.object, /** - /* Selected currency - */ - currentCurrency: PropTypes.string, - /** /* Triggers global alert */ showAlert: PropTypes.func, @@ -187,19 +177,11 @@ class AccountOverview extends PureComponent { * Prompts protect wallet modal */ protectWalletModalVisible: PropTypes.func, - /** - * Start transaction with asset - */ - newAssetTransaction: PropTypes.func, /** /* navigation object required to access the props /* passed by the parent component */ navigation: PropTypes.object, - /** - * Action that toggles the receive modal - */ - toggleReceiveModal: PropTypes.func, /** * The chain ID for the current selected network */ @@ -373,7 +355,7 @@ class AccountOverview extends PureComponent { style={styles.identiconBorder} disabled={onboardingWizard} onPress={this.openAccountSelector} - {...generateTestId(Platform, WALLET_ACCOUNT_ICON)} + testID={WalletViewSelectorsIDs.ACCOUNT_ICON} > {isDefaultAccountName(name) && ens ? ens : name} diff --git a/app/components/UI/AddressCopy/AddressCopy.tsx b/app/components/UI/AddressCopy/AddressCopy.tsx index 4aa60e4b880..17f8dbd1550 100644 --- a/app/components/UI/AddressCopy/AddressCopy.tsx +++ b/app/components/UI/AddressCopy/AddressCopy.tsx @@ -18,10 +18,10 @@ import ClipboardManager from '../../../core/ClipboardManager'; import { showAlert } from '../../../actions/alert'; import { protectWalletModalVisible } from '../../../actions/user'; import { strings } from '../../../../locales/i18n'; -import { Platform, View } from 'react-native'; +import { View } from 'react-native'; import { MetaMetricsEvents } from '../../../core/Analytics'; import { useStyles } from '../../../component-library/hooks'; -import generateTestId from '../../../../wdio/utils/generateTestId'; +import { WalletViewSelectorsIDs } from '../../../../e2e/selectors/wallet/WalletView.selectors'; // Internal dependencies import styleSheet from './AddressCopy.styles'; @@ -75,12 +75,12 @@ const AddressCopy = ({ formatAddressType = 'full' }: AddressCopyProps) => { {selectedInternalAccount ? formatAddress(selectedInternalAccount.address, formatAddressType) diff --git a/app/components/UI/CollectibleContracts/index.js b/app/components/UI/CollectibleContracts/index.js index 866d8b96d7b..d03c8bce4d3 100644 --- a/app/components/UI/CollectibleContracts/index.js +++ b/app/components/UI/CollectibleContracts/index.js @@ -5,7 +5,6 @@ import { StyleSheet, View, Image, - Platform, FlatList, RefreshControl, ActivityIndicator, @@ -30,7 +29,6 @@ import { compareTokenIds } from '../../../util/tokens'; import CollectibleDetectionModal from '../CollectibleDetectionModal'; import { useTheme } from '../../../util/theme'; import { MAINNET } from '../../../constants/network'; -import generateTestId from '../../../../wdio/utils/generateTestId'; import { selectChainId, selectProviderType, @@ -41,10 +39,7 @@ import { selectUseNftDetection, } from '../../../selectors/preferencesController'; import { selectSelectedInternalAccountChecksummedAddress } from '../../../selectors/accountsController'; -import { - IMPORT_NFT_BUTTON_ID, - NFT_TAB_CONTAINER_ID, -} from '../../../../wdio/screen-objects/testIDs/Screens/WalletView.testIds'; +import { WalletViewSelectorsIDs } from '../../../../e2e/selectors/wallet/WalletView.selectors'; import { useMetrics } from '../../../components/hooks/useMetrics'; import { RefreshTestId, SpinnerTestId } from './constants'; @@ -239,7 +234,7 @@ const CollectibleContracts = ({ {strings('wallet.add_collectibles')} @@ -376,7 +371,7 @@ const CollectibleContracts = ({ return ( {renderList()} diff --git a/app/components/UI/Navbar/index.js b/app/components/UI/Navbar/index.js index 53b37cd4c9a..d56aec0c3db 100644 --- a/app/components/UI/Navbar/index.js +++ b/app/components/UI/Navbar/index.js @@ -27,12 +27,10 @@ import Device from '../../../util/device'; import PickerNetwork from '../../../component-library/components/Pickers/PickerNetwork'; import BrowserUrlBar from '../BrowserUrlBar'; import generateTestId from '../../../../wdio/utils/generateTestId'; -import { NAVBAR_NETWORK_BUTTON } from '../../../../wdio/screen-objects/testIDs/Screens/WalletView.testIds'; import { NAV_ANDROID_BACK_BUTTON } from '../../../../wdio/screen-objects/testIDs/Screens/NetworksScreen.testids'; import { ASSET_BACK_BUTTON } from '../../../../wdio/screen-objects/testIDs/Screens/TokenOverviewScreen.testIds'; import { REQUEST_SEARCH_RESULTS_BACK_BUTTON } from '../../../../wdio/screen-objects/testIDs/Screens/RequestToken.testIds'; import { BACK_BUTTON_SIMPLE_WEBVIEW } from '../../../../wdio/screen-objects/testIDs/Components/SimpleWebView.testIds'; -import { EDIT_BUTTON } from '../../../../wdio/screen-objects/testIDs/Common.testIds'; import Routes from '../../../constants/navigation/Routes'; import ButtonIcon, { @@ -53,6 +51,7 @@ import { NetworksViewSelectorsIDs } from '../../../../e2e/selectors/Settings/Net import { SendLinkViewSelectorsIDs } from '../../../../e2e/selectors/SendLinkView.selectors'; import { SendViewSelectorsIDs } from '../../../../e2e/selectors/SendView.selectors'; import { getBlockaidTransactionMetricsParams } from '../../../util/blockaid'; +import { AddContactViewSelectorsIDs } from '../../../../e2e/selectors/Settings/Contacts/AddContactView.selectors'; const trackEvent = (event, params = {}) => { MetaMetrics.getInstance().trackEvent(event, params); @@ -290,7 +289,7 @@ export function getEditableOptions(title, navigation, route, themeColors) { {editMode @@ -984,7 +983,7 @@ export function getWalletNavbarOptions( label={networkName} imageSource={networkImageSource} onPress={onPressTitle} - {...generateTestId(Platform, NAVBAR_NETWORK_BUTTON)} + testID={WalletViewSelectorsIDs.NAVBAR_NETWORK_BUTTON} /> ), diff --git a/app/components/UI/Tokens/index.test.tsx b/app/components/UI/Tokens/index.test.tsx index fafe9d580cc..fd5add52d2b 100644 --- a/app/components/UI/Tokens/index.test.tsx +++ b/app/components/UI/Tokens/index.test.tsx @@ -6,11 +6,7 @@ import { BN } from 'ethereumjs-util'; import renderWithProvider from '../../../util/test/renderWithProvider'; import { createStackNavigator } from '@react-navigation/stack'; import Engine from '../../../core/Engine'; -import { - getAssetTestId, - IMPORT_TOKEN_BUTTON_ID, - MAIN_WALLET_VIEW_VIA_TOKENS_ID, -} from '../../../../wdio/screen-objects/testIDs/Screens/WalletView.testIds'; +import { getAssetTestId } from '../../../../wdio/screen-objects/testIDs/Screens/WalletView.testIds'; import { backgroundState } from '../../../util/test/initial-root-state'; import { strings } from '../../../../locales/i18n'; import AppConstants from '../../../../app/core/AppConstants'; @@ -173,14 +169,14 @@ describe('Tokens', () => { it('navigates to AddAsset screen when Add Tokens button is pressed', () => { const { getByTestId } = renderComponent(initialState); - fireEvent.press(getByTestId(IMPORT_TOKEN_BUTTON_ID)); + fireEvent.press(getByTestId(WalletViewSelectorsIDs.IMPORT_TOKEN_BUTTON)); expect(mockPush).toHaveBeenCalledWith('AddAsset', { assetType: 'token' }); }); it('shows remove menu when remove button is pressed', () => { const { getByTestId, queryAllByTestId } = renderComponent(initialState); fireEvent.press(queryAllByTestId(getAssetTestId('BAT'))[0], 'longPress'); - expect(getByTestId(MAIN_WALLET_VIEW_VIA_TOKENS_ID)).toBeDefined(); + expect(getByTestId(WalletViewSelectorsIDs.TOKENS_CONTAINER)).toBeDefined(); }); it('fiat balance must be defined', () => { diff --git a/app/components/UI/Tokens/index.tsx b/app/components/UI/Tokens/index.tsx index 783e9768408..326f9156999 100644 --- a/app/components/UI/Tokens/index.tsx +++ b/app/components/UI/Tokens/index.tsx @@ -3,7 +3,6 @@ import React, { useRef, useState, LegacyRef } from 'react'; import { TouchableOpacity, View, - Platform, FlatList, RefreshControl, Pressable, @@ -34,11 +33,6 @@ import { isMainnetByChainId, isTestNet, } from '../../../util/networks'; -import generateTestId from '../../../../wdio/utils/generateTestId'; -import { - IMPORT_TOKEN_BUTTON_ID, - MAIN_WALLET_VIEW_VIA_TOKENS_ID, -} from '../../../../wdio/screen-objects/testIDs/Screens/WalletView.testIds'; import { selectChainId, selectNetworkClientId, @@ -289,7 +283,7 @@ const Tokens: React.FC = ({ tokens }) => { style={styles.add} onPress={goToAddToken} disabled={!isAddTokenEnabled} - {...generateTestId(Platform, IMPORT_TOKEN_BUTTON_ID)} + testID={WalletViewSelectorsIDs.IMPORT_TOKEN_BUTTON} > @@ -717,7 +711,7 @@ const Tokens: React.FC = ({ tokens }) => { return ( {tokens?.length ? renderList() : renderEmpty()} { const { getByTestId } = renderWithProvider(, { state: mockInitialState, }); - expect(getByTestId('wallet-account-address')).toBeDefined(); + expect(getByTestId(WalletViewSelectorsIDs.ACCOUNT_ADDRESS)).toBeDefined(); }); it('copies the account address to the clipboard when the copy button is pressed', async () => { @@ -119,7 +120,7 @@ describe('WalletAccount', () => { state: mockInitialState, }); - fireEvent.press(getByTestId('wallet-account-copy-button')); + fireEvent.press(getByTestId(WalletViewSelectorsIDs.ACCOUNT_COPY_BUTTON)); expect(ClipboardManager.setString).toHaveBeenCalledTimes(1); }); @@ -128,7 +129,7 @@ describe('WalletAccount', () => { state: mockInitialState, }); - fireEvent.press(getByTestId('account-picker')); + fireEvent.press(getByTestId(WalletViewSelectorsIDs.ACCOUNT_ICON)); expect(mockNavigate).toHaveBeenCalledWith( ...createAccountSelectorNavDetails({}), ); diff --git a/app/components/UI/WalletAccount/WalletAccount.tsx b/app/components/UI/WalletAccount/WalletAccount.tsx index cae1ad1516c..c6996c325dc 100644 --- a/app/components/UI/WalletAccount/WalletAccount.tsx +++ b/app/components/UI/WalletAccount/WalletAccount.tsx @@ -2,7 +2,7 @@ import React, { forwardRef, useImperativeHandle, useMemo, useRef } from 'react'; import { useSelector } from 'react-redux'; import { useNavigation } from '@react-navigation/native'; -import { Platform, View } from 'react-native'; +import { View } from 'react-native'; // External dependencies import { IconName } from '../../../component-library/components/Icons/Icon'; @@ -10,16 +10,12 @@ import PickerAccount from '../../../component-library/components/Pickers/PickerA import { AvatarAccountType } from '../../../component-library/components/Avatars/Avatar/variants/AvatarAccount'; import { createAccountSelectorNavDetails } from '../../../components/Views/AccountSelector'; import { useStyles } from '../../../component-library/hooks'; -import generateTestId from '../../../../wdio/utils/generateTestId'; import AddressCopy from '../AddressCopy'; import { isDefaultAccountName } from '../../../util/ENSUtils'; import ButtonIcon from '../../../component-library/components/Buttons/ButtonIcon/ButtonIcon'; import { ButtonIconSizes } from '../../../component-library/components/Buttons/ButtonIcon'; import Routes from '../../../constants/navigation/Routes'; -import { - WALLET_ACCOUNT_ICON, - MAIN_WALLET_ACCOUNT_ACTIONS, -} from '../../../../wdio/screen-objects/testIDs/Screens/WalletView.testIds'; +import { WalletViewSelectorsIDs } from '../../../../e2e/selectors/wallet/WalletView.selectors'; import { getLabelTextByAddress } from '../../../util/address'; import { selectSelectedInternalAccount } from '../../../selectors/accountsController'; import useEnsNameByAddress from '../../../components/hooks/useEnsNameByAddress'; @@ -88,7 +84,7 @@ const WalletAccount = ({ style }: WalletAccountProps, ref: React.Ref) => { showAddress={false} cellAccountContainerStyle={styles.account} style={styles.accountPicker} - {...generateTestId(Platform, WALLET_ACCOUNT_ICON)} + testID={WalletViewSelectorsIDs.ACCOUNT_ICON} /> @@ -97,7 +93,7 @@ const WalletAccount = ({ style }: WalletAccountProps, ref: React.Ref) => { iconName={IconName.MoreHorizontal} size={ButtonIconSizes.Sm} onPress={onNavigateToAccountActions} - {...generateTestId(Platform, MAIN_WALLET_ACCOUNT_ACTIONS)} + testID={WalletViewSelectorsIDs.ACCOUNT_ACTIONS} /> diff --git a/app/components/Views/AccountActions/AccountActions.constants.ts b/app/components/Views/AccountActions/AccountActions.constants.ts deleted file mode 100644 index 1041c9a6af1..00000000000 --- a/app/components/Views/AccountActions/AccountActions.constants.ts +++ /dev/null @@ -1,5 +0,0 @@ -// Test IDs -export const EDIT_ACCOUNT = 'edit-account-action'; -export const VIEW_ETHERSCAN = 'view-etherscan-action'; -export const SHARE_ADDRESS = 'share-address-action'; -export const SHOW_PRIVATE_KEY = 'show-private-key-action'; diff --git a/app/components/Views/AccountActions/AccountActions.test.tsx b/app/components/Views/AccountActions/AccountActions.test.tsx index 7fd5fc6d35a..891f077f7a4 100644 --- a/app/components/Views/AccountActions/AccountActions.test.tsx +++ b/app/components/Views/AccountActions/AccountActions.test.tsx @@ -8,12 +8,7 @@ import renderWithProvider from '../../../util/test/renderWithProvider'; import Engine from '../../../core/Engine'; import Routes from '../../../constants/navigation/Routes'; import AccountActions from './AccountActions'; -import { - EDIT_ACCOUNT, - SHARE_ADDRESS, - SHOW_PRIVATE_KEY, - VIEW_ETHERSCAN, -} from './AccountActions.constants'; +import { AccountActionsModalSelectorsIDs } from '../../../../e2e/selectors/Modals/AccountActionsModal.selectors'; import { backgroundState } from '../../../util/test/initial-root-state'; import { MOCK_ACCOUNTS_CONTROLLER_STATE, @@ -77,10 +72,18 @@ describe('AccountActions', () => { state: initialState, }); - expect(getByTestId(EDIT_ACCOUNT)).toBeDefined(); - expect(getByTestId(VIEW_ETHERSCAN)).toBeDefined(); - expect(getByTestId(SHARE_ADDRESS)).toBeDefined(); - expect(getByTestId(SHOW_PRIVATE_KEY)).toBeDefined(); + expect( + getByTestId(AccountActionsModalSelectorsIDs.EDIT_ACCOUNT), + ).toBeDefined(); + expect( + getByTestId(AccountActionsModalSelectorsIDs.VIEW_ETHERSCAN), + ).toBeDefined(); + expect( + getByTestId(AccountActionsModalSelectorsIDs.SHARE_ADDRESS), + ).toBeDefined(); + expect( + getByTestId(AccountActionsModalSelectorsIDs.SHOW_PRIVATE_KEY), + ).toBeDefined(); }); it('navigates to webview when View on Etherscan is clicked', () => { @@ -88,7 +91,9 @@ describe('AccountActions', () => { state: initialState, }); - fireEvent.press(getByTestId(VIEW_ETHERSCAN)); + fireEvent.press( + getByTestId(AccountActionsModalSelectorsIDs.VIEW_ETHERSCAN), + ); expect(mockNavigate).toHaveBeenCalledWith('Webview', { screen: 'SimpleWebview', @@ -104,7 +109,7 @@ describe('AccountActions', () => { state: initialState, }); - fireEvent.press(getByTestId(SHARE_ADDRESS)); + fireEvent.press(getByTestId(AccountActionsModalSelectorsIDs.SHARE_ADDRESS)); expect(Share.open).toHaveBeenCalledWith({ message: toChecksumHexAddress(MOCK_ADDRESS_2), @@ -116,7 +121,9 @@ describe('AccountActions', () => { state: initialState, }); - fireEvent.press(getByTestId(SHOW_PRIVATE_KEY)); + fireEvent.press( + getByTestId(AccountActionsModalSelectorsIDs.SHOW_PRIVATE_KEY), + ); expect(mockNavigate).toHaveBeenCalledWith( Routes.SETTINGS.REVEAL_PRIVATE_CREDENTIAL, diff --git a/app/components/Views/AccountActions/AccountActions.tsx b/app/components/Views/AccountActions/AccountActions.tsx index a0d387b1fcc..6b0f0312877 100644 --- a/app/components/Views/AccountActions/AccountActions.tsx +++ b/app/components/Views/AccountActions/AccountActions.tsx @@ -1,6 +1,6 @@ // Third party dependencies. import React, { useMemo, useRef } from 'react'; -import { Platform, View } from 'react-native'; +import { View } from 'react-native'; import { useNavigation } from '@react-navigation/native'; import { useDispatch, useSelector } from 'react-redux'; import Share from 'react-native-share'; @@ -34,13 +34,7 @@ import styleSheet from './AccountActions.styles'; import Logger from '../../../util/Logger'; import { protectWalletModalVisible } from '../../../actions/user'; import Routes from '../../../constants/navigation/Routes'; -import generateTestId from '../../../../wdio/utils/generateTestId'; -import { - EDIT_ACCOUNT, - SHARE_ADDRESS, - SHOW_PRIVATE_KEY, - VIEW_ETHERSCAN, -} from './AccountActions.constants'; +import { AccountActionsModalSelectorsIDs } from '../../../../e2e/selectors/Modals/AccountActionsModal.selectors'; import { useMetrics } from '../../../components/hooks/useMetrics'; const AccountActions = () => { @@ -144,7 +138,7 @@ const AccountActions = () => { actionTitle={strings('account_actions.edit_name')} iconName={IconName.Edit} onPress={goToEditAccountName} - {...generateTestId(Platform, EDIT_ACCOUNT)} + testID={AccountActionsModalSelectorsIDs.EDIT_ACCOUNT} /> {isExplorerVisible && ( { } iconName={IconName.Export} onPress={viewInEtherscan} - {...generateTestId(Platform, VIEW_ETHERSCAN)} + testID={AccountActionsModalSelectorsIDs.VIEW_ETHERSCAN} /> )} diff --git a/app/components/Views/TransactionsView/index.js b/app/components/Views/TransactionsView/index.js index 9f6ece59d3f..4f60b3fb2d5 100644 --- a/app/components/Views/TransactionsView/index.js +++ b/app/components/Views/TransactionsView/index.js @@ -28,7 +28,6 @@ import { selectCurrentCurrency, } from '../../../selectors/currencyRateController'; import { selectTokens } from '../../../selectors/tokensController'; -import { WalletViewSelectorsIDs } from '../../../../e2e/selectors/wallet/WalletView.selectors'; import { selectSelectedInternalAccount } from '../../../selectors/accountsController'; import { store } from '../../../store'; import { NETWORK_ID_LOADING } from '../../../core/redux/slices/inpageProvider'; @@ -162,10 +161,7 @@ const TransactionsView = ({ }, [filterTransactions]); return ( - + { }); it('should render scan qr icon', () => { render(Wallet); - const scanButton = screen.getByTestId('wallet-scan-button'); + const scanButton = screen.getByTestId( + WalletViewSelectorsIDs.WALLET_SCAN_BUTTON, + ); expect(scanButton).toBeDefined(); }); it('should render ScrollableTabView', () => { @@ -147,7 +151,7 @@ describe('Wallet', () => { }); it('should render fox icon', () => { render(Wallet); - const foxIcon = screen.getByTestId('fox-icon'); + const foxIcon = screen.getByTestId(CommonSelectorsIDs.FOX_ICON); expect(foxIcon).toBeDefined(); }); }); diff --git a/app/components/Views/Wallet/index.tsx b/app/components/Views/Wallet/index.tsx index a77d9d97d81..59fe8f6090d 100644 --- a/app/components/Views/Wallet/index.tsx +++ b/app/components/Views/Wallet/index.tsx @@ -45,7 +45,6 @@ import { getIsNetworkOnboarded, isMainNet, } from '../../../util/networks'; -import generateTestId from '../../../../wdio/utils/generateTestId'; import { selectProviderConfig, selectTicker, @@ -589,7 +588,7 @@ const Wallet = ({ return ( - + {selectedAddress ? renderContent() : renderLoader()} {renderOnboardingWizard()} diff --git a/e2e/pages/Send/TransactionConfirmView.js b/e2e/pages/Send/TransactionConfirmView.js index 59dc11cb5c5..73c218a64e4 100644 --- a/e2e/pages/Send/TransactionConfirmView.js +++ b/e2e/pages/Send/TransactionConfirmView.js @@ -72,7 +72,7 @@ class TransactionConfirmationView { } async tapConfirmButton() { - await Gestures.waitAndTap(await this.confirmButton); + await Gestures.waitAndTap(this.confirmButton); } async tapCancelButton() { diff --git a/e2e/pages/WalletView.js b/e2e/pages/WalletView.js deleted file mode 100644 index 4dcaa4df454..00000000000 --- a/e2e/pages/WalletView.js +++ /dev/null @@ -1,144 +0,0 @@ -import TestHelpers from '../helpers'; - -import { - IMPORT_NFT_BUTTON_ID, - IMPORT_TOKEN_BUTTON_ID, - NAVBAR_NETWORK_BUTTON, - NAVBAR_NETWORK_TEXT, - NFT_TAB_CONTAINER_ID, - WALLET_ACCOUNT_ICON, - WALLET_ACCOUNT_NAME_LABEL_INPUT, -} from '../../wdio/screen-objects/testIDs/Screens/WalletView.testIds'; -import { - WalletViewSelectorsIDs, - WalletViewSelectorsText, -} from '../selectors/wallet/WalletView.selectors'; -import { CommonSelectorsText } from '../selectors/Common.selectors'; -import Gestures from '../utils/Gestures'; -import Matchers from '../utils/Matchers'; - -class WalletView { - get container() { - return Matchers.getElementByID(WalletViewSelectorsIDs.WALLET_CONTAINER); - } - - get portfolioButton() { - return Matchers.getElementByID(WalletViewSelectorsIDs.PORTFOLIO_BUTTON); - } - - get tokenDetectionLinkButton() { - return Matchers.getElementByID( - WalletViewSelectorsIDs.WALLET_TOKEN_DETECTION_LINK_BUTTON, - ); - } - - async tapOKAlertButton() { - await TestHelpers.tapAlertWithButton(CommonSelectorsText.OK_ALERT_BUTTON); // system alert. - } - - async tapOnToken(token) { - await TestHelpers.waitAndTapText( - token || WalletViewSelectorsText.DEFAULT_TOKEN, - ); - } - - async tapIdenticon() { - await TestHelpers.waitAndTap(WALLET_ACCOUNT_ICON); - } - - async tapNetworksButtonOnNavBar() { - await TestHelpers.waitAndTap(NAVBAR_NETWORK_BUTTON); - } - - async isConnectedNetwork(value) { - await TestHelpers.checkIfHasText(NAVBAR_NETWORK_TEXT, value); - } - - async tapNftTab() { - await TestHelpers.tapByText(WalletViewSelectorsText.NFTS_TAB); - } - - async tapTokensTab() { - await TestHelpers.tapByText(WalletViewSelectorsText.TOKENS_TAB); - } - - async scrollDownOnNFTsTab() { - await TestHelpers.swipe(NFT_TAB_CONTAINER_ID, 'up', 'slow', 0.6); - } - - async scrollUpOnNFTsTab() { - await TestHelpers.swipe(NFT_TAB_CONTAINER_ID, 'down', 'slow', 0.6); - } - - async tapImportNFTButton() { - await TestHelpers.tap(IMPORT_NFT_BUTTON_ID); - } - - async tapImportTokensButton() { - await TestHelpers.delay(2000); - if (device.getPlatform() === 'android') { - await TestHelpers.tapByText(WalletViewSelectorsText.IMPORT_TOKENS); - } else { - await TestHelpers.tap(IMPORT_TOKEN_BUTTON_ID); - } - } - - async tapOnNFTInWallet(nftName) { - await TestHelpers.tapByText(nftName); - } - - async removeTokenFromWallet(token) { - await element(by.text(token)).longPress(); - await TestHelpers.tapByText(WalletViewSelectorsText.HIDE_TOKENS); - } - - async isVisible() { - if (!device.getPlatform() === 'android') { - // Check that we are on the wallet screen - await TestHelpers.checkIfExists(WalletViewSelectorsIDs.WALLET_CONTAINER); - } - } - - async isTokenVisibleInWallet(tokenName) { - await TestHelpers.checkIfElementByTextIsVisible(tokenName); - } - - async tokenIsNotVisibleInWallet(tokenName) { - await TestHelpers.checkIfElementWithTextIsNotVisible(tokenName); - } - - async isNFTVisibleInWallet(nftName) { - await TestHelpers.checkIfElementByTextIsVisible(nftName); - } - - async isNFTNameVisible(nftName) { - await TestHelpers.checkIfElementHasString( - WalletViewSelectorsIDs.NFT_CONTAINER, - nftName, - ); - } - - async isNetworkNameVisible(networkName) { - await TestHelpers.checkIfElementHasString( - WalletViewSelectorsIDs.NETWORK_NAME, - networkName, - ); - } - - async isAccountNameCorrect(accountName) { - await TestHelpers.checkIfElementHasString( - WALLET_ACCOUNT_NAME_LABEL_INPUT, - accountName, - ); - } - - async tapNewTokensFound() { - await Gestures.waitAndTap(this.tokenDetectionLinkButton); - } - - async tapPortfolio() { - await Gestures.waitAndTap(this.portfolioButton); - } -} - -export default new WalletView(); diff --git a/e2e/pages/wallet/WalletView.js b/e2e/pages/wallet/WalletView.js new file mode 100644 index 00000000000..49d8cb692d7 --- /dev/null +++ b/e2e/pages/wallet/WalletView.js @@ -0,0 +1,145 @@ +import { + WalletViewSelectorsIDs, + WalletViewSelectorsText, +} from '../../selectors/wallet/WalletView.selectors'; +import { CommonSelectorsText } from '../../selectors/Common.selectors'; +import Gestures from '../../utils/Gestures'; +import Matchers from '../../utils/Matchers'; + +class WalletView { + get container() { + return Matchers.getElementByID(WalletViewSelectorsIDs.WALLET_CONTAINER); + } + + get portfolioButton() { + return Matchers.getElementByID(WalletViewSelectorsIDs.PORTFOLIO_BUTTON); + } + + get tokenDetectionLinkButton() { + return Matchers.getElementByID( + WalletViewSelectorsIDs.WALLET_TOKEN_DETECTION_LINK_BUTTON, + ); + } + + get okAlertButton() { + return Matchers.getElementByText(CommonSelectorsText.OK_ALERT_BUTTON); + } + + get accountIcon() { + return Matchers.getElementByID(WalletViewSelectorsIDs.ACCOUNT_ICON); + } + + get navbarNetworkText() { + return Matchers.getElementByID(WalletViewSelectorsIDs.NAVBAR_NETWORK_TEXT); + } + + get navbarNetworkButton() { + return Matchers.getElementByID( + WalletViewSelectorsIDs.NAVBAR_NETWORK_BUTTON, + ); + } + + get nftTab() { + return Matchers.getElementByText(WalletViewSelectorsText.NFTS_TAB); + } + + get nftTabContainer() { + return Matchers.getElementByID(WalletViewSelectorsIDs.NFT_TAB_CONTAINER); + } + + get importNFTButton() { + return Matchers.getElementByID(WalletViewSelectorsIDs.IMPORT_NFT_BUTTON); + } + + get importTokensButton() { + return device.getPlatform() === 'android' + ? Matchers.getElementByText(WalletViewSelectorsText.IMPORT_TOKENS) + : Matchers.getElementByID(WalletViewSelectorsIDs.IMPORT_TOKEN_BUTTON); + } + + get networkName() { + return Matchers.getElementByID(WalletViewSelectorsIDs.NETWORK_NAME); + } + + get totalBalance() { + return Matchers.getElementByID(WalletViewSelectorsIDs.TOTAL_BALANCE_TEXT); + } + + get accountName() { + return Matchers.getElementByID( + WalletViewSelectorsIDs.ACCOUNT_NAME_LABEL_TEXT, + ); + } + + get hideTokensLabel() { + return Matchers.getElementByText(WalletViewSelectorsText.HIDE_TOKENS); + } + + async tapOKAlertButton() { + await Gestures.waitAndTap(this.okAlertButton); + } + + async tapOnToken(token) { + const element = Matchers.getElementByText( + token || WalletViewSelectorsText.DEFAULT_TOKEN, + ); + await Gestures.waitAndTap(element); + } + + async tapIdenticon() { + await Gestures.waitAndTap(this.accountIcon); + } + + async tapNetworksButtonOnNavBar() { + await Gestures.waitAndTap(this.navbarNetworkButton); + } + + async tapNftTab() { + await Gestures.waitAndTap(this.nftTab); + } + + async scrollDownOnNFTsTab() { + await Gestures.swipe(this.nftTabContainer, 'up', 'slow', 0.6); + } + + async scrollUpOnNFTsTab() { + await Gestures.swipe(this.nftTabContainer, 'down', 'slow', 0.6); + } + + async tapImportNFTButton() { + await Gestures.waitAndTap(this.importNFTButton); + } + + async tapImportTokensButton() { + await Gestures.waitAndTap(this.importTokensButton); + } + + async tapOnNFTInWallet(nftName) { + const elem = Matchers.getElementByText(nftName); + await Gestures.waitAndTap(elem); + } + + async removeTokenFromWallet(token) { + const elem = Matchers.getElementByText(token); + await Gestures.tapAndLongPress(elem); + await Gestures.waitAndTap(this.hideTokensLabel); + } + + async tokenInWallet(tokenName) { + return Matchers.getElementByText(tokenName); + } + + async nftInWallet(nftName) { + return Matchers.getElementByText(nftName); + } + + async tapNewTokensFound() { + await Gestures.waitAndTap(this.tokenDetectionLinkButton); + } + + async tapPortfolio() { + await Gestures.waitAndTap(this.portfolioButton); + } +} + +export default new WalletView(); diff --git a/e2e/selectors/Common.selectors.js b/e2e/selectors/Common.selectors.js index 797c8df89f2..1e98c4c559e 100644 --- a/e2e/selectors/Common.selectors.js +++ b/e2e/selectors/Common.selectors.js @@ -14,6 +14,7 @@ export const CommonSelectorsIDs = { FOX_SCREEN: 'fox-screen', NAVBAR_TITLE_NETWORKS_TEXT: 'navbar-title-networks', STATUS_CONFIRMED: 'status-confirmed-text', + ANDROID_PROGRESS_BAR: 'android.widget.ProgressBar', }; export const CommonSelectorsText = { diff --git a/e2e/selectors/Modals/AccountActionsModal.selectors.js b/e2e/selectors/Modals/AccountActionsModal.selectors.js new file mode 100644 index 00000000000..69127fb8436 --- /dev/null +++ b/e2e/selectors/Modals/AccountActionsModal.selectors.js @@ -0,0 +1,7 @@ +// eslint-disable-next-line import/prefer-default-export +export const AccountActionsModalSelectorsIDs = { + EDIT_ACCOUNT: 'edit-account-action', + VIEW_ETHERSCAN: 'view-etherscan-action', + SHARE_ADDRESS: 'share-address-action', + SHOW_PRIVATE_KEY: 'show-private-key-action', +}; diff --git a/e2e/selectors/TransactionConfirmView.selectors.js b/e2e/selectors/TransactionConfirmView.selectors.js index e6cd712b7a4..2ca017253e5 100644 --- a/e2e/selectors/TransactionConfirmView.selectors.js +++ b/e2e/selectors/TransactionConfirmView.selectors.js @@ -1,6 +1,5 @@ import enContent from '../../locales/languages/en.json'; -// eslint-disable-next-line import/prefer-default-export export const TransactionConfirmViewSelectorsIDs = { COMFIRM_TXN_AMOUNT: 'confirm-txn-amount', TRANSACTION_VIEW_CONTAINER_ID: 'txn-confirm-screen', diff --git a/e2e/selectors/wallet/WalletView.selectors.js b/e2e/selectors/wallet/WalletView.selectors.js index 13641f781c1..add1b222bdc 100644 --- a/e2e/selectors/wallet/WalletView.selectors.js +++ b/e2e/selectors/wallet/WalletView.selectors.js @@ -10,6 +10,19 @@ export const WalletViewSelectorsIDs = { PORTFOLIO_BUTTON: 'portfolio-button', TOTAL_BALANCE_TEXT: 'total-balance-text', STAKE_BUTTON: 'stake-button', + IMPORT_NFT_BUTTON: 'import-collectible-button', + IMPORT_TOKEN_BUTTON: 'import-token-button', + NAVBAR_NETWORK_BUTTON: 'open-networks-button', + NAVBAR_NETWORK_TEXT: 'open-networks-text', + NFT_TAB_CONTAINER: 'collectible-contracts', + ACCOUNT_ICON: 'account-picker', + ACCOUNT_NAME_LABEL_INPUT: 'account-label-text-input', + ACCOUNT_NAME_LABEL_TEXT: 'account-label', + TOKENS_CONTAINER: 'tokens', + ACCOUNT_OVERVIEW: 'account-overview', + ACCOUNT_ACTIONS: 'main-wallet-account-actions', + ACCOUNT_COPY_BUTTON: 'wallet-account-copy-button', + ACCOUNT_ADDRESS: 'wallet-account-address', }; export const WalletViewSelectorsText = { diff --git a/e2e/specs/accounts/create-wallet-account.spec.js b/e2e/specs/accounts/create-wallet-account.spec.js index 431ffb86914..b13d5b2a07f 100644 --- a/e2e/specs/accounts/create-wallet-account.spec.js +++ b/e2e/specs/accounts/create-wallet-account.spec.js @@ -1,6 +1,6 @@ 'use strict'; import { SmokeAccounts } from '../../tags'; -import WalletView from '../../pages/WalletView'; +import WalletView from '../../pages/wallet/WalletView'; import { importWalletWithRecoveryPhrase } from '../../viewHelper'; import AccountListView from '../../pages/AccountListView'; diff --git a/e2e/specs/accounts/import-wallet-account.spec.js b/e2e/specs/accounts/import-wallet-account.spec.js index 381ff25ee85..b61ff03f3e6 100644 --- a/e2e/specs/accounts/import-wallet-account.spec.js +++ b/e2e/specs/accounts/import-wallet-account.spec.js @@ -1,9 +1,10 @@ 'use strict'; import { SmokeAccounts } from '../../tags'; -import WalletView from '../../pages/WalletView'; +import WalletView from '../../pages/wallet/WalletView'; import { importWalletWithRecoveryPhrase } from '../../viewHelper'; import AccountListView from '../../pages/AccountListView'; import ImportAccountView from '../../pages/ImportAccountView'; +import Assertions from '../../utils/Assertions'; describe(SmokeAccounts('Import account via private to wallet'), () => { // This key is for testing private key import only @@ -33,7 +34,10 @@ describe(SmokeAccounts('Import account via private to wallet'), () => { await ImportAccountView.isImportSuccessSreenVisible(); await ImportAccountView.tapCloseButtonOnImportSuccess(); await AccountListView.swipeToDimssAccountsModal(); - await WalletView.isVisible(); - await WalletView.isAccountNameCorrect('Account 3'); + await Assertions.checkIfVisible(WalletView.container); + await Assertions.checkIfElementNotToHaveText( + WalletView.accountName, + 'Account 1', + ); }); }); diff --git a/e2e/specs/assets/import-tokens.spec.js b/e2e/specs/assets/import-tokens.spec.js index f85b160f879..511a9adf1d9 100644 --- a/e2e/specs/assets/import-tokens.spec.js +++ b/e2e/specs/assets/import-tokens.spec.js @@ -1,7 +1,7 @@ 'use strict'; import { SmokeAssets } from '../../tags'; import TestHelpers from '../../helpers'; -import WalletView from '../../pages/WalletView'; +import WalletView from '../../pages/wallet/WalletView'; import ImportTokensView from '../../pages/ImportTokensView'; import FixtureBuilder from '../../fixtures/fixture-builder'; import { @@ -13,6 +13,7 @@ import { getFixturesServerPort } from '../../fixtures/utils'; import FixtureServer from '../../fixtures/fixture-server'; import { loginToApp } from '../../viewHelper'; import ConfirmAddAssetView from '../../pages/ConfirmAddAsset'; +import Assertions from '../../utils/Assertions'; const fixtureServer = new FixtureServer(); @@ -46,9 +47,9 @@ describe(SmokeAssets('Import Tokens'), () => { await ConfirmAddAssetView.tapOnConfirmButton(); - await WalletView.isVisible(); + await Assertions.checkIfVisible(WalletView.container); await TestHelpers.delay(8000); // to prevent flakey behavior in bitrise - await WalletView.isTokenVisibleInWallet('0 SNX'); + await Assertions.checkIfVisible(WalletView.tokenInWallet('0 SNX')); }); it('should cancel add a token via token autocomplete', async () => { @@ -72,6 +73,6 @@ describe(SmokeAssets('Import Tokens'), () => { it('should hide token from Wallet view', async () => { await WalletView.removeTokenFromWallet('0 SNX'); await TestHelpers.delay(1500); - await WalletView.tokenIsNotVisibleInWallet('SNX'); + await Assertions.checkIfNotVisible(WalletView.tokenInWallet('SNX')); }); }); diff --git a/e2e/specs/assets/nft-detection-modal.spec.js b/e2e/specs/assets/nft-detection-modal.spec.js index 77893af2d3d..fe6cb9d0b21 100644 --- a/e2e/specs/assets/nft-detection-modal.spec.js +++ b/e2e/specs/assets/nft-detection-modal.spec.js @@ -1,5 +1,5 @@ 'use strict'; -import WalletView from '../../pages/WalletView'; +import WalletView from '../../pages/wallet/WalletView'; import { loginToApp } from '../../viewHelper'; import FixtureBuilder from '../../fixtures/fixture-builder'; import { @@ -44,7 +44,7 @@ describe(SmokeAssets('NFT Detection Modal'), () => { await Assertions.checkIfVisible(NftDetectionModal.container); await NftDetectionModal.tapCancelButton(); // Check that we are on the wallet screen - await WalletView.isVisible(); + await Assertions.checkIfVisible(WalletView.container); // Go to NFTs tab and check that the banner is visible await WalletView.tapNftTab(); @@ -80,7 +80,7 @@ describe(SmokeAssets('NFT Detection Modal'), () => { await Assertions.checkIfVisible(NftDetectionModal.container); await NftDetectionModal.tapAllowButton(); // Check that we are on the wallet screen - await WalletView.isVisible(); + await Assertions.checkIfVisible(WalletView.container); // Go to NFTs tab and check that the banner is NOT visible await WalletView.tapNftTab(); diff --git a/e2e/specs/assets/token-detection-import-all.spec.js b/e2e/specs/assets/token-detection-import-all.spec.js index b13a2c42593..b9b400055db 100644 --- a/e2e/specs/assets/token-detection-import-all.spec.js +++ b/e2e/specs/assets/token-detection-import-all.spec.js @@ -1,38 +1,44 @@ 'use strict'; -import { importWalletWithRecoveryPhrase } from '../../viewHelper'; +import { loginToApp } from '../../viewHelper'; import { SmokeAssets } from '../../tags'; -import WalletView from '../../pages/WalletView'; +import WalletView from '../../pages/wallet/WalletView'; import DetectedTokensView from '../../pages/wallet/DetectedTokensView'; import Assertions from '../../utils/Assertions'; +import TestHelpers from '../../helpers'; +import FixtureBuilder from '../../fixtures/fixture-builder'; +import { withFixtures } from '../../fixtures/fixture-helper'; describe(SmokeAssets('Import all tokens detected'), () => { beforeAll(async () => { - await device.launchApp(); - }); - - it('should import wallet and go to the wallet view', async () => { - await importWalletWithRecoveryPhrase(); + jest.setTimeout(150000); + await TestHelpers.reverseServerPort(); }); it('should import all tokens detected', async () => { - await WalletView.tapNewTokensFound(); - await DetectedTokensView.tapImport(); - }); - - it('should land on wallet view after tokens detected', async () => { - await WalletView.isVisible(); - }); + await withFixtures( + { + fixture: new FixtureBuilder().build(), + restartDevice: true, + }, + async () => { + await loginToApp(); + await WalletView.tapNewTokensFound(); + await DetectedTokensView.tapImport(); + await Assertions.checkIfVisible(WalletView.container); - it('should show toast alert for tokens imported', async () => { - try { - await Assertions.checkIfTextIsDisplayed('Imported Tokens', 6000); - await Assertions.checkIfTextIsDisplayed( - 'Successfully imported WETH', - 6000, - ); - } catch (e) { - // eslint-disable-next-line no-console - console.log(`Toast message is slow to appear or did not appear: ${e}`); - } + try { + await Assertions.checkIfTextIsDisplayed('Imported Tokens', 6000); + await Assertions.checkIfTextIsDisplayed( + 'Successfully imported WETH', + 6000, + ); + } catch (e) { + // eslint-disable-next-line no-console + console.log( + `Toast message is slow to appear or did not appear: ${e}`, + ); + } + }, + ); }); }); diff --git a/e2e/specs/confirmations/advanced-gas-fees.spec.js b/e2e/specs/confirmations/advanced-gas-fees.spec.js index 24c63da4812..415179891b8 100644 --- a/e2e/specs/confirmations/advanced-gas-fees.spec.js +++ b/e2e/specs/confirmations/advanced-gas-fees.spec.js @@ -1,6 +1,6 @@ 'use strict'; import { SmokeConfirmations } from '../../tags'; -import WalletView from '../../pages/WalletView'; +import WalletView from '../../pages/wallet/WalletView'; import AmountView from '../../pages/Send/AmountView'; import SendView from '../../pages/Send/SendView'; import TransactionConfirmationView from '../../pages/Send/TransactionConfirmView'; @@ -35,7 +35,7 @@ describe(SmokeConfirmations('Advanced Gas Fees and Priority Tests'), () => { await loginToApp(); // Check that we are on the wallet screen - await WalletView.isVisible(); + await Assertions.checkIfVisible(WalletView.container); //Tap send Icon await TestHelpers.delay(2000); @@ -56,13 +56,13 @@ describe(SmokeConfirmations('Advanced Gas Fees and Priority Tests'), () => { // Check that we are on the confirm view await Assertions.checkIfVisible( - await TransactionConfirmationView.transactionViewContainer, + TransactionConfirmationView.transactionViewContainer, ); // Check different gas options await TransactionConfirmationView.tapEstimatedGasLink(); await Assertions.checkIfVisible( - await TransactionConfirmationView.editPriorityFeeSheetContainer, + TransactionConfirmationView.editPriorityFeeSheetContainer, ); await TransactionConfirmationView.tapLowPriorityGasOption(); await TransactionConfirmationView.tapAdvancedOptionsPriorityGasOption(); @@ -74,13 +74,13 @@ describe(SmokeConfirmations('Advanced Gas Fees and Priority Tests'), () => { await TransactionConfirmationView.tapAdvancedOptionsPriorityGasOption(); await TransactionConfirmationView.tapMaxPriorityFeeSaveButton(); await Assertions.checkIfVisible( - await TransactionConfirmationView.transactionViewContainer, + TransactionConfirmationView.transactionViewContainer, ); // Tap on the send button await TransactionConfirmationView.tapConfirmButton(); // Check that we are on the wallet screen - await WalletView.isVisible(); + await Assertions.checkIfVisible(WalletView.container); }, ); }); diff --git a/e2e/specs/confirmations/approve-custom-erc20.spec.js b/e2e/specs/confirmations/approve-custom-erc20.spec.js index ec65fd3c22d..e149bb45ed2 100644 --- a/e2e/specs/confirmations/approve-custom-erc20.spec.js +++ b/e2e/specs/confirmations/approve-custom-erc20.spec.js @@ -55,7 +55,7 @@ describe(SmokeConfirmations('ERC20 tokens'), () => { await ContractApprovalModal.inputCustomAmount('2'); // Assert that custom token amount is shown - await Assertions.checkIfHasText( + await Assertions.checkIfElementToHaveText( ContractApprovalModal.approveTokenAmount, '2', ); diff --git a/e2e/specs/confirmations/increase-allowance-erc20.spec.js b/e2e/specs/confirmations/increase-allowance-erc20.spec.js index d69dc1be120..aa76f2f7a07 100644 --- a/e2e/specs/confirmations/increase-allowance-erc20.spec.js +++ b/e2e/specs/confirmations/increase-allowance-erc20.spec.js @@ -54,7 +54,7 @@ describe(SmokeConfirmations('ERC20 - Increase Allowance'), () => { await ContractApprovalModal.inputCustomAmount('2'); // Assert that custom token amount is shown - await Assertions.checkIfHasText( + await Assertions.checkIfElementToHaveText( ContractApprovalModal.approveTokenAmount, '2', ); diff --git a/e2e/specs/networks/add-custom-rpc.spec.js b/e2e/specs/networks/add-custom-rpc.spec.js index 51f490d9b1e..9082b97bbd8 100644 --- a/e2e/specs/networks/add-custom-rpc.spec.js +++ b/e2e/specs/networks/add-custom-rpc.spec.js @@ -2,7 +2,8 @@ import TestHelpers from '../../helpers'; import { Regression } from '../../tags'; import NetworkView from '../../pages/Settings/NetworksView'; -import WalletView from '../../pages/WalletView'; +import WalletView from '../../pages/wallet/WalletView'; +import ToastModal from '../../pages/modals/ToastModal'; import SettingsView from '../../pages/Settings/SettingsView'; import NetworkListModal from '../../pages/modals/NetworkListModal'; import NetworkEducationModal from '../../pages/modals/NetworkEducationModal'; @@ -78,10 +79,6 @@ describe(Regression('Custom RPC Tests'), () => { await NetworkApprovalModal.tapApproveButton(); await Assertions.checkIfVisible(NetworkAddedModal.switchNetwork); await NetworkAddedModal.tapSwitchToNetwork(); - await WalletView.isVisible(); - await WalletView.isNetworkNameVisible( - CustomNetworks.Gnosis.providerConfig.nickname, - ); }); it('should dismiss network education modal', async () => { @@ -92,6 +89,11 @@ describe(Regression('Custom RPC Tests'), () => { ); await NetworkEducationModal.tapGotItButton(); await Assertions.checkIfNotVisible(NetworkEducationModal.container); + await Assertions.checkIfVisible(WalletView.container); + await Assertions.checkIfElementToHaveText( + WalletView.navbarNetworkText, + CustomNetworks.Gnosis.providerConfig.nickname, + ); }); it('should validate that Gnosis is added to network list', async () => { @@ -118,11 +120,12 @@ describe(Regression('Custom RPC Tests'), () => { ); await NetworkEducationModal.tapGotItButton(); await Assertions.checkIfNotVisible(NetworkEducationModal.container); - await WalletView.isVisible(); + await Assertions.checkIfVisible(WalletView.container); }); it('should switch back to Gnosis', async () => { - await WalletView.isNetworkNameVisible( + await Assertions.checkIfElementToHaveText( + WalletView.navbarNetworkText, CustomNetworks.Sepolia.providerConfig.nickname, ); await WalletView.tapNetworksButtonOnNavBar(); @@ -133,15 +136,23 @@ describe(Regression('Custom RPC Tests'), () => { CustomNetworks.Gnosis.providerConfig.nickname, true, ); - await WalletView.isVisible(); - await WalletView.isNetworkNameVisible( + await Assertions.checkIfVisible(WalletView.container); + await Assertions.checkIfElementToHaveText( + WalletView.navbarNetworkText, CustomNetworks.Gnosis.providerConfig.nickname, ); await Assertions.checkIfNotVisible(NetworkEducationModal.container); + + try { + await Assertions.checkIfVisible(ToastModal.container); + await Assertions.checkIfNotVisible(ToastModal.container); + } catch { + // eslint-disable-next-line no-console + console.log('Toast is not visible'); + } }); it('should go to settings networks and remove xDai network', async () => { - await TestHelpers.delay(3000); await TabBarComponent.tapSettings(); await SettingsView.tapNetworks(); await Assertions.checkIfVisible(NetworkView.networkContainer); @@ -151,10 +162,20 @@ describe(Regression('Custom RPC Tests'), () => { await NetworkView.longPressToRemoveNetwork( CustomNetworks.Gnosis.providerConfig.nickname, ); // Tap on Gnosis to remove network - await TestHelpers.delay(3000); await NetworkEducationModal.tapGotItButton(); + + try { + await Assertions.checkIfVisible(ToastModal.container); + await Assertions.checkIfNotVisible(ToastModal.container); + } catch { + // eslint-disable-next-line no-console + console.log('Toast is not visible'); + } await TabBarComponent.tapWallet(); - await WalletView.isVisible(); - await WalletView.isNetworkNameVisible(MAINNET); + await Assertions.checkIfVisible(WalletView.container); + await Assertions.checkIfElementToHaveText( + WalletView.navbarNetworkText, + MAINNET, + ); }); }); diff --git a/e2e/specs/networks/connect-test-network.spec.js b/e2e/specs/networks/connect-test-network.spec.js index 4b483da9fb9..b5711acfa9e 100644 --- a/e2e/specs/networks/connect-test-network.spec.js +++ b/e2e/specs/networks/connect-test-network.spec.js @@ -1,6 +1,6 @@ import { Regression } from '../../tags'; import { loginToApp } from '../../viewHelper'; -import WalletView from '../../pages/WalletView'; +import WalletView from '../../pages/wallet/WalletView'; import NetworkListModal from '../../pages/modals/NetworkListModal'; import NetworkEducationModal from '../../pages/modals/NetworkEducationModal'; import Assertions from '../../utils/Assertions'; @@ -53,8 +53,9 @@ describe(Regression('Connect to a Test Network'), () => { ); await NetworkEducationModal.tapGotItButton(); await Assertions.checkIfNotVisible(NetworkEducationModal.container); - await WalletView.isVisible(); - await WalletView.isConnectedNetwork( + await Assertions.checkIfVisible(WalletView.container); + await Assertions.checkIfElementToHaveText( + WalletView.navbarNetworkText, CustomNetworks.Sepolia.providerConfig.nickname, ); }); @@ -75,13 +76,19 @@ describe(Regression('Connect to a Test Network'), () => { ); await NetworkEducationModal.tapGotItButton(); await Assertions.checkIfNotVisible(NetworkEducationModal.container); - await WalletView.isVisible(); - await WalletView.isConnectedNetwork(ETHEREUM); + await Assertions.checkIfVisible(WalletView.container); + await Assertions.checkIfElementToHaveText( + WalletView.navbarNetworkText, + ETHEREUM, + ); }); it('should toggle off the Test Network switch', async () => { await WalletView.tapNetworksButtonOnNavBar(); await Assertions.checkIfVisible(NetworkListModal.networkScroll); + await Assertions.checkIfTextIsDisplayed( + CustomNetworks.Sepolia.providerConfig.nickname, + ); await Assertions.checkIfToggleIsOn(NetworkListModal.testNetToggle); await NetworkListModal.tapTestNetworkSwitch(); await Assertions.checkIfToggleIsOff(NetworkListModal.testNetToggle); diff --git a/e2e/specs/onboarding/onboarding-wizard-opt-in.spec.js b/e2e/specs/onboarding/onboarding-wizard-opt-in.spec.js index 4ae17644ef0..9c393ffb29b 100644 --- a/e2e/specs/onboarding/onboarding-wizard-opt-in.spec.js +++ b/e2e/specs/onboarding/onboarding-wizard-opt-in.spec.js @@ -7,7 +7,7 @@ import OnboardingView from '../../pages/Onboarding/OnboardingView'; import OnboardingCarouselView from '../../pages/Onboarding/OnboardingCarouselView'; import MetaMetricsOptIn from '../../pages/Onboarding/MetaMetricsOptInView'; import OnboardingSuccessView from '../../pages/Onboarding/OnboardingSuccessView'; -import WalletView from '../../pages/WalletView'; +import WalletView from '../../pages/wallet/WalletView'; import EnableAutomaticSecurityChecksView from '../../pages/EnableAutomaticSecurityChecksView'; import SettingsView from '../../pages/Settings/SettingsView'; import SecurityAndPrivacy from '../../pages/Settings/SecurityAndPrivacy/SecurityAndPrivacyView'; @@ -55,8 +55,6 @@ describe( await SkipAccountSecurityModal.tapIUnderstandCheckBox(); await SkipAccountSecurityModal.tapSkipButton(); await OnboardingSuccessView.tapDone(); - - await WalletView.isVisible(); }); it('Should dismiss Automatic Security checks screen', async () => { @@ -118,7 +116,7 @@ describe( await ProtectYourWalletModal.tapRemindMeLaterButton(); await SkipAccountSecurityModal.tapIUnderstandCheckBox(); await SkipAccountSecurityModal.tapSkipButton(); - await WalletView.isVisible(); + await Assertions.checkIfVisible(WalletView.container); }); it('should check that metametrics is enabled in settings', async () => { @@ -142,7 +140,7 @@ describe( await TestHelpers.delay(4500); await LoginView.isVisible(); await LoginView.enterPassword(PASSWORD); - await WalletView.isVisible(); + await Assertions.checkIfVisible(WalletView.container); }); it('should dismiss the onboarding wizard after logging in', async () => { diff --git a/e2e/specs/permission-systems/permission-system-delete-wallet.spec.js b/e2e/specs/permission-systems/permission-system-delete-wallet.spec.js index 2ba00efa9a9..0686d0f76a9 100644 --- a/e2e/specs/permission-systems/permission-system-delete-wallet.spec.js +++ b/e2e/specs/permission-systems/permission-system-delete-wallet.spec.js @@ -4,7 +4,7 @@ import { Regression } from '../../tags'; import OnboardingView from '../../pages/Onboarding/OnboardingView'; import ProtectYourWalletView from '../../pages/Onboarding/ProtectYourWalletView'; import CreatePasswordView from '../../pages/Onboarding/CreatePasswordView'; -import WalletView from '../../pages/WalletView'; +import WalletView from '../../pages/wallet/WalletView'; import Browser from '../../pages/Browser/BrowserView'; import SettingsView from '../../pages/Settings/SettingsView'; import TabBarComponent from '../../pages/TabBarComponent'; @@ -89,7 +89,7 @@ describe( await SkipAccountSecurityModal.tapIUnderstandCheckBox(); await SkipAccountSecurityModal.tapSkipButton(); await OnboardingSuccessView.tapDone(); - await WalletView.isVisible(); + await Assertions.checkIfVisible(WalletView.container); await ProtectYourWalletModal.tapRemindMeLaterButton(); await SkipAccountSecurityModal.tapIUnderstandCheckBox(); await SkipAccountSecurityModal.tapSkipButton(); diff --git a/e2e/specs/quarantine/add-edit-custom-eth-mainnet.failing.js b/e2e/specs/quarantine/add-edit-custom-eth-mainnet.failing.js index 9a991067a83..a36a4dc5503 100644 --- a/e2e/specs/quarantine/add-edit-custom-eth-mainnet.failing.js +++ b/e2e/specs/quarantine/add-edit-custom-eth-mainnet.failing.js @@ -9,7 +9,7 @@ import CreatePasswordView from '../../pages/Onboarding/CreatePasswordView'; import OnboardingSuccessView from '../../pages/Onboarding/OnboardingSuccessView'; import EnableAutomaticSecurityChecksView from '../../pages/EnableAutomaticSecurityChecksView'; import SkipAccountSecurityModal from '../../pages/modals/SkipAccountSecurityModal'; -import WalletView from '../../pages/WalletView'; +import WalletView from '../../pages/wallet/WalletView'; import ProtectYourWalletView from '../../pages/Onboarding/ProtectYourWalletView'; import NetworksView from '../../pages/Settings/NetworksView'; import Accounts from '../../../wdio/helpers/Accounts'; @@ -71,7 +71,8 @@ describe(Regression('Add custom default ETH Mainnet'), () => { }); it('should show custom default ETH Mainnet as active', async () => { - await WalletView.isNetworkNameVisible( + await Assertions.checkIfElementToHaveText( + WalletView.navbarNetworkText, CustomNetworks.EthereumMainCustom.providerConfig.nickname, ); }); @@ -107,8 +108,9 @@ describe(Regression('Add custom default ETH Mainnet'), () => { CustomNetworks.EthereumMainCustom.providerConfig.rpcUrlAlt, ); await NetworksView.tapSave(); - await WalletView.isConnectedNetwork( - CustomNetworks.EthereumMainCustom.providerConfig.nickname, + await Assertions.checkIfElementToHaveText( + WalletView.navbarNetworkText, + CustomNetworks.Sepolia.providerConfig.nickname, ); }); @@ -118,8 +120,9 @@ describe(Regression('Add custom default ETH Mainnet'), () => { CustomNetworks.EthereumMainCustom.providerConfig.nickname, true, //setting this made this step work for iOS ); - await WalletView.isConnectedNetwork( - CustomNetworks.EthereumMainCustom.providerConfig.nickname, + await Assertions.checkIfElementToHaveText( + WalletView.navbarNetworkText, + CustomNetworks.Sepolia.providerConfig.nickname, ); }); }); diff --git a/e2e/specs/quarantine/contract-nickname.failing.js b/e2e/specs/quarantine/contract-nickname.failing.js index cb055fe407a..c670e028718 100644 --- a/e2e/specs/quarantine/contract-nickname.failing.js +++ b/e2e/specs/quarantine/contract-nickname.failing.js @@ -6,7 +6,7 @@ import OnboardingCarouselView from '../../pages/Onboarding/OnboardingCarouselVie import ContractNickNameView from '../../pages/ContractNickNameView'; import SendView from '../../pages/Send/SendView'; import MetaMetricsOptIn from '../../pages/Onboarding/MetaMetricsOptInView'; -import WalletView from '../../pages/WalletView'; +import WalletView from '../../pages/wallet/WalletView'; import EnableAutomaticSecurityChecksView from '../../pages/EnableAutomaticSecurityChecksView'; import LoginView from '../../pages/LoginView'; @@ -64,7 +64,7 @@ describe('Adding Contract Nickname', () => { await ImportWalletView.enterSecretRecoveryPhrase(validAccount.seedPhrase); await ImportWalletView.enterPassword(validAccount.password); await ImportWalletView.reEnterPassword(validAccount.password); - await WalletView.isVisible(); + await Assertions.checkIfVisible(WalletView.container); }); it('Should dismiss Automatic Security checks screen', async () => { @@ -103,8 +103,8 @@ describe('Adding Contract Nickname', () => { await NetworkListModal.changeNetworkTo( CustomNetworks.Sepolia.providerConfig.nickname, ); - - await WalletView.isNetworkNameVisible( + await Assertions.checkIfElementToHaveText( + WalletView.navbarNetworkText, CustomNetworks.Sepolia.providerConfig.nickname, ); await TestHelpers.delay(1500); @@ -138,7 +138,7 @@ describe('Adding Contract Nickname', () => { await LoginView.toggleRememberMe(); await LoginView.enterPassword(validAccount.password); - await WalletView.isVisible(); + await Assertions.checkIfVisible(WalletView.container); }); it('should deep link to the approval modal', async () => { @@ -174,7 +174,7 @@ describe('Adding Contract Nickname', () => { it('should verify contract does not appear in contacts view', async () => { // Check that we are on the wallet screen - await WalletView.isVisible(); + await Assertions.checkIfVisible(WalletView.container); await TabBarComponent.tapSettings(); await SettingsView.tapContacts(); diff --git a/e2e/specs/quarantine/deeplinks.failing.js b/e2e/specs/quarantine/deeplinks.failing.js index ea7211e06b1..0f6533a03f6 100644 --- a/e2e/specs/quarantine/deeplinks.failing.js +++ b/e2e/specs/quarantine/deeplinks.failing.js @@ -14,11 +14,12 @@ import TransactionConfirmationView from '../../pages/Send/TransactionConfirmView import SecurityAndPrivacy from '../../pages/Settings/SecurityAndPrivacy/SecurityAndPrivacyView'; -import WalletView from '../../pages/WalletView'; +import WalletView from '../../pages/wallet/WalletView'; import { importWalletWithRecoveryPhrase } from '../../viewHelper'; import Accounts from '../../../wdio/helpers/Accounts'; import TabBarComponent from '../../pages/TabBarComponent'; import Assertions from '../../utils/Assertions'; +import { PopularNetworksList } from '../../resources/networks.e2e'; //const BINANCE_RPC_URL = 'https://bsc-dataseed1.binance.org'; @@ -71,7 +72,7 @@ describe(Regression('Deep linking Tests'), () => { await LoginView.toggleRememberMe(); await LoginView.enterPassword(validAccount.password); - await WalletView.isVisible(); + await Assertions.checkIfVisible(WalletView.container); }); it('should deep link to Binance Smart Chain & show a network not found error message', async () => { @@ -87,7 +88,7 @@ describe(Regression('Deep linking Tests'), () => { await TabBarComponent.tapSettings(); await SettingsView.tapNetworks(); - await NetworkView.isNetworkViewVisible(); + await Assertions.checkIfVisible(NetworkView.networkContainer); }); it('should add BSC network', async () => { @@ -95,28 +96,32 @@ describe(Regression('Deep linking Tests'), () => { await TestHelpers.delay(3000); await NetworkView.tapAddNetworkButton(); - await NetworkView.isRpcViewVisible(); - await NetworkView.tapPopularNetworkByName('BNB Smart Chain'); + await Assertions.checkIfVisible(NetworkView.networkContainer); + await NetworkView.tapNetworkByName( + PopularNetworksList.BNB.providerConfig.nickname, + ); await Assertions.checkIfVisible(NetworkApprovalModal.container); await Assertions.checkIfElementToHaveText( NetworkApprovalModal.displayName, - 'BNB Smart Chain', + PopularNetworksList.BNB.providerConfig.nickname, ); await NetworkApprovalModal.tapApproveButton(); await Assertions.checkIfVisible(NetworkAddedModal.switchNetwork); await NetworkAddedModal.tapCloseButton(); - await NetworkView.isRpcViewVisible(); + await Assertions.checkIfVisible(NetworkView.networkContainer); }); it('should add polygon network', async () => { - await NetworkView.tapPopularNetworkByName('Polygon Mainnet'); + await NetworkView.tapNetworkByName( + PopularNetworksList.Polygon.providerConfig.nickname, + ); await Assertions.checkIfVisible(NetworkApprovalModal.container); await Assertions.checkIfElementToHaveText( NetworkApprovalModal.displayName, - 'Polygon Mainnet', + PopularNetworksList.Polygon.providerConfig.nickname, ); await NetworkApprovalModal.tapApproveButton(); @@ -125,49 +130,64 @@ describe(Regression('Deep linking Tests'), () => { await Assertions.checkIfVisible(NetworkAddedModal.switchNetwork); await NetworkAddedModal.tapSwitchToNetwork(); - await WalletView.isVisible(); - await WalletView.isNetworkNameVisible('Polygon Mainnet'); + await Assertions.checkIfVisible(WalletView.container); + await Assertions.checkIfElementToHaveText( + WalletView.navbarNetworkText, + PopularNetworksList.Polygon.providerConfig.nickname, + ); }); it('should deep link to the send flow on matic', async () => { await TestHelpers.openDeepLink(POLYGON_DEEPLINK_URL); //FIXME: this is failing on iOS simulator await TestHelpers.delay(4500); - await TransactionConfirmationView.isVisible(); - await TransactionConfirmationView.isNetworkNameVisible('Polygon Mainnet'); + await Assertions.checkIfVisible( + TransactionConfirmationView.transactionViewContainer, + ); + //TODO: Update isNetworkNameVisible method + //await TransactionConfirmationView.isNetworkNameVisible('Polygon Mainnet'); await TestHelpers.delay(1500); await TransactionConfirmationView.tapCancelButton(); }); it('should deep link to the send flow on BSC', async () => { await TestHelpers.openDeepLink(BINANCE_DEEPLINK_URL); await TestHelpers.delay(4500); - await TransactionConfirmationView.isVisible(); - await TransactionConfirmationView.isNetworkNameVisible('BNB Smart Chain'); + await Assertions.checkIfVisible( + TransactionConfirmationView.transactionViewContainer, + ); + //TODO: Update isNetworkNameVisible method + //await TransactionConfirmationView.isNetworkNameVisible('BNB Smart Chain'); }); it('should deep link to the send flow on Goerli and submit the transaction', async () => { await TestHelpers.openDeepLink(GOERLI_DEEPLINK_URL); await TestHelpers.delay(4500); - await TransactionConfirmationView.isVisible(); - await TransactionConfirmationView.isNetworkNameVisible( - 'Goerli Test Network', + await Assertions.checkIfVisible( + TransactionConfirmationView.transactionViewContainer, ); + //TODO: Update isNetworkNameVisible method + /*await TransactionConfirmationView.isNetworkNameVisible( + 'Goerli Test Network', + );*/ await Assertions.checkIfTextIsDisplayed('0.00001 GoerliETH'); // Tap on the Send CTA await TransactionConfirmationView.tapConfirmButton(); // Check that we are on the wallet screen - await WalletView.isVisible(); + await Assertions.checkIfVisible(WalletView.container); }); it('should deep link to the send flow on mainnet', async () => { await TestHelpers.openDeepLink(ETHEREUM_DEEPLINK_URL); await TestHelpers.delay(4500); - await TransactionConfirmationView.isVisible(); - await TransactionConfirmationView.isNetworkNameVisible( - 'Ethereum Main Network', + await Assertions.checkIfVisible( + TransactionConfirmationView.transactionViewContainer, ); + //TODO: Update isNetworkNameVisible method + /*await TransactionConfirmationView.isNetworkNameVisible( + 'Ethereum Main Network', + );*/ await TransactionConfirmationView.tapCancelButton(); }); diff --git a/e2e/specs/quarantine/import-nft.failing.js b/e2e/specs/quarantine/import-nft.failing.js index 68eca90dcf0..004ffef6158 100644 --- a/e2e/specs/quarantine/import-nft.failing.js +++ b/e2e/specs/quarantine/import-nft.failing.js @@ -1,7 +1,7 @@ 'use strict'; import { SmokeAssets } from '../../tags'; -import TestHelpers from '../../helpers'; -import WalletView from '../../pages/WalletView'; +import Assertions from '../../utils/Assertions'; +import WalletView from '../../pages/wallet/WalletView'; import AddCustomTokenView from '../../pages/AddCustomTokenView'; import { loginToApp } from '../../viewHelper'; import { @@ -48,13 +48,13 @@ describe(SmokeAssets('Import NFT'), () => { await AddCustomTokenView.isVisible(); await AddCustomTokenView.typeInNFTAddress(erc1155ContractAddress); await AddCustomTokenView.typeInNFTIdentifier('1'); - await WalletView.isVisible(); + await Assertions.checkIfVisible(WalletView.container); // Wait for asset to load - await TestHelpers.delay(3000); - await WalletView.isNFTVisibleInWallet('TestDappNFTs'); + await Assertions.checkIfVisible(WalletView.nftInWallet('TestDappNFTs')); // Tap on Collectible await WalletView.tapOnNFTInWallet('TestDappNFTs'); - await WalletView.isNFTNameVisible('TestDappNFTs #1'); + //TODO: isNFTNameVisible have been removed. Update it for valid implementations + //await WalletView.isNFTNameVisible('TestDappNFTs #1'); await WalletView.scrollUpOnNFTsTab(); }, ); diff --git a/e2e/specs/quarantine/permission-system-removing-imported-account.failing.js b/e2e/specs/quarantine/permission-system-removing-imported-account.failing.js index 242b7d3466e..e6088415059 100644 --- a/e2e/specs/quarantine/permission-system-removing-imported-account.failing.js +++ b/e2e/specs/quarantine/permission-system-removing-imported-account.failing.js @@ -1,7 +1,7 @@ 'use strict'; import TestHelpers from '../../helpers'; import { Regression } from '../../tags'; -import WalletView from '../../pages/WalletView'; +import WalletView from '../../pages/wallet/WalletView'; import ImportAccountView from '../../pages/ImportAccountView'; import TabBarComponent from '../../pages/TabBarComponent'; @@ -44,6 +44,7 @@ describe( it('should trigger connect modal in the test dapp', async () => { await TestHelpers.delay(3000); + //TODO: Create goToTestDappAndTapConnectButton method. await TestDApp.goToTestDappAndTapConnectButton(); }); @@ -88,7 +89,7 @@ describe( it('should navigate to wallet view', async () => { await TestHelpers.delay(1500); await TabBarComponent.tapWallet(); - await WalletView.isVisible(); + await Assertions.checkIfVisible(WalletView.container); }); it('should remove imported account', async () => { diff --git a/e2e/specs/settings/fiat-on-testnets.spec.js b/e2e/specs/settings/fiat-on-testnets.spec.js index 906c2a6649b..a28448e2641 100644 --- a/e2e/specs/settings/fiat-on-testnets.spec.js +++ b/e2e/specs/settings/fiat-on-testnets.spec.js @@ -7,14 +7,12 @@ import FixtureBuilder from '../../fixtures/fixture-builder'; import { withFixtures } from '../../fixtures/fixture-helper'; import { CustomNetworks } from '../../resources/networks.e2e'; import NetworkListModal from '../../pages/modals/NetworkListModal'; -import WalletView from '../../pages/WalletView'; +import WalletView from '../../pages/wallet/WalletView'; import NetworkEducationModal from '../../pages/modals/NetworkEducationModal'; import AdvancedSettingsView from '../../pages/Settings/AdvancedView'; import FiatOnTestnetsModal from '../../pages/modals/FiatOnTestnetsModal.js'; import Assertions from '../../utils/Assertions.js'; -import Matchers from '../../utils/Matchers.js'; import TestHelpers from '../../helpers.js'; -import { WalletViewSelectorsIDs } from '../../selectors/wallet/WalletView.selectors'; const SEPOLIA = CustomNetworks.Sepolia.providerConfig.nickname; @@ -39,8 +37,8 @@ describe(SmokeAssets('Fiat On Testnets Setting'), () => { await NetworkEducationModal.tapGotItButton(); // Verify no fiat values displayed - await Assertions.checkIfHasText( - Matchers.getElementByID(WalletViewSelectorsIDs.TOTAL_BALANCE_TEXT), + await Assertions.checkIfElementToHaveText( + WalletView.totalBalance, '$0', ); @@ -57,7 +55,7 @@ describe(SmokeAssets('Fiat On Testnets Setting'), () => { // Verify fiat values are displayed await TabBarComponent.tapWallet(); await Assertions.checkIfElementNotToHaveText( - Matchers.getElementByID(WalletViewSelectorsIDs.TOTAL_BALANCE_TEXT), + WalletView.totalBalance, '$0', ); }, diff --git a/e2e/specs/swaps/swap-token-chart.spec.js b/e2e/specs/swaps/swap-token-chart.spec.js index 96ddd4aa070..844479e1759 100644 --- a/e2e/specs/swaps/swap-token-chart.spec.js +++ b/e2e/specs/swaps/swap-token-chart.spec.js @@ -4,7 +4,7 @@ import Onboarding from '../../pages/swaps/OnBoarding'; import QuoteView from '../../pages/swaps/QuoteView'; import SwapView from '../../pages/swaps/SwapView'; import TabBarComponent from '../../pages/TabBarComponent'; -import WalletView from '../../pages/WalletView'; +import WalletView from '../../pages/wallet/WalletView'; import TokenOverview from '../../pages/TokenOverview'; import FixtureBuilder from '../../fixtures/fixture-builder'; import { @@ -17,6 +17,7 @@ import TestHelpers from '../../helpers'; import FixtureServer from '../../fixtures/fixture-server'; import { getFixturesServerPort } from '../../fixtures/utils'; import { Regression } from '../../tags'; +import Assertions from '../../utils/Assertions'; const fixtureServer = new FixtureServer(); @@ -46,7 +47,7 @@ describe(Regression('Swap from Token view'), () => { it('should complete a USDC to DAI swap from the token chart', async () => { await TabBarComponent.tapWallet(); - await WalletView.isVisible(); + await Assertions.checkIfVisible(WalletView.container); await WalletView.tapOnToken('Ethereum'); await TokenOverview.isVisible(); await TokenOverview.tapSwapButton(); diff --git a/e2e/specs/swaps/token-details.spec.js b/e2e/specs/swaps/token-details.spec.js index c183d718382..66a74e9f51e 100644 --- a/e2e/specs/swaps/token-details.spec.js +++ b/e2e/specs/swaps/token-details.spec.js @@ -1,6 +1,6 @@ 'use strict'; import { SmokeSwaps } from '../../tags'; -import WalletView from '../../pages/WalletView'; +import WalletView from '../../pages/wallet/WalletView'; import TokenOverview from '../../pages/TokenOverview'; import { importWalletWithRecoveryPhrase, diff --git a/e2e/specs/wallet/portfolio-connect-account.spec.js b/e2e/specs/wallet/portfolio-connect-account.spec.js index 719b8d42bab..d66af7a65ee 100644 --- a/e2e/specs/wallet/portfolio-connect-account.spec.js +++ b/e2e/specs/wallet/portfolio-connect-account.spec.js @@ -9,7 +9,7 @@ import { } from '../../fixtures/fixture-helper'; import FixtureBuilder from '../../fixtures/fixture-builder'; import TestHelpers from '../../helpers'; -import WalletView from '../../pages/WalletView'; +import WalletView from '../../pages/wallet/WalletView'; import { getFixturesServerPort } from '../../fixtures/utils'; import FixtureServer from '../../fixtures/fixture-server'; import BrowserView from '../../pages/Browser/BrowserView'; @@ -57,10 +57,10 @@ describe(SmokeCore('Connect account to Portfolio'), () => { }); it('should not open additional browser tabs to portfolio', async () => { - await Assertions.checkIfHasText(BrowserView.tabsNumber, '1'); + await Assertions.checkIfElementToHaveText(BrowserView.tabsNumber, '1'); await TabBarComponent.tapWallet(); await WalletView.tapPortfolio(); await BrowserView.waitForBrowserPageToLoad(); - await Assertions.checkIfHasText(BrowserView.tabsNumber, '1'); + await Assertions.checkIfElementToHaveText(BrowserView.tabsNumber, '1'); }); }); diff --git a/e2e/specs/wallet/request-token-flow.spec.js b/e2e/specs/wallet/request-token-flow.spec.js index 36e647c59ee..fc783dc8045 100644 --- a/e2e/specs/wallet/request-token-flow.spec.js +++ b/e2e/specs/wallet/request-token-flow.spec.js @@ -14,7 +14,7 @@ import { } from '../../fixtures/fixture-helper'; import FixtureBuilder from '../../fixtures/fixture-builder'; import TestHelpers from '../../helpers'; -import WalletView from '../../pages/WalletView'; +import WalletView from '../../pages/wallet/WalletView'; import { getFixturesServerPort } from '../../fixtures/utils'; import FixtureServer from '../../fixtures/fixture-server'; import Assertions from '../../utils/Assertions'; @@ -45,7 +45,7 @@ describe(SmokeCore('Request Token Flow with Unprotected Wallet'), () => { it('should request asset from Action button', async () => { await loginToApp(); - await WalletView.isVisible(); + await Assertions.checkIfVisible(WalletView.container); await TabBarComponent.tapActions(); await WalletActionsModal.tapReceiveButton(); await RequestPaymentModal.tapRequestPaymentButton(); diff --git a/e2e/specs/wallet/send-ERC-token.spec.js b/e2e/specs/wallet/send-ERC-token.spec.js index 38ed65cf729..baf4aacd48e 100644 --- a/e2e/specs/wallet/send-ERC-token.spec.js +++ b/e2e/specs/wallet/send-ERC-token.spec.js @@ -1,7 +1,7 @@ 'use strict'; import { SmokeCore } from '../../tags'; import TestHelpers from '../../helpers'; -import WalletView from '../../pages/WalletView'; +import WalletView from '../../pages/wallet/WalletView'; import NetworkEducationModal from '../../pages/modals/NetworkEducationModal'; import AddCustomTokenView from '../../pages/AddCustomTokenView'; import AmountView from '../../pages/Send/AmountView'; @@ -56,7 +56,7 @@ describe(SmokeCore('Send ERC Token'), () => { await TestHelpers.delay(500); await ConfirmAddAssetView.isVisible(); await ConfirmAddAssetView.tapOnConfirmButton(); - await WalletView.isVisible(); + await Assertions.checkIfVisible(WalletView.container); }); it('should send token to address via asset overview screen', async () => { diff --git a/e2e/specs/wallet/start-exploring.spec.js b/e2e/specs/wallet/start-exploring.spec.js index ecf1be6ee73..e42fab7aaa8 100644 --- a/e2e/specs/wallet/start-exploring.spec.js +++ b/e2e/specs/wallet/start-exploring.spec.js @@ -6,7 +6,6 @@ import OnboardingCarouselView from '../../pages/Onboarding/OnboardingCarouselVie import ProtectYourWalletView from '../../pages/Onboarding/ProtectYourWalletView'; import CreatePasswordView from '../../pages/Onboarding/CreatePasswordView'; import MetaMetricsOptIn from '../../pages/Onboarding/MetaMetricsOptInView'; -import WalletView from '../../pages/WalletView'; import OnboardingSuccessView from '../../pages/Onboarding/OnboardingSuccessView'; import EnableAutomaticSecurityChecksView from '../../pages/EnableAutomaticSecurityChecksView'; import Browser from '../../pages/Browser/BrowserView'; @@ -16,7 +15,6 @@ import WhatsNewModal from '../../pages/modals/WhatsNewModal'; import { acceptTermOfUse } from '../../viewHelper'; import Assertions from '../../utils/Assertions'; -const ACCOUNT = 'Test Account One'; const PASSWORD = '12345678'; describe(SmokeCore('Start Exploring'), () => { @@ -52,7 +50,6 @@ describe(SmokeCore('Start Exploring'), () => { await CreatePasswordView.tapIUnderstandCheckBox(); await CreatePasswordView.enterPassword(PASSWORD); await CreatePasswordView.reEnterPassword(PASSWORD); - // await CreatePasswordView.tapCreatePasswordButton(); }); it('Should skip backup check', async () => { @@ -61,7 +58,6 @@ describe(SmokeCore('Start Exploring'), () => { await ProtectYourWalletView.tapOnRemindMeLaterButton(); await SkipAccountSecurityModal.tapIUnderstandCheckBox(); await SkipAccountSecurityModal.tapSkipButton(); - await WalletView.isVisible(); }); it('Should skip onboarding success screen', async () => { @@ -86,7 +82,6 @@ describe(SmokeCore('Start Exploring'), () => { await Assertions.checkIfVisible(OnboardingWizardModal.stepThreeContainer); // await WalletView.editAccountName(ACCOUNT); await OnboardingWizardModal.tapGotItButton(); - await WalletView.isAccountNameCorrect(ACCOUNT); // Ensure step 4 is shown correctly await Assertions.checkIfVisible(OnboardingWizardModal.stepFourContainer); await OnboardingWizardModal.tapGotItButton(); diff --git a/e2e/utils/Assertions.js b/e2e/utils/Assertions.js index 3b19d651385..e3b15781d21 100644 --- a/e2e/utils/Assertions.js +++ b/e2e/utils/Assertions.js @@ -114,20 +114,6 @@ class Assertions { .withTimeout(timeout); } - /** - * Check if an element with the specified ID has the specified text. - * @param {Promise} elementId - The ID of the element to check. - * @param {string} text - The expected text content. - * @param {number} timeout - Timeout in milliseconds. - */ - static async checkIfHasText(elementId, text, timeout = TIMEOUT) { - // rename this. checkIfELEMENTHasText makes it clear - - return waitFor(await elementId) - .toHaveText(text) - .withTimeout(timeout); - } - /** * Check if the toggle with the specified ID is in the "on" state. * @param {Promise} elementID - The ID of the toggle element. diff --git a/e2e/viewHelper.js b/e2e/viewHelper.js index 7cc2de054b6..8e1340bc222 100644 --- a/e2e/viewHelper.js +++ b/e2e/viewHelper.js @@ -11,7 +11,7 @@ import OnboardingCarouselView from './pages/Onboarding/OnboardingCarouselView'; import OnboardingWizardModal from './pages/modals/OnboardingWizardModal'; import ExperienceEnhancerModal from './pages/modals/ExperienceEnhancerModal'; import SettingsView from './pages/Settings/SettingsView'; -import WalletView from './pages/WalletView'; +import WalletView from './pages/wallet/WalletView'; import WhatsNewModal from './pages/modals/WhatsNewModal'; import Accounts from '../wdio/helpers/Accounts'; import SkipAccountSecurityModal from './pages/modals/SkipAccountSecurityModal'; @@ -153,7 +153,7 @@ export const CreateNewWallet = async () => { await SkipAccountSecurityModal.tapIUnderstandCheckBox(); await SkipAccountSecurityModal.tapSkipButton(); await device.enableSynchronization(); - await WalletView.isVisible(); + await Assertions.checkIfVisible(WalletView.container); //'Should dismiss Automatic Security checks screen' await TestHelpers.delay(3500); @@ -208,10 +208,20 @@ export const switchToSepoliaNetwork = async () => { await NetworkListModal.changeNetworkTo( CustomNetworks.Sepolia.providerConfig.nickname, ); - await WalletView.isNetworkNameVisible( + await Assertions.checkIfVisible(NetworkEducationModal.container); + await Assertions.checkIfElementToHaveText( + NetworkEducationModal.networkName, CustomNetworks.Sepolia.providerConfig.nickname, ); await NetworkEducationModal.tapGotItButton(); + await Assertions.checkIfNotVisible(NetworkEducationModal.container); + try { + await Assertions.checkIfVisible(ToastModal.container); + await Assertions.checkIfNotVisible(ToastModal.container); + } catch { + // eslint-disable-next-line no-console + console.log('Toast is not visible'); + } }; export const loginToApp = async () => { diff --git a/wdio/screen-objects/AddContact.js b/wdio/screen-objects/AddContact.js index 86f69542249..e6e0a4a557f 100644 --- a/wdio/screen-objects/AddContact.js +++ b/wdio/screen-objects/AddContact.js @@ -7,7 +7,7 @@ import { ADD_CONTACT_NAME_INPUT, ADD_CONTACTS_CONTAINER_ID, } from './testIDs/Screens/AddContact.testIds'; -import { EDIT_BUTTON } from './testIDs/Common.testIds'; +import { AddContactViewSelectorsIDs } from '../../e2e/selectors/Settings/Contacts/AddContactView.selectors'; class AddContacts { get container() { @@ -31,7 +31,7 @@ class AddContacts { } get editButton() { - return Selectors.getElementByPlatform(EDIT_BUTTON); + return Selectors.getElementByPlatform(AddContactViewSelectorsIDs.EDIT_BUTTON); } async waitForDisplay() { diff --git a/wdio/screen-objects/CommonScreen.js b/wdio/screen-objects/CommonScreen.js index ec55c68f7e8..b422059e565 100644 --- a/wdio/screen-objects/CommonScreen.js +++ b/wdio/screen-objects/CommonScreen.js @@ -1,15 +1,16 @@ import Selectors from '../helpers/Selectors'; import Gestures from '../helpers/Gestures'; -import { ANDROID_PROGRESS_BAR, TOAST_ID } from './testIDs/Common.testIds'; +import { ToastSelectorsIDs } from '../../e2e/selectors/Modals/ToastModal.selectors'; +import { CommonSelectorsIDs } from '../../e2e/selectors/Common.selectors'; import { NOTIFICATION_TITLE } from './testIDs/Components/Notification.testIds'; class CommonScreen { get toast() { - return Selectors.getXpathElementByResourceId(TOAST_ID); + return Selectors.getXpathElementByResourceId(ToastSelectorsIDs.CONTAINER); } get androidProgressBar() { - return Selectors.getElementByCss(ANDROID_PROGRESS_BAR); + return Selectors.getElementByCss(CommonSelectorsIDs.ANDROID_PROGRESS_BAR); } get TokenNotificationTitle() { diff --git a/wdio/screen-objects/Modals/WalletAccountModal.js b/wdio/screen-objects/Modals/WalletAccountModal.js index 8237566f91e..a01bea88abd 100644 --- a/wdio/screen-objects/Modals/WalletAccountModal.js +++ b/wdio/screen-objects/Modals/WalletAccountModal.js @@ -1,23 +1,18 @@ -import { - ACCOUNT_OVERVIEW_ID, - WALLET_ACCOUNT_NAME_LABEL_INPUT, - WALLET_ACCOUNT_NAME_LABEL_TEXT, -} from '../testIDs/Screens/WalletView.testIds'; - +import { WalletViewSelectorsIDs } from '../../../e2e/selectors/wallet/WalletView.selectors'; import Selectors from '../../helpers/Selectors'; import Gestures from '../../helpers/Gestures'; class WalletAccountModal { get accountNameLabelText() { - return Selectors.getXpathElementByResourceId(WALLET_ACCOUNT_NAME_LABEL_TEXT); + return Selectors.getXpathElementByResourceId(WalletViewSelectorsIDs.ACCOUNT_NAME_LABEL_TEXT); } get accountNameLabelInput() { - return Selectors.getElementByPlatform(WALLET_ACCOUNT_NAME_LABEL_INPUT); + return Selectors.getElementByPlatform(WalletViewSelectorsIDs.ACCOUNT_NAME_LABEL_INPUT); } get walletAccountOverview() { - return Selectors.getXpathElementByResourceId(ACCOUNT_OVERVIEW_ID); + return Selectors.getXpathElementByResourceId(WalletViewSelectorsIDs.ACCOUNT_OVERVIEW); } async longPressAccountNameLabel() { diff --git a/wdio/screen-objects/WalletMainScreen.js b/wdio/screen-objects/WalletMainScreen.js index 76fab29103d..e21fd6148a0 100644 --- a/wdio/screen-objects/WalletMainScreen.js +++ b/wdio/screen-objects/WalletMainScreen.js @@ -1,24 +1,13 @@ import Selectors from '../helpers/Selectors'; import Gestures from '../helpers/Gestures.js'; import { ONBOARDING_WIZARD_STEP_1_NO_THANKS_ID } from './testIDs/Components/OnboardingWizard.testIds'; -import { - IMPORT_NFT_BUTTON_ID, - IMPORT_TOKEN_BUTTON_ID, - MAIN_WALLET_ACCOUNT_ACTIONS, - NAVBAR_NETWORK_BUTTON, - NAVBAR_NETWORK_TEXT, - NOTIFICATION_REMIND_ME_LATER_BUTTON_ID, - SECURE_WALLET_BACKUP_ALERT_MODAL, - SHARE_ADDRESS, - SHOW_PRIVATE_KEY, - VIEW_ETHERSCAN, - WALLET_ACCOUNT_ICON, -} from './testIDs/Screens/WalletView.testIds'; +import { ProtectWalletModalSelectorsIDs } from '../../e2e/selectors/Modals/ProtectWalletModal.selectors'; +import { AccountActionsModalSelectorsIDs } from '../../e2e/selectors/Modals/AccountActionsModal.selectors'; import { NOTIFICATION_TITLE } from './testIDs/Components/Notification.testIds'; import { TabBarSelectorIDs } from '../../e2e/selectors/TabBar.selectors'; import { BACK_BUTTON_SIMPLE_WEBVIEW } from './testIDs/Components/SimpleWebView.testIds'; -import { WalletViewSelectorsIDs } from "../../e2e/selectors/wallet/WalletView.selectors.js"; +import { WalletViewSelectorsIDs } from '../../e2e/selectors/wallet/WalletView.selectors.js'; class WalletMainScreen { get noThanks() { @@ -28,19 +17,19 @@ class WalletMainScreen { } get ImportToken() { - return Selectors.getElementByPlatform(IMPORT_TOKEN_BUTTON_ID); + return Selectors.getElementByPlatform(WalletViewSelectorsIDs.IMPORT_TOKEN_BUTTON); } get ImportNFT() { - return Selectors.getElementByPlatform(IMPORT_NFT_BUTTON_ID); + return Selectors.getElementByPlatform(WalletViewSelectorsIDs.IMPORT_NFT_BUTTON); } get TokenNotificationTitle() { return Selectors.getElementByPlatform(NOTIFICATION_TITLE); } - get Identicon() { - return Selectors.getXpathElementByResourceId(WALLET_ACCOUNT_ICON); + get accountIcon() { + return Selectors.getXpathElementByResourceId(WalletViewSelectorsIDs.ACCOUNT_ICON); } get WalletScreenContainer() { @@ -48,37 +37,37 @@ class WalletMainScreen { } get networkInNavBar() { - return Selectors.getXpathElementByResourceId(NAVBAR_NETWORK_BUTTON); + return Selectors.getXpathElementByResourceId(WalletViewSelectorsIDs.NAVBAR_NETWORK_BUTTON); } get remindMeLaterNotification() { return Selectors.getElementByPlatform( - NOTIFICATION_REMIND_ME_LATER_BUTTON_ID, + ProtectWalletModalSelectorsIDs.REMIND_ME_LATER_BUTTON, ); } get backupAlertModal() { - return Selectors.getElementByPlatform(SECURE_WALLET_BACKUP_ALERT_MODAL); + return Selectors.getElementByPlatform(ProtectWalletModalSelectorsIDs.COLLAPSED_WALLET_MODAL); } get networkNavbarTitle() { - return Selectors.getXpathElementByResourceId(NAVBAR_NETWORK_TEXT); + return Selectors.getXpathElementByResourceId(WalletViewSelectorsIDs.NAVBAR_NETWORK_TEXT); } get accountActionsButton() { - return Selectors.getXpathElementByResourceId(MAIN_WALLET_ACCOUNT_ACTIONS); + return Selectors.getXpathElementByResourceId(WalletViewSelectorsIDs.ACCOUNT_ACTIONS); } get privateKeyActionButton() { - return Selectors.getElementByPlatform(SHOW_PRIVATE_KEY); + return Selectors.getElementByPlatform(AccountActionsModalSelectorsIDs.SHOW_PRIVATE_KEY); } get shareAddressActionButton() { - return Selectors.getElementByPlatform(SHARE_ADDRESS); + return Selectors.getElementByPlatform(AccountActionsModalSelectorsIDs.SHARE_ADDRESS); } get viewEtherscanActionButton() { - return Selectors.getElementByPlatform(VIEW_ETHERSCAN); + return Selectors.getElementByPlatform(AccountActionsModalSelectorsIDs.VIEW_ETHERSCAN); } get walletButton() { @@ -122,7 +111,7 @@ class WalletMainScreen { } async tapIdenticon() { - await Gestures.waitAndTap(this.Identicon); + await Gestures.waitAndTap(this.accountIcon); } async tapNetworkNavBar() { diff --git a/wdio/screen-objects/testIDs/Common.testIds.js b/wdio/screen-objects/testIDs/Common.testIds.js deleted file mode 100644 index c3fc5be7aba..00000000000 --- a/wdio/screen-objects/testIDs/Common.testIds.js +++ /dev/null @@ -1,3 +0,0 @@ -export const TOAST_ID = 'toast'; -export const ANDROID_PROGRESS_BAR = 'android.widget.ProgressBar'; -export const EDIT_BUTTON = 'edit-button'; diff --git a/wdio/screen-objects/testIDs/Screens/WalletView.testIds.js b/wdio/screen-objects/testIDs/Screens/WalletView.testIds.js index 4be4f63eb87..acc724a2389 100644 --- a/wdio/screen-objects/testIDs/Screens/WalletView.testIds.js +++ b/wdio/screen-objects/testIDs/Screens/WalletView.testIds.js @@ -1,26 +1,2 @@ export const SEND_BUTTON_ID = 'token-send-button'; -export const IMPORT_NFT_BUTTON_ID = 'import-collectible-button'; -export const IMPORT_TOKEN_BUTTON_ID = 'import-token-button'; -export const MAIN_WALLET_VIEW_VIA_TOKENS_ID = 'tokens'; - -export const WALLET_ACCOUNT_ICON = 'account-picker'; -export const WALLET_ACCOUNT_NAME_LABEL_TEXT = 'account-label'; -export const WALLET_ACCOUNT_NAME_LABEL_INPUT = 'account-label-text-input'; - -export const ACCOUNT_OVERVIEW_ID = 'account-overview'; -export const NAVBAR_NETWORK_BUTTON = 'open-networks-button'; - -export const NFT_TAB_CONTAINER_ID = 'collectible-contracts'; - -export const NOTIFICATION_REMIND_ME_LATER_BUTTON_ID = - 'notification-remind-later-button'; - -export const SECURE_WALLET_BACKUP_ALERT_MODAL = 'backup-alert'; - -export const NAVBAR_NETWORK_TEXT = 'open-networks-text'; export const getAssetTestId = (token) => `asset-${token}`; - -export const MAIN_WALLET_ACCOUNT_ACTIONS = 'main-wallet-account-actions'; -export const VIEW_ETHERSCAN = 'view-etherscan-action'; -export const SHARE_ADDRESS = 'share-address-action'; -export const SHOW_PRIVATE_KEY = 'show-private-key-action';