MetaMask / MetaMask/metamask-extension

[Refactor] Replace getText() with findElement using css

Open
#19,870 2 comments 1 reaction 1 assignee Claimed by @seaona View on GitHub
release-12.6.0 team-extension-platform
Dominant language
TypeScript
Stars
13.2k
Forks
5.6k
Avg merge
2d 5h
Merged PRs (30d)
451

Description

After a few fixes for flaky tests in MV3, it is noticeable that lots are related to an assertion pattern change, which is to find an element, then assert what its contents are. There's a racing condition in some e2e tests to find the dom and assert, and we'll try to avoid this pattern.

Proposed by Mark in [this thread](https://consensys.slack.com/archives/GTQAGKY5V/p1686238528522549)

e.g. Instead of this:
```
const element = await driver.findElement('[data-testid="foo"]');
assert(await element.getText(), 'Bar')
```
Do this:
```
await driver.findElement({
css: '[data-testid="foo"]',
text: 'Bar',
});
```
Hence, we want to introduce an new lint rules to forbid this pattern from being written;
Also refactor all existing places we used this pattern to reduce the noise if monitoring MV3 e2e tests.

**_Acceptance criteria:_**
1. lint error for using `findElement` and `getText` when comes to comparing element text and string
2. all existing tests use new `findElement` pattern.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.