Skip to content

Commit

Permalink
Merge pull request #860 from Synthetixio/dev
Browse files Browse the repository at this point in the history
Promote `dev` to `master`
  • Loading branch information
duckception authored Sep 6, 2023
2 parents 19bffd5 + 96db944 commit f9825c2
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 33 deletions.
36 changes: 26 additions & 10 deletions commands/metamask.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
11 changes: 9 additions & 2 deletions commands/playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions pages/metamask/notification-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand Down Expand Up @@ -102,6 +103,7 @@ module.exports.confirmPageElements = {
networkLabel,
senderButton,
recipientButton,
recipientAddressTooltipContainerButton,
editGasFeeLegacyButton,
editGasFeeLegacyOverrideAckButton,
editGasLegacyPopup,
Expand Down
49 changes: 29 additions & 20 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions tests/e2e/specs/metamask-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit f9825c2

Please sign in to comment.