Skip to content
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
4 changes: 1 addition & 3 deletions packages/browser-service/src/browser.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ type BrowserServiceOptions = {
*/
export class BrowserService {
private logger = new ConsoleLogger(BrowserService.name);
private walletPage: WalletPage<
WalletConnectTypes.WC | WalletConnectTypes.EOA | WalletConnectTypes.IFRAME
>;
private walletPage: WalletPage;
private browserContextService: BrowserContextService;
public ethereumNodeService: EthereumNodeService;

Expand Down
14 changes: 7 additions & 7 deletions packages/wallets/src/bitget/bitgetPage.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { WalletConnectTypes } from '../wallets.constants';
import { WalletPage, WalletPageOptions } from '../wallet.page';
import { test, Page } from '@playwright/test';
import { ConsoleLogger } from '@nestjs/common';
import { getNotificationPage } from '../../utils/helper';

export class BitgetPage implements WalletPage<WalletConnectTypes.EOA> {
export class BitgetPage implements WalletPage {
logger = new ConsoleLogger(BitgetPage.name);
page: Page | undefined;

Expand Down Expand Up @@ -82,8 +82,12 @@ export class BitgetPage implements WalletPage<WalletConnectTypes.EOA> {
});
}

async connectWallet(page: Page) {
async connectWallet() {
await test.step('Connect wallet', async () => {
const page = await getNotificationPage(
this.options.browserContext,
this.options.extensionUrl,
);
await page.waitForTimeout(1000);
await page.click("button:has-text('Connect')");
await page.close();
Expand Down Expand Up @@ -122,10 +126,6 @@ export class BitgetPage implements WalletPage<WalletConnectTypes.EOA> {
throw new Error('Method not implemented.');
}

async approveTokenTx() {
throw new Error('Method not implemented.');
}

async assertReceiptAddress() {
throw new Error('Method not implemented.');
}
Expand Down
17 changes: 13 additions & 4 deletions packages/wallets/src/coin98/coin98.page.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { WalletConnectTypes } from '../wallets.constants';
import { WalletPage, WalletPageOptions } from '../wallet.page';
import { test, Page } from '@playwright/test';
import { ConsoleLogger } from '@nestjs/common';
import { getNotificationPage } from '../../utils/helper';

export class Coin98 implements WalletPage<WalletConnectTypes.EOA> {
export class Coin98 implements WalletPage {
logger = new ConsoleLogger(Coin98.name);
page: Page | undefined;

Expand Down Expand Up @@ -42,7 +42,7 @@
await this.page.locator('button:has-text("Continue")').click(); // Terms page
await this.page.locator('button:has-text("Continue")').last().click(); // Language page
await this.page.locator('button:has-text("Continue")').last().click(); // Security page
await this.page.waitForSelector('input[type=password]');

Check failure on line 45 in packages/wallets/src/coin98/coin98.page.ts

View workflow job for this annotation

GitHub Actions / Testing

[Widget] › test/widgets/connection.spec.ts:27:7 › Ethereum › Coin98 connect

1) [Widget] › test/widgets/connection.spec.ts:27:7 › Ethereum › Coin98 connect › Setup › First time setup TimeoutError: page.waitForSelector: Timeout 120000ms exceeded. Call log: - waiting for locator('input[type=password]') to be visible at ../../packages/wallets/src/coin98/coin98.page.ts:45 43 | await this.page.locator('button:has-text("Continue")').last().click(); // Language page 44 | await this.page.locator('button:has-text("Continue")').last().click(); // Security page > 45 | await this.page.waitForSelector('input[type=password]'); | ^ 46 | await this.page.waitForTimeout(1000); 47 | const inputs = this.page.locator('input[type=password]'); 48 | for (const char of this.options.accountConfig.PASSWORD) { at /home/runner/work/wallets-testing-modules/wallets-testing-modules/packages/wallets/src/coin98/coin98.page.ts:45:23 at Coin98.firstTimeSetup (/home/runner/work/wallets-testing-modules/wallets-testing-modules/packages/wallets/src/coin98/coin98.page.ts:35:5) at /home/runner/work/wallets-testing-modules/wallets-testing-modules/packages/wallets/src/coin98/coin98.page.ts:30:22 at Coin98.setup (/home/runner/work/wallets-testing-modules/wallets-testing-modules/packages/wallets/src/coin98/coin98.page.ts:24:5) at BrowserService.setup (/home/runner/work/wallets-testing-modules/wallets-testing-modules/packages/browser-service/src/browser.service.ts:137:5) at BrowserService.initWalletSetup (/home/runner/work/wallets-testing-modules/wallets-testing-modules/packages/browser-service/src/browser.service.ts:84:7) at initBrowserWithExtension (/home/runner/work/wallets-testing-modules/wallets-testing-modules/wallets-testing/utils/helpers.ts:37:3) at /home/runner/work/wallets-testing-modules/wallets-testing-modules/wallets-testing/test/widgets/connection.spec.ts:28:22
await this.page.waitForTimeout(1000);
const inputs = this.page.locator('input[type=password]');
for (const char of this.options.accountConfig.PASSWORD) {
Expand Down Expand Up @@ -94,8 +94,12 @@
});
}

async connectWallet(page: Page) {
async connectWallet() {
await test.step('Connect wallet', async () => {
const page = await getNotificationPage(
this.options.browserContext,
this.options.extensionUrl,
);
await this.unlock(page);
const selectAllBtn = page.getByText('Select all', { exact: true });
// for polygon network there is no account selection preview
Expand All @@ -108,6 +112,7 @@
await page.click('button:has-text("Connect")');
});
}

async closePopover(popUpPage: Page) {
//popUpPage param required since noisy pop-up can appear in confirmation pages
try {
Expand Down Expand Up @@ -137,8 +142,12 @@
throw new Error('Method not implemented.');
}

async confirmTx(page: Page) {
async confirmTx() {
await test.step('Confirm TX', async () => {
const page = await getNotificationPage(
this.options.browserContext,
this.options.extensionUrl,
);
await page.click('button:has-text("Confirm")');
});
}
Expand Down
23 changes: 18 additions & 5 deletions packages/wallets/src/coinbase/coinbase.page.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { NetworkConfig, WalletConnectTypes } from '../wallets.constants';
import { NetworkConfig } from '../wallets.constants';
import { WalletPage, WalletPageOptions } from '../wallet.page';
import expect from 'expect';
import { test, Page } from '@playwright/test';
import { ConsoleLogger } from '@nestjs/common';
import { getNotificationPage } from '../../utils/helper';

export class CoinbasePage implements WalletPage<WalletConnectTypes.EOA> {
export class CoinbasePage implements WalletPage {
logger = new ConsoleLogger(CoinbasePage.name);
page: Page | undefined;

Expand Down Expand Up @@ -120,22 +121,34 @@ export class CoinbasePage implements WalletPage<WalletConnectTypes.EOA> {
});
}

async connectWallet(page: Page) {
async connectWallet() {
await test.step('Connect wallet', async () => {
const page = await getNotificationPage(
this.options.browserContext,
this.options.extensionUrl,
);
await page.click('button:has-text("Connect")');
});
}

async assertTxAmount(page: Page, expectedAmount: string) {
async assertTxAmount(expectedAmount: string) {
await test.step('Assert TX Amount', async () => {
const page = await getNotificationPage(
this.options.browserContext,
this.options.extensionUrl,
);
expect(await page.textContent('.currency-display-component__text')).toBe(
expectedAmount,
);
});
}

async confirmTx(page: Page) {
async confirmTx() {
await test.step('Confirm TX', async () => {
const page = await getNotificationPage(
this.options.browserContext,
this.options.extensionUrl,
);
await this.closeTransactionPopover();
await page.click('button[data-testid="request-confirm-button"]');
});
Expand Down
14 changes: 7 additions & 7 deletions packages/wallets/src/ctrl/ctrl.page.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { WalletPage } from '../wallet.page';
import { test, Page } from '@playwright/test';
import { WalletConnectTypes } from '../wallets.constants';
import { LoginPage, OnboardingPage, WalletOperations } from './pages';
import { WalletPageOptions } from '../wallet.page';
import { ConsoleLogger } from '@nestjs/common';
import { getNotificationPage } from '../../utils/helper';

export class CtrlPage implements WalletPage<WalletConnectTypes.EOA> {
export class CtrlPage implements WalletPage {
logger = new ConsoleLogger(CtrlPage.name);
page: Page | undefined;
onboardingPage: OnboardingPage;
Expand Down Expand Up @@ -53,8 +53,12 @@ export class CtrlPage implements WalletPage<WalletConnectTypes.EOA> {
}

/** Click `Connect` button */
async connectWallet(page: Page) {
async connectWallet() {
await test.step('Connect Ctrl wallet', async () => {
const page = await getNotificationPage(
this.options.browserContext,
this.options.extensionUrl,
);
const operationPage = new WalletOperations(page);
await operationPage.connectBtn.waitFor({
state: 'visible',
Expand Down Expand Up @@ -94,10 +98,6 @@ export class CtrlPage implements WalletPage<WalletConnectTypes.EOA> {
throw new Error('Method not implemented.');
}

approveTokenTx(): Promise<void> {
throw new Error('Method not implemented.');
}

openLastTxInEthplorer(): Promise<Page> {
throw new Error('Method not implemented.');
}
Expand Down
16 changes: 12 additions & 4 deletions packages/wallets/src/exodus/exodus.page.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { WalletConnectTypes } from '../wallets.constants';
import { WalletPage, WalletPageOptions } from '../wallet.page';
import { test, Page } from '@playwright/test';
import { OnboardingPage } from './pages';
import { ConsoleLogger } from '@nestjs/common';
import { getNotificationPage } from '../../utils/helper';

export class ExodusPage implements WalletPage<WalletConnectTypes.EOA> {
export class ExodusPage implements WalletPage {
logger = new ConsoleLogger(ExodusPage.name);
page: Page | undefined;
onboardingPage: OnboardingPage;
Expand Down Expand Up @@ -63,8 +63,12 @@ export class ExodusPage implements WalletPage<WalletConnectTypes.EOA> {
}

/** Click `Connect` button on the transaction `page` */
async connectWallet(page: Page) {
async connectWallet() {
await test.step('Connect wallet', async () => {
const page = await getNotificationPage(
this.options.browserContext,
this.options.extensionUrl,
);
const connectWalletBtn = page.getByText('Connect').nth(2);
// the connect button is disabled by default, and it will be enabled after hover with awaiting
await connectWalletBtn.hover();
Expand All @@ -74,8 +78,12 @@ export class ExodusPage implements WalletPage<WalletConnectTypes.EOA> {
}

/** Click `Confirm` button on the transaction `page` */
async confirmTx(page: Page) {
async confirmTx() {
await test.step('Confirm TX', async () => {
const page = await getNotificationPage(
this.options.browserContext,
this.options.extensionUrl,
);
await page.getByText('Confirm').click();
});
}
Expand Down
63 changes: 48 additions & 15 deletions packages/wallets/src/metamask/metamask-latest/metamask.page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NetworkConfig, WalletConnectTypes } from '../../wallets.constants';
import { NetworkConfig } from '../../wallets.constants';
import { WalletPage, WalletPageOptions } from '../../wallet.page';
import { expect } from '@playwright/test';
import { test, Page } from '@playwright/test';
Expand All @@ -18,8 +18,12 @@ import {
} from './pages/elements';
import { getAddress } from 'viem';
import { isPopularMainnetNetwork, isPopularTestnetNetwork } from './helper';
import {
getNotificationPage,
waitForWalletPageClosed,
} from '../../../utils/helper';

export class MetamaskPage implements WalletPage<WalletConnectTypes.EOA> {
export class MetamaskPage implements WalletPage {
page: Page | undefined;
header: Header;
homePage: HomePage;
Expand Down Expand Up @@ -109,6 +113,7 @@ export class MetamaskPage implements WalletPage<WalletConnectTypes.EOA> {

async setupNetwork(networkConfig: NetworkConfig) {
await test.step(`Setup "${networkConfig.chainName}" Network`, async () => {
if (this.page.isClosed()) await this.navigate();
await this.settingsMenu.openNetworksSettings();
if (
await this.networkList.isNetworkExist(
Expand Down Expand Up @@ -154,26 +159,38 @@ export class MetamaskPage implements WalletPage<WalletConnectTypes.EOA> {
});
}

async connectWallet(page: Page) {
async connectWallet() {
await test.step('Connect Metamask wallet', async () => {
const page = await getNotificationPage(
this.options.browserContext,
this.options.extensionUrl,
);
const operationPage = new WalletOperationPage(page);
await operationPage.connectBtn.click(); // "Confirm" button to give permission
await operationPage.page.close();
});
}

async assertTxAmount(page: Page, expectedAmount: string) {
async assertTxAmount(expectedAmount: string) {
await test.step('Assert TX Amount', async () => {
const page = await getNotificationPage(
this.options.browserContext,
this.options.extensionUrl,
);
const txAmount = await new WalletOperationPage(page).getTxAmount();
if (txAmount) {
expect(txAmount).toBe(expectedAmount);
}
});
}

async confirmAddTokenToWallet(confirmPage: Page) {
async confirmAddTokenToWallet() {
await test.step('Confirm add token to wallet', async () => {
await new WalletOperationPage(confirmPage).addTokenButton.click();
const page = await getNotificationPage(
this.options.browserContext,
this.options.extensionUrl,
);
await new WalletOperationPage(page).addTokenButton.click();
});
}

Expand Down Expand Up @@ -212,26 +229,42 @@ export class MetamaskPage implements WalletPage<WalletConnectTypes.EOA> {
});
}

async confirmTx(page: Page, setAggressiveGas?: boolean) {
async confirmTx(setAggressiveGas?: boolean) {
await test.step('Confirm TX', async () => {
const page = await getNotificationPage(
this.options.browserContext,
this.options.extensionUrl,
);
const pageTitle = await page
.locator('h2')
.textContent()
.catch(() => undefined);
await new WalletOperationPage(page).confirmTransaction(setAggressiveGas);
await waitForWalletPageClosed(page, pageTitle);
});
}

async cancelTx(page: Page) {
async cancelTx() {
await test.step('Reject TX', async () => {
const page = await getNotificationPage(
this.options.browserContext,
this.options.extensionUrl,
);
const pageTitle = await page
.locator('h2')
.textContent()
.catch(() => undefined);
await new WalletOperationPage(page).cancelTransaction();
await waitForWalletPageClosed(page, pageTitle);
});
}

async approveTokenTx(page: Page) {
await test.step('Approve token TX', async () => {
await new WalletOperationPage(page).confirmTransactionOfTokenApproval();
});
}

async assertReceiptAddress(page: Page, expectedAddress: string) {
async assertReceiptAddress(expectedAddress: string) {
await test.step('Assert receiptAddress/Contract', async () => {
const page = await getNotificationPage(
this.options.browserContext,
this.options.extensionUrl,
);
const recipientAddress = await new WalletOperationPage(
page,
).getReceiptAddress();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ export class WalletOperationPage {
'button[aria-label="Close"]',
);
this.txDetailBlock = this.page.getByTestId('simulation-details-layout');
this.txDetailAmount = this.txDetailBlock.getByTestId(
'simulation-details-amount-pill',
);
this.txDetailAmount = this.txDetailBlock
.getByTestId('simulation-details-amount-pill')
.first();
}

async cancelAllTxInQueue() {
Expand Down Expand Up @@ -79,15 +79,6 @@ export class WalletOperationPage {
}
}

async confirmTransactionOfTokenApproval() {
await test.step('Click "Use default" button in case if it exist', async () => {
// todo: im not sure this step is needed now
if (await this.page.locator('text=Use default').isVisible())
await this.page.click('text=Use default');
});
await this.confirmButton.click();
}

async confirmTransaction(setAggressiveGas?: boolean) {
if (setAggressiveGas) {
await this.editGasFeeButton.click();
Expand All @@ -110,7 +101,8 @@ export class WalletOperationPage {

async getTxAmount() {
if (await this.txDetailBlock.isVisible()) {
return await this.txDetailAmount.textContent();
const amount = await this.txDetailAmount.textContent();
return amount.match(/\d+\.\d*/)[0];
}
return null;
}
Expand Down
Loading
Loading