Skip to content

Commit

Permalink
Mm flaky improve (#103)
Browse files Browse the repository at this point in the history
* fix: metamask improve flaky
  • Loading branch information
itaven authored Nov 2, 2023
1 parent 1ec21d1 commit 6cbdd35
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions packages/wallets/src/metamask/metamask.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ export class MetamaskPage implements WalletPage {
this.page = await this.browserContext.newPage();
await this.page.goto(
this.extensionUrl + this.config.COMMON.EXTENSION_START_PATH,
{ waitUntil: 'load' },
);
await this.page.reload();
await this.page.waitForTimeout(1000);
await this.closePopover();
await this.unlock();
});
Expand All @@ -28,20 +27,12 @@ export class MetamaskPage implements WalletPage {
async setup() {
await test.step('Setup', async () => {
// added explicit route to #onboarding due to unexpected first time route from /home.html to /onboarding - page is close
this.page = await this.browserContext.newPage();
await this.page.goto(this.extensionUrl + '/home.html#onboarding/welcome');
await this.navigate();
if (!this.page) throw "Page isn't ready";
// Remove me when MM to be more stable
// const firstTime =
// (await this.page.locator('data-testid=onboarding-welcome').count()) > 0;
// if (firstTime) await this.firstTimeSetup();
do {
await this.page.reload();
} while (
(await this.page.locator('data-testid=onboarding-welcome').count()) ===
0
);
await this.firstTimeSetup();
const firstTime = await this.page
.locator('data-testid=onboarding-welcome')
.isVisible();
if (firstTime) await this.firstTimeSetup();
});
}

Expand All @@ -68,13 +59,16 @@ export class MetamaskPage implements WalletPage {
async closePopover() {
await test.step('Close popover if exists', async () => {
if (!this.page) throw "Page isn't ready";
const popover =
(await this.page.getByTestId('popover-close').count()) > 0;
if (popover) {
await this.page.click('data-testid=popover-close');
const popover = this.page.getByTestId('popover-close');
try {
await popover.waitFor({ state: 'visible', timeout: 7000 });
} catch (error) {
return;
}

if (await popover.isVisible()) {
await popover.click();
// Remove me when MM to be more stable
await this.page.waitForTimeout(1000);
expect((await this.page.getByTestId('popover-close').count()) === 0);
}
});
}
Expand Down Expand Up @@ -174,9 +168,9 @@ export class MetamaskPage implements WalletPage {
await this.closePopover();
await this.page.click('data-testid=account-menu-icon');
} while (
(await this.page
!(await this.page
.locator('text=Add account or hardware wallet')
.count()) === 0
.isVisible())
);
await this.page.click('text=Add account or hardware wallet');
await this.page.click('text=Import account');
Expand Down

0 comments on commit 6cbdd35

Please sign in to comment.