Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: [POM] Migrate token tests #29375

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open

test: [POM] Migrate token tests #29375

wants to merge 27 commits into from

Conversation

cmd-ob
Copy link
Contributor

@cmd-ob cmd-ob commented Dec 20, 2024

Description

  • Updates asset-list Page Object - Adds methods for interacting with token list (i.e sorting, getting list, assertion on increase/decrease price and percentage)
  • Adds new method for importing a custom token using contract address
  • Adds new method for adding multiple tokens by search in one step
  • Minor update to send-token page for warning message
  • New page object for token-overview
  • Tests Updated - import-tokens, send-erc20-to-contract, token-list and token-sort

Related issues

Fixes:

Manual testing steps

  • All tests must pass on CI

Screenshots/Recordings

Before

After

Pre-merge author checklist

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.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-qa QA team label Dec 20, 2024
private readonly swapButton = {
text: 'Swap',
css: '.icon-button',
};
Copy link
Contributor Author

@cmd-ob cmd-ob Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using text based selectors here, it's more accessible and means we don't have to create multiple selectors depending on the type of token screen we are looking at. i.e Is the token enabled for swap, bridge, send etc.

The other selector would be either coin-overview-* or token-overview-* or eth-overview-*
This would cause flakiness in the e2e test. I do think there is a bug on the correct selector/element being rendered. It is not affecting the user but they might need to cover it with unit tests so something else does not break

@cmd-ob cmd-ob requested review from seaona and chloeYue December 20, 2024 07:57
@cmd-ob cmd-ob marked this pull request as ready for review December 20, 2024 07:58
@cmd-ob cmd-ob enabled auto-merge December 20, 2024 09:32
@metamaskbot
Copy link
Collaborator

Builds ready [7f54477]
Page Load Metrics (1801 ± 78 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint27220811725368177
domContentLoaded14932069175814268
load14982084180116278
domInteractive2293462010
backgroundConnect7288436029
firstReactRender16101503015
getState565212211
initialActions01000
loadScripts10431559129412560
setupStore68713178
uiStartup183528322192278134
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

const percentageElement = await this.driver.findElement(
this.tokenPercentage(assetAddress),
);
const percentage = await percentageElement.getText();
Copy link
Contributor

@seaona seaona Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm this is an anti-pattern that opens the door to race conditions, where the element is rendered but it does not have yet the value we expect.
We should try to avoid finding an element and then getting its text where possible. I think in this case it's possible to avoid this. In the specs below, we should directly try to find the element by its expected inner value instead of this assert

const percentage =
  await assetListPage.getAssetPercentageIncreaseDecrease(tokenAddress);
assert.equal(percentage, '');

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I agree with you here. I have used isElementPresent to check for the existence of the element for a given token address


private readonly swapButton = {
text: 'Swap',
css: '.icon-button',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of small things:

  • could we sort these selectors alphabetically maybe?
  • I think these buttons are the exact same buttons we have in the home screen. Maybe we could separate them in their own component, and re-use them in the homepage class and in the token overview class? Just a thought, it doesn't have to be in this PR. The advantage would be that if a button from this group changes, we'll only need to update it in one place. The disadvantage might be that it might complicate a bit the component? though not too much. What are your thoughts? In any case, it can be left outside this PR, if we decide to have this separate component

Screenshot from 2024-12-20 10-45-01

Screenshot from 2024-12-20 10-45-09

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I also had the same thought. It could make sense (if we keep it text based as I have done here)
the only doubt that I have is the depending on the token type different buttons are displayed so that is still something to think about. I do agree though there is a way we could make this easier to deal with

await driver.findElement(`[data-testid="${testId}"]`)
).getText();
const percentage =
await assetListPage.getAssetPercentageIncreaseDecrease(tokenAddress);
assert.equal(percentage, '');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with these 2 asserts race conditions can happen (see above comment)

@metamaskbot
Copy link
Collaborator

Builds ready [6be682d]
Page Load Metrics (1758 ± 61 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint26421271691354170
domContentLoaded15532064173112962
load15682075175812761
domInteractive24101412311
backgroundConnect966332110
firstReactRender1894542512
getState58114189
initialActions01000
loadScripts11421534129011053
setupStore65911115
uiStartup17442374204116278
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [c09fd7d]
Page Load Metrics (1613 ± 47 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint14581852162210952
domContentLoaded1414176515919445
load1458181216139847
domInteractive23117382311
backgroundConnect8102212210
firstReactRender1673412512
getState44715157
initialActions01000
loadScripts1036131711668239
setupStore66711136
uiStartup16592040184010450
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@cmd-ob cmd-ob requested a review from seaona December 20, 2024 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-qa QA team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants