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

Improve network config #213

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
"branches": [
"main",
{
"name": "develop",
"channel": "alpha",
"prerelease": "alpha"
"name": "improve-network-config",
"channel": "alpha-netconf",
"prerelease": "alpha-netconf"
}
]
}
Expand Down
38 changes: 21 additions & 17 deletions packages/wallets/src/bitget/bitgetPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,27 +78,31 @@ export class BitgetPage implements WalletPage {
});
}

// eslint-disable-next-line
async addNetwork(networkName: string, networkUrl: string, chainId: number, tokenSymbol: string) {}

// eslint-disable-next-line
async importKey(key: string) {}
async addNetwork() {
throw new Error('Method not implemented.');
}

// eslint-disable-next-line
async assertTxAmount(page: Page, expectedAmount: string) {}
async importKey() {
throw new Error('Method not implemented.');
}

// eslint-disable-next-line
async confirmTx(page: Page) {}
async assertTxAmount() {
throw new Error('Method not implemented.');
}

// eslint-disable-next-line
async signTx(page: Page) {}
async confirmTx() {
throw new Error('Method not implemented.');
}

// eslint-disable-next-line
async approveTokenTx(page: Page) {}
async signTx() {
throw new Error('Method not implemented.');
}

// eslint-disable-next-line
async useDefaultToApprove(page: Page) {}
async approveTokenTx() {
throw new Error('Method not implemented.');
}

// eslint-disable-next-line
async assertReceiptAddress(page: Page, expectedAddress: string) {}
async assertReceiptAddress() {
throw new Error('Method not implemented.');
}
}
26 changes: 15 additions & 11 deletions packages/wallets/src/coin98/coin98.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,29 +105,33 @@ export class Coin98 implements WalletPage {
});
}

// eslint-disable-next-line
async assertTxAmount(page: Page, expectedAmount: string) {}
async assertTxAmount() {
throw new Error('Method not implemented.');
}

async confirmTx(page: Page) {
await test.step('Confirm TX', async () => {
await page.click('button:has-text("Confirm")');
});
}

// eslint-disable-next-line
async signTx(page: Page) {}
async signTx() {
throw new Error('Method not implemented.');
}

// eslint-disable-next-line
async assertReceiptAddress(page: Page, expectedAmount: string) {}
async assertReceiptAddress() {
throw new Error('Method not implemented.');
}

// eslint-disable-next-line
async addNetwork(networkName: string, networkUrl: string, chainId: number, tokenSymbol: string) {}
async addNetwork() {
throw new Error('Method not implemented.');
}

// We need this function cause Coin98 wallet open the extension page after installation
// and close other opened wallet pages (include page with we work so here was test crash)
// We wait for that action and after it we continue testing
// and close other opened wallet pages (include page with we work so here was the test crash)
// We wait for that action and after that we continue testing
async waitForAutomaticallyOpenedWalletPageAfterInstallation() {
if ((await this.browserContext.pages().length) === 1) {
if (this.browserContext.pages().length === 1) {
await this.browserContext.waitForEvent('page');
}
this.page = await this.browserContext.pages()[1];
Expand Down
40 changes: 23 additions & 17 deletions packages/wallets/src/coinbase/coinbase.page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WalletConfig } from '../wallets.constants';
import { NetworkConfig, WalletConfig } from '../wallets.constants';
import { WalletPage } from '../wallet.page';
import expect from 'expect';
import { test, BrowserContext, Page } from '@playwright/test';
Expand Down Expand Up @@ -70,12 +70,7 @@ export class CoinbasePage implements WalletPage {
});
}

async addNetwork(
networkName: string,
networkUrl: string,
chainId: number,
tokenSymbol: string,
) {
async addNetwork(networkConfig: NetworkConfig) {
await test.step('Add network', async () => {
if (!this.page) throw "Page isn't ready";
await this.navigate();
Expand All @@ -85,12 +80,21 @@ export class CoinbasePage implements WalletPage {
this.page.context().waitForEvent('page', { timeout: 5000 }),
await this.page.click('button[data-testid="add-custom-network"]'),
]);
await addNetworkPage.fill('input[name="chainName"]', networkName);
await addNetworkPage.fill('input[name="rpcUrls[0]"]', networkUrl);
await addNetworkPage.fill('input[name="chainId"]', String(chainId));
await addNetworkPage.fill(
'input[name="chainName"]',
networkConfig.chainName,
);
await addNetworkPage.fill(
'input[name="rpcUrls[0]"]',
networkConfig.rpcUrl,
);
await addNetworkPage.fill(
'input[name="chainId"]',
String(networkConfig.chainId),
);
await addNetworkPage.fill(
'input[name="nativeCurrency.symbol"]',
tokenSymbol,
networkConfig.tokenSymbol,
);
await addNetworkPage.click('text=Save');
});
Expand Down Expand Up @@ -126,13 +130,15 @@ export class CoinbasePage implements WalletPage {
});
}

// eslint-disable-next-line
async signTx(page: Page) {}
async signTx() {
throw new Error('Method not implemented.');
}

// eslint-disable-next-line
async assertReceiptAddress(page: Page, expectedAddress: string) {
async assertReceiptAddress() {
throw new Error('Method not implemented.');
}

// eslint-disable-next-line
async importKey(key: string) {}
async importKey() {
throw new Error('Method not implemented.');
}
}
29 changes: 15 additions & 14 deletions packages/wallets/src/exodus/exodus.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,23 @@ export class ExodusPage implements WalletPage {
});
}

