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

Promote dev to master #844

Merged
merged 15 commits into from
Aug 21, 2023
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/e2e_cypress-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: pnpm/action-setup@d882d12c64e032187b2edb46d3a0d003b7a43598 # pin@v2.4.0

- name: Setup node
uses: actions/setup-node@bea5baf987ba7aa777a8a0b4ace377a21c45c381 # pin@v3.8.0
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # pin@v3.8.1
with:
node-version: 18.16

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e_debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: pnpm/action-setup@d882d12c64e032187b2edb46d3a0d003b7a43598 # pin@v2.4.0

- name: Setup node
uses: actions/setup-node@bea5baf987ba7aa777a8a0b4ace377a21c45c381 # pin@v3.8.0
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # pin@v3.8.1
with:
node-version: 18.16

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e_headful.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: pnpm/action-setup@d882d12c64e032187b2edb46d3a0d003b7a43598 # pin@v2.4.0

- name: Setup node
uses: actions/setup-node@bea5baf987ba7aa777a8a0b4ace377a21c45c381 # pin@v3.8.0
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # pin@v3.8.1
with:
node-version: 18.16

Expand Down
16 changes: 16 additions & 0 deletions commands/metamask.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,18 @@ const metamask = {
mainPageElements.actionableMessage.closeButton,
);
}

// Closes "You have switched to [network]" popup.
// It appears if you connect to a new network for the first time.
if (
(await playwright
.metamaskWindow()
.locator(recipientPopupElements.popupCloseButton)
.count()) > 0
) {
await playwright.waitAndClick(recipientPopupElements.popupCloseButton);
}

