diff --git a/commands/metamask.js b/commands/metamask.js index ba858bcf6..4c005ed4b 100644 --- a/commands/metamask.js +++ b/commands/metamask.js @@ -1088,18 +1088,34 @@ const metamask = { .count()) > 0 ) { log('[confirmTransaction] Getting recipient address..'); - await playwright.waitAndClick( - confirmPageElements.recipientButton, - notificationPage, - ); - txData.recipientPublicAddress = await playwright.waitAndGetValue( - recipientPopupElements.recipientPublicAddress, - notificationPage, - ); - await playwright.waitAndClick( - recipientPopupElements.popupCloseButton, + + const tooltip = await playwright.waitAndGetAttributeValue( + confirmPageElements.recipientAddressTooltipContainerButton, + 'aria-describedby', notificationPage, + true, ); + + // Handles the case where the recipient address is saved and has a "nickname". + if (tooltip === 'tippy-tooltip-2') { + txData.recipientPublicAddress = await playwright.waitAndGetValue( + confirmPageElements.recipientButton, + notificationPage, + ); + } else { + await playwright.waitAndClick( + confirmPageElements.recipientButton, + notificationPage, + ); + txData.recipientPublicAddress = await playwright.waitAndGetValue( + recipientPopupElements.recipientPublicAddress, + notificationPage, + ); + await playwright.waitAndClick( + recipientPopupElements.popupCloseButton, + notificationPage, + ); + } } log('[confirmTransaction] Checking if network name is present..'); if ( diff --git a/commands/playwright.js b/commands/playwright.js index f895d7a1d..a474e8b5f 100644 --- a/commands/playwright.js +++ b/commands/playwright.js @@ -275,12 +275,19 @@ module.exports = { const value = await element.inputValue(); return value; }, - async waitAndGetAttributeValue(selector, attribute, page = metamaskWindow) { + async waitAndGetAttributeValue( + selector, + attribute, + page = metamaskWindow, + skipValidation = false, + ) { const expect = expectInstance ? expectInstance : require('@playwright/test').expect; const element = await module.exports.waitFor(selector, page); - await expect(element).toHaveAttribute(attribute, /[a-zA-Z0-9]/); + if (!skipValidation) { + await expect(element).toHaveAttribute(attribute, /[a-zA-Z0-9]/); + } const attrValue = await element.getAttribute(attribute); return attrValue; }, diff --git a/pages/metamask/notification-page.js b/pages/metamask/notification-page.js index f848564fb..ccac8014c 100644 --- a/pages/metamask/notification-page.js +++ b/pages/metamask/notification-page.js @@ -66,6 +66,7 @@ const confirmPageContent = `${notificationPage} .confirm-page-container-content` const networkLabel = `${confirmPageHeader} .network-display`; const senderButton = `${confirmPageHeader} .sender-to-recipient__party--sender`; const recipientButton = `${confirmPageHeader} .sender-to-recipient__party--recipient-with-address`; +const recipientAddressTooltipContainerButton = `${confirmPageHeader} .sender-to-recipient__party--recipient .sender-to-recipient__tooltip-container`; const editGasFeeLegacyButton = `${notificationPage} .transaction-detail-edit button`; const editGasFeeLegacyOverrideAckButton = `${notificationPage} .edit-gas-display .edit-gas-display__dapp-acknowledgement-button`; const editGasLegacyPopup = `${notificationPage} .edit-gas-popover__wrapper`; @@ -102,6 +103,7 @@ module.exports.confirmPageElements = { networkLabel, senderButton, recipientButton, + recipientAddressTooltipContainerButton, editGasFeeLegacyButton, editGasFeeLegacyOverrideAckButton, editGasLegacyPopup, diff --git a/tests/e2e/specs/metamask-spec.js b/tests/e2e/specs/metamask-spec.js index 65509240d..dc632ee4a 100644 --- a/tests/e2e/specs/metamask-spec.js +++ b/tests/e2e/specs/metamask-spec.js @@ -341,6 +341,13 @@ describe('Metamask', () => { expect(txData.confirmed).to.be.true; }); }); + it(`confirmMetamaskTransaction should confirm legacy ETH transfer to yourself`, () => { + cy.get('#fromInput').type('0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266') + cy.get('#toInput').type('0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266') + cy.get('#amountInput').type('0x38D7EA4C68000') // 0.001 ETH + cy.get("#submitForm").click(); + cy.confirmMetamaskTransaction() + }); it(`confirmMetamaskTransaction should confirm eip-1559 transaction using default settings`, () => { cy.get('#sendEIP1559Button').click(); cy.confirmMetamaskTransaction().then(txData => {