// eslint-disable-next-line
async signTx(page: Page) {}
async signTx() {
throw new Error('Method not implemented.');
}

// eslint-disable-next-line
async importKey(key: string) {}
async importKey() {
throw new Error('Method not implemented.');
}

async addNetwork(
networkName: string, // eslint-disable-line
networkUrl: string, // eslint-disable-line
chainId: number, // eslint-disable-line
tokenSymbol: string, // eslint-disable-line
) {} // eslint-disable-line
async addNetwork() {
throw new Error('Method not implemented.');
}

// eslint-disable-next-line
async assertTxAmount(page: Page, expectedAmount: string) {}
async assertTxAmount() {
throw new Error('Method not implemented.');
}

// eslint-disable-next-line
async assertReceiptAddress(page: Page, expectedAddress: string) {}
async assertReceiptAddress() {
throw new Error('Method not implemented.');
}
}
48 changes: 16 additions & 32 deletions packages/wallets/src/metamask/metamask.page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WalletConfig } from '../wallets.constants';
import { NetworkConfig, WalletConfig } from '../wallets.constants';
import { WalletPage } from '../wallet.page';
import { expect } from '@playwright/test';
import { test, BrowserContext, Page } from '@playwright/test';
Expand Down Expand Up @@ -85,52 +85,36 @@ export class MetamaskPage implements WalletPage {
});
}

async setupNetwork(standConfig: Record<string, any>) {
await test.step(`Setup "${standConfig.chainName}" Network`, async () => {
async setupNetwork(networkConfig: NetworkConfig) {
await test.step(`Setup "${networkConfig.chainName}" Network`, async () => {
await this.header.networkListButton.click();
if (
await this.header.networkList.isNetworkExist(
standConfig.chainName,
standConfig.rpcUrl,
standConfig.chainId,
networkConfig.chainName,
networkConfig.rpcUrl,
networkConfig.chainId,
)
) {
await this.header.networkList.clickToNetworkItemButton(
standConfig.chainName,
networkConfig.chainName,
);
} else {
await this.header.networkList.networkDisplayCloseBtn.click();
await this.addNetwork(
standConfig.chainName,
standConfig.rpcUrl,
standConfig.chainId,
standConfig.tokenSymbol,
standConfig.scan,
);
await this.addNetwork(networkConfig);
}
});
}

async addNetwork(
networkName: string,
networkUrl: string,
chainId: number,
tokenSymbol: string,
blockExplorer = '',
isClosePage = false,
) {
await test.step(`Add new network "${networkName}"`, async () => {
async addNetwork(networkConfig: NetworkConfig, isClosePage = false) {
networkConfig.scan = !networkConfig.scan ? '' : networkConfig.scan;
await test.step(`Add new network "${networkConfig.chainName}"`, async () => {
await this.navigate();
if (await isPopularNetwork(networkName)) {
await this.header.networkList.addPopularNetwork(networkName);
} else {
await this.header.networkList.addNetworkManually(
networkName,
networkUrl,
chainId,
tokenSymbol,
blockExplorer,
if (await isPopularNetwork(networkConfig.chainName)) {
await this.header.networkList.addPopularNetwork(
networkConfig.chainName,
);
} else {
await this.header.networkList.addNetworkManually(networkConfig);
}
if (isClosePage) await this.page.close();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Locator, Page, test } from '@playwright/test';
import { NetworkSetting } from './networkSetting.element';
import { NetworkConfig } from '../../../wallets.constants';

export class NetworkList {
page: Page;
Expand Down Expand Up @@ -42,11 +43,6 @@ export class NetworkList {
});
}

async switchNetwork(networkName: string) {
await this.networkListButton.click();
await this.dialogSection.getByText(networkName).click();
}

async getNetworkListText() {
return await test.step('Get network list', async () => {
const networkList = await this.networkItemText.all();
Expand Down Expand Up @@ -86,35 +82,27 @@ export class NetworkList {
);
const rpcUrlsFound = await elements.filter({ hasText: rpcUrl }).count();

if (rpcUrlsFound == 0) return false;
return true;
return rpcUrlsFound != 0;
}

async addNetworkManually(
networkName: string,
networkUrl: string,
chainId: number,
tokenSymbol: string,
blockExplorer = '',
) {
async addNetworkManually(networkConfig: NetworkConfig) {
await test.step('Open the form to add network manually', async () => {
await this.networkListButton.click();
});

if (await this.dialogSection.getByText(networkName).isVisible()) {
await this.openModalNetworkEdit(chainId);
await this.networkSetting.addRpcForNetwork(networkUrl, blockExplorer);
if (
await this.dialogSection.getByText(networkConfig.chainName).isVisible()
) {
await this.openModalNetworkEdit(networkConfig.chainId);
await this.networkSetting.addRpcForNetwork(
networkConfig.rpcUrl,
networkConfig.scan,
);
} else {
await test.step('Add custom network', async () => {
await this.addCustomNetworkButton.click();
});
await this.networkSetting.addCustomNetwork(
networkName,
networkUrl,
chainId,
tokenSymbol,
blockExplorer,
);
await this.networkSetting.addCustomNetwork(networkConfig);
}
}

Expand Down
Loading
Loading