From d41ee011141fa6c122bf75142211faea7e4e389f Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Wed, 29 May 2024 13:22:43 +0800 Subject: [PATCH 1/7] Improves for MM wallet browser context --- .vscode/settings.json | 3 +++ .../wallets/src/metamask/metamask.page.ts | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..54acfcf5 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "git.enableCommitSigning": true +} diff --git a/packages/wallets/src/metamask/metamask.page.ts b/packages/wallets/src/metamask/metamask.page.ts index d1d5dac0..a22bc504 100644 --- a/packages/wallets/src/metamask/metamask.page.ts +++ b/packages/wallets/src/metamask/metamask.page.ts @@ -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(); + } }); } @@ -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(); } }); } @@ -57,11 +60,21 @@ export class MetamaskPage implements WalletPage { }); } + async isPopoverVisible() { + try { + const popoverContent = await this.page.getByTestId('popover-close'); + await popoverContent.waitFor({ state: 'visible', timeout: 1500 }); + 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 ( From 07eeee03c270afab1b317b2d3c4d576b34b579e6 Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Wed, 29 May 2024 23:54:41 +0800 Subject: [PATCH 2/7] try to fix tests --- packages/wallets/src/metamask/metamask.page.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/wallets/src/metamask/metamask.page.ts b/packages/wallets/src/metamask/metamask.page.ts index a22bc504..6b0f99c1 100644 --- a/packages/wallets/src/metamask/metamask.page.ts +++ b/packages/wallets/src/metamask/metamask.page.ts @@ -86,6 +86,12 @@ export class MetamaskPage implements WalletPage { .locator('button:has-text("Don\'t enable enhanced protection")') .click(); } + if ( + await this.page.getByText('Enhanced Transaction Protection').isVisible() + ) { + await this.page.locator('button:has-text("Enable")').click(); + } + if (await this.page.getByText('Not right now').isVisible()) await this.page.click('text=Not right now'); }); From 3778263a04e1667f171a9fe395319acb4da02ba0 Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Thu, 30 May 2024 21:46:01 +0800 Subject: [PATCH 3/7] Wait timeout was up --- packages/wallets/src/metamask/metamask.page.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/wallets/src/metamask/metamask.page.ts b/packages/wallets/src/metamask/metamask.page.ts index c39c8d74..489bc7b8 100644 --- a/packages/wallets/src/metamask/metamask.page.ts +++ b/packages/wallets/src/metamask/metamask.page.ts @@ -63,7 +63,7 @@ export class MetamaskPage implements WalletPage { async isPopoverVisible() { try { const popoverContent = await this.page.getByTestId('popover-close'); - await popoverContent.waitFor({ state: 'visible', timeout: 1500 }); + await popoverContent.waitFor({ state: 'visible', timeout: 3000 }); return true; } catch (error) { return false; From 51778265c99628bec60aef249291185be954f24c Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Thu, 30 May 2024 22:12:45 +0800 Subject: [PATCH 4/7] Try to reverse changes --- packages/wallets/src/metamask/metamask.page.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/wallets/src/metamask/metamask.page.ts b/packages/wallets/src/metamask/metamask.page.ts index 489bc7b8..fec6b356 100644 --- a/packages/wallets/src/metamask/metamask.page.ts +++ b/packages/wallets/src/metamask/metamask.page.ts @@ -73,8 +73,8 @@ export class MetamaskPage implements WalletPage { async closePopover() { await test.step('Close popover if exists', async () => { if (!this.page) throw "Page isn't ready"; - - if (await this.isPopoverVisible()) { + await new Promise((resolve) => setTimeout(resolve, 5000)); + if (await this.page.getByTestId('popover-close').isVisible()) { await this.page.getByTestId('popover-close').click(); } if ( From 688f20a7654c338708aec8d05c560a7bf6bde809 Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Thu, 30 May 2024 22:18:23 +0800 Subject: [PATCH 5/7] Try to wait popover correctly --- packages/wallets/src/metamask/metamask.page.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/wallets/src/metamask/metamask.page.ts b/packages/wallets/src/metamask/metamask.page.ts index fec6b356..28beee92 100644 --- a/packages/wallets/src/metamask/metamask.page.ts +++ b/packages/wallets/src/metamask/metamask.page.ts @@ -62,8 +62,8 @@ export class MetamaskPage implements WalletPage { async isPopoverVisible() { try { - const popoverContent = await this.page.getByTestId('popover-close'); - await popoverContent.waitFor({ state: 'visible', timeout: 3000 }); + const popoverContent = this.page.getByTestId('popover-close'); + await popoverContent.waitFor({ state: 'visible', timeout: 5000 }); return true; } catch (error) { return false; @@ -73,8 +73,8 @@ export class MetamaskPage implements WalletPage { 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 ( From 928c454ff0fb799d55b5d2b3c15bbc3aad849238 Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Thu, 30 May 2024 22:33:55 +0800 Subject: [PATCH 6/7] remove unnecessary condition --- packages/wallets/src/metamask/metamask.page.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/wallets/src/metamask/metamask.page.ts b/packages/wallets/src/metamask/metamask.page.ts index 28beee92..006f02ef 100644 --- a/packages/wallets/src/metamask/metamask.page.ts +++ b/packages/wallets/src/metamask/metamask.page.ts @@ -86,11 +86,6 @@ export class MetamaskPage implements WalletPage { .locator('button:has-text("Manage in settings")') .click(); } - if ( - await this.page.getByText('Enhanced Transaction Protection').isVisible() - ) { - await this.page.locator('button:has-text("Enable")').click(); - } if (await this.page.getByText('Not right now').isVisible()) await this.page.click('text=Not right now'); From d9e8f8f76d0fa7c6080b3e4450cb34ff2daadcef Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Thu, 30 May 2024 23:04:04 +0800 Subject: [PATCH 7/7] Remove vscode files --- .gitignore | 1 + .vscode/settings.json | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore index ef0c3950..4bc91627 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ generated/ /.jest .idea +.vscode diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 54acfcf5..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "git.enableCommitSigning": true -}