Skip to content

Commit

Permalink
feat: add bunch of new command for advanced settings
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Mucha <jakub.mucha@icloud.com>
  • Loading branch information
drptbl committed Oct 18, 2022
1 parent 2fc1423 commit d1c7ad8
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 2 deletions.
46 changes: 44 additions & 2 deletions commands/metamask.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
24 changes: 24 additions & 0 deletions plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
24 changes: 24 additions & 0 deletions support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand Down
36 changes: 36 additions & 0 deletions support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,48 @@ declare namespace Cypress {
* cy.getMetamaskWalletAddress().then(address => cy.log(address))
*/
getMetamaskWalletAddress(): Chainable<Subject>;
/**
* Activate ability (in metamask settings) to specify custom gas price and limit while doing transactions in metamask
* @example
* cy.activateAdvancedGasControlInMetamask()
*/
activateAdvancedGasControlInMetamask(): Chainable<Subject>;
/**
* Activate ability (in metamask settings) to detect custom tokens using ConsenSys API in metamask
* @example
* cy.activateEnhancedTokenDetectionInMetamask()
*/
activateEnhancedTokenDetectionInMetamask(): Chainable<Subject>;
/**
* Activate ability (in metamask settings) to show hex data while doing transaction in metamask
* @example
* cy.activateShowHexDataInMetamask()
*/
activateShowHexDataInMetamask(): Chainable<Subject>;
/**
* Activate ability (in metamask settings) to show fiat conversions on testnets in metamask
* @example
* cy.activateTestnetConversionInMetamask()
*/
activateTestnetConversionInMetamask(): Chainable<Subject>;
/**
* Activate ability (in metamask settings) to show testnet networks in metamask
* @example
* cy.activateShowTestnetNetworksInMetamask()
*/
activateShowTestnetNetworksInMetamask(): Chainable<Subject>;
/**
* Activate ability (in metamask settings) to specify custom nonce while doing transactions in metamask
* @example
* cy.activateCustomNonceInMetamask()
*/
activateCustomNonceInMetamask(): Chainable<Subject>;
/**
* Activate ability (in metamask settings) to dismiss secret recovery phrase reminder in metamask
* @example
* cy.activateDismissBackupReminderInMetamask()
*/
activateDismissBackupReminderInMetamask(): Chainable<Subject>;
/**
* Reset metamask account state in settings
* @example
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/specs/metamask-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d1c7ad8

Please sign in to comment.