Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update metamast to v11 #1121

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions commands/metamask.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const {
confirmationPageElements,
} = require('../pages/metamask/confirmation-page');
const {
resetState,
setNetwork,
addNetwork,
findNetwork,
Expand Down Expand Up @@ -462,22 +463,18 @@ const metamask = {
if (typeof network === 'string') {
network = await findNetwork(network);
}

// handle a case if network is already changed
const currentNetwork = getCurrentNetwork();
if (network === currentNetwork) {
return false;
}

const networkAdded = await checkNetworkAdded(network);
if (!networkAdded) {
await module.exports.addNetwork(network);
return true;
}

await switchToMetamaskIfNotActive();
await playwright.waitAndClick(mainPageElements.networkSwitcher.button);

await playwright.waitAndClickByText(
mainPageElements.networkSwitcher.dropdownMenuItem,
network.name,
Expand Down Expand Up @@ -642,13 +639,6 @@ const metamask = {
await switchToCypressIfNotActive();
return true;
},
async activateAdvancedGasControl(skipSetup) {
return await activateAdvancedSetting(
advancedPageElements.advancedGasControlToggleOn,
advancedPageElements.advancedGasControlToggleOff,
skipSetup,
);
},
async activateShowHexData(skipSetup) {
return await activateAdvancedSetting(
advancedPageElements.showHexDataToggleOn,
Expand Down Expand Up @@ -864,11 +854,13 @@ const metamask = {
.locator(notificationPageElements.customSpendingLimitInput)
.count()) > 0
) {
await playwright.waitAndSetValue(
spendLimit,
notificationPageElements.customSpendingLimitInput,
notificationPage,
);
if (spendLimit) {
await playwright.waitAndSetValue(
spendLimit,
notificationPageElements.customSpendingLimitInput,
notificationPage,
);
}
await playwright.waitAndClick(
notificationPageElements.allowToSpendButton,
notificationPage,
Expand Down Expand Up @@ -1128,7 +1120,7 @@ const metamask = {
confirmPageElements.recipientButton,
notificationPage,
);
txData.recipientPublicAddress = await playwright.waitAndGetValue(
txData.recipientPublicAddress = await playwright.waitAndGetInputValue(
recipientPopupElements.recipientPublicAddress,
notificationPage,
);
Expand Down Expand Up @@ -1497,12 +1489,17 @@ const metamask = {
await module.exports.getExtensionDetails();
await playwright.fixBlankPage();
await playwright.fixCriticalError();
await resetState();
if (
(await playwright
.metamaskWindow()
.locator(onboardingWelcomePageElements.onboardingWelcomePage)
.count()) > 0
) {
await playwright.waitAndClick(
onboardingWelcomePageElements.onboardingTermsCheckbox,
await playwright.metamaskWindow(),
);
if (secretWordsOrPrivateKey.includes(' ')) {
// secret words
await module.exports.importWallet(secretWordsOrPrivateKey, password);
Expand Down Expand Up @@ -1601,7 +1598,6 @@ async function setupSettings(
) {
await switchToMetamaskIfNotActive();
await metamask.goToAdvancedSettings();
await metamask.activateAdvancedGasControl(true);
await metamask.activateShowHexData(true);
await metamask.activateShowTestnetNetworks(true);
await metamask.activateCustomNonce(true);
Expand Down
2 changes: 2 additions & 0 deletions pages/metamask/first-time-flow-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ module.exports.metametricsPageElements = {

const app = '#app-content .app';
const onboardingWelcomePage = `${onboardingFlow} [data-testid="onboarding-welcome"]`;
const onboardingTermsCheckbox = `${onboardingWelcomePage} [data-testid="onboarding-terms-checkbox"]`;
const importWalletButton = `${onboardingWelcomePage} [data-testid="onboarding-import-wallet"]`;
const createWalletButton = `${onboardingWelcomePage} [data-testid="onboarding-create-wallet"]`;
module.exports.onboardingWelcomePageElements = {
app,
onboardingWelcomePage,
onboardingTermsCheckbox,
importWalletButton,
createWalletButton,
};
Expand Down
14 changes: 7 additions & 7 deletions pages/metamask/main-page.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const networkSwitcherButtonSelector = '.network-display';
const networkSwitcherButtonSelector = '[data-testid="network-display"]';
const networkSwitcher = {
button: networkSwitcherButtonSelector,
networkName: `${networkSwitcherButtonSelector} .typography`,
networkName: `${networkSwitcherButtonSelector} .mm-text--ellipsis`,
dropdownMenu: '[data-testid="network-droppo"]',
dropdownMenuItem: `[data-testid="network-droppo"] .dropdown-menu-item`,
mainnetNetworkItem: `[data-testid="network-droppo"] [data-testid="mainnet-network-item"]`,
Expand Down Expand Up @@ -74,8 +74,8 @@ const accountMenu = {

const optionsMenu = {
button: '[data-testid=account-options-menu-button]',
accountDetailsButton: '[data-testid="account-options-menu__account-details"]',
connectedSitesButton: '[data-testid="account-options-menu__connected-sites"]',
accountDetailsButton: '[data-testid="account-list-menu-details"]',
connectedSitesButton: '[data-testid="global-menu-connected-sites"]',
};

const connectedSitesSelector = '.connected-sites';
Expand All @@ -87,10 +87,10 @@ const connectedSites = {
closeButton: `${connectedSitesSelector} [data-testid="popover-close"]`,
};

const accountModalSelector = '.account-modal';
const accountModalSelector = '.mm-modal-content__dialog';
const accountModal = {
walletAddressInput: `${accountModalSelector} .qr-code__address`,
closeButton: '.account-modal__close',
walletAddressInput: `${accountModalSelector} [data-testid="address-copy-button-text"]`,
closeButton: '.mm-button-icon[aria-label="Close"]',
};

const renameAccount = {
Expand Down
12 changes: 6 additions & 6 deletions pages/metamask/notification-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ const notificationPage = '.notification';
const notificationAppContent = `${notificationPage} #app-content .app`;
const loadingLogo = `${notificationPage} #loading__logo`;
const loadingSpinner = `${notificationPage} #loading__spinner`;
const nextButton = `${notificationPage} .permissions-connect-choose-account__bottom-buttons .btn-primary`;
const nextButton = `${notificationPage} [data-testid="page-container-footer-next"]`;
const cancelButton = `${notificationPage} .permissions-connect-choose-account__bottom-buttons .btn-secondary`;
const customSpendingLimitInput = `${notificationPage} [data-testid="custom-spending-cap-input"]`;
const allowToSpendButton = `${notificationPage} [data-testid="page-container-footer-next"]`;
const rejectToSpendButton = `${notificationPage} [data-testid="page-container-footer-cancel"]`;
const selectAllCheckbox = `${notificationPage} .choose-account-list__header-check-box`;
const selectAllCheckbox = `${notificationPage} [data-testid="choose-account-list-operate-all-check-box"]`;
const approveWarningToSpendButton = `${notificationPage} .set-approval-for-all-warning__footer__approve-button`;
const rejectWarningToSpendButton = `${notificationPage} .btn-secondary.set-approval-for-all-warning__footer__cancel-button`;

Expand Down Expand Up @@ -50,10 +50,10 @@ module.exports.permissionsPageElements = {
connectButton,
};

const popupContainer = '.popover-container';
const popupCloseButton = `${popupContainer} .popover-header__button`;
const popupCopyRecipientPublicAddressButton = `${popupContainer} .nickname-popover__public-address button`;
const recipientPublicAddress = `${popupContainer} .nickname-popover__public-address__constant`;
const popupContainer = '.mm-modal';
const popupCloseButton = `${popupContainer} [aria-label="Close"]`;
const popupCopyRecipientPublicAddressButton = `${popupContainer} [aria-label="Copy address to clipboard"]`;
const recipientPublicAddress = `${popupContainer} .mm-text-field--disabled input`;
module.exports.recipientPopupElements = {
popupContainer,
popupCloseButton,
Expand Down
16 changes: 5 additions & 11 deletions pages/metamask/settings-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,18 @@ module.exports.settingsPageElements = {

const resetAccountButton =
'[data-testid="advanced-setting-reset-account"] button';
const advancedGasControlToggleOn =
'[data-testid="advanced-setting-advanced-gas-inline"] .toggle-button--on';
const advancedGasControlToggleOff =
'[data-testid="advanced-setting-advanced-gas-inline"] .toggle-button--off';
const showHexDataToggleOn =
'[data-testid="advanced-setting-hex-data"] .toggle-button--on';
const showHexDataToggleOff =
'[data-testid="advanced-setting-hex-data"] .toggle-button--off';
const showTestnetConversionOn =
'[data-testid="advanced-setting-show-testnet-conversion"]:nth-child(6) .toggle-button--on';
'[data-testid="advanced-setting-show-testnet-conversion"]:nth-child(4) .toggle-button--on';
const showTestnetConversionOff =
'[data-testid="advanced-setting-show-testnet-conversion"]:nth-child(6) .toggle-button--off';
'[data-testid="advanced-setting-show-testnet-conversion"]:nth-child(4) .toggle-button--off';
const showTestnetNetworksOn =
'[data-testid="advanced-setting-show-testnet-conversion"]:nth-child(7) .toggle-button--on';
'[data-testid="advanced-setting-show-testnet-conversion"]:nth-child(5) .toggle-button--on';
const showTestnetNetworksOff =
'[data-testid="advanced-setting-show-testnet-conversion"]:nth-child(7) .toggle-button--off';
'[data-testid="advanced-setting-show-testnet-conversion"]:nth-child(5) .toggle-button--off';
const customNonceToggleOn =
'[data-testid="advanced-setting-custom-nonce"] .toggle-button--on';
const customNonceToggleOff =
Expand All @@ -41,8 +37,6 @@ const ethSignRequestsToggleOff =
'[data-testid="advanced-setting-toggle-ethsign"] .toggle-button--off';
module.exports.advancedPageElements = {
resetAccountButton,
advancedGasControlToggleOn,
advancedGasControlToggleOff,
showHexDataToggleOn,
showHexDataToggleOff,
showTestnetConversionOn,
Expand Down Expand Up @@ -80,7 +74,7 @@ const addNetworkForm = '.networks-tab__add-network-form-body';
const networkNameInput = `${addNetworkForm} .form-field:nth-child(1) input`;
const rpcUrlInput = `${addNetworkForm} .form-field:nth-child(2) input`;
const chainIdInput = `${addNetworkForm} .form-field:nth-child(3) input`;
const symbolInput = `${addNetworkForm} .form-field:nth-child(4) input`;
const symbolInput = `${addNetworkForm} [data-testid="network-form-ticker"] input`;
const blockExplorerInput = `${addNetworkForm} .form-field:nth-child(5) input`;
const saveButton = '.networks-tab__add-network-form-footer .btn-primary';
module.exports.addNetworkPageElements = {
Expand Down