Skip to content

Commit

Permalink
Merge branch 'develop' into fix/qr-and-blockexplore-for-multichain
Browse files Browse the repository at this point in the history
  • Loading branch information
montelaidev authored Jul 2, 2024
2 parents 47cd8ec + 4886a3f commit 0df3873
Show file tree
Hide file tree
Showing 32 changed files with 824 additions and 216 deletions.
12 changes: 9 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ develop_master_rc_only: &develop_master_rc_only
- master
- /^Version-v(\d+)[.](\d+)[.](\d+)/

exclude_develop_master_rc: &exclude_develop_master_rc
filters:
branches:
ignore:
- develop
- master
- /^Version-v(\d+)[.](\d+)[.](\d+)/
aliases:
# Shallow Git Clone
- &shallow-git-clone
Expand Down Expand Up @@ -106,6 +113,7 @@ workflows:
- check-pr-tag
- prep-deps
- get-changed-files-with-git-diff:
<<: *exclude_develop_master_rc
requires:
- prep-deps
- test-deps-audit:
Expand Down Expand Up @@ -203,7 +211,6 @@ workflows:
<<: *develop_master_rc_only
requires:
- prep-build-confirmation-redesign-test-mv2
- get-changed-files-with-git-diff
- test-e2e-chrome-rpc:
requires:
- prep-build-test
Expand All @@ -223,7 +230,6 @@ workflows:
<<: *develop_master_rc_only
requires:
- prep-build-test-flask-mv2
- get-changed-files-with-git-diff
- test-e2e-chrome-mmi:
requires:
- prep-build-test-mmi
Expand All @@ -243,7 +249,6 @@ workflows:
- /^Version-v(\d+)[.](\d+)[.](\d+)/
requires:
- prep-build
- get-changed-files-with-git-diff
- test-unit-jest-main:
requires:
- prep-deps
Expand Down Expand Up @@ -488,6 +493,7 @@ jobs:

