diff --git a/test/e2e/fixture-builder.js b/test/e2e/fixture-builder.js index 844c4766db3e..0a397acb6c97 100644 --- a/test/e2e/fixture-builder.js +++ b/test/e2e/fixture-builder.js @@ -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', diff --git a/test/e2e/tests/multichain/asset-list.spec.ts b/test/e2e/tests/multichain/asset-list.spec.ts index 5b210730ef36..924e1b9e1b8c 100644 --- a/test/e2e/tests/multichain/asset-list.spec.ts +++ b/test/e2e/tests/multichain/asset-list.spec.ts @@ -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, @@ -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(); @@ -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"]', @@ -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, @@ -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', @@ -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, @@ -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 ({ @@ -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'); @@ -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(