Skip to content

Commit

Permalink
feat: getActiveTabName
Browse files Browse the repository at this point in the history
  • Loading branch information
drptbl committed Oct 28, 2021
1 parent 43f1414 commit 138db2e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions commands/puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const fetch = require('node-fetch');
let puppeteerBrowser;
let mainWindow;
let metamaskWindow;
let activeTabName;

module.exports = {
puppeteerBrowser: () => {
Expand All @@ -15,6 +16,9 @@ module.exports = {
metamaskWindow: () => {
return metamaskWindow;
},
activeTabName: () => {
return activeTabName;
},
init: async () => {
const debuggerDetails = await fetch('http://localhost:9222/json/version'); //DevSkim: ignore DS137138
const debuggerDetailsConfig = await debuggerDetails.json();
Expand Down Expand Up @@ -43,37 +47,37 @@ module.exports = {
}
return true;
},
assignActiveTabName: async tabName => {
activeTabName = tabName;
return true;
},
clearWindows: async () => {
mainWindow = null;
metamaskWindow = null;
},
},
isMetamaskWindowActive: async () => {
let activeTabPage = await module.exports.getActiveTabPage();
if (
activeTabPage.url().includes('extension') ||
activeTabPage.url().includes('notification')
) {
if (activeTabName === 'metamask') {
return true;
} else {
return false;
}
},
isCypressWindowActive: async () => {
let activeTabPage = await module.exports.getActiveTabPage();
if (activeTabPage.url().includes('integration')) {
if (activeTabName === 'cypress') {
return true;
} else {
return false;
}
},
switchToCypressWindow: async () => {
await mainWindow.bringToFront();
await module.exports.assignActiveTabName('cypress');
return true;
},
switchToMetamaskWindow: async () => {
await metamaskWindow.bringToFront();
await module.exports.assignActiveTabName('metamask');
return true;
},
switchToMetamaskNotification: async () => {
Expand Down

0 comments on commit 138db2e

Please sign in to comment.