diff --git a/commands/metamask.js b/commands/metamask.js index 8dc857fec..a6cc75903 100644 --- a/commands/metamask.js +++ b/commands/metamask.js @@ -501,12 +501,54 @@ module.exports = { await switchToCypressIfNotActive(); return true; }, + activateAdvancedGasControl: async () => { + await activateAdvancedSetting( + advancedPageElements.advancedGasControlToggleOn, + advancedPageElements.advancedGasControlToggleOff, + ); + return; + }, + activateEnhancedTokenDetection: async () => { + await activateAdvancedSetting( + advancedPageElements.enhancedTokenDetectionToggleOn, + advancedPageElements.enhancedTokenDetectionToggleOff, + ); + return; + }, + activateShowHexData: async () => { + await activateAdvancedSetting( + advancedPageElements.showHexDataToggleOn, + advancedPageElements.showHexDataToggleOff, + ); + return; + }, + activateTestnetConversion: async () => { + await activateAdvancedSetting( + advancedPageElements.showTestnetConversionOn, + advancedPageElements.showTestnetConversionOff, + ); + return; + }, + activateShowTestnetNetworks: async () => { + await activateAdvancedSetting( + advancedPageElements.showTestnetNetworksOn, + advancedPageElements.showTestnetNetworksOff, + ); + return; + }, activateCustomNonce: async () => { - const activated = await activateAdvancedSetting( + await activateAdvancedSetting( advancedPageElements.customNonceToggleOn, advancedPageElements.customNonceToggleOff, ); - return activated; + return; + }, + activateDismissBackupReminder: async () => { + await activateAdvancedSetting( + advancedPageElements.dismissBackupReminderOn, + advancedPageElements.dismissBackupReminderOff, + ); + return; }, resetAccount: async () => { await switchToMetamaskIfNotActive(); diff --git a/plugins/index.js b/plugins/index.js index 0a486f8c3..d9a38d7f9 100644 --- a/plugins/index.js +++ b/plugins/index.js @@ -123,10 +123,34 @@ module.exports = (on, config) => { const networkChanged = await metamask.changeNetwork(network); return networkChanged; }, + activateAdvancedGasControlInMetamask: async () => { + const activated = await metamask.activateAdvancedGasControl(); + return activated; + }, + activateEnhancedTokenDetectionInMetamask: async () => { + const activated = await metamask.activateEnhancedTokenDetection(); + return activated; + }, + activateShowHexDataInMetamask: async () => { + const activated = await metamask.activateShowHexData(); + return activated; + }, + activateTestnetConversionInMetamask: async () => { + const activated = await metamask.activateTestnetConversion(); + return activated; + }, + activateShowTestnetNetworksInMetamask: async () => { + const activated = await metamask.activateShowTestnetNetworks(); + return activated; + }, activateCustomNonceInMetamask: async () => { const activated = await metamask.activateCustomNonce(); return activated; }, + activateDismissBackupReminderInMetamask: async () => { + const activated = await metamask.activateDismissBackupReminder(); + return activated; + }, resetMetamaskAccount: async () => { const resetted = await metamask.resetAccount(); return resetted; diff --git a/support/commands.js b/support/commands.js index f59f8f99b..84696f64a 100644 --- a/support/commands.js +++ b/support/commands.js @@ -63,10 +63,34 @@ Cypress.Commands.add('getMetamaskWalletAddress', () => { }); }); +Cypress.Commands.add('activateAdvancedGasControlInMetamask', () => { + return cy.task('activateAdvancedGasControlInMetamask'); +}); + +Cypress.Commands.add('activateEnhancedTokenDetectionInMetamask', () => { + return cy.task('activateEnhancedTokenDetectionInMetamask'); +}); + +Cypress.Commands.add('activateShowHexDataInMetamask', () => { + return cy.task('activateShowHexDataInMetamask'); +}); + +Cypress.Commands.add('activateTestnetConversionInMetamask', () => { + return cy.task('activateTestnetConversionInMetamask'); +}); + +Cypress.Commands.add('activateShowTestnetNetworksInMetamask', () => { + return cy.task('activateShowTestnetNetworksInMetamask'); +}); + Cypress.Commands.add('activateCustomNonceInMetamask', () => { return cy.task('activateCustomNonceInMetamask'); }); +Cypress.Commands.add('activateDismissBackupReminderInMetamask', () => { + return cy.task('activateDismissBackupReminderInMetamask'); +}); + Cypress.Commands.add('resetMetamaskAccount', () => { return cy.task('resetMetamaskAccount'); }); diff --git a/support/index.d.ts b/support/index.d.ts index 3c708438c..bd614f8a6 100644 --- a/support/index.d.ts +++ b/support/index.d.ts @@ -97,12 +97,48 @@ declare namespace Cypress { * cy.getMetamaskWalletAddress().then(address => cy.log(address)) */ getMetamaskWalletAddress(): Chainable; + /** + * Activate ability (in metamask settings) to specify custom gas price and limit while doing transactions in metamask + * @example + * cy.activateAdvancedGasControlInMetamask() + */ + activateAdvancedGasControlInMetamask(): Chainable; + /** + * Activate ability (in metamask settings) to detect custom tokens using ConsenSys API in metamask + * @example + * cy.activateEnhancedTokenDetectionInMetamask() + */ + activateEnhancedTokenDetectionInMetamask(): Chainable; + /** + * Activate ability (in metamask settings) to show hex data while doing transaction in metamask + * @example + * cy.activateShowHexDataInMetamask() + */ + activateShowHexDataInMetamask(): Chainable; + /** + * Activate ability (in metamask settings) to show fiat conversions on testnets in metamask + * @example + * cy.activateTestnetConversionInMetamask() + */ + activateTestnetConversionInMetamask(): Chainable; + /** + * Activate ability (in metamask settings) to show testnet networks in metamask + * @example + * cy.activateShowTestnetNetworksInMetamask() + */ + activateShowTestnetNetworksInMetamask(): Chainable; /** * Activate ability (in metamask settings) to specify custom nonce while doing transactions in metamask * @example * cy.activateCustomNonceInMetamask() */ activateCustomNonceInMetamask(): Chainable; + /** + * Activate ability (in metamask settings) to dismiss secret recovery phrase reminder in metamask + * @example + * cy.activateDismissBackupReminderInMetamask() + */ + activateDismissBackupReminderInMetamask(): Chainable; /** * Reset metamask account state in settings * @example diff --git a/tests/e2e/specs/metamask-spec.js b/tests/e2e/specs/metamask-spec.js index 027d799b5..5e1a9b4cd 100644 --- a/tests/e2e/specs/metamask-spec.js +++ b/tests/e2e/specs/metamask-spec.js @@ -134,6 +134,7 @@ describe('Metamask', () => { expect(activated).to.be.true; }); }); + // todo: add tests for advanced settings it(`resetMetamaskAccount should reset current account`, () => { cy.resetMetamaskAccount().then(resetted => { expect(resetted).to.be.true;