Skip to content

Commit

Permalink
Merge pull request #149 from lidofinance/tech/mm-context
Browse files Browse the repository at this point in the history
Improves for MM wallet browser context
  • Loading branch information
Vorobeyko authored May 30, 2024
2 parents 545e78e + d9e8f8f commit 08d5876
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ generated/
/.jest

.idea
.vscode
20 changes: 17 additions & 3 deletions packages/wallets/src/metamask/metamask.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export class MetamaskPage implements WalletPage {
// added explicit route to #onboarding due to unexpected first time route from /home.html to /onboarding - page is close
await this.navigate();
if (!this.page) throw "Page isn't ready";
await this.firstTimeSetup();
if (!(await this.page.getByTestId('network-display').isVisible())) {
await this.firstTimeSetup();
}
});
}

Expand All @@ -43,6 +45,7 @@ export class MetamaskPage implements WalletPage {
if ((await this.page.locator('id=password').count()) > 0) {
await this.page.fill('id=password', this.config.PASSWORD);
await this.page.click('text=Unlock');
await this.closePopover();
}
});
}
Expand All @@ -57,11 +60,21 @@ export class MetamaskPage implements WalletPage {
});
}

async isPopoverVisible() {
try {
const popoverContent = this.page.getByTestId('popover-close');
await popoverContent.waitFor({ state: 'visible', timeout: 5000 });
return true;
} catch (error) {
return false;
}
}

async closePopover() {
await test.step('Close popover if exists', async () => {
if (!this.page) throw "Page isn't ready";
await new Promise((resolve) => setTimeout(resolve, 5000));
if (await this.page.getByTestId('popover-close').isVisible()) {

if (await this.isPopoverVisible()) {
await this.page.getByTestId('popover-close').click();
}
if (
Expand All @@ -73,6 +86,7 @@ export class MetamaskPage implements WalletPage {
.locator('button:has-text("Manage in settings")')
.click();
}

if (await this.page.getByText('Not right now').isVisible())
await this.page.click('text=Not right now');
});
Expand Down

0 comments on commit 08d5876

Please sign in to comment.