Skip to content

Commit

Permalink
Merge branch 'NOTIFY-1256-e-2-e-tests-for-accounts-sync' of github.co…
Browse files Browse the repository at this point in the history
…m:MetaMask/metamask-extension into NOTIFY-1256-e-2-e-tests-for-accounts-sync
  • Loading branch information
cmd-ob committed Oct 24, 2024
2 parents 0330f21 + 17d2e9a commit 45e1167
Show file tree
Hide file tree
Showing 21 changed files with 1,004 additions and 713 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { strict: assert } = require('assert');
const { By } = require('selenium-webdriver');
const FixtureBuilder = require('../../fixture-builder');
const {
withFixtures,
Expand All @@ -10,7 +10,6 @@ const {
WINDOW_TITLES,
defaultGanacheOptions,
largeDelayMs,
switchToNotificationWindow,
} = require('../../helpers');
const { PAGES } = require('../../webdriver/driver');

Expand Down Expand Up @@ -59,7 +58,7 @@ describe('Request Queuing for Multiple Dapps and Txs on same networks', function

await driver.delay(regularDelayMs);

await switchToNotificationWindow(driver);
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);

await driver.clickElement({
text: 'Connect',
Expand Down Expand Up @@ -98,7 +97,7 @@ describe('Request Queuing for Multiple Dapps and Txs on same networks', function

await driver.delay(regularDelayMs);

await switchToNotificationWindow(driver, 4);
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);

await driver.clickElement({
text: 'Connect',
Expand Down Expand Up @@ -134,16 +133,12 @@ describe('Request Queuing for Multiple Dapps and Txs on same networks', function
await driver.clickElement('#sendButton');
await driver.clickElement('#sendButton');

await switchToNotificationWindow(driver, 4);
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);

let navigationElement = await driver.findElement(
'.confirm-page-container-navigation',
await driver.waitForSelector(
By.xpath("//div[normalize-space(.)='1 of 2']"),
);

let navigationText = await navigationElement.getText();

assert.equal(navigationText.includes('1 of 2'), true);

// Check correct network on confirm tx.
await driver.findElement({
css: '[data-testid="network-display"]',
Expand All @@ -162,14 +157,10 @@ describe('Request Queuing for Multiple Dapps and Txs on same networks', function
await driver.delay(largeDelayMs);
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);

navigationElement = await driver.findElement(
'.confirm-page-container-navigation',
await driver.waitForSelector(
By.xpath("//div[normalize-space(.)='1 of 2']"),
);

navigationText = await navigationElement.getText();

assert.equal(navigationText.includes('1 of 2'), true);

// Check correct network on confirm tx.
await driver.findElement({
css: '[data-testid="network-display"]',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const {
DAPP_URL,
regularDelayMs,
WINDOW_TITLES,
switchToNotificationWindow,
defaultGanacheOptions,
} = require('../../helpers');

Expand Down Expand Up @@ -45,31 +44,25 @@ describe('Request Queue WatchAsset -> SwitchChain -> WatchAsset', function () {

// Create Token
await driver.clickElement({ text: 'Create Token', tag: 'button' });
await switchToNotificationWindow(driver);
await driver.findClickableElement({ text: 'Confirm', tag: 'button' });
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);
await driver.clickElement({ text: 'Confirm', tag: 'button' });

// Wait for token address to populate in dapp
await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp);
await driver.wait(async () => {
const tokenAddressesElement = await driver.findElement(
'#tokenAddresses',
);
const tokenAddresses = await tokenAddressesElement.getText();
return tokenAddresses !== '';
}, 10000);
await driver.waitForSelector({
css: '#tokenAddresses',
text: '0x581c3C1A2A4EBDE2A0Df29B5cf4c116E42945947',
});

// Watch Asset 1st call
await driver.clickElement({
text: 'Add Token(s) to Wallet',
tag: 'button',
});

await driver.waitUntilXWindowHandles(3);
await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp);

// Switch Ethereum Chain
await driver.findClickableElement('#switchEthereumChain');
await driver.clickElement('#switchEthereumChain');

await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp);
Expand All @@ -83,7 +76,7 @@ describe('Request Queue WatchAsset -> SwitchChain -> WatchAsset', function () {
// Wait for token to show in list of tokens to watch
await driver.delay(regularDelayMs);

await switchToNotificationWindow(driver);
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);

const multipleSuggestedtokens = await driver.findElements(
'.confirm-add-suggested-token__token-list-item',
Expand All @@ -92,7 +85,7 @@ describe('Request Queue WatchAsset -> SwitchChain -> WatchAsset', function () {
// Confirm only 1 token is present in suggested token list
assert.equal(multipleSuggestedtokens.length, 1);

await switchToNotificationWindow(driver);
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);

await driver.waitUntilXWindowHandles(2);

Expand Down
21 changes: 12 additions & 9 deletions test/e2e/tests/responsive-ui/metamask-responsive-ui.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ describe('MetaMask Responsive UI', function () {
await driver.clickElement('[data-testid="pin-extension-done"]');
await driver.assertElementNotPresent('.loading-overlay__spinner');
// assert balance
const balance = await driver.findElement(
'[data-testid="eth-overview__primary-currency"]',
);
assert.ok(/^0\sETH$/u.test(await balance.getText()));
await driver.waitForSelector({
css: '[data-testid="eth-overview__primary-currency"]',
text: '0',
});
},
);
});
Expand All @@ -93,11 +93,14 @@ describe('MetaMask Responsive UI', function () {
await driver.navigate();

// Import Secret Recovery Phrase
const restoreSeedLink = await driver.findClickableElement(
'.unlock-page__link',
);
assert.equal(await restoreSeedLink.getText(), 'Forgot password?');
await restoreSeedLink.click();
await driver.waitForSelector({
tag: 'span',
text: 'Localhost 8545',
});
await driver.clickElement({
css: '.unlock-page__link',
text: 'Forgot password?',
});

await driver.pasteIntoField(
'[data-testid="import-srp__srp-word-0"]',
Expand Down
13 changes: 4 additions & 9 deletions test/e2e/tests/settings/about-metamask-ui-validation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,11 @@ describe('Setting - About MetaMask : @no-mmi', function (this: Suite) {
);

// verify the version number of the MetaMask
const metaMaskVersion = await driver.findElement(
selectors.metaMaskVersion,
);
const getVersionNumber = await metaMaskVersion.getText();
const { version } = packageJson;
assert.equal(
getVersionNumber,
version,
'Meta Mask version is incorrect in the about view section',
);
await driver.waitForSelector({
css: selectors.metaMaskVersion,
text: version,
});

// Validating the header text
const isHeaderTextPresent = await driver.isElementPresent(
Expand Down
29 changes: 9 additions & 20 deletions test/e2e/tests/settings/address-book.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ describe('Address Book', function () {

await driver.clickElement({ css: 'button', text: 'Contacts' });

const recipientTitle = await driver.findElement(
'.address-list-item__label',
);
await driver.waitForSelector({
css: '.address-list-item__label',
text: 'Test Name 1',
});

const recipientRowTitleString = await recipientTitle.getText();
assert.equal(recipientRowTitleString, 'Test Name 1');
await driver.clickElement('.address-list-item__label');

await driver.fill('input[placeholder="0"]', '2');
Expand Down Expand Up @@ -111,25 +110,15 @@ describe('Address Book', function () {

await driver.clickElement('[data-testid="page-container-footer-next"]');

const recipientUsername = await driver.findElement({
await driver.waitForSelector({
text: 'Test Name Edit',
css: '.address-list-item__label',
});

assert.equal(
await recipientUsername.getText(),
'Test Name Edit',
'Username is not edited correctly',
);

const recipientAddress = await driver.findElement(
'[data-testid="address-list-item-address"]',
);
assert.equal(
await recipientAddress.getText(),
shortenAddress('0x74cE91B75935D6Bedc27eE002DeFa566c5946f74'),
'Recipient address is not edited correctly',
);
await driver.waitForSelector({
css: '[data-testid="address-list-item-address"]',
text: shortenAddress('0x74cE91B75935D6Bedc27eE002DeFa566c5946f74'),
});
},
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ describe('Contract Deployment Confirmation', () => {
expect(editGasFeesRow).toHaveTextContent(tEn('networkFee') as string);

const firstGasField = within(editGasFeesRow).getByTestId('first-gas-field');
expect(firstGasField).toHaveTextContent('0.0001 ETH');
expect(firstGasField).toHaveTextContent('0.0001 SepoliaETH');
const editGasFeeNativeCurrency =
within(editGasFeesRow).getByTestId('native-currency');
expect(editGasFeeNativeCurrency).toHaveTextContent('$0.47');
Expand Down Expand Up @@ -371,7 +371,7 @@ describe('Contract Deployment Confirmation', () => {
const maxFee = screen.getByTestId('gas-fee-details-max-fee');
expect(gasFeesSection).toContainElement(maxFee);
expect(maxFee).toHaveTextContent(tEn('maxFee') as string);
expect(maxFee).toHaveTextContent('0.0023 ETH');
expect(maxFee).toHaveTextContent('0.0023 SepoliaETH');
expect(maxFee).toHaveTextContent('$7.72');

const nonceSection = screen.getByTestId('advanced-details-nonce-section');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ describe('Contract Interaction Confirmation', () => {
expect(editGasFeesRow).toHaveTextContent(tEn('networkFee') as string);

const firstGasField = within(editGasFeesRow).getByTestId('first-gas-field');
expect(firstGasField).toHaveTextContent('0.0001 ETH');
expect(firstGasField).toHaveTextContent('0.0001 SepoliaETH');
const editGasFeeNativeCurrency =
within(editGasFeesRow).getByTestId('native-currency');
expect(editGasFeeNativeCurrency).toHaveTextContent('$0.47');
Expand Down Expand Up @@ -402,7 +402,7 @@ describe('Contract Interaction Confirmation', () => {
const maxFee = screen.getByTestId('gas-fee-details-max-fee');
expect(gasFeesSection).toContainElement(maxFee);
expect(maxFee).toHaveTextContent(tEn('maxFee') as string);
expect(maxFee).toHaveTextContent('0.0023 ETH');
expect(maxFee).toHaveTextContent('0.0023 SepoliaETH');
expect(maxFee).toHaveTextContent('$7.72');

const nonceSection = screen.getByTestId('advanced-details-nonce-section');
Expand Down
Loading

0 comments on commit 45e1167

Please sign in to comment.