Skip to content

Commit

Permalink
fix: flaky test `Add account should not affect public address when us…
Browse files Browse the repository at this point in the history
…ing secret recovery phrase to recover account with non-zero balance @no-mmi`aded (#27420)

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**
In the process for creating a new account, we get to see this error:

```
TimeoutError: Waiting for element to be located By(css selector, [data-testid="account-list-menu-details"])
Wait timed out after 10023ms
  (Ran on CircleCI Node 17 of 20, Job test-e2e-chrome)
    at /home/circleci/project/node_modules/selenium-webdriver/lib/webdriver.js:929:17
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
```
This happens after clicking the account menu, and after clicking the Add
account. It seems that the click doesn't hit exactly the button due to
the account list loading, making the button move. When the account list
is loaded, the click is performed outside the button boundary, and this
makes the popup close and you cannot find the next element:
"account-list-menu-details" element.

I haven't been able to reproduce this but I've seen this behaviour in
the manual process

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27420?quickstart=1)

## **Related issues**

Fixes: those 3 are fixed in this PR, as they were caused by the same
issue

- #27419
- #27337
- #27336

## **Manual testing steps**

1. Check ci
2. Run tests locally

## **Screenshots/Recordings**



<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
  • Loading branch information
seaona authored Sep 26, 2024
1 parent 251b480 commit 7a5e4d6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/e2e/tests/account/add-account.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ describe('Add account', function () {

// Create 2nd account
await driver.clickElement('[data-testid="account-menu-icon"]');
// Wait until account list is loaded to mitigate race condition
await driver.waitForSelector({
text: 'Account 1',
tag: 'span',
});
await driver.clickElement(
'[data-testid="multichain-account-menu-popover-action-button"]',
);
Expand Down
41 changes: 41 additions & 0 deletions test/e2e/tests/account/import-flow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ describe('Import flow @no-mmi', function () {

// Show account information
await driver.clickElement('[data-testid="account-menu-icon"]');
// Wait until account list is loaded to mitigate race condition
await driver.waitForSelector({
text: 'Account 1',
tag: 'span',
});
await driver.clickElement(
'[data-testid="account-list-item-menu-button"]',
);
Expand Down Expand Up @@ -99,6 +104,11 @@ describe('Import flow @no-mmi', function () {

// choose Create account from the account menu
await driver.clickElement('[data-testid="account-menu-icon"]');
// Wait until account list is loaded to mitigate race condition
await driver.waitForSelector({
text: 'Account 1',
tag: 'span',
});
await driver.clickElement(
'[data-testid="multichain-account-menu-popover-action-button"]',
);
Expand Down Expand Up @@ -182,6 +192,11 @@ describe('Import flow @no-mmi', function () {

// Show account information
await driver.clickElement('[data-testid="account-menu-icon"]');
// Wait until account list is loaded to mitigate race condition
await driver.waitForSelector({
text: 'Account 1',
tag: 'span',
});
await driver.clickElement(
'[data-testid="account-list-item-menu-button"]',
);
Expand Down Expand Up @@ -226,6 +241,11 @@ describe('Import flow @no-mmi', function () {
await unlockWallet(driver);

await driver.clickElement('[data-testid="account-menu-icon"]');
// Wait until account list is loaded to mitigate race condition
await driver.waitForSelector({
text: 'Account 1',
tag: 'span',
});
await driver.clickElement(
'[data-testid="multichain-account-menu-popover-action-button"]',
);
Expand All @@ -249,6 +269,11 @@ describe('Import flow @no-mmi', function () {
text: 'Imported',
});

// Wait until account list is loaded to mitigate race condition
await driver.waitForSelector({
text: 'Account 4',
tag: 'span',
});
// Imports Account 5 with private key
await driver.clickElement(
'[data-testid="multichain-account-menu-popover-action-button"]',
Expand Down Expand Up @@ -307,6 +332,11 @@ describe('Import flow @no-mmi', function () {
await logInWithBalanceValidation(driver, ganacheServer);
// Imports an account with JSON file
await driver.clickElement('[data-testid="account-menu-icon"]');
// Wait until account list is loaded to mitigate race condition
await driver.waitForSelector({
text: 'Account 1',
tag: 'span',
});
await driver.clickElement(
'[data-testid="multichain-account-menu-popover-action-button"]',
);
Expand Down Expand Up @@ -372,6 +402,11 @@ describe('Import flow @no-mmi', function () {

// choose Import Account from the account menu
await driver.clickElement('[data-testid="account-menu-icon"]');
// Wait until account list is loaded to mitigate race condition
await driver.waitForSelector({
text: 'Account 1',
tag: 'span',
});
await driver.clickElement(
'[data-testid="multichain-account-menu-popover-action-button"]',
);
Expand Down Expand Up @@ -406,6 +441,12 @@ describe('Import flow @no-mmi', function () {

// choose Connect hardware wallet from the account menu
await driver.clickElement('[data-testid="account-menu-icon"]');

// Wait until account list is loaded to mitigate race condition
await driver.waitForSelector({
text: 'Account 1',
tag: 'span',
});
await driver.clickElement(
'[data-testid="multichain-account-menu-popover-action-button"]',
);
Expand Down

0 comments on commit 7a5e4d6

Please sign in to comment.