Skip to content

Commit

Permalink
Merge pull request #838 from Synthetixio/add-reset-state
Browse files Browse the repository at this point in the history
Add reset state
  • Loading branch information
r3kt-eth authored Aug 17, 2023
2 parents 3d695f8 + 13ae8ae commit 983b806
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
15 changes: 15 additions & 0 deletions commands/metamask.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ let walletAddress;
let switchBackToCypressWindow;

const metamask = {
async resetState() {
log('Resetting state of metamask');
extensionId = undefined;
extensionVersion = undefined;
extensionHomeUrl = undefined;
extensionSettingsUrl = undefined;
extensionAdvancedSettingsUrl = undefined;
extensionExperimentalSettingsUrl = undefined;
extensionAddNetworkUrl = undefined;
extensionNewAccountUrl = undefined;
extensionImportAccountUrl = undefined;
extensionImportTokenUrl = undefined;
walletAddress = undefined;
switchBackToCypressWindow = undefined;
},
extensionId: () => {
return extensionId;
},
Expand Down
12 changes: 12 additions & 0 deletions commands/playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ let retries = 0;
let extensionsData = {};

module.exports = {
async resetState() {
log('Resetting state of playwright');
expectInstance = undefined;
browser = undefined;
mainWindow = undefined;
metamaskWindow = undefined;
metamaskNotificationWindow = undefined;
metamaskPopupWindow = undefined;
activeTabName = undefined;
retries = 0;
extensionsData = {};
},
getExpectInstance() {
return expectInstance;
},
Expand Down
13 changes: 13 additions & 0 deletions commands/synpress.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const log = require('debug')('synpress:synpress');
const playwright = require('./playwright');
const metamask = require('./metamask');
const helpers = require('../helpers');

module.exports = {
async resetState() {
log('Resetting state of synpress');
await playwright.resetState();
await metamask.resetState();
await helpers.resetState();
},
};
5 changes: 5 additions & 0 deletions helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ let currentNetwork = chains.mainnet;
let addedNetworks = [chains.mainnet, chains.goerli, chains.sepolia];

module.exports = {
async resetState() {
log('Resetting state of helpers');
currentNetwork = chains.mainnet;
addedNetworks = [chains.mainnet, chains.goerli, chains.sepolia];
},
// set currently active network
async setNetwork(network) {
log(`Setting network to ${JSON.stringify(network)}`);
Expand Down

0 comments on commit 983b806

Please sign in to comment.