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 4byte setting does not try to get contract method name from 4byte when the setting is off #27560

Merged
merged 2 commits into from
Oct 2, 2024

Conversation

seaona
Copy link
Contributor

@seaona seaona commented Oct 2, 2024

Description

This test is failing as it's trying to look for the Deposit initiated element in the test dapp and it doesn't appear in time.

Screenshot from 2024-10-02 12-21-16

We shouldn't care if the test dapp sets the value to Deposit initiated into its div element, as long as the popup is open (which it does). This removes any potential race condition on the test dapp side

There are several things to fix/improve around the 2 specs for 4byte, so I took the opportunity to fix those too.

Open in GitHub Codespaces

Related issues

Fixes: #21494

Manual testing steps

  1. Check ci
  2. Run test locally

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.

@seaona seaona added team-extension-platform flaky tests area-qa Relating to QA work (Quality Assurance) labels Oct 2, 2024
@seaona seaona self-assigned this Oct 2, 2024
@seaona seaona requested a review from a team as a code owner October 2, 2024 10:13
Copy link
Contributor

github-actions bot commented Oct 2, 2024

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.

assert.equal(
await actionElement.getText(),
contractInteraction.toUpperCase(),
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this way of asserting can cause race conditions, when the element it's present but not the value we expected. This is an anti-pattern, that needs to be switch by waiting for a value (text) we want. This way we can safely remove the delay

@@ -83,28 +78,23 @@ describe('4byte setting', function () {
await openDapp(driver, contractAddress);

// wait for deployed contract, calls and confirms a contract method where ETH is sent
await driver.findClickableElement('#depositButton');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not needed

text: 'Deposit initiated',
});

await driver.waitUntilXWindowHandles(3);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not needed


// deploy contract
await openDapp(driver, contractAddress);

// wait for deployed contract, calls and confirms a contract method where ETH is sent
await driver.delay(largeDelayMs);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we make sure we login with balance validation, we can safely remove this delay

await driver.waitForSelector({
css: 'span',
text: 'Deposit initiated',
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we don't care if the test dapp loads this value in time or not

text: 'Deposit',
});
assert.equal(await actionElement.getText(), 'DEPOSIT');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

asserting an element by it's inner value to match an expect value, opens the door to race conditions. We should find the element by its value directly. I've also added the 2 conditions we want (deposit is there, and contract interaction is not there)

Copy link

sonarcloud bot commented Oct 2, 2024

@metamaskbot
Copy link
Collaborator

Builds ready [fdfa487]
Page Load Metrics (1953 ± 141 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint31925401874465223
domContentLoaded154724951925279134
load155525081953293141
domInteractive19144482813
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@seaona seaona added this pull request to the merge queue Oct 2, 2024
Copy link
Contributor

@chloeYue chloeYue left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the fix !

Merged via the queue into develop with commit 2069163 Oct 2, 2024
80 checks passed
@seaona seaona deleted the fix-flaky-4byte branch October 2, 2024 13:03
@github-actions github-actions bot locked and limited conversation to collaborators Oct 2, 2024
@metamaskbot metamaskbot added the release-12.6.0 Issue or pull request that will be included in release 12.6.0 label Oct 2, 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.6.0 Issue or pull request that will be included in release 12.6.0 team-extension-platform
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Fix flaky test "does not try to get contract method name from 4byte when the setting is off"
5 participants