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

test: Migrate switch chain tests #28481

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from
Draft
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
516 changes: 0 additions & 516 deletions test/e2e/json-rpc/switchEthereumChain.spec.js

This file was deleted.

389 changes: 389 additions & 0 deletions test/e2e/json-rpc/switch_ethereum_chain.spec.ts

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions test/e2e/page-objects/flows/send-transaction.flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export const sendTransactionToAddress = async ({

// confirm transaction when user lands on confirm transaction screen
const confirmTxPage = new ConfirmTxPage(driver);
await confirmTxPage.check_pageIsLoaded(gasFee, totalFee);
await confirmTxPage.check_pageIsLoaded(gasFee);
await confirmTxPage.check_totalFeeIsDisplayed(totalFee);
await confirmTxPage.confirmTx();
};

Expand Down Expand Up @@ -86,7 +87,8 @@ export const sendTransactionToAccount = async ({

// confirm transaction when user lands on confirm transaction screen
const confirmTxPage = new ConfirmTxPage(driver);
await confirmTxPage.check_pageIsLoaded(gasFee, totalFee);
await confirmTxPage.check_pageIsLoaded(gasFee);
await confirmTxPage.check_totalFeeIsDisplayed(totalFee);
await confirmTxPage.confirmTx();
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { Driver } from '../../../../webdriver/driver';

class ConnectConfirmation {
private driver: Driver;

private readonly confirmConnectButton = '[data-testid="confirm-btn"]';

private readonly connectDialogTitle = {
tag: 'h2',
text: 'Connect with MetaMask',
};

private readonly editNetworksTitle = {
tag: 'h4',
text: 'Edit networks',
};

private readonly editButton = '[data-testid="edit"]';

private readonly updateNetworkButton =
'[data-testid="connect-more-chains-button"]';

constructor(driver: Driver) {
this.driver = driver;
}

async check_pageIsLoaded(): Promise<void> {
try {
await this.driver.waitForMultipleSelectors([
this.connectDialogTitle,
this.confirmConnectButton,
]);
} catch (e) {
console.log(
'Timeout while waiting for Connect Confirmation page to be loaded',
e,
);
throw e;
}
console.log('Connect Confirmation page is loaded');
}

/**
* Edit network in connect confirmation dialog and confirm connect
*
* @param networkName - Network name to check the network checkbox
*/
async editNetworkAndConfirmConnect(networkName: string) {
console.log(
'Edit network in connect confirmation dialog and confirm connect',
);
const editButtons = await this.driver.findElements(this.editButton);
await editButtons[1].click();
await this.driver.waitForSelector(this.editNetworksTitle);
await this.driver.clickElement({
text: networkName,
tag: 'p',
});
await this.driver.clickElement(this.updateNetworkButton);
await this.driver.waitForSelector(this.connectDialogTitle);
await this.driver.clickElementAndWaitToDisappear(this.confirmConnectButton);
}
}

export default ConnectConfirmation;
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Driver } from '../../../../webdriver/driver';

class ReviewPermissionConfirmation {
private driver: Driver;

private readonly confirmationDialogTitle = {
tag: 'h3',
text: 'Review permissions',
};

private readonly footerCancelButton =
'[data-testid="page-container-footer-cancel"]';

private readonly footerConfirmButton =
'[data-testid="page-container-footer-next"]';

constructor(driver: Driver) {
this.driver = driver;
}

async check_pageIsLoaded(): Promise<void> {
try {
await this.driver.waitForSelector(this.confirmationDialogTitle);
} catch (e) {
console.log(
'Timeout while waiting for Review Permission Confirmation page to be loaded',
e,
);
throw e;
}
console.log('Review Permission Confirmation page is loaded');
}

async cancelReviewPermissions() {
console.log('Cancel review permissions in dialog');
await this.driver.clickElementAndWaitToDisappear(this.footerCancelButton);
}

async confirmReviewPermissions() {
console.log('Confirm review permissions in dialog');
await this.driver.clickElementAndWaitToDisappear(this.footerConfirmButton);
}
}

export default ReviewPermissionConfirmation;
10 changes: 10 additions & 0 deletions test/e2e/page-objects/pages/homepage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ class HomePage {

private readonly nftTab = '[data-testid="account-overview__nfts-tab"]';

private readonly noTransactionMessage = {
text: 'You have no transactions',
tag: 'div',
};

private readonly successImportNftMessage = {
text: 'NFT was successfully added!',
tag: 'h6',
Expand Down Expand Up @@ -310,6 +315,11 @@ class HomePage {
});
}

async check_noTransactionMessageIsDisplayed(): Promise<void> {
console.log('Check that no transaction message is displayed on homepage');
await this.driver.waitForSelector(this.noTransactionMessage);
}

async check_successImportNftMessageIsDisplayed(): Promise<void> {
console.log(
'Check that success imported NFT message is displayed on homepage',
Expand Down
54 changes: 38 additions & 16 deletions test/e2e/page-objects/pages/send/confirm-tx-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,78 @@ import { Driver } from '../../../webdriver/driver';
class ConfirmTxPage {
private driver: Driver;

private confirmButton: string;
private readonly confirmButton = '[data-testid="page-container-footer-next"]';

private totalFee: string;
private readonly totalFee = '[data-testid="confirm-page-total-amount"]';

private transactionFee: string;
private readonly transactionFee = '[data-testid="confirm-gas-display"]';

private readonly actionNameSummary =
'.confirm-page-container-summary__action__name';

constructor(driver: Driver) {
this.driver = driver;
this.confirmButton = '[data-testid="page-container-footer-next"]';
this.transactionFee = '[data-testid="confirm-gas-display"]';
this.totalFee = '[data-testid="confirm-page-total-amount"]';
}

/**
* Verifies that the confirm transaction page is fully loaded by checking for the presence of confirm button and the expected gas values.
*
* @param expectedGasFee - The expected gas fee value to be displayed on the page.
* @param expectedTotalFee - The expected total fee value to be displayed on the page.
* @returns A promise that resolves when all specified elements are verified to be present and contain the expected values, indicating the page has fully loaded.
*/
async check_pageIsLoaded(
expectedGasFee: string,
expectedTotalFee: string,
): Promise<void> {
async check_pageIsLoaded(expectedGasFee: string): Promise<void> {
try {
await Promise.all([
this.driver.waitForSelector(this.confirmButton),
this.driver.waitForSelector({
css: this.transactionFee,
text: `${expectedGasFee} ETH`,
}),
this.driver.waitForSelector({
css: this.totalFee,
text: `${expectedTotalFee} ETH`,
}),
]);
} catch (e) {
console.log(
`Timeout while waiting for confirm transaction screen to be loaded, expected gas fee is: ${expectedGasFee} and expected total fee is: ${expectedTotalFee}`,
`Timeout while waiting for confirm transaction screen to be loaded, expected gas fee is ${expectedGasFee}`,
e,
);
throw e;
}
console.log('Confirm transaction page is loaded with expected gas value');
}

/**
* Checks if the action name is displayed on the confirm transaction page.
*
* @param expectedActionName - The expected action name to be displayed.
* @returns A boolean indicating whether the action name is displayed.
*/
async actionNameIsDisplayed(expectedActionName: string): Promise<boolean> {
try {
await this.driver.waitForSelector({
css: this.actionNameSummary,
text: expectedActionName,
});
return true;
} catch (e) {
return false;
}
}

async confirmTx(): Promise<void> {
console.log('Click confirm button to confirm transaction');
await this.driver.clickElement(this.confirmButton);
}

/**
* Verifies that the total fee is displayed on confirm transaction dialog.
*
* @param expectedTotalFee - The expected total fee value to be displayed.
*/
async check_totalFeeIsDisplayed(expectedTotalFee: string): Promise<void> {
await this.driver.waitForSelector({
css: this.totalFee,
text: `${expectedTotalFee} ETH`,
});
}
}

export default ConfirmTxPage;
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class ExperimentalSettings {
private readonly redesignedSignatureToggle =
'[data-testid="toggle-redesigned-confirmations-container"]';

private readonly requestQueueToggle =
'[data-testid="experimental-setting-toggle-request-queue"]';

constructor(driver: Driver) {
this.driver = driver;
}
Expand All @@ -41,6 +44,11 @@ class ExperimentalSettings {
console.log('Toggle Redesigned Signature on experimental setting page');
await this.driver.clickElement(this.redesignedSignatureToggle);
}

async toggleRequestQueue(): Promise<void> {
console.log('Toggle Request Queue on experimental setting page');
await this.driver.clickElement(this.requestQueueToggle);
}
}

export default ExperimentalSettings;
Loading