Skip to content

Commit

Permalink
chore: rebase fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
maximgeerinck committed Sep 20, 2023
1 parent a08518f commit b40f6c8
Showing 5 changed files with 29 additions and 47 deletions.
27 changes: 15 additions & 12 deletions commands/metamask.js
Original file line number Diff line number Diff line change
@@ -128,9 +128,12 @@ const metamask = {
const metamaskExtensionData = (await playwright.getExtensionsData())
.metamask;

const extensionURL = `chrome-extension://${extensionId}`;

extensionId = metamaskExtensionData.id;
extensionVersion = metamaskExtensionData.version;
extensionHomeUrl = `chrome-extension://${extensionId}/home.html`;
console.log({ extensionHomeUrl, extensionId });
extensionSettingsUrl = `${extensionHomeUrl}#settings`;
extensionAdvancedSettingsUrl = `${extensionSettingsUrl}/advanced`;
extensionExperimentalSettingsUrl = `${extensionSettingsUrl}/experimental`;
@@ -196,7 +199,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 +1332,7 @@ const metamask = {

await switchToMetamaskIfNotActive();
await playwright
.metamaskWindow()
.windows(PROVIDER)
.locator(mainPageElements.tabs.activityButton)
.click();

@@ -1339,7 +1342,7 @@ const metamask = {
// 120 seconds
while (retries < retiresLimit) {
const unapprovedTxs = await playwright
.metamaskWindow()
.windows(PROVIDER)
.getByText('Unapproved')
.count();
if (unapprovedTxs === 1) {
@@ -1360,11 +1363,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 +1399,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,20 +1429,20 @@ 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();
}

await visibleTxs[txIndex].click();

await playwright
.metamaskWindow()
.windows(PROVIDER)
.locator(mainPageElements.popup.container)
.waitFor({ state: 'visible', timeout: 10000 });

2 changes: 1 addition & 1 deletion commands/phantom.js
Original file line number Diff line number Diff line change
@@ -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,
41 changes: 10 additions & 31 deletions commands/playwright.js
Original file line number Diff line number Diff line change
@@ -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,
5 changes: 2 additions & 3 deletions pages/phantom/first-time-flow-page.js
Original file line number Diff line number Diff line change
@@ -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';
1 change: 1 addition & 0 deletions pages/phantom/main-page.js
Original file line number Diff line number Diff line change
@@ -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 = {

0 comments on commit b40f6c8

Please sign in to comment.