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

fix: flaky test BTC Account - Overview has portfolio button enabled for BTC accounts #27017

Merged
merged 3 commits into from
Sep 10, 2024

Conversation

seaona
Copy link
Contributor

@seaona seaona commented Sep 10, 2024

Description

The way the last 2 assertions are constructed are an anti-pattern, that give place to a race condition, where we wait for the selector to appear, but we don't wait for it to be enabled, so it can happen that when we do the assertion, the button is not yet enabled.

const buySellButton = await driver.waitForSelector(
  '[data-testid="coin-overview-buy"]',
);
assert.equal(await buySellButton.isEnabled(), true);

const portfolioButton = await driver.waitForSelector(
  '[data-testid="coin-overview-receive"]',
);
assert.equal(await portfolioButton.isEnabled(), true);

Screenshot from 2024-09-10 11-48-09

To fix this, we need to directly wait for the element to be enabled (findClickableElement).

Open in GitHub Codespaces

Related issues

Fixes: #27018

Manual testing steps

  1. Check ci

Screenshots/Recordings

See how the element Buy is present and it's already enabled but when the assertion took place, the button was still disabled.

image

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.

@seaona seaona requested a review from a team as a code owner September 10, 2024 09:26
@seaona seaona self-assigned this Sep 10, 2024
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.

@seaona seaona added team-extension-platform flaky tests area-qa Relating to QA work (Quality Assurance) labels Sep 10, 2024
Copy link

sonarcloud bot commented Sep 10, 2024


const portfolioButton = await driver.waitForSelector(
// receive button
await driver.findClickableElement(
'[data-testid="coin-overview-receive"]',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

extra note: the name of the const is miss-leading, as this is not the portfolio link but the receive button

@metamaskbot
Copy link
Collaborator

Builds ready [aa6a10c]
Page Load Metrics (1757 ± 106 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint26622181585470226
domContentLoaded14662221173520599
load147422711757221106
domInteractive127035147
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@seaona seaona merged commit 9f8651c into develop Sep 10, 2024
77 of 78 checks passed
@seaona seaona deleted the fix-flaky-btc-btn-state branch September 10, 2024 10:40
@github-actions github-actions bot locked and limited conversation to collaborators Sep 10, 2024
@metamaskbot metamaskbot added the release-12.6.0 Issue or pull request that will be included in release 12.6.0 label Sep 10, 2024
@gauthierpetetin gauthierpetetin added release-12.5.0 Issue or pull request that will be included in release 12.5.0 and removed release-12.6.0 Issue or pull request that will be included in release 12.6.0 labels Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-qa Relating to QA work (Quality Assurance) flaky tests release-12.5.0 Issue or pull request that will be included in release 12.5.0 team-extension-platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix: "BTC Account - Overview has portfolio button enabled for BTC accounts" flaky test
5 participants