Skip to content

Commit

Permalink
fix: flaky test ENS domain resolves to a correct address (#25248)
Browse files Browse the repository at this point in the history
<!--
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.
-->

This PR fixes the flaky test `ENS domain resolves to a correct address`

The error is:
```

[driver] Called 'clickElement' with arguments [".address-list-item"]
[driver] Called 'findElement' with arguments [{"css":".ens-input__selected-input__title","text":"test.eth"}]
Failure on testcase: 'ENS domain resolves to a correct address', for more information see the artifacts tab in CI

TimeoutError: Waiting for element to be located By(xpath, .//*[contains(concat(' ', normalize-space(./@Class), ' '), ' ens-input__selected-input__title ')][(contains(string(.), 'test.eth') or contains(string(.), 'test.eth'))])`

```

The problem is that we are clicking the address-list-item button, and
nothing happens afterwards. Then we try to find the next element but is
not there.
If we look into the address-list-item button element we can see how it
has nested elements inside, which will render the address and the ENS
domain.
Clicking on a "container" element with other elements inside might not
work as we expect, since the inside elements might not be fully updated
before clicking with unknown effects (in this case, the ENS and address
resolution) .

To fix this, we are doing 2 things:
- waiting for both the ENS and the address to be fully rendered (before
we were just waiting for the ENS domain to be loaded)
- clicking on a more specific element inside the container -> we now
click into the inner element for the domain ENS

See Box as the container button, and nested elements with address and
ENS domain.

![Screenshot from 2024-06-12
10-49-23](https://github.com/MetaMask/metamask-extension/assets/54408225/bef54bcf-9f67-46f3-9155-b877fb9c844f)

- ci failure example:
https://app.circleci.com/pipelines/github/MetaMask/metamask-extension/86997/workflows/200911a8-50a6-42f2-b56a-b6f7afc8fc1e/jobs/3178850/artifacts

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

Fixes: #24652

1. Check ci
2. Run test multiple times locally with different builds `yarn
test:e2e:single test/e2e/tests/transaction/ens.spec.js --browser=chrome
--leave-running --retryUntilFailure --retries=10`

Ci failure screenshot: notice how, after clicking the ENS address
button, we don't see the asset below, this means that the click didn't
have any effect.

![image](https://github.com/MetaMask/metamask-extension/assets/54408225/c62f66e5-a194-4d70-917b-5677cdb13f87)

Expected: after clicking the EN address button, we should see the asset
below

![Screenshot from 2024-06-12
10-04-33](https://github.com/MetaMask/metamask-extension/assets/54408225/9478f881-edeb-4a32-9e95-ce715526e72b)

- [ ] 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.

- [ ] 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 and hjetpoluru committed Jun 26, 2024
1 parent f538723 commit fcc5641
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test/e2e/tests/transaction/ens.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ const FixtureBuilder = require('../../fixture-builder');

describe('ENS', function () {
const sampleAddress = '1111111111111111111111111111111111111111';

// Having 2 versions of the address is a bug(#25286)
const shortSampleAddress = '0x1111...1111';
const shortSampleAddresV2 = '0x11111...11111';

const sampleEnsDomain = 'test.eth';
const infuraUrl =
'https://mainnet.infura.io/v3/00000000000000000000000000000000';
Expand Down Expand Up @@ -95,15 +100,23 @@ describe('ENS', function () {
css: '[data-testid="address-list-item-label"]',
});

await driver.clickElement('.address-list-item');
await driver.waitForSelector({
text: shortSampleAddress,
css: '.multichain-send-page__recipient__item__subtitle',
});

await driver.clickElement({
text: sampleEnsDomain,
css: '[data-testid="multichain-send-page__recipient__item__title"]',
});

await driver.findElement({
css: '.ens-input__selected-input__title',
text: 'test.eth',
});

await driver.findElement({
text: '0x11111...11111',
text: shortSampleAddresV2,
});
},
);
Expand Down

0 comments on commit fcc5641

Please sign in to comment.