Skip to content

Commit

Permalink
Merge pull request #26 from Synthetixio/dev
Browse files Browse the repository at this point in the history
promote dev to master
  • Loading branch information
drptbl authored Dec 12, 2020
2 parents 888bea6 + e32a10d commit 8f45dc9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
34 changes: 16 additions & 18 deletions commands/metamask.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const {
firstTimeFlowPageElements,
metametricsPageElements,
firstTimeFlowFormPageElements,
revealSeedPageElements,
endOfFlowPageElements,
} = require('../pages/metamask/first-time-flow-page');
const { mainPageElements } = require('../pages/metamask/main-page');
const { unlockPageElements } = require('../pages/metamask/unlock-page');
Expand All @@ -22,13 +22,13 @@ module.exports = {
walletAddress,
// workaround for metamask random blank page on first run
fixBlankPage: async () => {
await puppeteer.metamaskWindow.waitForTimeout(1000);
await puppeteer.metamaskWindow().waitForTimeout(1000);
for (let times = 0; times < 5; times++) {
if (
(await puppeteer.metamaskWindow.$(welcomePageElements.app)) === null
(await puppeteer.metamaskWindow().$(welcomePageElements.app)) === null
) {
await puppeteer.metamaskWindow.reload();
await puppeteer.metamaskWindow.waitForTimeout(2000);
await puppeteer.metamaskWindow().reload();
await puppeteer.metamaskWindow().waitForTimeout(2000);
} else {
break;
}
Expand Down Expand Up @@ -63,16 +63,13 @@ module.exports = {
await puppeteer.waitAndClick(firstTimeFlowFormPageElements.termsCheckbox);
await puppeteer.waitAndClick(firstTimeFlowFormPageElements.importButton);

// metamask hangs, reload as workaround
// await puppeteer.waitAndClick(endOfFlowPageElements.allDoneButton);
await puppeteer.waitFor(pageElements.loadingSpinner);
await puppeteer.metamaskWindow.reload();
await puppeteer.waitAndClick(revealSeedPageElements.remindLaterButton);
await puppeteer.waitAndClick(endOfFlowPageElements.allDoneButton);
await puppeteer.waitFor(mainPageElements.walletOverview);

// close popup if present
if (
(await puppeteer.metamaskWindow.$(mainPageElements.popup.container)) !==
(await puppeteer.metamaskWindow().$(mainPageElements.popup.container)) !==
null
) {
await puppeteer.waitAndClick(mainPageElements.popup.closeButton);
Expand Down Expand Up @@ -113,7 +110,7 @@ module.exports = {
return true;
},
acceptAccess: async () => {
await puppeteer.metamaskWindow.waitForTimeout(3000);
await puppeteer.metamaskWindow().waitForTimeout(3000);
const notificationPage = await puppeteer.switchToMetamaskNotification();
await puppeteer.waitAndClick(
notificationPageElements.nextButton,
Expand All @@ -123,11 +120,11 @@ module.exports = {
permissionsPageElements.connectButton,
notificationPage,
);
await puppeteer.metamaskWindow.waitForTimeout(3000);
await puppeteer.metamaskWindow().waitForTimeout(3000);
return true;
},
confirmTransaction: async () => {
await puppeteer.metamaskWindow.waitForTimeout(3000);
await puppeteer.metamaskWindow().waitForTimeout(3000);
const notificationPage = await puppeteer.switchToMetamaskNotification();
const currentGasFee = await puppeteer.waitAndGetValue(
confirmPageElements.gasFeeInput,
Expand All @@ -143,17 +140,17 @@ module.exports = {
confirmPageElements.confirmButton,
notificationPage,
);
await puppeteer.metamaskWindow.waitForTimeout(3000);
await puppeteer.metamaskWindow().waitForTimeout(3000);
return true;
},
rejectTransaction: async () => {
await puppeteer.metamaskWindow.waitForTimeout(3000);
await puppeteer.metamaskWindow().waitForTimeout(3000);
const notificationPage = await puppeteer.switchToMetamaskNotification();
await puppeteer.waitAndClick(
confirmPageElements.rejectButton,
notificationPage,
);
await puppeteer.metamaskWindow.waitForTimeout(3000);
await puppeteer.metamaskWindow().waitForTimeout(3000);
return true;
},
getWalletAddress: async () => {
Expand All @@ -171,9 +168,10 @@ module.exports = {
}
await puppeteer.init();
await puppeteer.assignWindows();
await puppeteer.metamaskWindow.waitForTimeout(1000);
await puppeteer.metamaskWindow().waitForTimeout(1000);
if (
(await puppeteer.metamaskWindow.$(unlockPageElements.unlockPage)) === null
(await puppeteer.metamaskWindow().$(unlockPageElements.unlockPage)) ===
null
) {
await module.exports.confirmWelcomePage();
await module.exports.importWallet(secretWords, password);
Expand Down
12 changes: 9 additions & 3 deletions commands/puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ let mainWindow;
let metamaskWindow;

module.exports = {
puppeteerBrowser,
mainWindow,
metamaskWindow,
puppeteerBrowser: () => {
return puppeteerBrowser;
},
mainWindow: () => {
return mainWindow;
},
metamaskWindow: () => {
return metamaskWindow;
},
init: async () => {
const debuggerDetails = await fetch('http://localhost:9222/json/version');
const debuggerDetailsConfig = await debuggerDetails.json();
Expand Down

0 comments on commit 8f45dc9

Please sign in to comment.