Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix asset-list e2e test (#28822) #28841

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
27 changes: 14 additions & 13 deletions test/e2e/tests/multichain/asset-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,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 +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.waitUntilAssetListHasItems(2);
await assetListPage.waitUntilAssetListHasItems(3);
await assetListPage.openNetworksFilter();
await assetListPage.clickCurrentNetworkOption();
await headerNavbar.clickSwitchNetworkDropDown();
Expand Down Expand Up @@ -79,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.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 +98,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 +113,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 +133,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,14 +147,14 @@ 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',
);
},
Expand All @@ -175,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.waitUntilAssetListHasItems(2);
await assetListPage.waitUntilAssetListHasItems(3);

await assetListPage.clickOnAsset('Ethereum');

Expand All @@ -187,7 +188,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
Loading