Skip to content

Commit

Permalink
Added checks for token balance
Browse files Browse the repository at this point in the history
  • Loading branch information
davibroc committed Nov 29, 2024
1 parent 6ed9fd5 commit e1eb17b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
12 changes: 11 additions & 1 deletion test/e2e/playwright/shared/pageObjects/wallet-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export class WalletPage {

readonly importAccountConfirmBtn: Locator;

readonly tokenBalance: Locator;

constructor(page: Page) {
this.page = page;
this.swapButton = this.page.getByTestId('token-overview-button-swap');
Expand All @@ -29,6 +31,9 @@ export class WalletPage {
this.importAccountButton = this.page.getByText('Import account');
this.importButton = this.page.getByText('Import (');
this.tokenTab = this.page.getByTestId('account-overview__asset-tab');
this.tokenBalance = this.page.getByTestId(
'multichain-token-list-item-value',
);
this.addAccountButton = this.page.getByTestId(
'multichain-account-menu-popover-action-button',
);
Expand All @@ -54,6 +59,8 @@ export class WalletPage {
await this.importAccountButton.click();
await this.page.fill('#private-key-box', accountPK);
await this.importAccountConfirmBtn.click();
await this.page.waitForTimeout(2000);
return await this.accountMenu.textContent();
}

async selectTokenWallet() {
Expand All @@ -63,10 +70,13 @@ export class WalletPage {
async selectSwapAction() {
await this.swapButton.waitFor({ state: 'visible' });
await this.swapButton.click();
await this.page.waitForTimeout(10000);
}

async selectActivityList() {
await this.activityListTab.click();
}

async getTokenBalance() {
return await this.tokenBalance.first().textContent();
}
}
10 changes: 6 additions & 4 deletions test/e2e/playwright/swap/specs/swap.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ethers } from 'ethers';
import { test } from '@playwright/test';
import { test, expect } from '@playwright/test';
import log from 'loglevel';

import { ChromeExtensionPage } from '../../shared/pageObjects/extension-page';
Expand Down Expand Up @@ -73,18 +73,20 @@ test.beforeAll(
walletPage = new WalletPage(page);

await networkController.addCustomNetwork(Tenderly.Mainnet);
await walletPage.importAccount(wallet.privateKey);
const account_name = await walletPage.importAccount(wallet.privateKey);
expect(account_name).toEqual('Account 2');
const balance = await walletPage.getTokenBalance();
expect(balance).toEqual('1 ETH');
},
);

testSet.forEach((options) => {
test(`should swap ${options.type} token ${options.source} to ${options.destination} on ${options.network.name}'`, async () => {
await walletPage.selectTokenWallet();
await networkController.selectNetwork(options.network);
await walletPage.page.waitForTimeout(5000);
await walletPage.selectSwapAction();
await walletPage.page.waitForTimeout(5000);
// Allow balance label to populate
await walletPage.page.waitForTimeout(3000);
const quoteEntered = await swapPage.enterQuote({
from: options.source,
to: options.destination,
Expand Down

0 comments on commit e1eb17b

Please sign in to comment.