Skip to content

Commit

Permalink
put home related pages together
Browse files Browse the repository at this point in the history
  • Loading branch information
chloeYue committed Nov 28, 2024
1 parent 74eea0b commit 9c84fb4
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 35 deletions.
4 changes: 0 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ workflows:
requires:
- prep-deps
- prep-build-test-flask-mv2:
<<: *develop_master_rc_only
requires:
- prep-deps
- prep-build-test-mmi:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down
18 changes: 10 additions & 8 deletions test/e2e/page-objects/pages/home/asset-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ class AssetListPage {
}

async clickOnAsset(assetName: string): Promise<void> {
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)) {
Expand Down Expand Up @@ -108,6 +106,12 @@ class AssetListPage {
return text;
}

async getNumberOfAssets(): Promise<number> {
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.
*
Expand Down Expand Up @@ -188,9 +192,7 @@ class AssetListPage {
}

async check_ifAssetIsVisible(assetName: string): Promise<boolean> {
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)) {
Expand Down Expand Up @@ -255,8 +257,8 @@ class AssetListPage {
async check_tokenItemNumber(expectedNumber: number = 1): Promise<void> {
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.`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/multichain/aggregated-balances.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/tests/tokens/add-hide-token.spec.ts
Original file line number Diff line number Diff line change
@@ -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 () {
Expand Down Expand Up @@ -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);
},
);
});
Expand Down
10 changes: 5 additions & 5 deletions test/e2e/tests/tokens/add-token-using-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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',
);
Expand Down
6 changes: 4 additions & 2 deletions test/e2e/tests/tokens/nft/auto-detect-nft.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
},
);
});
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/tests/tokens/watch-asset-call-add-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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');
},
);
});
Expand Down Expand Up @@ -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);
},
);
});
Expand Down

0 comments on commit 9c84fb4

Please sign in to comment.