Skip to content

Commit

Permalink
fix: fix asset-list e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
salimtb committed Nov 29, 2024
1 parent 5e52a7d commit b6f3eab
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
16 changes: 16 additions & 0 deletions test/e2e/fixture-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,22 @@ class FixtureBuilder {
});
}

withNetworkControllerOnPolygon() {
return this.withNetworkController({
networkConfigurations: {
networkConfigurationId: {
chainId: CHAIN_IDS.POLYGON,
nickname: 'Polygon Mainnet',
rpcPrefs: {},
rpcUrl: 'https://mainnet.infura.io',
ticker: 'ETH',
networkConfigurationId: 'networkConfigurationId',
id: 'networkConfigurationId',
},
},
});
}

withNetworkControllerDoubleGanache() {
const ganacheNetworks = mockNetworkStateOld({
id: '76e9cd59-d8e2-47e7-b369-9c205ccb602c',
Expand Down
28 changes: 15 additions & 13 deletions test/e2e/tests/multichain/asset-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ import AssetListPage from '../../page-objects/pages/asset-list';
const NETWORK_NAME_MAINNET = 'Ethereum Mainnet';
const LINEA_NAME_MAINNET = 'Linea Mainnet';
const LOCALHOST = 'Localhost 8545';
const POLYGON_NAME_MAINNET = 'Polygon';
const BALANCE_AMOUNT = '24.9956';

function buildFixtures(title: string) {
function buildFixtures(title: string, chainId: number = 1337) {
return {
fixtures: new FixtureBuilder()
.withPermissionControllerConnectedToTestDapp()
.withTokensControllerERC20()
.withNetworkControllerOnPolygon()
.withTokensControllerERC20({ chainId })
.build(),
ganacheOptions: defaultGanacheOptions,
smartContract: SMART_CONTRACTS.HST,
Expand Down Expand Up @@ -49,7 +51,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.waitUntilAssetListHasItems(3);
await assetListPage.openNetworksFilter();
await assetListPage.clickCurrentNetworkOption();
await headerNavbar.clickSwitchNetworkDropDown();
Expand Down Expand Up @@ -79,7 +81,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.waitUntilAssetListHasItems(3);
await driver.clickElement('.multichain-token-list-item');
const coinOverviewElement = await driver.findElement(
'[data-testid="coin-overview-buy"]',
Expand All @@ -97,7 +99,7 @@ describe('Multichain Asset List', function (this: Suite) {
});
it('switches networks when clicking on send for a token on another network', async function () {
await withFixtures(
buildFixtures(this.test?.fullTitle() as string),
buildFixtures(this.test?.fullTitle() as string, 137),
async ({
driver,
ganacheServer,
Expand All @@ -112,10 +114,10 @@ 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.waitUntilAssetListHasItems(4);
await assetListPage.clickOnAsset('TST');
await driver.clickElement('[data-testid="eth-overview-send"]');
await sendPage.check_networkChange(LOCALHOST);
await sendPage.check_networkChange(POLYGON_NAME_MAINNET);
await sendPage.check_pageIsLoaded();
await sendPage.fillRecipient(
'0x2f318C334780961FB129D2a6c30D0763d9a5C970',
Expand All @@ -132,7 +134,7 @@ describe('Multichain Asset List', function (this: Suite) {
});
it('switches networks when clicking on swap for a token on another network', async function () {
await withFixtures(
buildFixtures(this.test?.fullTitle() as string),
buildFixtures(this.test?.fullTitle() as string, 137),
async ({
driver,
ganacheServer,
Expand All @@ -146,20 +148,20 @@ 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.waitUntilAssetListHasItems(4);
await assetListPage.clickOnAsset('TST');
await driver.clickElement('.mm-box > button:nth-of-type(3)');
const toastTextElement = await driver.findElement('.toast-text');
const toastText = await toastTextElement.getText();
assert.equal(
toastText,
`You're now using ${LOCALHOST}`,
`You're now using ${POLYGON_NAME_MAINNET}`,
'Toast text is correct',
);
},
);
});
it('shows correct asset and balance when swapping on a different chain', async function () {
it.only('shows correct asset and balance when swapping on a different chain', async function () {
await withFixtures(
buildFixtures(this.test?.fullTitle() as string),
async ({
Expand All @@ -175,7 +177,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.waitUntilAssetListHasItems(3);

await assetListPage.clickOnAsset('Ethereum');

Expand All @@ -187,7 +189,7 @@ describe('Multichain Asset List', function (this: Suite) {
const toastText = await toastTextElement.getText();
assert.equal(
toastText,
`You're now using ${LOCALHOST}`,
`You're now using Ethereum Mainnet`,
'Toast text is correct',
);
const balanceMessageElement = await driver.findElement(
Expand Down

0 comments on commit b6f3eab

Please sign in to comment.