diff --git a/commands/metamask.js b/commands/metamask.js index ba858bcf..4c005ed4 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 f895d7a1..a474e8b5 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/package.json b/package.json index deec3e0b..286413a5 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "babel-plugin-transform-react-styled-components-qa": "^2.1.0", "bytes32": "^0.0.3", "commander": "^11.0.0", - "cypress": "^12.17.4", + "cypress": "12.17.3", "cypress-wait-until": "^2.0.1", "debug": "^4.3.4", "dotenv": "^16.3.1", diff --git a/pages/metamask/notification-page.js b/pages/metamask/notification-page.js index f848564f..ccac8014 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/pnpm-lock.yaml b/pnpm-lock.yaml index 3c61e32e..b9bfa0f1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,7 +13,7 @@ overrides: dependencies: '@cypress/code-coverage': specifier: ^3.11.0 - version: 3.11.0(@babel/core@7.21.8)(@babel/preset-env@7.21.5)(babel-loader@9.1.2)(cypress@12.17.4)(webpack@5.81.0) + version: 3.11.0(@babel/core@7.21.8)(@babel/preset-env@7.21.5)(babel-loader@9.1.2)(cypress@12.17.3)(webpack@5.81.0) '@cypress/webpack-dev-server': specifier: ^3.5.2 version: 3.5.2(debug@4.3.4)(webpack@5.81.0) @@ -28,7 +28,7 @@ dependencies: version: 1.37.0 '@testing-library/cypress': specifier: ^9.0.0 - version: 9.0.0(cypress@12.17.4) + version: 9.0.0(cypress@12.17.3) '@testing-library/react': specifier: ^14.0.0 version: 14.0.0(react-dom@18.2.0)(react@18.2.0) @@ -66,8 +66,8 @@ dependencies: specifier: ^11.0.0 version: 11.0.0 cypress: - specifier: ^12.17.4 - version: 12.17.4 + specifier: 12.17.3 + version: 12.17.3 cypress-wait-until: specifier: ^2.0.1 version: 2.0.1 @@ -513,6 +513,7 @@ packages: /@babel/plugin-proposal-async-generator-functions@7.20.7(@babel/core@7.21.8): resolution: {integrity: sha512-xMbiLsn/8RK7Wq7VeVytytS2L6qE69bXPB10YCmMdDZbKF4okCqY74pI/jJQ/8U0b/F6NrT2+14b8/P9/3AMGA==} engines: {node: '>=6.9.0'} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead. peerDependencies: '@babel/core': ^7.0.0-0 dependencies: @@ -528,6 +529,7 @@ packages: /@babel/plugin-proposal-class-properties@7.18.6(@babel/core@7.21.8): resolution: {integrity: sha512-cumfXOF0+nzZrrN8Rf0t7M+tF6sZc7vhQwYQck9q1/5w2OExlD+b4v4RpMJFaV1Z7WcDRgO6FqvxqxGlwo+RHQ==} engines: {node: '>=6.9.0'} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead. peerDependencies: '@babel/core': ^7.0.0-0 dependencies: @@ -541,6 +543,7 @@ packages: /@babel/plugin-proposal-class-static-block@7.21.0(@babel/core@7.21.8): resolution: {integrity: sha512-XP5G9MWNUskFuP30IfFSEFB0Z6HzLIUcjYM4bYOPHXl7eiJ9HFv8tWj6TXTN5QODiEhDZAeI4hLok2iHFFV4hw==} engines: {node: '>=6.9.0'} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-static-block instead. peerDependencies: '@babel/core': ^7.12.0 dependencies: @@ -555,6 +558,7 @@ packages: /@babel/plugin-proposal-dynamic-import@7.18.6(@babel/core@7.21.8): resolution: {integrity: sha512-1auuwmK+Rz13SJj36R+jqFPMJWyKEDd7lLSdOj4oJK0UTgGueSAtkrCvz9ewmgyU/P941Rv2fQwZJN8s6QruXw==} engines: {node: '>=6.9.0'} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-dynamic-import instead. peerDependencies: '@babel/core': ^7.0.0-0 dependencies: @@ -566,6 +570,7 @@ packages: /@babel/plugin-proposal-export-namespace-from@7.18.9(@babel/core@7.21.8): resolution: {integrity: sha512-k1NtHyOMvlDDFeb9G5PhUXuGj8m/wiwojgQVEhJ/fsVsMCpLyOP4h0uGEjYJKrRI+EVPlb5Jk+Gt9P97lOGwtA==} engines: {node: '>=6.9.0'} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead. peerDependencies: '@babel/core': ^7.0.0-0 dependencies: @@ -577,6 +582,7 @@ packages: /@babel/plugin-proposal-json-strings@7.18.6(@babel/core@7.21.8): resolution: {integrity: sha512-lr1peyn9kOdbYc0xr0OdHTZ5FMqS6Di+H0Fz2I/JwMzGmzJETNeOFq2pBySw6X/KFL5EWDjlJuMsUGRFb8fQgQ==} engines: {node: '>=6.9.0'} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-json-strings instead. peerDependencies: '@babel/core': ^7.0.0-0 dependencies: @@ -588,6 +594,7 @@ packages: /@babel/plugin-proposal-logical-assignment-operators@7.20.7(@babel/core@7.21.8): resolution: {integrity: sha512-y7C7cZgpMIjWlKE5T7eJwp+tnRYM89HmRvWM5EQuB5BoHEONjmQ8lSNmBUwOyy/GFRsohJED51YBF79hE1djug==} engines: {node: '>=6.9.0'} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-logical-assignment-operators instead. peerDependencies: '@babel/core': ^7.0.0-0 dependencies: @@ -599,6 +606,7 @@ packages: /@babel/plugin-proposal-nullish-coalescing-operator@7.18.6(@babel/core@7.21.8): resolution: {integrity: sha512-wQxQzxYeJqHcfppzBDnm1yAY0jSRkUXR2z8RePZYrKwMKgMlE8+Z6LUno+bd6LvbGh8Gltvy74+9pIYkr+XkKA==} engines: {node: '>=6.9.0'} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead. peerDependencies: '@babel/core': ^7.0.0-0 dependencies: @@ -610,6 +618,7 @@ packages: /@babel/plugin-proposal-numeric-separator@7.18.6(@babel/core@7.21.8): resolution: {integrity: sha512-ozlZFogPqoLm8WBr5Z8UckIoE4YQ5KESVcNudyXOR8uqIkliTEgJ3RoketfG6pmzLdeZF0H/wjE9/cCEitBl7Q==} engines: {node: '>=6.9.0'} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead. peerDependencies: '@babel/core': ^7.0.0-0 dependencies: @@ -621,6 +630,7 @@ packages: /@babel/plugin-proposal-object-rest-spread@7.20.7(@babel/core@7.21.8): resolution: {integrity: sha512-d2S98yCiLxDVmBmE8UjGcfPvNEUbA1U5q5WxaWFUGRzJSVAZqm5W6MbPct0jxnegUZ0niLeNX+IOzEs7wYg9Dg==} engines: {node: '>=6.9.0'} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead. peerDependencies: '@babel/core': ^7.0.0-0 dependencies: @@ -635,6 +645,7 @@ packages: /@babel/plugin-proposal-optional-catch-binding@7.18.6(@babel/core@7.21.8): resolution: {integrity: sha512-Q40HEhs9DJQyaZfUjjn6vE8Cv4GmMHCYuMGIWUnlxH6400VGxOuwWsPt4FxXxJkC/5eOzgn0z21M9gMT4MOhbw==} engines: {node: '>=6.9.0'} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-catch-binding instead. peerDependencies: '@babel/core': ^7.0.0-0 dependencies: @@ -646,6 +657,7 @@ packages: /@babel/plugin-proposal-optional-chaining@7.21.0(@babel/core@7.21.8): resolution: {integrity: sha512-p4zeefM72gpmEe2fkUr/OnOXpWEf8nAgk7ZYVqqfFiyIG7oFfVZcCrU64hWn5xp4tQ9LkV4bTIa5rD0KANpKNA==} engines: {node: '>=6.9.0'} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead. peerDependencies: '@babel/core': ^7.0.0-0 dependencies: @@ -658,6 +670,7 @@ packages: /@babel/plugin-proposal-private-methods@7.18.6(@babel/core@7.21.8): resolution: {integrity: sha512-nutsvktDItsNn4rpGItSNV2sz1XwS+nfU0Rg8aCx3W3NOKVzdMjJRu0O5OkgDp3ZGICSTbgRpxZoWsxoKRvbeA==} engines: {node: '>=6.9.0'} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-methods instead. peerDependencies: '@babel/core': ^7.0.0-0 dependencies: @@ -671,6 +684,7 @@ packages: /@babel/plugin-proposal-private-property-in-object@7.21.0(@babel/core@7.21.8): resolution: {integrity: sha512-ha4zfehbJjc5MmXBlHec1igel5TJXXLDDRbuJ4+XT2TJcyD9/V1919BA8gMvsdHcNMBy4WBUBiRb3nw/EQUtBw==} engines: {node: '>=6.9.0'} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-property-in-object instead. peerDependencies: '@babel/core': ^7.0.0-0 dependencies: @@ -686,6 +700,7 @@ packages: /@babel/plugin-proposal-unicode-property-regex@7.18.6(@babel/core@7.21.8): resolution: {integrity: sha512-2BShG/d5yoZyXZfVePH91urL5wTG6ASZU9M4o03lKK8u8UW1y08OMttBSOADTcJrnPMpvDXRG3G8fyLh4ovs8w==} engines: {node: '>=4'} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-unicode-property-regex instead. peerDependencies: '@babel/core': ^7.0.0-0 dependencies: @@ -1356,14 +1371,14 @@ packages: requiresBuild: true optional: true - /@cypress/code-coverage@3.11.0(@babel/core@7.21.8)(@babel/preset-env@7.21.5)(babel-loader@9.1.2)(cypress@12.17.4)(webpack@5.81.0): + /@cypress/code-coverage@3.11.0(@babel/core@7.21.8)(@babel/preset-env@7.21.5)(babel-loader@9.1.2)(cypress@12.17.3)(webpack@5.81.0): resolution: {integrity: sha512-ihSO1s03gmLRE224oIjrbdG1ey63vw/UY+VSqQ5m/TKkAvyz6GIiniq6juk3AV/+0vQC1Eb4UWFu8ndtji4M1g==} peerDependencies: cypress: '*' dependencies: '@cypress/webpack-preprocessor': 5.17.1(@babel/core@7.21.8)(@babel/preset-env@7.21.5)(babel-loader@9.1.2)(webpack@5.81.0) chalk: 4.1.2 - cypress: 12.17.4 + cypress: 12.17.3 dayjs: 1.11.9 debug: 4.3.4(supports-color@8.1.1) execa: 4.1.0 @@ -1986,7 +2001,7 @@ packages: defer-to-connect: 2.0.1 dev: true - /@testing-library/cypress@9.0.0(cypress@12.17.4): + /@testing-library/cypress@9.0.0(cypress@12.17.3): resolution: {integrity: sha512-c1XiCGeHGGTWn0LAU12sFUfoX3qfId5gcSE2yHode+vsyHDWraxDPALjVnHd4/Fa3j4KBcc5k++Ccy6A9qnkMA==} engines: {node: '>=12', npm: '>=6'} peerDependencies: @@ -1994,7 +2009,7 @@ packages: dependencies: '@babel/runtime': 7.21.5 '@testing-library/dom': 8.20.0 - cypress: 12.17.4 + cypress: 12.17.3 dev: false /@testing-library/dom@8.20.0: @@ -2258,7 +2273,7 @@ packages: resolution: {integrity: sha512-WTiIZhZKWDnV+Tgo42pxff8YfHdmaNFQz/bFoTlmfw2vbXcstCcb39VRaRi5yFHj/lb7t3K47btKYEbR1fci+Q==} dependencies: '@testing-library/dom': 8.20.0 - cypress: 12.17.4 + cypress: 12.17.3 dev: false /@types/uglify-js@3.17.1: @@ -3821,8 +3836,8 @@ packages: resolution: {integrity: sha512-+IyVnYNiaX1+C+V/LazrJWAi/CqiwfNoRSrFviECQEyolW1gDRy765PZosL2alSSGK8V10Y7BGfOQyZUDgmnjQ==} dev: false - /cypress@12.17.4: - resolution: {integrity: sha512-gAN8Pmns9MA5eCDFSDJXWKUpaL3IDd89N9TtIupjYnzLSmlpVr+ZR+vb4U/qaMp+lB6tBvAmt7504c3Z4RU5KQ==} + /cypress@12.17.3: + resolution: {integrity: sha512-/R4+xdIDjUSLYkiQfwJd630S81KIgicmQOLXotFxVXkl+eTeVO+3bHXxdi5KBh/OgC33HWN33kHX+0tQR/ZWpg==} engines: {node: ^14.0.0 || ^16.0.0 || >=18.0.0} hasBin: true requiresBuild: true @@ -3862,7 +3877,6 @@ packages: minimist: 1.2.8 ospath: 1.2.2 pretty-bytes: 5.6.0 - process: 0.11.10 proxy-from-env: 1.0.0 request-progress: 3.0.0 semver: 7.5.4 @@ -4009,7 +4023,7 @@ packages: array-buffer-byte-length: 1.0.0 call-bind: 1.0.2 es-get-iterator: 1.1.3 - get-intrinsic: 1.2.0 + get-intrinsic: 1.2.1 is-arguments: 1.1.1 is-array-buffer: 3.0.2 is-date-object: 1.0.5 @@ -4399,7 +4413,7 @@ packages: resolution: {integrity: sha512-sPZmqHBe6JIiTfN5q2pEi//TwxmAFHwj/XEuYjTuse78i8KxaqMTTzxPoFKuzRpDpTJ+0NAbpfenkmH2rePtuw==} dependencies: call-bind: 1.0.2 - get-intrinsic: 1.2.0 + get-intrinsic: 1.2.1 has-symbols: 1.0.3 is-arguments: 1.1.1 is-map: 2.0.2 @@ -8329,11 +8343,6 @@ packages: fromentries: 1.3.2 dev: false - /process@0.11.10: - resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==} - engines: {node: '>= 0.6.0'} - dev: false - /progress@2.0.3: resolution: {integrity: sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==} engines: {node: '>=0.4.0'} @@ -9168,7 +9177,7 @@ packages: resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} dependencies: call-bind: 1.0.2 - get-intrinsic: 1.2.0 + get-intrinsic: 1.2.1 object-inspect: 1.12.3 /signal-exit@3.0.7: diff --git a/tests/e2e/specs/metamask-spec.js b/tests/e2e/specs/metamask-spec.js index 65509240..4fb81052 100644 --- a/tests/e2e/specs/metamask-spec.js +++ b/tests/e2e/specs/metamask-spec.js @@ -341,6 +341,15 @@ 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().then(txData => { + expect(txData.recipientPublicAddress).to.be.equal('Account 1'); + }); + }); it(`confirmMetamaskTransaction should confirm eip-1559 transaction using default settings`, () => { cy.get('#sendEIP1559Button').click(); cy.confirmMetamaskTransaction().then(txData => {