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 f30bbfd
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 47 deletions.
24 changes: 12 additions & 12 deletions commands/metamask.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down Expand Up @@ -1329,7 +1329,7 @@ const metamask = {

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

Expand All @@ -1339,7 +1339,7 @@ const metamask = {
// 120 seconds
while (retries < retiresLimit) {
const unapprovedTxs = await playwright
.metamaskWindow()
.windows(PROVIDER)
.getByText('Unapproved')
.count();
if (unapprovedTxs === 1) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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`,
)
Expand All @@ -1426,20 +1426,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 });

Expand Down
2 changes: 1 addition & 1 deletion commands/phantom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
41 changes: 10 additions & 31 deletions commands/playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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(() => {
Expand All @@ -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}`);
}
Expand Down Expand Up @@ -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.',
Expand All @@ -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.',
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions pages/phantom/first-time-flow-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -47,7 +46,7 @@ module.exports.firstTimeFlowImportPageElements = {
importButton,
confirmWordsButton,
continueAfterPasswordButton,
getStartedButton
getStartedButton,
};

const firstTimeFlowCreatePage = '.first-time-flow';
Expand Down
1 change: 1 addition & 0 deletions pages/phantom/main-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit f30bbfd

Please sign in to comment.