diff --git a/commands/metamask.js b/commands/metamask.js index 6d4723322..1155d46f4 100644 --- a/commands/metamask.js +++ b/commands/metamask.js @@ -196,7 +196,7 @@ const metamask = { // It appears if you connect to a new network for the first time. if ( (await playwright - .metamaskWindow() + .windows(PROVIDER) .locator(recipientPopupElements.popupCloseButton) .count()) > 0 ) { @@ -1329,7 +1329,7 @@ const metamask = { await switchToMetamaskIfNotActive(); await playwright - .metamaskWindow() + .windows(PROVIDER) .locator(mainPageElements.tabs.activityButton) .click(); @@ -1339,7 +1339,7 @@ const metamask = { // 120 seconds while (retries < retiresLimit) { const unapprovedTxs = await playwright - .metamaskWindow() + .windows(PROVIDER) .getByText('Unapproved') .count(); if (unapprovedTxs === 1) { @@ -1360,11 +1360,11 @@ const metamask = { // 120 seconds while (retries < retiresLimit) { const pendingTxs = await playwright - .metamaskWindow() + .windows(PROVIDER) .getByText('Pending') .count(); const queuedTxs = await playwright - .metamaskWindow() + .windows(PROVIDER) .getByText('Queued') .count(); if (pendingTxs === 0 && queuedTxs === 0) { @@ -1396,24 +1396,24 @@ const metamask = { async openTransactionDetails(txIndex) { await switchToMetamaskIfNotActive(); await playwright - .metamaskWindow() + .windows(PROVIDER) .locator(mainPageElements.tabs.activityButton) .click(); let visibleTxs = await playwright - .metamaskWindow() + .windows(PROVIDER) .locator( `${mainPageElements.activityTab.completedTransactionsList} > div`, ) .filter({ - has: playwright.metamaskWindow().locator('div.list-item__heading'), + has: playwright.windows(PROVIDER).locator('div.list-item__heading'), }) .all(); while (txIndex >= visibleTxs.length) { try { await playwright - .metamaskWindow() + .windows(PROVIDER) .locator( `${mainPageElements.activityTab.completedTransactionsList} > button`, ) @@ -1426,12 +1426,12 @@ const metamask = { } visibleTxs = await playwright - .metamaskWindow() + .windows(PROVIDER) .locator( `${mainPageElements.activityTab.completedTransactionsList} > div`, ) .filter({ - has: playwright.metamaskWindow().locator('div.list-item__heading'), + has: playwright.windows(PROVIDER).locator('div.list-item__heading'), }) .all(); } @@ -1439,7 +1439,7 @@ const metamask = { await visibleTxs[txIndex].click(); await playwright - .metamaskWindow() + .windows(PROVIDER) .locator(mainPageElements.popup.container) .waitFor({ state: 'visible', timeout: 10000 }); diff --git a/commands/phantom.js b/commands/phantom.js index b35c5a830..502807f2a 100644 --- a/commands/phantom.js +++ b/commands/phantom.js @@ -168,8 +168,8 @@ module.exports = { PROVIDER, firstTimeFlowImportPageElements.continueAfterPasswordButton, ); - // finish await new Promise(resolve => setTimeout(resolve, 1000)); // the transitioning is too fast + // finish await playwright.waitAndClick( PROVIDER, firstTimeFlowImportPageElements.getStartedButton, diff --git a/commands/playwright.js b/commands/playwright.js index a1409ed7f..97eca42bf 100644 --- a/commands/playwright.js +++ b/commands/playwright.js @@ -93,7 +93,9 @@ module.exports = { extensionsData = pages .filter(page => page.url.startsWith('chrome-extension://')) .map(extension => { - const matches = extension.url.match(/chrome-extension:\/\/(.*)\/.*/); + const matches = extension.url + .replace('chrome-extension://', '') + .match(/(\w*)(\/.*)?/); return { name: extension.title === 'Phantom Wallet' @@ -112,12 +114,6 @@ module.exports = { }, clearExtensionData: async provider => { try { - // if (!mainWindow) { - // const newPage = await browser.contexts()[0].newPage(); - // mainWindow = newPage; - // } - - // await module.exports.switchToWindow(provider); await module.exports.windows(provider).evaluate(async () => { await new Promise((resolve, reject) => { return chrome.storage.local.clear(() => { @@ -138,27 +134,8 @@ module.exports = { } }); }); - // chrome.runtime.reload(); // closes the popup }); - // await mainWindow.waitForTimeout(1000); - // await module.exports.windows(provider).waitForTimeout(1000); await module.exports.windows(provider).reload(); - // return module.exports.windows(provider); - // await mainWindow.waitForTimeout(1000); - // const newPagePromise = new Promise(resolve => - // browser.contexts()[0].once('page', resolve), - // ); - // await mainWindow.evaluate(async extensionWelcomeUrl => { - // window.open(extensionWelcomeUrl, '_blank').focus(); - // }, extensionsData[provider].welcomeUrl); - - // await new Promise(resolve => setTimeout(resolve, 20000)); - // pageWindows[provider] = await newPagePromise; - // pageWindows[provider] = newPage; - // await module.exports.assignActiveTabName(provider); - // await module.exports.windows(provider).reload(); - // await module.exports.waitUntilStable(); - // return module.exports.windows(provider); } catch (ex) { console.log(`[${provider}]: ${ex.message}`); } @@ -597,13 +574,13 @@ module.exports = { ); if (times <= 3) { await page.reload(); - await module.exports.waitUntilMetamaskWindowIsStable(); + await module.exports.waitUntilWindowIsStable(); } else if (times === 4) { await module.exports.waitAndClick( provider, pageElements.criticalErrorRestartButton, ); - await module.exports.waitUntilMetamaskWindowIsStable(); + await module.exports.waitUntilWindowIsStable(); } else { throw new Error( '[fixCriticalError] Max amount of retries to fix critical metamask error has been reached.', @@ -613,7 +590,7 @@ module.exports = { log('[fixCriticalError] Metamask crashed with error, refreshing..'); if (times <= 4) { await page.reload(); - await module.exports.waitUntilMetamaskWindowIsStable(); + await module.exports.waitUntilWindowIsStable(); } else { throw new Error( '[fixCriticalError] Max amount of retries to fix critical metamask error has been reached.', @@ -657,9 +634,11 @@ module.exports = { .textContent() ).replace(/(\n| )/g, ''); - const extensionId = ( + const [_, extensionId] = ( await extensionData.locator('#extension-id').textContent() - ).replace('ID: ', ''); + ) + .replace('ID: ', '') + .match(/(\w*)(\/.*)?/); extensionsData[extensionName] = { version: extensionVersion, diff --git a/pages/phantom/first-time-flow-page.js b/pages/phantom/first-time-flow-page.js index e2fff218f..f64486e71 100644 --- a/pages/phantom/first-time-flow-page.js +++ b/pages/phantom/first-time-flow-page.js @@ -33,8 +33,7 @@ const confirmPasswordInput = `[data-testid="onboarding-form-confirm-password-inp const termsCheckbox = `[data-testid="onboarding-form-terms-of-service-checkbox"]`; const continueAfterPasswordButton = '[data-testid="onboarding-form-submit-button"]'; -const getStartedButton = - '[data-testid="onboarding-form-submit-button"]'; +const getStartedButton = '[data-testid="onboarding-form-submit-button"]'; const importButton = `${newVaultForm} .create-new-vault__submit-button`; module.exports.firstTimeFlowImportPageElements = { @@ -47,7 +46,7 @@ module.exports.firstTimeFlowImportPageElements = { importButton, confirmWordsButton, continueAfterPasswordButton, - getStartedButton + getStartedButton, }; const firstTimeFlowCreatePage = '.first-time-flow'; diff --git a/pages/phantom/main-page.js b/pages/phantom/main-page.js index 1f600b886..f43a67c4f 100644 --- a/pages/phantom/main-page.js +++ b/pages/phantom/main-page.js @@ -85,6 +85,7 @@ const whatsNew = { const welcome = { takeTheTourButton: '[data-testid="welcome-take_the_tour"]', takeTheTourButtonNext: '[data-testid="primary-button"]', + finishSetup: ['data-testid="onboarding-form-submit-button"'], }; const accountBar = {