return true;
},
async closeModal() {
Expand Down Expand Up @@ -1219,6 +1231,10 @@ const metamask = {
notificationPage,
{ waitForEvent: 'close' },
);

// TODO: Add test for the new network popup. Requires changes to the MetaMask Test Dapp.
await module.exports.closePopupAndTooltips();

return true;
},
async rejectToSwitchNetwork() {
Expand Down
272 changes: 61 additions & 211 deletions plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,214 +51,71 @@ module.exports = (on, config) => {
return true;
},
// playwright commands
initPlaywright: async () => {
const connected = await playwright.init();
return connected;
},
clearPlaywright: async () => {
const cleared = await playwright.clear();
return cleared;
},
assignWindows: async () => {
const assigned = await playwright.assignWindows();
return assigned;
},
clearWindows: async () => {
const cleared = await playwright.clearWindows();
return cleared;
},
assignActiveTabName: async tabName => {
const assigned = await playwright.assignActiveTabName(tabName);
return assigned;
},
isMetamaskWindowActive: async () => {
const isMetamaskActive = await playwright.isMetamaskWindowActive();
return isMetamaskActive;
},
isCypressWindowActive: async () => {
const isCypressActive = await playwright.isCypressWindowActive();
return isCypressActive;
},
switchToCypressWindow: async () => {
const switched = await playwright.switchToCypressWindow();
return switched;
},
switchToMetamaskWindow: async () => {
const switched = await playwright.switchToMetamaskWindow();
return switched;
},
switchToMetamaskNotification: async () => {
const notificationPage = await playwright.switchToMetamaskNotification();
return notificationPage;
},
unlockMetamask: async password => {
const unlocked = await metamask.unlock(password);
return unlocked;
},
importMetamaskAccount: async privateKey => {
const imported = await metamask.importAccount(privateKey);
return imported;
},
createMetamaskAccount: async accountName => {
const created = await metamask.createAccount(accountName);
return created;
},
switchMetamaskAccount: async accountNameOrAccountNumber => {
const switched = await metamask.switchAccount(accountNameOrAccountNumber);
return switched;
},
addMetamaskNetwork: async network => {
const networkAdded = await metamask.addNetwork(network);
return networkAdded;
},
initPlaywright: playwright.init,
clearPlaywright: playwright.clear,
assignWindows: playwright.assignWindows,
clearWindows: playwright.clearWindows,
assignActiveTabName: playwright.assignActiveTabName,
isMetamaskWindowActive: playwright.isMetamaskWindowActive,
isCypressWindowActive: playwright.isCypressWindowActive,
switchToCypressWindow: playwright.switchToCypressWindow,
switchToMetamaskWindow: playwright.switchToMetamaskWindow,
switchToMetamaskNotification: playwright.switchToMetamaskNotification,
unlockMetamask: metamask.unlock,
importMetamaskAccount: metamask.importAccount,
createMetamaskAccount: metamask.createAccount,
switchMetamaskAccount: metamask.switchAccount,
addMetamaskNetwork: metamask.addNetwork,
changeMetamaskNetwork: async network => {
if (process.env.NETWORK_NAME && !network) {
network = process.env.NETWORK_NAME;
} else if (!network) {
network = 'goerli';
}
const networkChanged = await metamask.changeNetwork(network);
return networkChanged;
},
activateAdvancedGasControlInMetamask: async skipSetup => {
const activated = await metamask.activateAdvancedGasControl(skipSetup);
return activated;
},
activateShowHexDataInMetamask: async skipSetup => {
const activated = await metamask.activateShowHexData(skipSetup);
return activated;
},
activateTestnetConversionInMetamask: async skipSetup => {
const activated = await metamask.activateTestnetConversion(skipSetup);
return activated;
},
activateShowTestnetNetworksInMetamask: async skipSetup => {
const activated = await metamask.activateShowTestnetNetworks(skipSetup);
return activated;
},
activateCustomNonceInMetamask: async skipSetup => {
const activated = await metamask.activateCustomNonce(skipSetup);
return activated;
},
activateDismissBackupReminderInMetamask: async skipSetup => {
const activated = await metamask.activateDismissBackupReminder(skipSetup);
return activated;
},
activateEthSignRequestsInMetamask: async skipSetup => {
const activated = await metamask.activateEthSignRequests(skipSetup);
return activated;
},
activateImprovedTokenAllowanceInMetamask: async skipSetup => {
const activated =
await metamask.activateImprovedTokenAllowance(skipSetup);
return activated;
},
resetMetamaskAccount: async () => {
const resetted = await metamask.resetAccount();
return resetted;
},
disconnectMetamaskWalletFromDapp: async () => {
const disconnected = await metamask.disconnectWalletFromDapp();
return disconnected;
},
disconnectMetamaskWalletFromAllDapps: async () => {
const disconnected = await metamask.disconnectWalletFromAllDapps();
return disconnected;
},
confirmMetamaskSignatureRequest: async () => {
const confirmed = await metamask.confirmSignatureRequest();
return confirmed;
},
confirmMetamaskDataSignatureRequest: async () => {
const confirmed = await metamask.confirmDataSignatureRequest();
return confirmed;
},
rejectMetamaskSignatureRequest: async () => {
const rejected = await metamask.rejectSignatureRequest();
return rejected;
},
rejectMetamaskDataSignatureRequest: async () => {
const rejected = await metamask.rejectDataSignatureRequest();
return rejected;
},
confirmMetamaskEncryptionPublicKeyRequest: async () => {
const confirmed = await metamask.confirmEncryptionPublicKeyRequest();
return confirmed;
},
rejectMetamaskEncryptionPublicKeyRequest: async () => {
const rejected = await metamask.rejectEncryptionPublicKeyRequest();
return rejected;
},
confirmMetamaskDecryptionRequest: async () => {
const confirmed = await metamask.confirmDecryptionRequest();
return confirmed;
},
rejectMetamaskDecryptionRequest: async () => {
const rejected = await metamask.rejectDecryptionRequest();
return rejected;
},
importMetamaskToken: async tokenConfig => {
const imported = await metamask.importToken(tokenConfig);
return imported;
},
confirmMetamaskAddToken: async () => {
const confirmed = await metamask.confirmAddToken();
return confirmed;
},
rejectMetamaskAddToken: async () => {
const rejected = await metamask.rejectAddToken();
return rejected;
},
confirmMetamaskPermissionToSpend: async spendLimit => {
const confirmed = await metamask.confirmPermissionToSpend(spendLimit);
return confirmed;
},
rejectMetamaskPermissionToSpend: async () => {
const rejected = await metamask.rejectPermissionToSpend();
return rejected;
},
return await metamask.changeNetwork(network);
},
activateAdvancedGasControlInMetamask: metamask.activateAdvancedGasControl,
activateShowHexDataInMetamask: metamask.activateShowHexData,
activateTestnetConversionInMetamask: metamask.activateTestnetConversion,
activateShowTestnetNetworksInMetamask: metamask.activateShowTestnetNetworks,
activateCustomNonceInMetamask: metamask.activateCustomNonce,
activateDismissBackupReminderInMetamask:
metamask.activateDismissBackupReminder,
activateEthSignRequestsInMetamask: metamask.activateEthSignRequests,
activateImprovedTokenAllowanceInMetamask:
metamask.activateImprovedTokenAllowance,
resetMetamaskAccount: metamask.resetAccount,
disconnectMetamaskWalletFromDapp: metamask.disconnectWalletFromDapp,
disconnectMetamaskWalletFromAllDapps: metamask.disconnectWalletFromAllDapps,
confirmMetamaskSignatureRequest: metamask.confirmSignatureRequest,
confirmMetamaskDataSignatureRequest: metamask.confirmDataSignatureRequest,
rejectMetamaskSignatureRequest: metamask.rejectSignatureRequest,
rejectMetamaskDataSignatureRequest: metamask.rejectDataSignatureRequest,
confirmMetamaskEncryptionPublicKeyRequest:
metamask.confirmEncryptionPublicKeyRequest,
rejectMetamaskEncryptionPublicKeyRequest:
metamask.rejectEncryptionPublicKeyRequest,
confirmMetamaskDecryptionRequest: metamask.confirmDecryptionRequest,
rejectMetamaskDecryptionRequest: metamask.rejectDecryptionRequest,
importMetamaskToken: metamask.importToken,
confirmMetamaskAddToken: metamask.confirmAddToken,
rejectMetamaskAddToken: metamask.rejectAddToken,
confirmMetamaskPermissionToSpend: metamask.confirmPermissionToSpend,
rejectMetamaskPermissionToSpend: metamask.rejectPermissionToSpend,
confirmMetamaskPermisionToApproveAll: metamask.confirmPermisionToApproveAll,
rejectMetamaskPermisionToApproveAll: metamask.rejectPermisionToApproveAll,
acceptMetamaskAccess: async options => {
const accepted = await metamask.acceptAccess(options);
return accepted;
},
acceptMetamaskAccess: metamask.acceptAccess,
rejectMetamaskAccess: metamask.rejectAccess,
confirmMetamaskTransaction: async gasConfig => {
const confirmed = await metamask.confirmTransaction(gasConfig);
return confirmed;
},
rejectMetamaskTransaction: async () => {
const rejected = await metamask.rejectTransaction();
return rejected;
},
allowMetamaskToAddNetwork: async ({ waitForEvent }) => {
const allowed = await metamask.allowToAddNetwork({ waitForEvent });
return allowed;
},
rejectMetamaskToAddNetwork: async () => {
const rejected = await metamask.rejectToAddNetwork();
return rejected;
},
allowMetamaskToSwitchNetwork: async () => {
const allowed = await metamask.allowToSwitchNetwork();
return allowed;
},
rejectMetamaskToSwitchNetwork: async () => {
const rejected = await metamask.rejectToSwitchNetwork();
return rejected;
},
allowMetamaskToAddAndSwitchNetwork: async () => {
const allowed = await metamask.allowToAddAndSwitchNetwork();
return allowed;
},
getMetamaskWalletAddress: async () => {
const walletAddress = await metamask.getWalletAddress();
return walletAddress;
},
fetchMetamaskWalletAddress: async () => {
return metamask.walletAddress();
},
confirmMetamaskTransaction: metamask.confirmTransaction,
rejectMetamaskTransaction: metamask.rejectTransaction,
allowMetamaskToAddNetwork: async ({ waitForEvent }) =>
await metamask.allowToAddNetwork({ waitForEvent }),
rejectMetamaskToAddNetwork: metamask.rejectToAddNetwork,
allowMetamaskToSwitchNetwork: metamask.allowToSwitchNetwork,
rejectMetamaskToSwitchNetwork: metamask.rejectToSwitchNetwork,
allowMetamaskToAddAndSwitchNetwork: metamask.allowToAddAndSwitchNetwork,
getMetamaskWalletAddress: metamask.getWalletAddress,
fetchMetamaskWalletAddress: metamask.walletAddress,
setupMetamask: async ({
secretWordsOrPrivateKey,
network,
Expand Down Expand Up @@ -307,18 +164,11 @@ module.exports = (on, config) => {
});
return true;
},
getCurrentNetwork: () => {
const network = helpers.getCurrentNetwork();
return network;
},
etherscanGetTransactionStatus: async ({ txid }) => {
const txStatus = await etherscan.getTransactionStatus(txid);
return txStatus;
},
etherscanWaitForTxSuccess: async ({ txid }) => {
const txSuccess = await etherscan.waitForTxSuccess(txid);
return txSuccess;
},
getCurrentNetwork: helpers.getCurrentNetwork,
etherscanGetTransactionStatus: async ({ txid }) =>
await etherscan.getTransactionStatus(txid),
etherscanWaitForTxSuccess: async ({ txid }) =>
await etherscan.waitForTxSuccess(txid),
});

if (process.env.BASE_URL) {
Expand Down