From 74eea0b0294f4e550738a046879ec24a76f62612 Mon Sep 17 00:00:00 2001 From: Chloe Gao Date: Thu, 28 Nov 2024 17:43:31 +0100 Subject: [PATCH 01/11] migrate tests --- test/e2e/page-objects/flows/login.flow.ts | 2 +- .../flows/send-transaction.flow.ts | 2 +- test/e2e/page-objects/flows/transaction.ts | 2 +- test/e2e/page-objects/pages/asset-list.ts | 172 ------ .../page-objects/pages/home/activity-list.ts | 128 +++++ .../e2e/page-objects/pages/home/asset-list.ts | 267 ++++++++++ test/e2e/page-objects/pages/home/homepage.ts | 179 +++++++ test/e2e/page-objects/pages/home/nft-list.ts | 89 ++++ test/e2e/page-objects/pages/homepage.ts | 497 ------------------ test/e2e/tests/account/add-account.spec.ts | 8 +- .../e2e/tests/account/forgot-password.spec.ts | 2 +- test/e2e/tests/account/import-flow.spec.ts | 2 +- test/e2e/tests/account/lock-account.spec.ts | 2 +- .../tests/account/migrate-old-vault.spec.ts | 2 +- .../snap-account-contract-interaction.spec.ts | 9 +- .../account/snap-account-transfers.spec.ts | 17 +- .../erc20-token-send-redesign.spec.ts | 2 +- .../transactions/native-send-redesign.spec.ts | 2 +- .../nft-token-send-redesign.spec.ts | 2 +- .../multichain/aggregated-balances.spec.ts | 4 +- test/e2e/tests/multichain/asset-list.spec.ts | 14 +- test/e2e/tests/network/multi-rpc.spec.ts | 2 +- test/e2e/tests/network/switch-network.spec.ts | 2 +- .../importing-private-key-account.spec.ts | 2 +- .../account-syncing/new-user-sync.spec.ts | 2 +- .../onboarding-with-opt-out.spec.ts | 2 +- .../sync-after-adding-account.spec.ts | 2 +- .../sync-after-modifying-account-name.spec.ts | 2 +- .../sync-after-onboarding.spec.ts | 2 +- .../sync-with-account-balances.spec.ts | 2 +- test/e2e/tests/onboarding/onboarding.spec.ts | 2 +- .../privacy/account-tracker-api-usage.spec.ts | 2 +- .../onboarding-infura-call-privacy.spec.ts | 2 +- ...nboarding-token-price-call-privacy.spec.ts | 2 +- test/e2e/tests/privacy/polling.spec.ts | 2 +- .../settings-security-reveal-srp.spec.ts | 2 +- test/e2e/tests/tokens/add-hide-token.spec.ts | 2 +- .../tests/tokens/add-token-using-search.ts | 2 +- .../tests/tokens/nft/auto-detect-nft.spec.ts | 2 +- test/e2e/tests/tokens/nft/import-nft.spec.ts | 31 +- test/e2e/tests/tokens/token-sort.spec.ts | 2 + .../tokens/watch-asset-call-add-token.ts | 2 +- test/e2e/tests/transaction/ens.spec.ts | 2 +- .../e2e/tests/transaction/simple-send.spec.ts | 8 +- .../stuck-approved-transaction.spec.ts | 11 +- test/e2e/vault-decryption-chrome.spec.ts | 2 +- 46 files changed, 752 insertions(+), 746 deletions(-) delete mode 100644 test/e2e/page-objects/pages/asset-list.ts create mode 100644 test/e2e/page-objects/pages/home/activity-list.ts create mode 100644 test/e2e/page-objects/pages/home/asset-list.ts create mode 100644 test/e2e/page-objects/pages/home/homepage.ts create mode 100644 test/e2e/page-objects/pages/home/nft-list.ts delete mode 100644 test/e2e/page-objects/pages/homepage.ts diff --git a/test/e2e/page-objects/flows/login.flow.ts b/test/e2e/page-objects/flows/login.flow.ts index f5ed61946ce8..0e5f2dd6281c 100644 --- a/test/e2e/page-objects/flows/login.flow.ts +++ b/test/e2e/page-objects/flows/login.flow.ts @@ -1,5 +1,5 @@ import LoginPage from '../pages/login-page'; -import HomePage from '../pages/homepage'; +import HomePage from '../pages/home/homepage'; import { Driver } from '../../webdriver/driver'; import { Ganache } from '../../seeder/ganache'; diff --git a/test/e2e/page-objects/flows/send-transaction.flow.ts b/test/e2e/page-objects/flows/send-transaction.flow.ts index 8af88f01aca6..50928f74c8b5 100644 --- a/test/e2e/page-objects/flows/send-transaction.flow.ts +++ b/test/e2e/page-objects/flows/send-transaction.flow.ts @@ -1,4 +1,4 @@ -import HomePage from '../pages/homepage'; +import HomePage from '../pages/home/homepage'; import ConfirmTxPage from '../pages/send/confirm-tx-page'; import SendTokenPage from '../pages/send/send-token-page'; import { Driver } from '../../webdriver/driver'; diff --git a/test/e2e/page-objects/flows/transaction.ts b/test/e2e/page-objects/flows/transaction.ts index e2fdbd652034..c75bf3601572 100644 --- a/test/e2e/page-objects/flows/transaction.ts +++ b/test/e2e/page-objects/flows/transaction.ts @@ -1,7 +1,7 @@ import { TransactionParams } from '@metamask/transaction-controller'; import { DEFAULT_FIXTURE_ACCOUNT } from '../../constants'; import { Driver } from '../../webdriver/driver'; -import HomePage from '../pages/homepage'; +import HomePage from '../pages/home/homepage'; import SendTokenPage from '../pages/send/send-token-page'; import TestDapp from '../pages/test-dapp'; diff --git a/test/e2e/page-objects/pages/asset-list.ts b/test/e2e/page-objects/pages/asset-list.ts deleted file mode 100644 index 6d6d8af391bd..000000000000 --- a/test/e2e/page-objects/pages/asset-list.ts +++ /dev/null @@ -1,172 +0,0 @@ -import { Driver } from '../../webdriver/driver'; - -class AssetListPage { - private readonly driver: Driver; - - private readonly allNetworksOption = - '[data-testid="network-filter-all__button"]'; - - private readonly currentNetworkOption = - '[data-testid="network-filter-current__button"]'; - - private readonly networksToggle = '[data-testid="sort-by-networks"]'; - - private readonly allNetworksTotal = - '[data-testid="network-filter-all__total"]'; - - private readonly currentNetworksTotal = `${this.currentNetworkOption} [data-testid="account-value-and-suffix"]`; - - constructor(driver: Driver) { - this.driver = driver; - } - - async checkNetworkFilterText(expectedText: string): Promise { - console.log( - `Verify the displayed account label in header is: ${expectedText}`, - ); - await this.driver.waitForSelector({ - css: this.networksToggle, - text: expectedText, - }); - } - - async openNetworksFilter(): Promise { - console.log(`Opening the network filter`); - await this.driver.clickElement(this.networksToggle); - await this.driver.waitUntil( - async () => { - return await this.driver.findElement(this.allNetworksOption); - }, - { - timeout: 5000, - interval: 100, - }, - ); - } - - async getNetworksFilterLabel(): Promise { - console.log(`Retrieving the network filter label`); - const toggle = await this.driver.findElement(this.networksToggle); - const text = await toggle.getText(); - return text; - } - - async clickCurrentNetworkOption(): Promise { - console.log(`Clicking on the current network option`); - await this.driver.clickElement(this.currentNetworkOption); - - await this.driver.waitUntil( - async () => { - const label = await this.getNetworksFilterLabel(); - return label !== 'All networks'; - }, - { timeout: 5000, interval: 100 }, - ); - } - - async waitUntilAssetListHasItems(expectedItemsCount: number): Promise { - console.log(`Waiting until the asset list has ${expectedItemsCount} items`); - await this.driver.waitUntil( - async () => { - const items = await this.getNumberOfAssets(); - return items === expectedItemsCount; - }, - { timeout: 5000, interval: 100 }, - ); - } - - async waitUntilFilterLabelIs(label: string): Promise { - console.log(`Waiting until the filter label is ${label}`); - await this.driver.waitUntil( - async () => { - const currentLabel = await this.getNetworksFilterLabel(); - return currentLabel === label; - }, - { timeout: 5000, interval: 100 }, - ); - } - - async getAllNetworksOptionTotal(): Promise { - console.log(`Retrieving the "All networks" option fiat value`); - const allNetworksValueElement = await this.driver.findElement( - this.allNetworksTotal, - ); - const value = await allNetworksValueElement.getText(); - return value; - } - - async clickOnAsset(assetName: string): Promise { - const buttons = await this.driver.findElements( - '[data-testid="multichain-token-list-button"]', - ); - - for (const button of buttons) { - const text = await button.getText(); - if (text.includes(assetName)) { - await button.click(); - return; - } - } - - throw new Error(`${assetName} button not found`); - } - - async getCurrentNetworksOptionTotal(): Promise { - console.log(`Retrieving the "Current network" option fiat value`); - const allNetworksValueElement = await this.driver.findElement( - this.currentNetworksTotal, - ); - const value = await allNetworksValueElement.getText(); - return value; - } - - async selectNetworkFilterAllNetworks(): Promise { - console.log(`Selecting "All networks" from the network filter`); - await this.driver.clickElement(this.allNetworksOption); - - await this.driver.waitUntil( - async () => { - const label = await this.getNetworksFilterLabel(); - return label === 'All networks'; - }, - { timeout: 5000, interval: 100 }, - ); - } - - async selectNetworkFilterCurrentNetwork(): Promise { - console.log(`Selecting "Current network" from the network filter`); - await this.driver.clickElement(this.currentNetworkOption); - - await this.driver.waitUntil( - async () => { - const label = await this.getNetworksFilterLabel(); - return label !== 'All networks'; - }, - { timeout: 5000, interval: 100 }, - ); - } - - async getNumberOfAssets(): Promise { - console.log(`Returning the total number of asset items in the token list`); - const assets = await this.driver.findElements( - '.multichain-token-list-item', - ); - return assets.length; - } - - // Added method to check if an asset is visible - async isAssetVisible(assetName: string): Promise { - const assets = await this.driver.findElements( - '[data-testid="multichain-token-list-button"]', - ); - for (const asset of assets) { - const text = await asset.getText(); - if (text.includes(assetName)) { - return true; - } - } - return false; - } -} - -export default AssetListPage; diff --git a/test/e2e/page-objects/pages/home/activity-list.ts b/test/e2e/page-objects/pages/home/activity-list.ts new file mode 100644 index 000000000000..869baee6c9bf --- /dev/null +++ b/test/e2e/page-objects/pages/home/activity-list.ts @@ -0,0 +1,128 @@ +import { Driver } from '../../../webdriver/driver'; + +class ActivityListPage { + private readonly driver: Driver; + + private readonly completedTransactions = '[data-testid="activity-list-item"]'; + + private readonly confirmedTransactions = { + text: 'Confirmed', + css: '.transaction-status-label--confirmed', + }; + + private readonly failedTransactions = { + text: 'Failed', + css: '.transaction-status-label--failed', + }; + + private readonly transactionAmountsInActivity = + '[data-testid="transaction-list-item-primary-currency"]'; + + constructor(driver: Driver) { + this.driver = driver; + } + + /** + * This function checks the specified number of completed transactions are displayed in the activity list on the homepage. + * It waits up to 10 seconds for the expected number of completed transactions to be visible. + * + * @param expectedNumber - The number of completed transactions expected to be displayed in the activity list. Defaults to 1. + * @returns A promise that resolves if the expected number of completed transactions is displayed within the timeout period. + */ + async check_completedTxNumberDisplayedInActivity( + expectedNumber: number = 1, + ): Promise { + console.log( + `Wait for ${expectedNumber} completed transactions to be displayed in activity list`, + ); + await this.driver.wait(async () => { + const completedTxs = await this.driver.findElements( + this.completedTransactions, + ); + return completedTxs.length === expectedNumber; + }, 10000); + console.log( + `${expectedNumber} completed transactions found in activity list on homepage`, + ); + } + + /** + * This function checks if the specified number of confirmed transactions are displayed in the activity list on homepage. + * It waits up to 10 seconds for the expected number of confirmed transactions to be visible. + * + * @param expectedNumber - The number of confirmed transactions expected to be displayed in activity list. Defaults to 1. + * @returns A promise that resolves if the expected number of confirmed transactions is displayed within the timeout period. + */ + async check_confirmedTxNumberDisplayedInActivity( + expectedNumber: number = 1, + ): Promise { + console.log( + `Wait for ${expectedNumber} confirmed transactions to be displayed in activity list`, + ); + await this.driver.wait(async () => { + const confirmedTxs = await this.driver.findElements( + this.confirmedTransactions, + ); + return confirmedTxs.length === expectedNumber; + }, 10000); + console.log( + `${expectedNumber} confirmed transactions found in activity list on homepage`, + ); + } + + /** + * This function checks if the specified number of failed transactions are displayed in the activity list on homepage. + * It waits up to 10 seconds for the expected number of failed transactions to be visible. + * + * @param expectedNumber - The number of failed transactions expected to be displayed in activity list. Defaults to 1. + * @returns A promise that resolves if the expected number of failed transactions is displayed within the timeout period. + */ + async check_failedTxNumberDisplayedInActivity( + expectedNumber: number = 1, + ): Promise { + console.log( + `Wait for ${expectedNumber} failed transactions to be displayed in activity list`, + ); + await this.driver.wait(async () => { + const failedTxs = await this.driver.findElements(this.failedTransactions); + return failedTxs.length === expectedNumber; + }, 10000); + console.log( + `${expectedNumber} failed transactions found in activity list on homepage`, + ); + } + + /** + * This function checks if a specified transaction amount at the specified index matches the expected one. + * + * @param expectedAmount - The expected transaction amount to be displayed. Defaults to '-1 ETH'. + * @param expectedNumber - The 1-based index of the transaction in the activity list whose amount is to be checked. + * Defaults to 1, indicating the first transaction in the list. + * @returns A promise that resolves if the transaction amount at the specified index matches the expected amount. + * The promise is rejected if the amounts do not match or if an error occurs during the process. + * @example + * // To check if the third transaction in the activity list displays an amount of '2 ETH' + * await check_txAmountInActivity('2 ETH', 3); + */ + async check_txAmountInActivity( + expectedAmount: string = '-1 ETH', + expectedNumber: number = 1, + ): Promise { + const transactionAmounts = await this.driver.findElements( + this.transactionAmountsInActivity, + ); + const transactionAmountsText = await transactionAmounts[ + expectedNumber - 1 + ].getText(); + assert.equal( + transactionAmountsText, + expectedAmount, + `${transactionAmountsText} is displayed as transaction amount instead of ${expectedAmount} for transaction ${expectedNumber}`, + ); + console.log( + `Amount for transaction ${expectedNumber} is displayed as ${expectedAmount}`, + ); + } +} + +export default ActivityListPage; diff --git a/test/e2e/page-objects/pages/home/asset-list.ts b/test/e2e/page-objects/pages/home/asset-list.ts new file mode 100644 index 000000000000..0fb9eb0ee279 --- /dev/null +++ b/test/e2e/page-objects/pages/home/asset-list.ts @@ -0,0 +1,267 @@ +import { Driver } from '../../../webdriver/driver'; + +class AssetListPage { + private readonly driver: Driver; + + private readonly allNetworksOption = + '[data-testid="network-filter-all__button"]'; + + private readonly allNetworksTotal = + '[data-testid="network-filter-all__total"]'; + + private readonly assetOptionsButton = '[data-testid="asset-options__button"]'; + + private readonly confirmImportTokenButton = + '[data-testid="import-tokens-modal-import-button"]'; + + private readonly confirmImportTokenMessage = { + text: 'Would you like to import this token?', + tag: 'p', + }; + + private readonly currentNetworkOption = + '[data-testid="network-filter-current__button"]'; + + private readonly currentNetworksTotal = `${this.currentNetworkOption} [data-testid="account-value-and-suffix"]`; + + private readonly hideTokenButton = '[data-testid="asset-options__hide"]'; + + private readonly hideTokenConfirmationButton = + '[data-testid="hide-token-confirmation__hide"]'; + + private readonly hideTokenConfirmationModalTitle = { + text: 'Hide token', + css: '.hide-token-confirmation__title', + }; + + private readonly importTokenModalTitle = { text: 'Import tokens', tag: 'h4' }; + + private readonly importTokensButton = '[data-testid="importTokens"]'; + + private readonly importTokensNextButton = + '[data-testid="import-tokens-button-next"]'; + + private readonly networksToggle = '[data-testid="sort-by-networks"]'; + + private readonly tokenAmountValue = + '[data-testid="multichain-token-list-item-value"]'; + + private readonly tokenLisiItem = + '[data-testid="multichain-token-list-button"]'; + + private readonly tokenOptionsButton = '[data-testid="import-token-button"]'; + + private readonly tokenSearchInput = 'input[placeholder="Search tokens"]'; + + constructor(driver: Driver) { + this.driver = driver; + } + + async clickCurrentNetworkOption(): Promise { + console.log(`Clicking on the current network option`); + await this.driver.clickElement(this.currentNetworkOption); + await this.driver.waitUntil( + async () => { + const label = await this.getNetworksFilterLabel(); + return label !== 'All networks'; + }, + { timeout: 5000, interval: 100 }, + ); + } + + async clickOnAsset(assetName: string): Promise { + const buttons = await this.driver.findElements( + '[data-testid="multichain-token-list-button"]', + ); + for (const button of buttons) { + const text = await button.getText(); + if (text.includes(assetName)) { + await button.click(); + return; + } + } + throw new Error(`${assetName} button not found`); + } + + async getAllNetworksOptionTotal(): Promise { + console.log(`Retrieving the "All networks" option fiat value`); + const allNetworksValueElement = await this.driver.findElement( + this.allNetworksTotal, + ); + const value = await allNetworksValueElement.getText(); + return value; + } + + async getCurrentNetworksOptionTotal(): Promise { + console.log(`Retrieving the "Current network" option fiat value`); + const allNetworksValueElement = await this.driver.findElement( + this.currentNetworksTotal, + ); + const value = await allNetworksValueElement.getText(); + return value; + } + + async getNetworksFilterLabel(): Promise { + console.log(`Retrieving the network filter label`); + const toggle = await this.driver.findElement(this.networksToggle); + const text = await toggle.getText(); + return text; + } + + /** + * Hides a token by clicking on the token name, and confirming the hide modal. + * + * @param tokenName - The name of the token to hide. + */ + async hideToken(tokenName: string): Promise { + console.log(`Hide token ${tokenName} on homepage`); + await this.driver.clickElement({ text: tokenName, tag: 'span' }); + await this.driver.clickElement(this.assetOptionsButton); + await this.driver.clickElement(this.hideTokenButton); + await this.driver.waitForSelector(this.hideTokenConfirmationModalTitle); + await this.driver.clickElementAndWaitToDisappear( + this.hideTokenConfirmationButton, + ); + } + + async importTokenBySearch(tokenName: string) { + console.log(`Import token ${tokenName} on homepage by search`); + await this.driver.clickElement(this.tokenOptionsButton); + await this.driver.clickElement(this.importTokensButton); + await this.driver.waitForSelector(this.importTokenModalTitle); + await this.driver.fill(this.tokenSearchInput, tokenName); + await this.driver.clickElement({ text: tokenName, tag: 'p' }); + await this.driver.clickElement(this.importTokensNextButton); + await this.driver.waitForSelector(this.confirmImportTokenMessage); + await this.driver.clickElementAndWaitToDisappear( + this.confirmImportTokenButton, + ); + } + + async openNetworksFilter(): Promise { + console.log(`Opening the network filter`); + await this.driver.clickElement(this.networksToggle); + await this.driver.waitUntil( + async () => { + return await this.driver.findElement(this.allNetworksOption); + }, + { + timeout: 5000, + interval: 100, + }, + ); + } + + async selectNetworkFilterAllNetworks(): Promise { + console.log(`Selecting "All networks" from the network filter`); + await this.driver.clickElement(this.allNetworksOption); + await this.driver.waitUntil( + async () => { + const label = await this.getNetworksFilterLabel(); + return label === 'All networks'; + }, + { timeout: 5000, interval: 100 }, + ); + } + + async selectNetworkFilterCurrentNetwork(): Promise { + console.log(`Selecting "Current network" from the network filter`); + await this.driver.clickElement(this.currentNetworkOption); + await this.driver.waitUntil( + async () => { + const label = await this.getNetworksFilterLabel(); + return label !== 'All networks'; + }, + { timeout: 5000, interval: 100 }, + ); + } + + async waitUntilFilterLabelIs(label: string): Promise { + console.log(`Waiting until the filter label is ${label}`); + await this.driver.waitUntil( + async () => { + const currentLabel = await this.getNetworksFilterLabel(); + return currentLabel === label; + }, + { timeout: 5000, interval: 100 }, + ); + } + + async check_ifAssetIsVisible(assetName: string): Promise { + const assets = await this.driver.findElements( + '[data-testid="multichain-token-list-button"]', + ); + for (const asset of assets) { + const text = await asset.getText(); + if (text.includes(assetName)) { + return true; + } + } + return false; + } + + async check_networkFilterText(expectedText: string): Promise { + console.log( + `Verify the displayed account label in header is: ${expectedText}`, + ); + await this.driver.waitForSelector({ + css: this.networksToggle, + text: expectedText, + }); + } + + /** + * Checks if the specified token amount is displayed in the token list. + * + * @param tokenAmount - The token amount to be checked for. + */ + async check_tokenAmountIsDisplayed(tokenAmount: string): Promise { + console.log(`Waiting for token amount ${tokenAmount} to be displayed`); + await this.driver.waitForSelector({ + css: this.tokenAmountValue, + text: tokenAmount, + }); + } + + /** + * Checks if the specified token amount is displayed in the token details modal. + * + * @param tokenName - The name of the token to check for. + * @param tokenAmount - The token amount to be checked for. + */ + async check_tokenAmountInTokenDetailsModal( + tokenName: string, + tokenAmount: string, + ): Promise { + console.log( + `Check that token amount ${tokenAmount} is displayed in token details modal for token ${tokenName}`, + ); + await this.driver.clickElement({ + tag: 'span', + text: tokenName, + }); + await this.driver.waitForSelector({ + css: this.tokenAmountValue, + text: tokenAmount, + }); + } + + /** + * This function checks if the specified number of token items is displayed in the token list. + * + * @param expectedNumber - The number of token items expected to be displayed. Defaults to 1. + * @returns A promise that resolves if the expected number of token items is displayed. + */ + async check_tokenItemNumber(expectedNumber: number = 1): Promise { + console.log(`Waiting for ${expectedNumber} token items to be displayed`); + await this.driver.wait(async () => { + const tokenItems = await this.driver.findElements(this.tokenLisiItem); + return tokenItems.length === expectedNumber; + }, 10000); + console.log( + `Expected number of token items ${expectedNumber} is displayed.`, + ); + } +} + +export default AssetListPage; diff --git a/test/e2e/page-objects/pages/home/homepage.ts b/test/e2e/page-objects/pages/home/homepage.ts new file mode 100644 index 000000000000..6b6197eed797 --- /dev/null +++ b/test/e2e/page-objects/pages/home/homepage.ts @@ -0,0 +1,179 @@ +import { Driver } from '../../../webdriver/driver'; +import { Ganache } from '../../../seeder/ganache'; +import { getCleanAppState } from '../../../helpers'; +import HeaderNavbar from '../header-navbar'; + +class HomePage { + private driver: Driver; + + public headerNavbar: HeaderNavbar; + + private readonly activityTab = + '[data-testid="account-overview__activity-tab"]'; + + private readonly balance = '[data-testid="eth-overview__primary-currency"]'; + + private readonly basicFunctionalityOffWarningMessage = { + text: 'Basic functionality is off', + css: '.mm-banner-alert', + }; + + private readonly closeUseNetworkNotificationModalButton = { + text: 'Got it', + tag: 'h6', + }; + + private readonly nftTab = '[data-testid="account-overview__nfts-tab"]'; + + private readonly popoverBackground = '.popover-bg'; + + private readonly popoverCloseButton = '[data-testid="popover-close"]'; + + private readonly sendButton = '[data-testid="eth-overview-send"]'; + + private readonly tokensTab = '[data-testid="account-overview__asset-tab"]'; + + constructor(driver: Driver) { + this.driver = driver; + this.headerNavbar = new HeaderNavbar(driver); + } + + async check_pageIsLoaded(): Promise { + try { + await this.driver.waitForMultipleSelectors([ + this.sendButton, + this.activityTab, + this.tokensTab, + ]); + } catch (e) { + console.log('Timeout while waiting for home page to be loaded', e); + throw e; + } + console.log('Home page is loaded'); + } + + async closePopover(): Promise { + console.log('Closing popover'); + await this.driver.clickElement(this.popoverCloseButton); + } + + async closeUseNetworkNotificationModal(): Promise { + // We need to use clickElementSafe + assertElementNotPresent as sometimes the network dialog doesn't appear, as per this issue (#25788) + // TODO: change the 2 actions for clickElementAndWaitToDisappear, once the issue is fixed + await this.driver.assertElementNotPresent(this.popoverBackground); + await this.driver.clickElementSafe( + this.closeUseNetworkNotificationModalButton, + ); + await this.driver.assertElementNotPresent( + this.closeUseNetworkNotificationModalButton, + ); + } + + async goToActivityList(): Promise { + console.log(`Open activity tab on homepage`); + await this.driver.clickElement(this.activityTab); + } + + async goToNftTab(): Promise { + console.log(`Go to NFT tab on homepage`); + await this.driver.clickElement(this.nftTab); + } + + async startSendFlow(): Promise { + await this.driver.clickElement(this.sendButton); + } + + /** + * Checks if the toaster message for adding a network is displayed on the homepage. + * + * @param networkName - The name of the network that was added. + */ + async check_addNetworkMessageIsDisplayed(networkName: string): Promise { + console.log( + `Check the toaster message for adding network ${networkName} is displayed on homepage`, + ); + await this.driver.waitForSelector({ + tag: 'h6', + text: `“${networkName}” was successfully added!`, + }); + } + + async check_basicFunctionalityOffWarnigMessageIsDisplayed(): Promise { + console.log( + 'Check if basic functionality off warning message is displayed on homepage', + ); + await this.driver.waitForSelector(this.basicFunctionalityOffWarningMessage); + } + + /** + * Checks if the toaster message for editing a network is displayed on the homepage. + * + * @param networkName - The name of the network that was edited. + */ + async check_editNetworkMessageIsDisplayed( + networkName: string, + ): Promise { + console.log( + `Check the toaster message for editing network ${networkName} is displayed on homepage`, + ); + await this.driver.waitForSelector({ + tag: 'h6', + text: `“${networkName}” was successfully edited!`, + }); + } + + /** + * Checks if the expected balance is displayed on homepage. + * + * @param expectedBalance - The expected balance to be displayed. Defaults to '0'. + * @param symbol - The symbol of the currency or token. Defaults to 'ETH'. + */ + async check_expectedBalanceIsDisplayed( + expectedBalance: string = '0', + symbol: string = 'ETH', + ): Promise { + try { + await this.driver.waitForSelector({ + css: this.balance, + text: expectedBalance, + }); + } catch (e) { + const balance = await this.driver.waitForSelector(this.balance); + const currentBalance = parseFloat(await balance.getText()); + const errorMessage = `Expected balance ${expectedBalance} ${symbol}, got balance ${currentBalance} ${symbol}`; + console.log(errorMessage, e); + throw e; + } + console.log( + `Expected balance ${expectedBalance} ${symbol} is displayed on homepage`, + ); + } + + /** + * This function checks if account syncing has been successfully completed at least once. + */ + async check_hasAccountSyncingSyncedAtLeastOnce(): Promise { + console.log('Check if account syncing has synced at least once'); + await this.driver.wait(async () => { + const uiState = await getCleanAppState(this.driver); + return uiState.metamask.hasAccountSyncingSyncedAtLeastOnce === true; + }, 10000); + } + + async check_localBlockchainBalanceIsDisplayed( + localBlockchainServer?: Ganache, + address = null, + ): Promise { + let expectedBalance: string; + if (localBlockchainServer) { + expectedBalance = ( + await localBlockchainServer.getBalance(address) + ).toString(); + } else { + expectedBalance = '0'; + } + await this.check_expectedBalanceIsDisplayed(expectedBalance); + } +} + +export default HomePage; diff --git a/test/e2e/page-objects/pages/home/nft-list.ts b/test/e2e/page-objects/pages/home/nft-list.ts new file mode 100644 index 000000000000..e26a98e44a92 --- /dev/null +++ b/test/e2e/page-objects/pages/home/nft-list.ts @@ -0,0 +1,89 @@ +import { Driver } from '../../../webdriver/driver'; + +class NftListPage { + private readonly driver: Driver; + + private readonly confirmImportNftButton = + '[data-testid="import-nfts-modal-import-button"]'; + + private readonly importNftAddressInput = '#address'; + + private readonly importNftButton = '[data-testid="import-nft-button"]'; + + private readonly importNftModalTitle = { text: 'Import NFT', tag: 'header' }; + + private readonly importNftTokenIdInput = '#token-id'; + + private readonly nftIconOnActivityList = '[data-testid="nft-item"]'; + + private readonly successImportNftMessage = { + text: 'NFT was successfully added!', + tag: 'h6', + }; + + constructor(driver: Driver) { + this.driver = driver; + } + + async clickNFTIconOnActivityList() { + await this.driver.clickElement(this.nftIconOnActivityList); + } + + /** + * Imports an NFT by entering the NFT contract address and token ID + * + * @param nftContractAddress - The address of the NFT contract to import + * @param id - The ID of the NFT to import + * @param expectedErrorMessage - Expected error message if the import should fail + */ + async importNft( + nftContractAddress: string, + id: string, + expectedErrorMessage?: string, + ) { + await this.driver.clickElement(this.importNftButton); + await this.driver.waitForSelector(this.importNftModalTitle); + await this.driver.fill(this.importNftAddressInput, nftContractAddress); + await this.driver.fill(this.importNftTokenIdInput, id); + if (expectedErrorMessage) { + await this.driver.clickElement(this.confirmImportNftButton); + await this.driver.waitForSelector({ + tag: 'p', + text: expectedErrorMessage, + }); + } else { + await this.driver.clickElementAndWaitToDisappear( + this.confirmImportNftButton, + ); + } + } + + async check_nftImageIsDisplayed(): Promise { + console.log('Check that NFT image is displayed in NFT tab on homepage'); + await this.driver.waitForSelector(this.nftIconOnActivityList); + } + + /** + * Checks if the NFT item with the specified name is displayed in the homepage nft tab. + * + * @param nftName - The name of the NFT to check for. + */ + async check_nftNameIsDisplayed(nftName: string): Promise { + console.log( + `Check that NFT item ${nftName} is displayed in NFT tab on homepage`, + ); + await this.driver.waitForSelector({ + tag: 'h5', + text: nftName, + }); + } + + async check_successImportNftMessageIsDisplayed(): Promise { + console.log( + 'Check that success imported NFT message is displayed on homepage', + ); + await this.driver.waitForSelector(this.successImportNftMessage); + } +} + +export default NftListPage; diff --git a/test/e2e/page-objects/pages/homepage.ts b/test/e2e/page-objects/pages/homepage.ts deleted file mode 100644 index 3722f35f98d9..000000000000 --- a/test/e2e/page-objects/pages/homepage.ts +++ /dev/null @@ -1,497 +0,0 @@ -import { strict as assert } from 'assert'; -import { Driver } from '../../webdriver/driver'; -import { Ganache } from '../../seeder/ganache'; -import { getCleanAppState } from '../../helpers'; -import HeaderNavbar from './header-navbar'; - -class HomePage { - private driver: Driver; - - public headerNavbar: HeaderNavbar; - - private readonly activityTab = - '[data-testid="account-overview__activity-tab"]'; - - private readonly balance = '[data-testid="eth-overview__primary-currency"]'; - - private readonly basicFunctionalityOffWarningMessage = { - text: 'Basic functionality is off', - css: '.mm-banner-alert', - }; - - private readonly closeUseNetworkNotificationModalButton = { - text: 'Got it', - tag: 'h6', - }; - - private readonly completedTransactions = '[data-testid="activity-list-item"]'; - - private readonly confirmedTransactions = { - text: 'Confirmed', - css: '.transaction-status-label--confirmed', - }; - - private readonly failedTransactions = { - text: 'Failed', - css: '.transaction-status-label--failed', - }; - - private readonly popoverBackground = '.popover-bg'; - - private readonly sendButton = '[data-testid="eth-overview-send"]'; - - private readonly tokensTab = '[data-testid="account-overview__asset-tab"]'; - - private readonly transactionAmountsInActivity = - '[data-testid="transaction-list-item-primary-currency"]'; - - // Token tab selectors - private readonly assetOptionsButton = '[data-testid="asset-options__button"]'; - - private readonly confirmImportTokenButton = - '[data-testid="import-tokens-modal-import-button"]'; - - private readonly confirmImportTokenMessage = { - text: 'Would you like to import this token?', - tag: 'p', - }; - - private readonly hideTokenButton = '[data-testid="asset-options__hide"]'; - - private readonly hideTokenConfirmationButton = - '[data-testid="hide-token-confirmation__hide"]'; - - private readonly hideTokenConfirmationModalTitle = { - text: 'Hide token', - css: '.hide-token-confirmation__title', - }; - - private readonly importTokenModalTitle = { text: 'Import tokens', tag: 'h4' }; - - private readonly importTokensButton = '[data-testid="importTokens"]'; - - private readonly importTokensNextButton = - '[data-testid="import-tokens-button-next"]'; - - private readonly tokenAmountValue = - '[data-testid="multichain-token-list-item-value"]'; - - private readonly tokenLisiItem = - '[data-testid="multichain-token-list-button"]'; - - private readonly tokenOptionsButton = '[data-testid="import-token-button"]'; - - private readonly tokenSearchInput = 'input[placeholder="Search tokens"]'; - - // NFT selectors - private readonly confirmImportNftButton = - '[data-testid="import-nfts-modal-import-button"]'; - - private readonly importNftAddressInput = '#address'; - - private readonly importNftButton = '[data-testid="import-nft-button"]'; - - private readonly importNftModalTitle = { text: 'Import NFT', tag: 'header' }; - - private readonly importNftTokenIdInput = '#token-id'; - - private readonly nftIconOnActivityList = '[data-testid="nft-item"]'; - - private readonly nftTab = '[data-testid="account-overview__nfts-tab"]'; - - private readonly popoverCloseButton = '[data-testid="popover-close"]'; - - private readonly successImportNftMessage = { - text: 'NFT was successfully added!', - tag: 'h6', - }; - - constructor(driver: Driver) { - this.driver = driver; - this.headerNavbar = new HeaderNavbar(driver); - } - - async check_pageIsLoaded(): Promise { - try { - await this.driver.waitForMultipleSelectors([ - this.sendButton, - this.activityTab, - this.tokensTab, - ]); - } catch (e) { - console.log('Timeout while waiting for home page to be loaded', e); - throw e; - } - console.log('Home page is loaded'); - } - - async clickNFTIconOnActivityList() { - await this.driver.clickElement(this.nftIconOnActivityList); - } - - async closePopover(): Promise { - console.log('Closing popover'); - await this.driver.clickElement(this.popoverCloseButton); - } - - async closeUseNetworkNotificationModal(): Promise { - // We need to use clickElementSafe + assertElementNotPresent as sometimes the network dialog doesn't appear, as per this issue (#25788) - // TODO: change the 2 actions for clickElementAndWaitToDisappear, once the issue is fixed - await this.driver.assertElementNotPresent(this.popoverBackground); - await this.driver.clickElementSafe( - this.closeUseNetworkNotificationModalButton, - ); - await this.driver.assertElementNotPresent( - this.closeUseNetworkNotificationModalButton, - ); - } - - async goToActivityList(): Promise { - console.log(`Open activity tab on homepage`); - await this.driver.clickElement(this.activityTab); - } - - async goToNftTab(): Promise { - console.log(`Go to NFT tab on homepage`); - await this.driver.clickElement(this.nftTab); - } - - /** - * Hides a token by clicking on the token name, and confirming the hide modal. - * - * @param tokenName - The name of the token to hide. - */ - async hideToken(tokenName: string): Promise { - console.log(`Hide token ${tokenName} on homepage`); - await this.driver.clickElement({ text: tokenName, tag: 'span' }); - await this.driver.clickElement(this.assetOptionsButton); - await this.driver.clickElement(this.hideTokenButton); - await this.driver.waitForSelector(this.hideTokenConfirmationModalTitle); - await this.driver.clickElementAndWaitToDisappear( - this.hideTokenConfirmationButton, - ); - } - - async startSendFlow(): Promise { - await this.driver.clickElement(this.sendButton); - } - - /** - * Imports an NFT by entering the NFT contract address and token ID - * - * @param nftContractAddress - The address of the NFT contract to import - * @param id - The ID of the NFT to import - * @param expectedErrorMessage - Expected error message if the import should fail - */ - async importNft( - nftContractAddress: string, - id: string, - expectedErrorMessage?: string, - ) { - await this.driver.clickElement(this.importNftButton); - await this.driver.waitForSelector(this.importNftModalTitle); - await this.driver.fill(this.importNftAddressInput, nftContractAddress); - await this.driver.fill(this.importNftTokenIdInput, id); - if (expectedErrorMessage) { - await this.driver.clickElement(this.confirmImportNftButton); - await this.driver.waitForSelector({ - tag: 'p', - text: expectedErrorMessage, - }); - } else { - await this.driver.clickElementAndWaitToDisappear( - this.confirmImportNftButton, - ); - } - } - - async importTokenBySearch(tokenName: string) { - console.log(`Import token ${tokenName} on homepage by search`); - await this.driver.clickElement(this.tokenOptionsButton); - await this.driver.clickElement(this.importTokensButton); - await this.driver.waitForSelector(this.importTokenModalTitle); - await this.driver.fill(this.tokenSearchInput, tokenName); - await this.driver.clickElement({ text: tokenName, tag: 'p' }); - await this.driver.clickElement(this.importTokensNextButton); - await this.driver.waitForSelector(this.confirmImportTokenMessage); - await this.driver.clickElementAndWaitToDisappear( - this.confirmImportTokenButton, - ); - } - - /** - * Checks if the toaster message for adding a network is displayed on the homepage. - * - * @param networkName - The name of the network that was added. - */ - async check_addNetworkMessageIsDisplayed(networkName: string): Promise { - console.log( - `Check the toaster message for adding network ${networkName} is displayed on homepage`, - ); - await this.driver.waitForSelector({ - tag: 'h6', - text: `“${networkName}” was successfully added!`, - }); - } - - async check_basicFunctionalityOffWarnigMessageIsDisplayed(): Promise { - console.log( - 'Check if basic functionality off warning message is displayed on homepage', - ); - await this.driver.waitForSelector(this.basicFunctionalityOffWarningMessage); - } - - /** - * This function checks the specified number of completed transactions are displayed in the activity list on the homepage. - * It waits up to 10 seconds for the expected number of completed transactions to be visible. - * - * @param expectedNumber - The number of completed transactions expected to be displayed in the activity list. Defaults to 1. - * @returns A promise that resolves if the expected number of completed transactions is displayed within the timeout period. - */ - async check_completedTxNumberDisplayedInActivity( - expectedNumber: number = 1, - ): Promise { - console.log( - `Wait for ${expectedNumber} completed transactions to be displayed in activity list`, - ); - await this.driver.wait(async () => { - const completedTxs = await this.driver.findElements( - this.completedTransactions, - ); - return completedTxs.length === expectedNumber; - }, 10000); - console.log( - `${expectedNumber} completed transactions found in activity list on homepage`, - ); - } - - /** - * This function checks if the specified number of confirmed transactions are displayed in the activity list on homepage. - * It waits up to 10 seconds for the expected number of confirmed transactions to be visible. - * - * @param expectedNumber - The number of confirmed transactions expected to be displayed in activity list. Defaults to 1. - * @returns A promise that resolves if the expected number of confirmed transactions is displayed within the timeout period. - */ - async check_confirmedTxNumberDisplayedInActivity( - expectedNumber: number = 1, - ): Promise { - console.log( - `Wait for ${expectedNumber} confirmed transactions to be displayed in activity list`, - ); - await this.driver.wait(async () => { - const confirmedTxs = await this.driver.findElements( - this.confirmedTransactions, - ); - return confirmedTxs.length === expectedNumber; - }, 10000); - console.log( - `${expectedNumber} confirmed transactions found in activity list on homepage`, - ); - } - - async check_nftImageIsDisplayed(): Promise { - console.log('Check that NFT image is displayed in NFT tab on homepage'); - await this.driver.waitForSelector(this.nftIconOnActivityList); - } - - /** - * Checks if the toaster message for editing a network is displayed on the homepage. - * - * @param networkName - The name of the network that was edited. - */ - async check_editNetworkMessageIsDisplayed( - networkName: string, - ): Promise { - console.log( - `Check the toaster message for editing network ${networkName} is displayed on homepage`, - ); - await this.driver.waitForSelector({ - tag: 'h6', - text: `“${networkName}” was successfully edited!`, - }); - } - - /** - * Checks if the expected balance is displayed on homepage. - * - * @param expectedBalance - The expected balance to be displayed. Defaults to '0'. - * @param symbol - The symbol of the currency or token. Defaults to 'ETH'. - */ - async check_expectedBalanceIsDisplayed( - expectedBalance: string = '0', - symbol: string = 'ETH', - ): Promise { - try { - await this.driver.waitForSelector({ - css: this.balance, - text: expectedBalance, - }); - } catch (e) { - const balance = await this.driver.waitForSelector(this.balance); - const currentBalance = parseFloat(await balance.getText()); - const errorMessage = `Expected balance ${expectedBalance} ${symbol}, got balance ${currentBalance} ${symbol}`; - console.log(errorMessage, e); - throw e; - } - console.log( - `Expected balance ${expectedBalance} ${symbol} is displayed on homepage`, - ); - } - - /** - * This function checks if the specified number of failed transactions are displayed in the activity list on homepage. - * It waits up to 10 seconds for the expected number of failed transactions to be visible. - * - * @param expectedNumber - The number of failed transactions expected to be displayed in activity list. Defaults to 1. - * @returns A promise that resolves if the expected number of failed transactions is displayed within the timeout period. - */ - async check_failedTxNumberDisplayedInActivity( - expectedNumber: number = 1, - ): Promise { - console.log( - `Wait for ${expectedNumber} failed transactions to be displayed in activity list`, - ); - await this.driver.wait(async () => { - const failedTxs = await this.driver.findElements(this.failedTransactions); - return failedTxs.length === expectedNumber; - }, 10000); - console.log( - `${expectedNumber} failed transactions found in activity list on homepage`, - ); - } - - async check_localBlockchainBalanceIsDisplayed( - localBlockchainServer?: Ganache, - address = null, - ): Promise { - let expectedBalance: string; - if (localBlockchainServer) { - expectedBalance = ( - await localBlockchainServer.getBalance(address) - ).toString(); - } else { - expectedBalance = '0'; - } - await this.check_expectedBalanceIsDisplayed(expectedBalance); - } - - /** - * Checks if the NFT item with the specified name is displayed in the homepage nft tab. - * - * @param nftName - The name of the NFT to check for. - */ - async check_nftNameIsDisplayed(nftName: string): Promise { - console.log( - `Check that NFT item ${nftName} is displayed in NFT tab on homepage`, - ); - await this.driver.waitForSelector({ - tag: 'h5', - text: nftName, - }); - } - - async check_successImportNftMessageIsDisplayed(): Promise { - console.log( - 'Check that success imported NFT message is displayed on homepage', - ); - await this.driver.waitForSelector(this.successImportNftMessage); - } - - /** - * Checks if the specified token amount is displayed in the token list. - * - * @param tokenAmount - The token amount to be checked for. - */ - async check_tokenAmountIsDisplayed(tokenAmount: string): Promise { - console.log(`Waiting for token amount ${tokenAmount} to be displayed`); - await this.driver.waitForSelector({ - css: this.tokenAmountValue, - text: tokenAmount, - }); - } - - /** - * Checks if the specified token amount is displayed in the token details modal. - * - * @param tokenName - The name of the token to check for. - * @param tokenAmount - The token amount to be checked for. - */ - async check_tokenAmountInTokenDetailsModal( - tokenName: string, - tokenAmount: string, - ): Promise { - console.log( - `Check that token amount ${tokenAmount} is displayed in token details modal for token ${tokenName}`, - ); - await this.driver.clickElement({ - tag: 'span', - text: tokenName, - }); - await this.driver.waitForSelector({ - css: this.tokenAmountValue, - text: tokenAmount, - }); - } - - /** - * This function checks if the specified number of token items is displayed in the token list. - * - * @param expectedNumber - The number of token items expected to be displayed. Defaults to 1. - * @returns A promise that resolves if the expected number of token items is displayed. - */ - async check_tokenItemNumber(expectedNumber: number = 1): Promise { - console.log(`Waiting for ${expectedNumber} token items to be displayed`); - await this.driver.wait(async () => { - const tokenItems = await this.driver.findElements(this.tokenLisiItem); - return tokenItems.length === expectedNumber; - }, 10000); - console.log( - `Expected number of token items ${expectedNumber} is displayed.`, - ); - } - - /** - * This function checks if a specified transaction amount at the specified index matches the expected one. - * - * @param expectedAmount - The expected transaction amount to be displayed. Defaults to '-1 ETH'. - * @param expectedNumber - The 1-based index of the transaction in the activity list whose amount is to be checked. - * Defaults to 1, indicating the first transaction in the list. - * @returns A promise that resolves if the transaction amount at the specified index matches the expected amount. - * The promise is rejected if the amounts do not match or if an error occurs during the process. - * @example - * // To check if the third transaction in the activity list displays an amount of '2 ETH' - * await check_txAmountInActivity('2 ETH', 3); - */ - async check_txAmountInActivity( - expectedAmount: string = '-1 ETH', - expectedNumber: number = 1, - ): Promise { - const transactionAmounts = await this.driver.findElements( - this.transactionAmountsInActivity, - ); - const transactionAmountsText = await transactionAmounts[ - expectedNumber - 1 - ].getText(); - assert.equal( - transactionAmountsText, - expectedAmount, - `${transactionAmountsText} is displayed as transaction amount instead of ${expectedAmount} for transaction ${expectedNumber}`, - ); - console.log( - `Amount for transaction ${expectedNumber} is displayed as ${expectedAmount}`, - ); - } - - /** - * This function checks if account syncing has been successfully completed at least once. - */ - async check_hasAccountSyncingSyncedAtLeastOnce(): Promise { - console.log('Check if account syncing has synced at least once'); - await this.driver.wait(async () => { - const uiState = await getCleanAppState(this.driver); - return uiState.metamask.hasAccountSyncingSyncedAtLeastOnce === true; - }, 10000); - } -} - -export default HomePage; diff --git a/test/e2e/tests/account/add-account.spec.ts b/test/e2e/tests/account/add-account.spec.ts index 906e01f50b4d..46eb27cab900 100644 --- a/test/e2e/tests/account/add-account.spec.ts +++ b/test/e2e/tests/account/add-account.spec.ts @@ -10,8 +10,9 @@ import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow' import { completeImportSRPOnboardingFlow } from '../../page-objects/flows/onboarding.flow'; import { sendTransactionToAccount } from '../../page-objects/flows/send-transaction.flow'; import AccountListPage from '../../page-objects/pages/account-list-page'; +import ActivityListPage from '../../page-objects/pages/home/activity-list'; import HeaderNavbar from '../../page-objects/pages/header-navbar'; -import HomePage from '../../page-objects/pages/homepage'; +import HomePage from '../../page-objects/pages/home/homepage'; import LoginPage from '../../page-objects/pages/login-page'; import ResetPasswordPage from '../../page-objects/pages/reset-password-page'; @@ -57,8 +58,9 @@ describe('Add account', function () { totalFee: '2.800042', }); await homePage.check_pageIsLoaded(); - await homePage.check_confirmedTxNumberDisplayedInActivity(); - await homePage.check_txAmountInActivity('-2.8 ETH'); + const activityList = new ActivityListPage(driver); + await activityList.check_confirmedTxNumberDisplayedInActivity(); + await activityList.check_txAmountInActivity('-2.8 ETH'); // Lock wallet and recover via SRP in "forget password" option await headerNavbar.lockMetaMask(); diff --git a/test/e2e/tests/account/forgot-password.spec.ts b/test/e2e/tests/account/forgot-password.spec.ts index 698efcbe0819..62d382cd69dc 100644 --- a/test/e2e/tests/account/forgot-password.spec.ts +++ b/test/e2e/tests/account/forgot-password.spec.ts @@ -3,7 +3,7 @@ import FixtureBuilder from '../../fixture-builder'; import { Driver } from '../../webdriver/driver'; import { E2E_SRP } from '../../default-fixture'; import { Ganache } from '../../seeder/ganache'; -import HomePage from '../../page-objects/pages/homepage'; +import HomePage from '../../page-objects/pages/home/homepage'; import LoginPage from '../../page-objects/pages/login-page'; import ResetPasswordPage from '../../page-objects/pages/reset-password-page'; import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; diff --git a/test/e2e/tests/account/import-flow.spec.ts b/test/e2e/tests/account/import-flow.spec.ts index 8dc989db4d41..2a8bd0256999 100644 --- a/test/e2e/tests/account/import-flow.spec.ts +++ b/test/e2e/tests/account/import-flow.spec.ts @@ -3,7 +3,7 @@ import { withFixtures } from '../../helpers'; import FixtureBuilder from '../../fixture-builder'; import AccountListPage from '../../page-objects/pages/account-list-page'; import HeaderNavbar from '../../page-objects/pages/header-navbar'; -import HomePage from '../../page-objects/pages/homepage'; +import HomePage from '../../page-objects/pages/home/homepage'; import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; import { completeImportSRPOnboardingFlow } from '../../page-objects/flows/onboarding.flow'; diff --git a/test/e2e/tests/account/lock-account.spec.ts b/test/e2e/tests/account/lock-account.spec.ts index b77170c23676..06e1523889e3 100644 --- a/test/e2e/tests/account/lock-account.spec.ts +++ b/test/e2e/tests/account/lock-account.spec.ts @@ -1,7 +1,7 @@ import { Suite } from 'mocha'; import { defaultGanacheOptions, withFixtures } from '../../helpers'; import FixtureBuilder from '../../fixture-builder'; -import HomePage from '../../page-objects/pages/homepage'; +import HomePage from '../../page-objects/pages/home/homepage'; import { Driver } from '../../webdriver/driver'; import { Ganache } from '../../seeder/ganache'; import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; diff --git a/test/e2e/tests/account/migrate-old-vault.spec.ts b/test/e2e/tests/account/migrate-old-vault.spec.ts index 702729bd6fe7..372c94351465 100644 --- a/test/e2e/tests/account/migrate-old-vault.spec.ts +++ b/test/e2e/tests/account/migrate-old-vault.spec.ts @@ -3,7 +3,7 @@ import { defaultGanacheOptions, withFixtures } from '../../helpers'; import FixtureBuilder from '../../fixture-builder'; import { Driver } from '../../webdriver/driver'; import { Ganache } from '../../seeder/ganache'; -import HomePage from '../../page-objects/pages/homepage'; +import HomePage from '../../page-objects/pages/home/homepage'; import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; describe('Migrate vault with old encryption', function (this: Suite) { diff --git a/test/e2e/tests/account/snap-account-contract-interaction.spec.ts b/test/e2e/tests/account/snap-account-contract-interaction.spec.ts index b5cfd4d2707c..da409e555246 100644 --- a/test/e2e/tests/account/snap-account-contract-interaction.spec.ts +++ b/test/e2e/tests/account/snap-account-contract-interaction.spec.ts @@ -10,8 +10,9 @@ import { WINDOW_TITLES, } from '../../helpers'; import { SMART_CONTRACTS } from '../../seeder/smart-contracts'; +import ActivityListPage from '../../page-objects/pages/home/activity-list'; import HeaderNavbar from '../../page-objects/pages/header-navbar'; -import HomePage from '../../page-objects/pages/homepage'; +import HomePage from '../../page-objects/pages/home/homepage'; import SnapSimpleKeyringPage from '../../page-objects/pages/snap-simple-keyring-page'; import TestDapp from '../../page-objects/pages/test-dapp'; import { installSnapSimpleKeyring } from '../../page-objects/flows/snap-simple-keyring.flow'; @@ -74,9 +75,9 @@ describe('Snap Account Contract interaction @no-mmi', function (this: Suite) { ); const homePage = new HomePage(driver); await homePage.check_pageIsLoaded(); - await homePage.goToActivityList(); - await homePage.check_confirmedTxNumberDisplayedInActivity(); - await homePage.check_txAmountInActivity('-4 ETH'); + const activityList = new ActivityListPage(driver); + await activityList.check_confirmedTxNumberDisplayedInActivity(); + await activityList.check_txAmountInActivity('-4 ETH'); }, ); }); diff --git a/test/e2e/tests/account/snap-account-transfers.spec.ts b/test/e2e/tests/account/snap-account-transfers.spec.ts index af2a61a62a39..d6ebff34d642 100644 --- a/test/e2e/tests/account/snap-account-transfers.spec.ts +++ b/test/e2e/tests/account/snap-account-transfers.spec.ts @@ -10,9 +10,10 @@ import { DEFAULT_FIXTURE_ACCOUNT } from '../../constants'; import { Driver } from '../../webdriver/driver'; import { Ganache } from '../../seeder/ganache'; import AccountListPage from '../../page-objects/pages/account-list-page'; +import ActivityListPage from '../../page-objects/pages/home/activity-list'; import FixtureBuilder from '../../fixture-builder'; import HeaderNavbar from '../../page-objects/pages/header-navbar'; -import HomePage from '../../page-objects/pages/homepage'; +import HomePage from '../../page-objects/pages/home/homepage'; import SnapSimpleKeyringPage from '../../page-objects/pages/snap-simple-keyring-page'; import { installSnapSimpleKeyring } from '../../page-objects/flows/snap-simple-keyring.flow'; import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; @@ -172,9 +173,10 @@ describe('Snap Account Transfers @no-mmi', function (this: Suite) { }); // check the transaction is failed in MetaMask activity list - const homepage = new HomePage(driver); - await homepage.check_pageIsLoaded(); - await homepage.check_failedTxNumberDisplayedInActivity(); + await new HomePage(driver).check_pageIsLoaded(); + await new ActivityListPage( + driver, + ).check_failedTxNumberDisplayedInActivity(); }, ); }); @@ -316,9 +318,10 @@ describe('Snap Account Transfers @no-mmi', function (this: Suite) { }); // check the transaction is failed in MetaMask activity list - const homepage = new HomePage(driver); - await homepage.check_pageIsLoaded(); - await homepage.check_failedTxNumberDisplayedInActivity(); + await new HomePage(driver).check_pageIsLoaded(); + await new ActivityListPage( + driver, + ).check_failedTxNumberDisplayedInActivity(); }, ); }); diff --git a/test/e2e/tests/confirmations/transactions/erc20-token-send-redesign.spec.ts b/test/e2e/tests/confirmations/transactions/erc20-token-send-redesign.spec.ts index 2fbe2c553a06..036a8287882c 100644 --- a/test/e2e/tests/confirmations/transactions/erc20-token-send-redesign.spec.ts +++ b/test/e2e/tests/confirmations/transactions/erc20-token-send-redesign.spec.ts @@ -9,7 +9,7 @@ import { import { Mockttp } from '../../../mock-e2e'; import WatchAssetConfirmation from '../../../page-objects/pages/confirmations/legacy/watch-asset-confirmation'; import TokenTransferTransactionConfirmation from '../../../page-objects/pages/confirmations/redesign/token-transfer-confirmation'; -import HomePage from '../../../page-objects/pages/homepage'; +import HomePage from '../../../page-objects/pages/home/homepage'; import SendTokenPage from '../../../page-objects/pages/send/send-token-page'; import TestDapp from '../../../page-objects/pages/test-dapp'; import ContractAddressRegistry from '../../../seeder/contract-address-registry'; diff --git a/test/e2e/tests/confirmations/transactions/native-send-redesign.spec.ts b/test/e2e/tests/confirmations/transactions/native-send-redesign.spec.ts index 46318e113c35..bbf7481a9fc1 100644 --- a/test/e2e/tests/confirmations/transactions/native-send-redesign.spec.ts +++ b/test/e2e/tests/confirmations/transactions/native-send-redesign.spec.ts @@ -7,7 +7,7 @@ import { WINDOW_TITLES, } from '../../../helpers'; import TokenTransferTransactionConfirmation from '../../../page-objects/pages/confirmations/redesign/token-transfer-confirmation'; -import HomePage from '../../../page-objects/pages/homepage'; +import HomePage from '../../../page-objects/pages/home/homepage'; import SendTokenPage from '../../../page-objects/pages/send/send-token-page'; import TestDapp from '../../../page-objects/pages/test-dapp'; import { Driver } from '../../../webdriver/driver'; diff --git a/test/e2e/tests/confirmations/transactions/nft-token-send-redesign.spec.ts b/test/e2e/tests/confirmations/transactions/nft-token-send-redesign.spec.ts index 6fc048c7f11b..bfc226501636 100644 --- a/test/e2e/tests/confirmations/transactions/nft-token-send-redesign.spec.ts +++ b/test/e2e/tests/confirmations/transactions/nft-token-send-redesign.spec.ts @@ -10,7 +10,7 @@ import { Mockttp } from '../../../mock-e2e'; import WatchAssetConfirmation from '../../../page-objects/pages/confirmations/legacy/watch-asset-confirmation'; import TokenTransferTransactionConfirmation from '../../../page-objects/pages/confirmations/redesign/token-transfer-confirmation'; import TransactionConfirmation from '../../../page-objects/pages/confirmations/redesign/transaction-confirmation'; -import HomePage from '../../../page-objects/pages/homepage'; +import HomePage from '../../../page-objects/pages/home/homepage'; import NFTDetailsPage from '../../../page-objects/pages/nft-details-page'; import SendTokenPage from '../../../page-objects/pages/send/send-token-page'; import TestDapp from '../../../page-objects/pages/test-dapp'; diff --git a/test/e2e/tests/multichain/aggregated-balances.spec.ts b/test/e2e/tests/multichain/aggregated-balances.spec.ts index 57df2362b236..1432d10ec77e 100644 --- a/test/e2e/tests/multichain/aggregated-balances.spec.ts +++ b/test/e2e/tests/multichain/aggregated-balances.spec.ts @@ -8,10 +8,10 @@ import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow' import { SMART_CONTRACTS } from '../../seeder/smart-contracts'; import HeaderNavbar from '../../page-objects/pages/header-navbar'; import SelectNetwork from '../../page-objects/pages/dialog/select-network'; -import HomePage from '../../page-objects/pages/homepage'; +import HomePage from '../../page-objects/pages/home/homepage'; import SettingsPage from '../../page-objects/pages/settings/settings-page'; import AccountListPage from '../../page-objects/pages/account-list-page'; -import AssetListPage from '../../page-objects/pages/asset-list'; +import AssetListPage from '../../page-objects/pages/home/asset-list'; import SendTokenPage from '../../page-objects/pages/send/send-token-page'; const EXPECTED_MAINNET_BALANCE_USD = '$84,985.04'; diff --git a/test/e2e/tests/multichain/asset-list.spec.ts b/test/e2e/tests/multichain/asset-list.spec.ts index 5b210730ef36..e5fe9532c3d8 100644 --- a/test/e2e/tests/multichain/asset-list.spec.ts +++ b/test/e2e/tests/multichain/asset-list.spec.ts @@ -9,7 +9,7 @@ import HeaderNavbar from '../../page-objects/pages/header-navbar'; import SelectNetwork from '../../page-objects/pages/dialog/select-network'; import { SMART_CONTRACTS } from '../../seeder/smart-contracts'; import SendTokenPage from '../../page-objects/pages/send/send-token-page'; -import AssetListPage from '../../page-objects/pages/asset-list'; +import AssetListPage from '../../page-objects/pages/home/asset-list'; const NETWORK_NAME_MAINNET = 'Ethereum Mainnet'; const LINEA_NAME_MAINNET = 'Linea Mainnet'; @@ -49,13 +49,13 @@ describe('Multichain Asset List', function (this: Suite) { const assetListPage = new AssetListPage(driver); await headerNavbar.clickSwitchNetworkDropDown(); await selectNetworkDialog.selectNetworkName(NETWORK_NAME_MAINNET); - await assetListPage.waitUntilAssetListHasItems(2); + await assetListPage.check_tokenItemNumber(2); await assetListPage.openNetworksFilter(); await assetListPage.clickCurrentNetworkOption(); await headerNavbar.clickSwitchNetworkDropDown(); await selectNetworkDialog.selectNetworkName(LINEA_NAME_MAINNET); await assetListPage.waitUntilFilterLabelIs(LINEA_NAME_MAINNET); - await assetListPage.waitUntilAssetListHasItems(1); + await assetListPage.check_tokenItemNumber(1); assert.equal( await assetListPage.getNetworksFilterLabel(), LINEA_NAME_MAINNET, @@ -79,7 +79,7 @@ describe('Multichain Asset List', function (this: Suite) { const assetListPage = new AssetListPage(driver); await headerNavbar.clickSwitchNetworkDropDown(); await selectNetworkDialog.selectNetworkName(NETWORK_NAME_MAINNET); - await assetListPage.waitUntilAssetListHasItems(2); + await assetListPage.check_tokenItemNumber(2); await driver.clickElement('.multichain-token-list-item'); const coinOverviewElement = await driver.findElement( '[data-testid="coin-overview-buy"]', @@ -112,7 +112,7 @@ describe('Multichain Asset List', function (this: Suite) { await headerNavbar.clickSwitchNetworkDropDown(); await selectNetworkDialog.selectNetworkName(NETWORK_NAME_MAINNET); const sendPage = new SendTokenPage(driver); - await assetListPage.waitUntilAssetListHasItems(2); + await assetListPage.check_tokenItemNumber(2); await assetListPage.clickOnAsset('TST'); await driver.clickElement('[data-testid="eth-overview-send"]'); await sendPage.check_networkChange(LOCALHOST); @@ -146,7 +146,7 @@ describe('Multichain Asset List', function (this: Suite) { const assetListPage = new AssetListPage(driver); await headerNavbar.clickSwitchNetworkDropDown(); await selectNetworkDialog.selectNetworkName(NETWORK_NAME_MAINNET); - await assetListPage.waitUntilAssetListHasItems(2); + await assetListPage.check_tokenItemNumber(2); await assetListPage.clickOnAsset('TST'); await driver.clickElement('.mm-box > button:nth-of-type(3)'); const toastTextElement = await driver.findElement('.toast-text'); @@ -175,7 +175,7 @@ describe('Multichain Asset List', function (this: Suite) { const selectNetworkDialog = new SelectNetwork(driver); await headerNavbar.clickSwitchNetworkDropDown(); await selectNetworkDialog.selectNetworkName(LINEA_NAME_MAINNET); - await assetListPage.waitUntilAssetListHasItems(2); + await assetListPage.check_tokenItemNumber(2); await assetListPage.clickOnAsset('Ethereum'); diff --git a/test/e2e/tests/network/multi-rpc.spec.ts b/test/e2e/tests/network/multi-rpc.spec.ts index f5c40259a33b..ebf8604a76ea 100644 --- a/test/e2e/tests/network/multi-rpc.spec.ts +++ b/test/e2e/tests/network/multi-rpc.spec.ts @@ -10,7 +10,7 @@ import { } from '../../helpers/mock-server'; import EditNetworkModal from '../../page-objects/pages/dialog/edit-network'; import HeaderNavbar from '../../page-objects/pages/header-navbar'; -import HomePage from '../../page-objects/pages/homepage'; +import HomePage from '../../page-objects/pages/home/homepage'; import OnboardingCompletePage from '../../page-objects/pages/onboarding/onboarding-complete-page'; import OnboardingPrivacySettingsPage from '../../page-objects/pages/onboarding/onboarding-privacy-settings-page'; import SelectNetwork from '../../page-objects/pages/dialog/select-network'; diff --git a/test/e2e/tests/network/switch-network.spec.ts b/test/e2e/tests/network/switch-network.spec.ts index b320e095cc69..78862ecb30b5 100644 --- a/test/e2e/tests/network/switch-network.spec.ts +++ b/test/e2e/tests/network/switch-network.spec.ts @@ -4,7 +4,7 @@ import { withFixtures, defaultGanacheOptions } from '../../helpers'; import FixtureBuilder from '../../fixture-builder'; import { Ganache } from '../../seeder/ganache'; import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; -import HomePage from '../../page-objects/pages/homepage'; +import HomePage from '../../page-objects/pages/home/homepage'; import HeaderNavbar from '../../page-objects/pages/header-navbar'; import { switchToNetworkFlow, diff --git a/test/e2e/tests/notifications/account-syncing/importing-private-key-account.spec.ts b/test/e2e/tests/notifications/account-syncing/importing-private-key-account.spec.ts index 1940d4bf3fd6..2c56f79e2c99 100644 --- a/test/e2e/tests/notifications/account-syncing/importing-private-key-account.spec.ts +++ b/test/e2e/tests/notifications/account-syncing/importing-private-key-account.spec.ts @@ -11,7 +11,7 @@ import { import { UserStorageMockttpController } from '../../../helpers/user-storage/userStorageMockttpController'; import HeaderNavbar from '../../../page-objects/pages/header-navbar'; import AccountListPage from '../../../page-objects/pages/account-list-page'; -import HomePage from '../../../page-objects/pages/homepage'; +import HomePage from '../../../page-objects/pages/home/homepage'; import { completeImportSRPOnboardingFlow } from '../../../page-objects/flows/onboarding.flow'; import { accountsSyncMockResponse } from './mockData'; import { IS_ACCOUNT_SYNCING_ENABLED } from './helpers'; diff --git a/test/e2e/tests/notifications/account-syncing/new-user-sync.spec.ts b/test/e2e/tests/notifications/account-syncing/new-user-sync.spec.ts index ae283c47fa8b..aead37e63002 100644 --- a/test/e2e/tests/notifications/account-syncing/new-user-sync.spec.ts +++ b/test/e2e/tests/notifications/account-syncing/new-user-sync.spec.ts @@ -7,7 +7,7 @@ import { NOTIFICATIONS_TEAM_PASSWORD } from '../constants'; import { UserStorageMockttpController } from '../../../helpers/user-storage/userStorageMockttpController'; import HeaderNavbar from '../../../page-objects/pages/header-navbar'; import AccountListPage from '../../../page-objects/pages/account-list-page'; -import HomePage from '../../../page-objects/pages/homepage'; +import HomePage from '../../../page-objects/pages/home/homepage'; import { completeCreateNewWalletOnboardingFlow, completeImportSRPOnboardingFlow, diff --git a/test/e2e/tests/notifications/account-syncing/onboarding-with-opt-out.spec.ts b/test/e2e/tests/notifications/account-syncing/onboarding-with-opt-out.spec.ts index 3ec44e4fd07e..f164ced25cdc 100644 --- a/test/e2e/tests/notifications/account-syncing/onboarding-with-opt-out.spec.ts +++ b/test/e2e/tests/notifications/account-syncing/onboarding-with-opt-out.spec.ts @@ -10,7 +10,7 @@ import { import { UserStorageMockttpController } from '../../../helpers/user-storage/userStorageMockttpController'; import AccountListPage from '../../../page-objects/pages/account-list-page'; import HeaderNavbar from '../../../page-objects/pages/header-navbar'; -import HomePage from '../../../page-objects/pages/homepage'; +import HomePage from '../../../page-objects/pages/home/homepage'; import OnboardingCompletePage from '../../../page-objects/pages/onboarding/onboarding-complete-page'; import OnboardingPrivacySettingsPage from '../../../page-objects/pages/onboarding/onboarding-privacy-settings-page'; import { diff --git a/test/e2e/tests/notifications/account-syncing/sync-after-adding-account.spec.ts b/test/e2e/tests/notifications/account-syncing/sync-after-adding-account.spec.ts index 1c1f7b3119d7..7a8e19cc4f13 100644 --- a/test/e2e/tests/notifications/account-syncing/sync-after-adding-account.spec.ts +++ b/test/e2e/tests/notifications/account-syncing/sync-after-adding-account.spec.ts @@ -10,7 +10,7 @@ import { import { UserStorageMockttpController } from '../../../helpers/user-storage/userStorageMockttpController'; import HeaderNavbar from '../../../page-objects/pages/header-navbar'; import AccountListPage from '../../../page-objects/pages/account-list-page'; -import HomePage from '../../../page-objects/pages/homepage'; +import HomePage from '../../../page-objects/pages/home/homepage'; import { completeImportSRPOnboardingFlow } from '../../../page-objects/flows/onboarding.flow'; import { accountsSyncMockResponse } from './mockData'; import { IS_ACCOUNT_SYNCING_ENABLED } from './helpers'; diff --git a/test/e2e/tests/notifications/account-syncing/sync-after-modifying-account-name.spec.ts b/test/e2e/tests/notifications/account-syncing/sync-after-modifying-account-name.spec.ts index 22618d70f3c5..97d56f66cf8d 100644 --- a/test/e2e/tests/notifications/account-syncing/sync-after-modifying-account-name.spec.ts +++ b/test/e2e/tests/notifications/account-syncing/sync-after-modifying-account-name.spec.ts @@ -10,7 +10,7 @@ import { import { UserStorageMockttpController } from '../../../helpers/user-storage/userStorageMockttpController'; import HeaderNavbar from '../../../page-objects/pages/header-navbar'; import AccountListPage from '../../../page-objects/pages/account-list-page'; -import HomePage from '../../../page-objects/pages/homepage'; +import HomePage from '../../../page-objects/pages/home/homepage'; import { completeImportSRPOnboardingFlow } from '../../../page-objects/flows/onboarding.flow'; import { accountsSyncMockResponse } from './mockData'; import { IS_ACCOUNT_SYNCING_ENABLED } from './helpers'; diff --git a/test/e2e/tests/notifications/account-syncing/sync-after-onboarding.spec.ts b/test/e2e/tests/notifications/account-syncing/sync-after-onboarding.spec.ts index be2b2604633c..f328244710ea 100644 --- a/test/e2e/tests/notifications/account-syncing/sync-after-onboarding.spec.ts +++ b/test/e2e/tests/notifications/account-syncing/sync-after-onboarding.spec.ts @@ -10,7 +10,7 @@ import { import { UserStorageMockttpController } from '../../../helpers/user-storage/userStorageMockttpController'; import HeaderNavbar from '../../../page-objects/pages/header-navbar'; import AccountListPage from '../../../page-objects/pages/account-list-page'; -import HomePage from '../../../page-objects/pages/homepage'; +import HomePage from '../../../page-objects/pages/home/homepage'; import { completeImportSRPOnboardingFlow } from '../../../page-objects/flows/onboarding.flow'; import { accountsSyncMockResponse } from './mockData'; import { IS_ACCOUNT_SYNCING_ENABLED } from './helpers'; diff --git a/test/e2e/tests/notifications/account-syncing/sync-with-account-balances.spec.ts b/test/e2e/tests/notifications/account-syncing/sync-with-account-balances.spec.ts index 8ecaff943721..6c6ce2dfd48a 100644 --- a/test/e2e/tests/notifications/account-syncing/sync-with-account-balances.spec.ts +++ b/test/e2e/tests/notifications/account-syncing/sync-with-account-balances.spec.ts @@ -9,7 +9,7 @@ import { import { UserStorageMockttpController } from '../../../helpers/user-storage/userStorageMockttpController'; import HeaderNavbar from '../../../page-objects/pages/header-navbar'; import AccountListPage from '../../../page-objects/pages/account-list-page'; -import HomePage from '../../../page-objects/pages/homepage'; +import HomePage from '../../../page-objects/pages/home/homepage'; import { completeImportSRPOnboardingFlow } from '../../../page-objects/flows/onboarding.flow'; import { accountsSyncMockResponse } from './mockData'; import { IS_ACCOUNT_SYNCING_ENABLED } from './helpers'; diff --git a/test/e2e/tests/onboarding/onboarding.spec.ts b/test/e2e/tests/onboarding/onboarding.spec.ts index 979e416f5090..b55ddc193569 100644 --- a/test/e2e/tests/onboarding/onboarding.spec.ts +++ b/test/e2e/tests/onboarding/onboarding.spec.ts @@ -7,7 +7,7 @@ import { import { Driver } from '../../webdriver/driver'; import FixtureBuilder from '../../fixture-builder'; import { FirstTimeFlowType } from '../../../../shared/constants/onboarding'; -import HomePage from '../../page-objects/pages/homepage'; +import HomePage from '../../page-objects/pages/home/homepage'; import OnboardingCompletePage from '../../page-objects/pages/onboarding/onboarding-complete-page'; import OnboardingMetricsPage from '../../page-objects/pages/onboarding/onboarding-metrics-page'; import OnboardingPasswordPage from '../../page-objects/pages/onboarding/onboarding-password-page'; diff --git a/test/e2e/tests/privacy/account-tracker-api-usage.spec.ts b/test/e2e/tests/privacy/account-tracker-api-usage.spec.ts index 24f2318fa13b..d5c9b3e82076 100644 --- a/test/e2e/tests/privacy/account-tracker-api-usage.spec.ts +++ b/test/e2e/tests/privacy/account-tracker-api-usage.spec.ts @@ -8,7 +8,7 @@ import { withFixtures, } from '../../helpers'; import { Mockttp } from '../../mock-e2e'; -import HomePage from '../../page-objects/pages/homepage'; +import HomePage from '../../page-objects/pages/home/homepage'; import { loginWithoutBalanceValidation } from '../../page-objects/flows/login.flow'; async function mockInfura(mockServer: Mockttp): Promise { diff --git a/test/e2e/tests/privacy/onboarding-infura-call-privacy.spec.ts b/test/e2e/tests/privacy/onboarding-infura-call-privacy.spec.ts index f1bdc08166b7..aca018eb52ee 100644 --- a/test/e2e/tests/privacy/onboarding-infura-call-privacy.spec.ts +++ b/test/e2e/tests/privacy/onboarding-infura-call-privacy.spec.ts @@ -2,7 +2,7 @@ import assert from 'assert'; import { Mockttp, MockedEndpoint } from 'mockttp'; import { withFixtures, regularDelayMs } from '../../helpers'; import FixtureBuilder from '../../fixture-builder'; -import HomePage from '../../page-objects/pages/homepage'; +import HomePage from '../../page-objects/pages/home/homepage'; import OnboardingCompletePage from '../../page-objects/pages/onboarding/onboarding-complete-page'; import { importSRPOnboardingFlow, diff --git a/test/e2e/tests/privacy/onboarding-token-price-call-privacy.spec.ts b/test/e2e/tests/privacy/onboarding-token-price-call-privacy.spec.ts index f565c0bb354e..7085c1317610 100644 --- a/test/e2e/tests/privacy/onboarding-token-price-call-privacy.spec.ts +++ b/test/e2e/tests/privacy/onboarding-token-price-call-privacy.spec.ts @@ -2,7 +2,7 @@ import assert from 'assert'; import { Mockttp, MockedEndpoint } from 'mockttp'; import { withFixtures, regularDelayMs } from '../../helpers'; import FixtureBuilder from '../../fixture-builder'; -import HomePage from '../../page-objects/pages/homepage'; +import HomePage from '../../page-objects/pages/home/homepage'; import OnboardingCompletePage from '../../page-objects/pages/onboarding/onboarding-complete-page'; import { importSRPOnboardingFlow, diff --git a/test/e2e/tests/privacy/polling.spec.ts b/test/e2e/tests/privacy/polling.spec.ts index b63e1bce6191..b91a72e9d23e 100644 --- a/test/e2e/tests/privacy/polling.spec.ts +++ b/test/e2e/tests/privacy/polling.spec.ts @@ -5,7 +5,7 @@ import { expect } from '@playwright/test'; import FixtureBuilder from '../../fixture-builder'; import { defaultGanacheOptions, withFixtures } from '../../helpers'; import { Mockttp } from '../../mock-e2e'; -import HomePage from '../../page-objects/pages/homepage'; +import HomePage from '../../page-objects/pages/home/homepage'; import { loginWithoutBalanceValidation } from '../../page-objects/flows/login.flow'; const infuraMainnetUrl = diff --git a/test/e2e/tests/settings/settings-security-reveal-srp.spec.ts b/test/e2e/tests/settings/settings-security-reveal-srp.spec.ts index 6ee57ae02490..eb9739e67bce 100644 --- a/test/e2e/tests/settings/settings-security-reveal-srp.spec.ts +++ b/test/e2e/tests/settings/settings-security-reveal-srp.spec.ts @@ -2,7 +2,7 @@ import { withFixtures } from '../../helpers'; import FixtureBuilder from '../../fixture-builder'; import { E2E_SRP } from '../../default-fixture'; import HeaderNavbar from '../../page-objects/pages/header-navbar'; -import HomePage from '../../page-objects/pages/homepage'; +import HomePage from '../../page-objects/pages/home/homepage'; import PrivacySettings from '../../page-objects/pages/settings/privacy-settings'; import SettingsPage from '../../page-objects/pages/settings/settings-page'; import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; diff --git a/test/e2e/tests/tokens/add-hide-token.spec.ts b/test/e2e/tests/tokens/add-hide-token.spec.ts index 8f85f2d9914e..e3731bac5352 100644 --- a/test/e2e/tests/tokens/add-hide-token.spec.ts +++ b/test/e2e/tests/tokens/add-hide-token.spec.ts @@ -1,7 +1,7 @@ import { toHex } from '@metamask/controller-utils'; import { withFixtures } from '../../helpers'; import FixtureBuilder from '../../fixture-builder'; -import HomePage from '../../page-objects/pages/homepage'; +import HomePage from '../../page-objects/pages/home/homepage'; import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; describe('Add hide token', function () { diff --git a/test/e2e/tests/tokens/add-token-using-search.ts b/test/e2e/tests/tokens/add-token-using-search.ts index 79b4715afb91..ce9eec58f8da 100644 --- a/test/e2e/tests/tokens/add-token-using-search.ts +++ b/test/e2e/tests/tokens/add-token-using-search.ts @@ -2,7 +2,7 @@ import { MockedEndpoint, Mockttp } from 'mockttp'; import { defaultGanacheOptions, withFixtures } from '../../helpers'; import FixtureBuilder from '../../fixture-builder'; import { CHAIN_IDS } from '../../../../shared/constants/network'; -import HomePage from '../../page-objects/pages/homepage'; +import HomePage from '../../page-objects/pages/home/homepage'; import { loginWithoutBalanceValidation } from '../../page-objects/flows/login.flow'; describe('Add existing token using search', function () { diff --git a/test/e2e/tests/tokens/nft/auto-detect-nft.spec.ts b/test/e2e/tests/tokens/nft/auto-detect-nft.spec.ts index c70a3860dd63..a248132d57b5 100644 --- a/test/e2e/tests/tokens/nft/auto-detect-nft.spec.ts +++ b/test/e2e/tests/tokens/nft/auto-detect-nft.spec.ts @@ -1,7 +1,7 @@ import { withFixtures } from '../../../helpers'; import FixtureBuilder from '../../../fixture-builder'; import HeaderNavbar from '../../../page-objects/pages/header-navbar'; -import Homepage from '../../../page-objects/pages/homepage'; +import Homepage from '../../../page-objects/pages/home/homepage'; import PrivacySettings from '../../../page-objects/pages/settings/privacy-settings'; import SettingsPage from '../../../page-objects/pages/settings/settings-page'; import { loginWithBalanceValidation } from '../../../page-objects/flows/login.flow'; diff --git a/test/e2e/tests/tokens/nft/import-nft.spec.ts b/test/e2e/tests/tokens/nft/import-nft.spec.ts index bc709ba463c0..5983d1002035 100644 --- a/test/e2e/tests/tokens/nft/import-nft.spec.ts +++ b/test/e2e/tests/tokens/nft/import-nft.spec.ts @@ -3,7 +3,8 @@ import { SMART_CONTRACTS } from '../../../seeder/smart-contracts'; import FixtureBuilder from '../../../fixture-builder'; import AccountListPage from '../../../page-objects/pages/account-list-page'; import HeaderNavbar from '../../../page-objects/pages/header-navbar'; -import Homepage from '../../../page-objects/pages/homepage'; +import Homepage from '../../../page-objects/pages/home/homepage'; +import NftListPage from '../../../page-objects/pages/home/nft-list'; import { loginWithBalanceValidation } from '../../../page-objects/flows/login.flow'; describe('Import NFT', function () { @@ -27,11 +28,11 @@ describe('Import NFT', function () { const homepage = new Homepage(driver); await homepage.goToNftTab(); - await homepage.importNft(contractAddress, '1'); - await homepage.check_successImportNftMessageIsDisplayed(); - - await homepage.check_nftNameIsDisplayed('TestDappNFTs'); - await homepage.check_nftImageIsDisplayed(); + const nftList = new NftListPage(driver); + await nftList.importNft(contractAddress, '1'); + await nftList.check_successImportNftMessageIsDisplayed(); + await nftList.check_nftNameIsDisplayed('TestDappNFTs'); + await nftList.check_nftImageIsDisplayed(); }, ); }); @@ -55,10 +56,11 @@ describe('Import NFT', function () { // Import a NFT and check that it is displayed in the NFT tab on homepage const homepage = new Homepage(driver); await homepage.goToNftTab(); - await homepage.importNft(contractAddress, '1'); - await homepage.check_successImportNftMessageIsDisplayed(); - await homepage.check_nftNameIsDisplayed('TestDappNFTs'); - await homepage.check_nftImageIsDisplayed(); + const nftList = new NftListPage(driver); + await nftList.importNft(contractAddress, '1'); + await nftList.check_successImportNftMessageIsDisplayed(); + await nftList.check_nftNameIsDisplayed('TestDappNFTs'); + await nftList.check_nftImageIsDisplayed(); // Create new account with default name Account 2 const headerNavbar = new HeaderNavbar(driver); @@ -76,8 +78,8 @@ describe('Import NFT', function () { await accountListPage.switchToAccount('Account 1'); await headerNavbar.check_accountLabel('Account 1'); await homepage.check_localBlockchainBalanceIsDisplayed(ganacheServer); - await homepage.check_nftNameIsDisplayed('TestDappNFTs'); - await homepage.check_nftImageIsDisplayed(); + await nftList.check_nftNameIsDisplayed('TestDappNFTs'); + await nftList.check_nftImageIsDisplayed(); }, ); }); @@ -98,9 +100,8 @@ describe('Import NFT', function () { contractRegistry.getContractAddress(smartContract); await loginWithBalanceValidation(driver, ganacheServer); - const homepage = new Homepage(driver); - await homepage.goToNftTab(); - await homepage.importNft( + await new Homepage(driver).goToNftTab(); + await new NftListPage(driver).importNft( contractAddress, '2', 'NFT can’t be added as the ownership details do not match. Make sure you have entered correct information.', diff --git a/test/e2e/tests/tokens/token-sort.spec.ts b/test/e2e/tests/tokens/token-sort.spec.ts index ff2d35a917dc..2530181f1764 100644 --- a/test/e2e/tests/tokens/token-sort.spec.ts +++ b/test/e2e/tests/tokens/token-sort.spec.ts @@ -53,6 +53,7 @@ describe('Token List', function () { }, async ({ driver }: { driver: Driver }) => { await unlockWallet(driver); + throw new Error('Not implemented'); await importToken(driver); const tokenListBeforeSorting = await driver.findElements( @@ -100,6 +101,7 @@ describe('Token List', function () { assert.ok( tokenListAfterSortingByDecliningBalance[0].includes('Ethereum'), ); + throw new Error('Not implemented'); }, ); }); diff --git a/test/e2e/tests/tokens/watch-asset-call-add-token.ts b/test/e2e/tests/tokens/watch-asset-call-add-token.ts index 35c66dda8ce6..543ca5dea3eb 100644 --- a/test/e2e/tests/tokens/watch-asset-call-add-token.ts +++ b/test/e2e/tests/tokens/watch-asset-call-add-token.ts @@ -6,7 +6,7 @@ import { import FixtureBuilder from '../../fixture-builder'; import { SMART_CONTRACTS } from '../../seeder/smart-contracts'; import AddTokenConfirmation from '../../page-objects/pages/confirmations/redesign/add-token-confirmations'; -import HomePage from '../../page-objects/pages/homepage'; +import HomePage from '../../page-objects/pages/home/homepage'; import TestDapp from '../../page-objects/pages/test-dapp'; import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; diff --git a/test/e2e/tests/transaction/ens.spec.ts b/test/e2e/tests/transaction/ens.spec.ts index 3291287ab5a4..b36765475b62 100644 --- a/test/e2e/tests/transaction/ens.spec.ts +++ b/test/e2e/tests/transaction/ens.spec.ts @@ -4,7 +4,7 @@ import { defaultGanacheOptions, withFixtures } from '../../helpers'; import { Driver } from '../../webdriver/driver'; import FixtureBuilder from '../../fixture-builder'; import { loginWithoutBalanceValidation } from '../../page-objects/flows/login.flow'; -import HomePage from '../../page-objects/pages/homepage'; +import HomePage from '../../page-objects/pages/home/homepage'; import SendTokenPage from '../../page-objects/pages/send/send-token-page'; import { mockServerJsonRpc } from '../ppom/mocks/mock-server-json-rpc'; import { mockMultiNetworkBalancePolling } from '../../mock-balance-polling/mock-balance-polling'; diff --git a/test/e2e/tests/transaction/simple-send.spec.ts b/test/e2e/tests/transaction/simple-send.spec.ts index 7d2f4835cdca..9ac091744974 100644 --- a/test/e2e/tests/transaction/simple-send.spec.ts +++ b/test/e2e/tests/transaction/simple-send.spec.ts @@ -9,7 +9,8 @@ import { import FixtureBuilder from '../../fixture-builder'; import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; import { sendTransactionToAddress } from '../../page-objects/flows/send-transaction.flow'; -import HomePage from '../../page-objects/pages/homepage'; +import ActivityListPage from '../../page-objects/pages/home/activity-list'; +import HomePage from '../../page-objects/pages/home/homepage'; describe('Simple send eth', function (this: Suite) { it('can send a simple transaction from one account to another', async function () { @@ -39,8 +40,9 @@ describe('Simple send eth', function (this: Suite) { }); const homePage = new HomePage(driver); await homePage.check_pageIsLoaded(); - await homePage.check_confirmedTxNumberDisplayedInActivity(); - await homePage.check_txAmountInActivity(); + const activityList = new ActivityListPage(driver); + await activityList.check_confirmedTxNumberDisplayedInActivity(); + await activityList.check_txAmountInActivity(); }, ); }); diff --git a/test/e2e/tests/transaction/stuck-approved-transaction.spec.ts b/test/e2e/tests/transaction/stuck-approved-transaction.spec.ts index 7afedc3187dd..5e2665627910 100644 --- a/test/e2e/tests/transaction/stuck-approved-transaction.spec.ts +++ b/test/e2e/tests/transaction/stuck-approved-transaction.spec.ts @@ -4,7 +4,8 @@ import FixtureBuilder from '../../fixture-builder'; import { Driver } from '../../webdriver/driver'; import { Ganache } from '../../seeder/ganache'; import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; -import HomePage from '../../page-objects/pages/homepage'; +import ActivityListPage from '../../page-objects/pages/home/activity-list'; +import HomePage from '../../page-objects/pages/home/homepage'; describe('Editing Confirm Transaction', function (this: Suite) { it('approves a transaction stuck in approved state on boot', async function () { @@ -25,10 +26,10 @@ describe('Editing Confirm Transaction', function (this: Suite) { }) => { await loginWithBalanceValidation(driver, ganacheServer); - const homePage = new HomePage(driver); - await homePage.goToActivityList(); - await homePage.check_completedTxNumberDisplayedInActivity(); - await homePage.check_txAmountInActivity(); + new HomePage(driver).goToActivityList(); + const activityList = new ActivityListPage(driver); + await activityList.check_completedTxNumberDisplayedInActivity(); + await activityList.check_txAmountInActivity(); }, ); }); diff --git a/test/e2e/vault-decryption-chrome.spec.ts b/test/e2e/vault-decryption-chrome.spec.ts index 939494b00a60..110b7726a614 100644 --- a/test/e2e/vault-decryption-chrome.spec.ts +++ b/test/e2e/vault-decryption-chrome.spec.ts @@ -5,7 +5,7 @@ import level from 'level'; import { Driver } from './webdriver/driver'; import { withFixtures, WALLET_PASSWORD } from './helpers'; import HeaderNavbar from './page-objects/pages/header-navbar'; -import HomePage from './page-objects/pages/homepage'; +import HomePage from './page-objects/pages/home/homepage'; import PrivacySettings from './page-objects/pages/settings/privacy-settings'; import SettingsPage from './page-objects/pages/settings/settings-page'; import VaultDecryptorPage from './page-objects/pages/vault-decryptor-page'; From 9c84fb4c6929bc7805b5d691183eec9d31a666aa Mon Sep 17 00:00:00 2001 From: Chloe Gao Date: Thu, 28 Nov 2024 18:43:14 +0100 Subject: [PATCH 02/11] put home related pages together --- .circleci/config.yml | 4 ---- test/e2e/page-objects/pages/home/asset-list.ts | 18 ++++++++++-------- .../nft-token-send-redesign.spec.ts | 11 +++++------ .../multichain/aggregated-balances.spec.ts | 2 +- test/e2e/tests/tokens/add-hide-token.spec.ts | 12 ++++++------ .../e2e/tests/tokens/add-token-using-search.ts | 10 +++++----- .../tests/tokens/nft/auto-detect-nft.spec.ts | 6 ++++-- .../tests/tokens/watch-asset-call-add-token.ts | 6 +++--- 8 files changed, 34 insertions(+), 35 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3178a687a617..4c3c0c5e69c3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -172,7 +172,6 @@ workflows: requires: - prep-deps - prep-build-test-flask-mv2: - <<: *develop_master_rc_only requires: - prep-deps - prep-build-test-mmi: @@ -200,7 +199,6 @@ workflows: requires: - prep-deps - test-e2e-chrome-webpack: - <<: *develop_master_rc_only requires: - prep-build-test-webpack - get-changed-files-with-git-diff @@ -209,7 +207,6 @@ workflows: - prep-build-test - get-changed-files-with-git-diff - test-e2e-firefox: - <<: *develop_master_rc_only requires: - prep-build-test-mv2 - get-changed-files-with-git-diff @@ -229,7 +226,6 @@ workflows: - prep-build-test-flask - get-changed-files-with-git-diff - test-e2e-firefox-flask: - <<: *develop_master_rc_only requires: - prep-build-test-flask-mv2 - test-e2e-chrome-mmi: diff --git a/test/e2e/page-objects/pages/home/asset-list.ts b/test/e2e/page-objects/pages/home/asset-list.ts index 0fb9eb0ee279..d7308974abe8 100644 --- a/test/e2e/page-objects/pages/home/asset-list.ts +++ b/test/e2e/page-objects/pages/home/asset-list.ts @@ -70,9 +70,7 @@ class AssetListPage { } async clickOnAsset(assetName: string): Promise { - const buttons = await this.driver.findElements( - '[data-testid="multichain-token-list-button"]', - ); + const buttons = await this.driver.findElements(this.tokenLisiItem); for (const button of buttons) { const text = await button.getText(); if (text.includes(assetName)) { @@ -108,6 +106,12 @@ class AssetListPage { return text; } + async getNumberOfAssets(): Promise { + console.log(`Returning the total number of asset items in the token list`); + const assets = await this.driver.findElements(this.tokenLisiItem); + return assets.length; + } + /** * Hides a token by clicking on the token name, and confirming the hide modal. * @@ -188,9 +192,7 @@ class AssetListPage { } async check_ifAssetIsVisible(assetName: string): Promise { - const assets = await this.driver.findElements( - '[data-testid="multichain-token-list-button"]', - ); + const assets = await this.driver.findElements(this.tokenLisiItem); for (const asset of assets) { const text = await asset.getText(); if (text.includes(assetName)) { @@ -255,8 +257,8 @@ class AssetListPage { async check_tokenItemNumber(expectedNumber: number = 1): Promise { console.log(`Waiting for ${expectedNumber} token items to be displayed`); await this.driver.wait(async () => { - const tokenItems = await this.driver.findElements(this.tokenLisiItem); - return tokenItems.length === expectedNumber; + const tokenItemsNumber = await this.getNumberOfAssets(); + return tokenItemsNumber === expectedNumber; }, 10000); console.log( `Expected number of token items ${expectedNumber} is displayed.`, diff --git a/test/e2e/tests/confirmations/transactions/nft-token-send-redesign.spec.ts b/test/e2e/tests/confirmations/transactions/nft-token-send-redesign.spec.ts index bfc226501636..09bd9d4b32a2 100644 --- a/test/e2e/tests/confirmations/transactions/nft-token-send-redesign.spec.ts +++ b/test/e2e/tests/confirmations/transactions/nft-token-send-redesign.spec.ts @@ -11,6 +11,7 @@ import WatchAssetConfirmation from '../../../page-objects/pages/confirmations/le import TokenTransferTransactionConfirmation from '../../../page-objects/pages/confirmations/redesign/token-transfer-confirmation'; import TransactionConfirmation from '../../../page-objects/pages/confirmations/redesign/transaction-confirmation'; import HomePage from '../../../page-objects/pages/home/homepage'; +import NFTListPage from '../../../page-objects/pages/home/nft-list'; import NFTDetailsPage from '../../../page-objects/pages/nft-details-page'; import SendTokenPage from '../../../page-objects/pages/send/send-token-page'; import TestDapp from '../../../page-objects/pages/test-dapp'; @@ -206,9 +207,8 @@ async function createERC721WalletInitiatedTransactionAndAssertDetails( await driver.switchToWindowWithTitle(WINDOW_TITLES.ExtensionInFullScreenView); - const homePage = new HomePage(driver); - await homePage.goToNftTab(); - await homePage.clickNFTIconOnActivityList(); + await new HomePage(driver).goToNftTab(); + await new NFTListPage(driver).clickNFTIconOnActivityList(); const nftDetailsPage = new NFTDetailsPage(driver); await nftDetailsPage.clickNFTSendButton(); @@ -295,9 +295,8 @@ async function createERC1155WalletInitiatedTransactionAndAssertDetails( await watchAssetConfirmation.clickFooterConfirmButton(); await driver.switchToWindowWithTitle(WINDOW_TITLES.ExtensionInFullScreenView); - const homePage = new HomePage(driver); - await homePage.goToNftTab(); - await homePage.clickNFTIconOnActivityList(); + await new HomePage(driver).goToNftTab(); + await new NFTListPage(driver).clickNFTIconOnActivityList(); const nftDetailsPage = new NFTDetailsPage(driver); await nftDetailsPage.clickNFTSendButton(); diff --git a/test/e2e/tests/multichain/aggregated-balances.spec.ts b/test/e2e/tests/multichain/aggregated-balances.spec.ts index 1432d10ec77e..5e99c2e909e7 100644 --- a/test/e2e/tests/multichain/aggregated-balances.spec.ts +++ b/test/e2e/tests/multichain/aggregated-balances.spec.ts @@ -118,7 +118,7 @@ describe('Multichain Aggregated Balances', function (this: Suite) { EXPECTED_SEPOLIA_BALANCE_NATIVE, SEPOLIA_NATIVE_TOKEN, ); - await assetListPage.checkNetworkFilterText(NETWORK_NAME_SEPOLIA); + await assetListPage.check_networkFilterText(NETWORK_NAME_SEPOLIA); // Step 11: Enable fiat display on testnets in settings await headerNavbar.openSettingsPage(); diff --git a/test/e2e/tests/tokens/add-hide-token.spec.ts b/test/e2e/tests/tokens/add-hide-token.spec.ts index e3731bac5352..f6d21430cd18 100644 --- a/test/e2e/tests/tokens/add-hide-token.spec.ts +++ b/test/e2e/tests/tokens/add-hide-token.spec.ts @@ -1,7 +1,7 @@ import { toHex } from '@metamask/controller-utils'; import { withFixtures } from '../../helpers'; import FixtureBuilder from '../../fixture-builder'; -import HomePage from '../../page-objects/pages/home/homepage'; +import AssetListPage from '../../page-objects/pages/home/asset-list'; import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; describe('Add hide token', function () { @@ -38,12 +38,12 @@ describe('Add hide token', function () { }, async ({ driver }) => { await loginWithBalanceValidation(driver); - const homepage = new HomePage(driver); - await homepage.check_tokenItemNumber(2); - await homepage.check_tokenAmountIsDisplayed('0 TST'); + const assetListPage = new AssetListPage(driver); + await assetListPage.check_tokenItemNumber(2); + await assetListPage.check_tokenAmountIsDisplayed('0 TST'); - await homepage.hideToken('TST'); - await homepage.check_tokenItemNumber(1); + await assetListPage.hideToken('TST'); + await assetListPage.check_tokenItemNumber(1); }, ); }); diff --git a/test/e2e/tests/tokens/add-token-using-search.ts b/test/e2e/tests/tokens/add-token-using-search.ts index ce9eec58f8da..c1ae188a39b9 100644 --- a/test/e2e/tests/tokens/add-token-using-search.ts +++ b/test/e2e/tests/tokens/add-token-using-search.ts @@ -2,7 +2,7 @@ import { MockedEndpoint, Mockttp } from 'mockttp'; import { defaultGanacheOptions, withFixtures } from '../../helpers'; import FixtureBuilder from '../../fixture-builder'; import { CHAIN_IDS } from '../../../../shared/constants/network'; -import HomePage from '../../page-objects/pages/home/homepage'; +import AssetListPage from '../../page-objects/pages/home/asset-list'; import { loginWithoutBalanceValidation } from '../../page-objects/flows/login.flow'; describe('Add existing token using search', function () { @@ -56,10 +56,10 @@ describe('Add existing token using search', function () { }, async ({ driver }) => { await loginWithoutBalanceValidation(driver); - const homepage = new HomePage(driver); - await homepage.check_tokenAmountIsDisplayed('25 BNB'); - await homepage.importTokenBySearch('BAT'); - await homepage.check_tokenAmountInTokenDetailsModal( + const assetListPage = new AssetListPage(driver); + await assetListPage.check_tokenAmountIsDisplayed('25 BNB'); + await assetListPage.importTokenBySearch('BAT'); + await assetListPage.check_tokenAmountInTokenDetailsModal( 'Basic Attention Token', '0 BAT', ); diff --git a/test/e2e/tests/tokens/nft/auto-detect-nft.spec.ts b/test/e2e/tests/tokens/nft/auto-detect-nft.spec.ts index a248132d57b5..a1bc9005a2f3 100644 --- a/test/e2e/tests/tokens/nft/auto-detect-nft.spec.ts +++ b/test/e2e/tests/tokens/nft/auto-detect-nft.spec.ts @@ -2,6 +2,7 @@ import { withFixtures } from '../../../helpers'; import FixtureBuilder from '../../../fixture-builder'; import HeaderNavbar from '../../../page-objects/pages/header-navbar'; import Homepage from '../../../page-objects/pages/home/homepage'; +import NFTListPage from '../../../page-objects/pages/home/nft-list'; import PrivacySettings from '../../../page-objects/pages/settings/privacy-settings'; import SettingsPage from '../../../page-objects/pages/settings/settings-page'; import { loginWithBalanceValidation } from '../../../page-objects/flows/login.flow'; @@ -39,10 +40,11 @@ describe('NFT detection', function () { await homepage.check_pageIsLoaded(); await homepage.check_expectedBalanceIsDisplayed(); await homepage.goToNftTab(); - await homepage.check_nftNameIsDisplayed( + const nftListPage = new NFTListPage(driver); + await nftListPage.check_nftNameIsDisplayed( 'ENS: Ethereum Name Service (1)', ); - await homepage.check_nftImageIsDisplayed(); + await nftListPage.check_nftImageIsDisplayed(); }, ); }); diff --git a/test/e2e/tests/tokens/watch-asset-call-add-token.ts b/test/e2e/tests/tokens/watch-asset-call-add-token.ts index 543ca5dea3eb..b1dc4ae98746 100644 --- a/test/e2e/tests/tokens/watch-asset-call-add-token.ts +++ b/test/e2e/tests/tokens/watch-asset-call-add-token.ts @@ -6,7 +6,7 @@ import { import FixtureBuilder from '../../fixture-builder'; import { SMART_CONTRACTS } from '../../seeder/smart-contracts'; import AddTokenConfirmation from '../../page-objects/pages/confirmations/redesign/add-token-confirmations'; -import HomePage from '../../page-objects/pages/home/homepage'; +import AssetListPage from '../../page-objects/pages/home/asset-list'; import TestDapp from '../../page-objects/pages/test-dapp'; import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; @@ -55,7 +55,7 @@ describe('Add token using wallet_watchAsset', function () { await driver.switchToWindowWithTitle( WINDOW_TITLES.ExtensionInFullScreenView, ); - await new HomePage(driver).check_tokenAmountIsDisplayed('0 TST'); + await new AssetListPage(driver).check_tokenAmountIsDisplayed('0 TST'); }, ); }); @@ -102,7 +102,7 @@ describe('Add token using wallet_watchAsset', function () { await driver.switchToWindowWithTitle( WINDOW_TITLES.ExtensionInFullScreenView, ); - await new HomePage(driver).check_tokenItemNumber(1); + await new AssetListPage(driver).check_tokenItemNumber(1); }, ); }); From f901d21de6dc9ba465e5f8fec7a57117508640f4 Mon Sep 17 00:00:00 2001 From: Chloe Gao Date: Thu, 28 Nov 2024 22:27:10 +0100 Subject: [PATCH 03/11] fix --- test/e2e/page-objects/pages/home/activity-list.ts | 1 + test/e2e/tests/account/snap-account-contract-interaction.spec.ts | 1 + test/e2e/tests/tokens/token-sort.spec.ts | 1 - 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/e2e/page-objects/pages/home/activity-list.ts b/test/e2e/page-objects/pages/home/activity-list.ts index 869baee6c9bf..76ea76c5932f 100644 --- a/test/e2e/page-objects/pages/home/activity-list.ts +++ b/test/e2e/page-objects/pages/home/activity-list.ts @@ -1,3 +1,4 @@ +import { strict as assert } from 'assert'; import { Driver } from '../../../webdriver/driver'; class ActivityListPage { diff --git a/test/e2e/tests/account/snap-account-contract-interaction.spec.ts b/test/e2e/tests/account/snap-account-contract-interaction.spec.ts index da409e555246..4b12b71b293e 100644 --- a/test/e2e/tests/account/snap-account-contract-interaction.spec.ts +++ b/test/e2e/tests/account/snap-account-contract-interaction.spec.ts @@ -75,6 +75,7 @@ describe('Snap Account Contract interaction @no-mmi', function (this: Suite) { ); const homePage = new HomePage(driver); await homePage.check_pageIsLoaded(); + await homePage.goToActivityList(); const activityList = new ActivityListPage(driver); await activityList.check_confirmedTxNumberDisplayedInActivity(); await activityList.check_txAmountInActivity('-4 ETH'); diff --git a/test/e2e/tests/tokens/token-sort.spec.ts b/test/e2e/tests/tokens/token-sort.spec.ts index 2530181f1764..ccead6768277 100644 --- a/test/e2e/tests/tokens/token-sort.spec.ts +++ b/test/e2e/tests/tokens/token-sort.spec.ts @@ -53,7 +53,6 @@ describe('Token List', function () { }, async ({ driver }: { driver: Driver }) => { await unlockWallet(driver); - throw new Error('Not implemented'); await importToken(driver); const tokenListBeforeSorting = await driver.findElements( From f710b80b4f923da456187c3b8d72d68667994b79 Mon Sep 17 00:00:00 2001 From: Chloe Gao Date: Thu, 28 Nov 2024 22:49:28 +0100 Subject: [PATCH 04/11] fix --- test/e2e/tests/tokens/token-sort.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/e2e/tests/tokens/token-sort.spec.ts b/test/e2e/tests/tokens/token-sort.spec.ts index ccead6768277..ff2d35a917dc 100644 --- a/test/e2e/tests/tokens/token-sort.spec.ts +++ b/test/e2e/tests/tokens/token-sort.spec.ts @@ -100,7 +100,6 @@ describe('Token List', function () { assert.ok( tokenListAfterSortingByDecliningBalance[0].includes('Ethereum'), ); - throw new Error('Not implemented'); }, ); }); From 67b97c0d605b76724183b362783f985bbd325ee2 Mon Sep 17 00:00:00 2001 From: Chloe Gao Date: Mon, 2 Dec 2024 11:04:00 +0100 Subject: [PATCH 05/11] revert changes in circleci --- .circleci/config.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4c3c0c5e69c3..3178a687a617 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -172,6 +172,7 @@ workflows: requires: - prep-deps - prep-build-test-flask-mv2: + <<: *develop_master_rc_only requires: - prep-deps - prep-build-test-mmi: @@ -199,6 +200,7 @@ workflows: requires: - prep-deps - test-e2e-chrome-webpack: + <<: *develop_master_rc_only requires: - prep-build-test-webpack - get-changed-files-with-git-diff @@ -207,6 +209,7 @@ workflows: - prep-build-test - get-changed-files-with-git-diff - test-e2e-firefox: + <<: *develop_master_rc_only requires: - prep-build-test-mv2 - get-changed-files-with-git-diff @@ -226,6 +229,7 @@ workflows: - prep-build-test-flask - get-changed-files-with-git-diff - test-e2e-firefox-flask: + <<: *develop_master_rc_only requires: - prep-build-test-flask-mv2 - test-e2e-chrome-mmi: From 24ca1c3b79f9ec7a3f0333d830ce6d2f55f21869 Mon Sep 17 00:00:00 2001 From: Chloe Gao Date: Mon, 2 Dec 2024 11:25:30 +0100 Subject: [PATCH 06/11] fix --- test/e2e/tests/multichain/asset-list.spec.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/e2e/tests/multichain/asset-list.spec.ts b/test/e2e/tests/multichain/asset-list.spec.ts index 46ea68bab23a..b206ef1b4e56 100644 --- a/test/e2e/tests/multichain/asset-list.spec.ts +++ b/test/e2e/tests/multichain/asset-list.spec.ts @@ -50,7 +50,7 @@ describe('Multichain Asset List', function (this: Suite) { const assetListPage = new AssetListPage(driver); await headerNavbar.clickSwitchNetworkDropDown(); await selectNetworkDialog.selectNetworkName(NETWORK_NAME_MAINNET); - await assetListPage.check_tokenItemNumber(2); + await assetListPage.check_tokenItemNumber(3); await assetListPage.openNetworksFilter(); await assetListPage.clickCurrentNetworkOption(); await headerNavbar.clickSwitchNetworkDropDown(); @@ -80,7 +80,7 @@ describe('Multichain Asset List', function (this: Suite) { const assetListPage = new AssetListPage(driver); await headerNavbar.clickSwitchNetworkDropDown(); await selectNetworkDialog.selectNetworkName(NETWORK_NAME_MAINNET); - await assetListPage.check_tokenItemNumber(2); + await assetListPage.check_tokenItemNumber(3); await driver.clickElement('.multichain-token-list-item'); const coinOverviewElement = await driver.findElement( '[data-testid="coin-overview-buy"]', @@ -113,7 +113,7 @@ describe('Multichain Asset List', function (this: Suite) { await headerNavbar.clickSwitchNetworkDropDown(); await selectNetworkDialog.selectNetworkName(NETWORK_NAME_MAINNET); const sendPage = new SendTokenPage(driver); - await assetListPage.check_tokenItemNumber(2); + await assetListPage.check_tokenItemNumber(4); await assetListPage.clickOnAsset('TST'); await driver.clickElement('[data-testid="eth-overview-send"]'); await sendPage.check_networkChange(POLYGON_NAME_MAINNET); @@ -147,7 +147,7 @@ describe('Multichain Asset List', function (this: Suite) { const assetListPage = new AssetListPage(driver); await headerNavbar.clickSwitchNetworkDropDown(); await selectNetworkDialog.selectNetworkName(NETWORK_NAME_MAINNET); - await assetListPage.check_tokenItemNumber(2); + await assetListPage.check_tokenItemNumber(4); await assetListPage.clickOnAsset('TST'); await driver.clickElement('.mm-box > button:nth-of-type(3)'); const toastTextElement = await driver.findElement('.toast-text'); @@ -176,7 +176,7 @@ describe('Multichain Asset List', function (this: Suite) { const selectNetworkDialog = new SelectNetwork(driver); await headerNavbar.clickSwitchNetworkDropDown(); await selectNetworkDialog.selectNetworkName(LINEA_NAME_MAINNET); - await assetListPage.check_tokenItemNumber(2); + await assetListPage.check_tokenItemNumber(3); await assetListPage.clickOnAsset('Ethereum'); const swapButton = await driver.findElement( From 2cffd275efb88f4c45d5f5c140f6f7b0c0f6b0f5 Mon Sep 17 00:00:00 2001 From: Chloe Gao Date: Mon, 2 Dec 2024 11:40:38 +0100 Subject: [PATCH 07/11] fix lint --- test/e2e/tests/settings/change-language.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/tests/settings/change-language.spec.ts b/test/e2e/tests/settings/change-language.spec.ts index 469ad3ceec30..234f83eb1271 100644 --- a/test/e2e/tests/settings/change-language.spec.ts +++ b/test/e2e/tests/settings/change-language.spec.ts @@ -6,7 +6,7 @@ import FixtureBuilder from '../../fixture-builder'; import AdvancedSettings from '../../page-objects/pages/settings/advanced-settings'; import GeneralSettings from '../../page-objects/pages/settings/general-settings'; import HeaderNavbar from '../../page-objects/pages/header-navbar'; -import Homepage from '../../page-objects/pages/homepage'; +import Homepage from '../../page-objects/pages/home/homepage'; import SendTokenPage from '../../page-objects/pages/send/send-token-page'; import SettingsPage from '../../page-objects/pages/settings/settings-page'; import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; From 316ed1bb97e5f2fd616e516e4e0eeba7206afd65 Mon Sep 17 00:00:00 2001 From: chloeYue <105063779+chloeYue@users.noreply.github.com> Date: Mon, 2 Dec 2024 16:58:27 +0100 Subject: [PATCH 08/11] Update test/e2e/page-objects/pages/home/asset-list.ts Co-authored-by: Harika <153644847+hjetpoluru@users.noreply.github.com> --- test/e2e/page-objects/pages/home/asset-list.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/page-objects/pages/home/asset-list.ts b/test/e2e/page-objects/pages/home/asset-list.ts index d7308974abe8..7ac55714c800 100644 --- a/test/e2e/page-objects/pages/home/asset-list.ts +++ b/test/e2e/page-objects/pages/home/asset-list.ts @@ -46,7 +46,7 @@ class AssetListPage { private readonly tokenAmountValue = '[data-testid="multichain-token-list-item-value"]'; - private readonly tokenLisiItem = + private readonly tokenListItem = '[data-testid="multichain-token-list-button"]'; private readonly tokenOptionsButton = '[data-testid="import-token-button"]'; From 0f4ff24901ba01c0a4e5f971173a471ad91369e5 Mon Sep 17 00:00:00 2001 From: chloeYue <105063779+chloeYue@users.noreply.github.com> Date: Mon, 2 Dec 2024 16:58:54 +0100 Subject: [PATCH 09/11] Update test/e2e/page-objects/pages/home/asset-list.ts Co-authored-by: Harika <153644847+hjetpoluru@users.noreply.github.com> --- test/e2e/page-objects/pages/home/asset-list.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/page-objects/pages/home/asset-list.ts b/test/e2e/page-objects/pages/home/asset-list.ts index 7ac55714c800..5e36e3110c1f 100644 --- a/test/e2e/page-objects/pages/home/asset-list.ts +++ b/test/e2e/page-objects/pages/home/asset-list.ts @@ -70,7 +70,7 @@ class AssetListPage { } async clickOnAsset(assetName: string): Promise { - const buttons = await this.driver.findElements(this.tokenLisiItem); + const buttons = await this.driver.findElements(this.tokenListItem); for (const button of buttons) { const text = await button.getText(); if (text.includes(assetName)) { From f7a84e58ccd55097ac63311afd5e00807f35ad7f Mon Sep 17 00:00:00 2001 From: chloeYue <105063779+chloeYue@users.noreply.github.com> Date: Mon, 2 Dec 2024 16:59:16 +0100 Subject: [PATCH 10/11] Update test/e2e/page-objects/pages/home/asset-list.ts Co-authored-by: Harika <153644847+hjetpoluru@users.noreply.github.com> --- test/e2e/page-objects/pages/home/asset-list.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/page-objects/pages/home/asset-list.ts b/test/e2e/page-objects/pages/home/asset-list.ts index 5e36e3110c1f..e646f72b6732 100644 --- a/test/e2e/page-objects/pages/home/asset-list.ts +++ b/test/e2e/page-objects/pages/home/asset-list.ts @@ -108,7 +108,7 @@ class AssetListPage { async getNumberOfAssets(): Promise { console.log(`Returning the total number of asset items in the token list`); - const assets = await this.driver.findElements(this.tokenLisiItem); + const assets = await this.driver.findElements(this.tokenListItem); return assets.length; } From 2f6321228f243ddb273a8800e438cd0e914ba9da Mon Sep 17 00:00:00 2001 From: Chloe Gao Date: Mon, 2 Dec 2024 17:00:00 +0100 Subject: [PATCH 11/11] typo --- test/e2e/page-objects/pages/home/asset-list.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/page-objects/pages/home/asset-list.ts b/test/e2e/page-objects/pages/home/asset-list.ts index e646f72b6732..c80eb9e96eed 100644 --- a/test/e2e/page-objects/pages/home/asset-list.ts +++ b/test/e2e/page-objects/pages/home/asset-list.ts @@ -192,7 +192,7 @@ class AssetListPage { } async check_ifAssetIsVisible(assetName: string): Promise { - const assets = await this.driver.findElements(this.tokenLisiItem); + const assets = await this.driver.findElements(this.tokenListItem); for (const asset of assets) { const text = await asset.getText(); if (text.includes(assetName)) {