# This job is used for the e2e quality gate.
# It must be run before any job which uses the run-all.js script.
# The job is skipped in develop, master or RC branches.
get-changed-files-with-git-diff:
executor: node-browsers-small
steps:
Expand Down
24 changes: 15 additions & 9 deletions development/generate-rc-commits.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,31 @@ const authorTeams = {
'Niranjana Binoy',
'Victor Thomas',
'vthomas13',
'seaona',
'Norbert Elter',
],
DappAPI: ['tmashuang', 'jiexi', 'BelfordZ', 'Shane'],
'Confirmation UX': [
'Wallet API': ['tmashuang', 'jiexi', 'BelfordZ', 'Shane'],
Confirmations: [
'Pedro Figueiredo',
'Sylva Elendu',
'Olusegun Akintayo',
'Jyoti Puri',
'Ariella Vu',
'seaona',
],
'Confirmation Systems': [
'OGPoyraz',
'vinistevam',
'Matthew Walsh',
'cryptotavares',
'Vinicius Stevam',
'Derek Brans',
'sleepytanya',
'Priya',
],
'Design Systems': [
'georgewrmarshall',
'Garrett Bear',
'George Marshall',
'Devin',
],
'Design Systems': ['georgewrmarshall', 'Garrett Bear', 'George Marshall'],
Snaps: [
'David Drazic',
'hmalik88',
Expand All @@ -84,7 +89,7 @@ const authorTeams = {
Assets: ['salimtb', 'sahar-fehri', 'Brian Bergeron'],
Linea: ['VGau', 'Victorien Gauch'],
lavamoat: ['weizman', 'legobeat', 'kumavis', 'LeoTM'],
'Shared Libraries': [
'Wallet Framework': [
'Michele Esposito',
'Elliot Winkler',
'Gudahtt',
Expand All @@ -98,10 +103,11 @@ const authorTeams = {
'Shane T',
'Bernardo Garces Chapero',
],
Swaps: ['Daniel', 'Davide Brocchetto', 'Nicolas Ferro'],
Swaps: ['Daniel', 'Davide Brocchetto', 'Nicolas Ferro', 'infiniteflower'],
Devex: ['Thomas Huang', 'Alex Donesky', 'jiexi', 'Zachary Belford'],
Notifications: ['Prithpal-Sooriya', 'Matteo Scurati', 'Prithpal Sooriya'],
Bridging: ['Bilal', 'micaelae'],
Bridging: ['Bilal', 'micaelae', 'Ethan Wessel'],
Ramps: ['George Weiler'],
};

// Function to get PR labels
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/changedFilesUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function readChangedFiles() {
return changedFiles;
} catch (error) {
console.error('Error reading from file:', error);
return '';
return [];
}
}

Expand Down
3 changes: 3 additions & 0 deletions test/e2e/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ export const TEST_SNAPS_SIMPLE_KEYRING_WEBSITE_URL =

/* Address of the VerifyingPaymaster smart contract deployed to Ganache. */
export const VERIFYING_PAYMASTER = '0xbdbDEc38ed168331b1F7004cc9e5392A2272C1D7';

/* Default ganache ETH balance in decimal when first login */
export const DEFAULT_GANACHE_ETH_BALANCE_DEC = '25';
27 changes: 22 additions & 5 deletions test/e2e/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ const { PAGES } = require('./webdriver/driver');
const GanacheSeeder = require('./seeder/ganache-seeder');
const { Bundler } = require('./bundler');
const { SMART_CONTRACTS } = require('./seeder/smart-contracts');
const { ERC_4337_ACCOUNT } = require('./constants');
const {
ERC_4337_ACCOUNT,
DEFAULT_GANACHE_ETH_BALANCE_DEC,
} = require('./constants');

const tinyDelayMs = 200;
const regularDelayMs = tinyDelayMs * 2;
Expand Down Expand Up @@ -672,6 +675,14 @@ const openDapp = async (driver, contract = null, dappURL = DAPP_URL) => {
: await driver.openNewPage(dappURL);
};

const openDappConnectionsPage = async (driver) => {
await driver.openNewPage(
`${driver.extensionUrl}/home.html#connections/${encodeURIComponent(
DAPP_URL,
)}`,
);
};

const createDappTransaction = async (driver, transaction) => {
await openDapp(
driver,
Expand Down Expand Up @@ -730,25 +741,30 @@ const ACCOUNT_1 = '0x5cfe73b6021e818b776b421b1c4db2474086a7e1';
const ACCOUNT_2 = '0x09781764c08de8ca82e156bbf156a3ca217c7950';

const defaultGanacheOptions = {
accounts: [{ secretKey: PRIVATE_KEY, balance: convertETHToHexGwei(25) }],
accounts: [
{
secretKey: PRIVATE_KEY,
balance: convertETHToHexGwei(DEFAULT_GANACHE_ETH_BALANCE_DEC),
},
],
};

const multipleGanacheOptions = {
accounts: [
{
secretKey: PRIVATE_KEY,
balance: convertETHToHexGwei(25),
balance: convertETHToHexGwei(DEFAULT_GANACHE_ETH_BALANCE_DEC),
},
{
secretKey: PRIVATE_KEY_TWO,
balance: convertETHToHexGwei(25),
balance: convertETHToHexGwei(DEFAULT_GANACHE_ETH_BALANCE_DEC),
},
],
};

const generateGanacheOptions = ({
secretKey = PRIVATE_KEY,
balance = convertETHToHexGwei(25),
balance = convertETHToHexGwei(DEFAULT_GANACHE_ETH_BALANCE_DEC),
...otherProps
}) => {
const accounts = [
Expand Down Expand Up @@ -1150,6 +1166,7 @@ module.exports = {
importWrongSRPOnboardingFlow,
testSRPDropdownIterations,
openDapp,
openDappConnectionsPage,
createDappTransaction,
switchToOrOpenDapp,
connectToDapp,
Expand Down
18 changes: 18 additions & 0 deletions test/e2e/page-objects/pages/header-navbar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Driver } from '../../webdriver/driver';

class HeaderNavbar {
private driver: Driver;

private accountMenuButton: string;

constructor(driver: Driver) {
this.driver = driver;
this.accountMenuButton = '[data-testid="account-menu-icon"]';
}

async openAccountMenu(): Promise<void> {
await this.driver.clickElement(this.accountMenuButton);
}
}

export default HeaderNavbar;
165 changes: 165 additions & 0 deletions test/e2e/page-objects/pages/homepage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
import { strict as assert } from 'assert';
import { Driver } from '../../webdriver/driver';
import { DEFAULT_GANACHE_ETH_BALANCE_DEC } from '../../constants';
import HeaderNavbar from './header-navbar';

class HomePage {
private driver: Driver;

private sendButton: string;

private activityTab: string;

private tokensTab: string;

private balance: string;

private completedTransactions: string;

private confirmedTransactions: object;

private transactionAmountsInActivity: string;

public headerNavbar: HeaderNavbar;

constructor(driver: Driver) {
this.driver = driver;
this.headerNavbar = new HeaderNavbar(driver);
this.sendButton = '[data-testid="eth-overview-send"]';
this.activityTab = '[data-testid="account-overview__activity-tab"]';
this.tokensTab = '[data-testid="account-overview__asset-tab"]';
this.confirmedTransactions = {
text: 'Confirmed',
css: '.transaction-status-label--confirmed',
};
this.balance = '[data-testid="eth-overview__primary-currency"]';
this.completedTransactions = '[data-testid="activity-list-item"]';
this.transactionAmountsInActivity =
'[data-testid="transaction-list-item-primary-currency"]';
}

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

async check_expectedBalanceIsDisplayed(
expectedBalance: string = DEFAULT_GANACHE_ETH_BALANCE_DEC,
): Promise<void> {
try {
await this.driver.waitForSelector({
css: this.balance,
text: `${expectedBalance} ETH`,
});
} catch (e) {
const balance = await this.driver.waitForSelector(this.balance);
const currentBalance = parseFloat(await balance.getText());
const errorMessage = `Expected balance ${expectedBalance} ETH, got balance ${currentBalance} ETH`;
console.log(errorMessage, e);
throw e;
}
console.log(
`Expected balance ${expectedBalance} ETH is displayed on homepage`,
);
}

async startSendFlow(): Promise<void> {
await this.driver.clickElement(this.sendButton);
}

async goToActivityList(): Promise<void> {
console.log(`Open activity tab on homepage`);
await this.driver.clickElement(this.activityTab);
}

/**
* This function checks if the specified number of confirmed transactions are displayed in the activity list on homepage.
* It waits up to 10 seconds for the expected number of confirmed transactions to be visible.
*
* @param expectedNumber - The number of confirmed transactions expected to be displayed in activity list. Defaults to 1.
* @returns A promise that resolves if the expected number of confirmed transactions is displayed within the timeout period.
*/
async check_confirmedTxNumberDisplayedInActivity(
expectedNumber: number = 1,
): Promise<void> {
console.log(
`Wait for ${expectedNumber} confirmed transactions to be displayed in activity list`,
);
await this.driver.wait(async () => {
const confirmedTxs = await this.driver.findElements(
this.confirmedTransactions,
);
return confirmedTxs.length === expectedNumber;
}, 10000);
console.log(
`${expectedNumber} confirmed transactions found in activity list on homepage`,
);
}

/**
* This function checks the specified number of completed transactions are displayed in the activity list on the homepage.
* It waits up to 10 seconds for the expected number of completed transactions to be visible.
*
* @param expectedNumber - The number of completed transactions expected to be displayed in the activity list. Defaults to 1.
* @returns A promise that resolves if the expected number of completed transactions is displayed within the timeout period.
*/
async check_completedTxNumberDisplayedInActivity(
expectedNumber: number = 1,
): Promise<void> {
console.log(
`Wait for ${expectedNumber} completed transactions to be displayed in activity list`,
);
await this.driver.wait(async () => {
const completedTxs = await this.driver.findElements(
this.completedTransactions,
);
return completedTxs.length === expectedNumber;
}, 10000);
console.log(
`${expectedNumber} completed transactions found in activity list on homepage`,
);
}

/**
* This function checks if a specified transaction amount at the specified index matches the expected one.
*
* @param expectedAmount - The expected transaction amount to be displayed. Defaults to '-1 ETH'.
* @param expectedNumber - The 1-based index of the transaction in the activity list whose amount is to be checked.
* Defaults to 1, indicating the first transaction in the list.
* @returns A promise that resolves if the transaction amount at the specified index matches the expected amount.
* The promise is rejected if the amounts do not match or if an error occurs during the process.
* @example
* // To check if the third transaction in the activity list displays an amount of '2 ETH'
* await check_txAmountInActivity('2 ETH', 3);
*/
async check_txAmountInActivity(
expectedAmount: string = '-1 ETH',
expectedNumber: number = 1,
): Promise<void> {
const transactionAmounts = await this.driver.findElements(
this.transactionAmountsInActivity,
);
const transactionAmountsText = await transactionAmounts[
expectedNumber - 1
].getText();
assert.equal(
transactionAmountsText,
expectedAmount,
`${transactionAmountsText} is displayed as transaction amount instead of ${expectedAmount} for transaction ${expectedNumber}`,
);
console.log(
`Amount for transaction ${expectedNumber} is displayed as ${expectedAmount}`,
);
}
}

export default HomePage;
Loading

0 comments on commit 0df3873

Please sign in to comment.