Skip to content

Commit

Permalink
Added network tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davibroc committed Sep 19, 2024
1 parent 5a3e201 commit 1bf2d8e
Show file tree
Hide file tree
Showing 6 changed files with 217 additions and 104 deletions.
38 changes: 26 additions & 12 deletions test/e2e/playwright/shared/pageObjects/network-controller-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export class NetworkController {

readonly networkTicker: Locator;

readonly dismissBtn: Locator;

constructor(page: Page) {
this.page = page;
this.networkDisplay = this.page.getByTestId('network-display');
Expand All @@ -45,26 +47,35 @@ export class NetworkController {
this.networkRpc = this.page.getByTestId('network-form-rpc-url');
this.networkChainId = this.page.getByTestId('network-form-chain-id');
this.networkTicker = this.page.getByTestId('network-form-ticker-input');
this.dismissBtn = this.page.getByRole('button', { name: 'Dismiss' });
}

async addCustomNetwork(options: {
name: string;
url: string;
chainID: string;
symbol: string;
}) {
async addCustomNetwork(
options: {
name: string;
url: string;
chainID: string;
symbol: string;
},
switchToNetwork: boolean,
) {
await this.networkDisplay.click();
await this.addNetworkButton.click();
await this.addNetworkManuallyButton.click();

await this.networkName.waitFor();
await this.networkName.fill(options.name);
await this.networkRpc.fill(options.url);
await this.networkChainId.fill(options.chainID);
await this.networkTicker.fill(options.symbol);
await this.saveBtn.click();
await this.switchToNetworkBtn.click();
await this.waitForNetworkToSwitch(options.name);

if (switchToNetwork) {
await this.switchToNetworkBtn.click();
await this.waitForNetworkToSwitch(options.name);
try {
await this.gotItBtn.click({ timeout: 2000 });
} catch (e) {}
} else await this.dismissBtn.click();
}

async addPopularNetwork(options: { networkName: string }) {
Expand All @@ -75,14 +86,17 @@ export class NetworkController {
await this.approveBtn.click();
await this.switchToNetworkBtn.click();
await this.gotItBtn.click();
await this.waitForNetworkToSwitch(options.networkName);
}

async selectNetwork(options: { networkName: string }) {
await this.networkDisplay.click();
const network = await this.page.$(`text=/${options.networkName}/`);
if (network) return; // if already selected we exit
await this.networkDisplay.getAttribute;
await this.networkDisplay.first().click();
await this.networkSearch.fill(options.networkName);
await this.page.getByText(options.networkName).click();
await this.page.getByText(options.networkName).first().click();
await this.waitForNetworkToSwitch(options.networkName);
await this.page.waitForTimeout(1000);
}

async waitForNetworkToSwitch(networkName: string) {
Expand Down
38 changes: 36 additions & 2 deletions test/e2e/playwright/shared/pageObjects/signup-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export class SignUpPage {

readonly importWalletBtn: Locator;

readonly createWalletBtn: Locator;

readonly metametricsBtn: Locator;

readonly confirmSecretBtn: Locator;

readonly agreeBtn: Locator;
Expand All @@ -21,6 +25,8 @@ export class SignUpPage {

readonly passwordConfirmTxt: Locator;

readonly createPasswordBtn: Locator;

readonly agreeCheck: Locator;

readonly agreeTandCCheck: Locator;
Expand All @@ -35,30 +41,42 @@ export class SignUpPage {

readonly nextBtn: Locator;

readonly enableButton: Locator;
readonly enableBtn: Locator;

readonly secureWalletBtn: Locator;

readonly skipBackupBtn: Locator;

readonly skipSrpBackupBtn: Locator;

constructor(page: Page) {
this.page = page;
this.getStartedBtn = page.locator('button:has-text("Get started")');
this.createWalletBtn = page.getByTestId('onboarding-create-wallet');
this.importWalletBtn = page.locator(
'button:has-text("Import an existing wallet")',
);
this.confirmSecretBtn = page.locator(
'button:has-text("Confirm Secret Recovery Phrase")',
);
this.metametricsBtn = page.getByTestId('metametrics-no-thanks');
this.agreeBtn = page.locator('button:has-text("I agree")');
this.createPasswordBtn = page.getByTestId('create-password-wallet');
this.noThanksBtn = page.locator('button:has-text("No thanks")');
this.passwordTxt = page.getByTestId('create-password-new');
this.passwordConfirmTxt = page.getByTestId('create-password-confirm');
this.agreeCheck = page.getByTestId('create-new-vault__terms-checkbox');
this.agreeTandCCheck = page.getByTestId('onboarding-terms-checkbox');
this.agreePasswordTermsCheck = page.getByTestId('create-password-terms');
this.secureWalletBtn = page.getByTestId('secure-wallet-later');
this.skipBackupBtn = page.getByTestId('skip-srp-backup-popover-checkbox');
this.skipSrpBackupBtn = page.getByTestId('skip-srp-backup');
this.importBtn = page.getByTestId('create-password-import');
this.doneBtn = page.getByTestId('pin-extension-done');
this.gotItBtn = page.getByTestId('onboarding-complete-done');
this.nextBtn = page.getByTestId('pin-extension-next');
this.agreeBtn = page.locator('button:has-text("I agree")');
this.enableButton = page.locator('button:has-text("Enable")');
this.enableBtn = page.locator('button:has-text("Enable")');
}

async importWallet() {
Expand All @@ -81,4 +99,20 @@ export class SignUpPage {
await this.nextBtn.click();
await this.doneBtn.click();
}

async createWallet() {
await this.agreeTandCCheck.click();
await this.createWalletBtn.click();
await this.metametricsBtn.click();
await this.passwordTxt.fill(ACCOUNT_PASSWORD as string);
await this.passwordConfirmTxt.fill(ACCOUNT_PASSWORD as string);
await this.agreePasswordTermsCheck.click();
await this.createPasswordBtn.click();
await this.secureWalletBtn.click();
await this.skipBackupBtn.click();
await this.skipSrpBackupBtn.click();
await this.gotItBtn.click();
await this.nextBtn.click();
await this.doneBtn.click();
}
}
26 changes: 26 additions & 0 deletions test/e2e/playwright/shared/pageObjects/wallet-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,31 @@ export class WalletPage {

readonly tokenTab: Locator;

readonly accountMenu: Locator;

readonly addAccountButton: Locator;

readonly importAccountButton: Locator;

readonly importAccountConfirmBtn: Locator;

constructor(page: Page) {
this.page = page;
this.swapButton = this.page.getByTestId('token-overview-button-swap');
this.importTokensButton = this.page.getByText('Import tokens').first();
this.accountMenu = this.page.getByTestId('account-menu-icon');
this.importAccountButton = this.page.getByText('Import account');
this.importButton = this.page.getByText('Import (');
this.tokenTab = this.page.getByTestId('account-overview__asset-tab');
this.addAccountButton = this.page.getByTestId(
'multichain-account-menu-popover-action-button',
);
this.activityListTab = this.page.getByTestId(
'account-overview__activity-tab',
);
this.importAccountConfirmBtn = this.page.getByTestId(
'import-account-confirm-button',
);
}

async importTokens() {
Expand All @@ -31,11 +47,21 @@ export class WalletPage {
await this.importButton.click();
}

async importAccount(accountPK: string) {
await this.accountMenu.waitFor({ state: 'visible' });
await this.accountMenu.click();
await this.addAccountButton.click();
await this.importAccountButton.click();
await this.page.fill('#private-key-box', accountPK);
await this.importAccountConfirmBtn.click();
}

async selectTokenWallet() {
await this.tokenTab.click();
}

async selectSwapAction() {
await this.swapButton.waitFor({ state: 'visible' });
await this.swapButton.click();
}

Expand Down
3 changes: 2 additions & 1 deletion test/e2e/playwright/swap/pageObjects/swap-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export class SwapPage {

async enterQuote(options: { from?: string; to: string; qty: string }) {
// Enter source token
if (options.from) {
const native = await this.page.$(`text=/${options.from}/`);
if (!native && options.from) {
this.swapFromDropDown.click();
await this.selectTokenFromList(options.from);
}
Expand Down
Loading

0 comments on commit 1bf2d8e

Please sign in to comment.