-
Notifications
You must be signed in to change notification settings - Fork 5k
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
[e2e] Using ganache requests to getBalance and getAccounts #18215
Conversation
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. |
const balanceInt = parseInt(balanceHex, 16) / 10 ** 18; | ||
|
||
const balanceFormatted = | ||
balanceInt % 1 === 0 ? balanceInt : balanceInt.toFixed(4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the balance is a float number, we round it up to 4 decimals to match UI.
If it's a whole number, do nothing
@@ -145,6 +145,7 @@ async function withFixtures(options, testSuite) { | |||
driver: driverProxy ?? driver, | |||
mockServer, | |||
contractRegistry, | |||
ganacheServer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we pass ganacheServer to the testsuite to be able to access its methods
@@ -104,9 +104,10 @@ describe('MetaMask Responsive UI', function () { | |||
await driver.press('#confirm-password', driver.Key.ENTER); | |||
|
|||
// balance renders | |||
const balance = await ganacheServer.getBalance(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here we access the current balance of the acocunt, instead of hardcoding the balance
Builds ready [b2e3f70]
Page Load Metrics (1628 ± 40 ms)
Bundle size diffs
|
Builds ready [775498e]
Page Load Metrics (1718 ± 45 ms)
Bundle size diffs
|
Codecov Report
@@ Coverage Diff @@
## develop #18215 +/- ##
========================================
Coverage 63.96% 63.96%
========================================
Files 914 914
Lines 35623 35623
Branches 9030 9030
========================================
Hits 22784 22784
Misses 12839 12839 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Great idea
Explanation
Context: sometimes we need to validate tests against the current ETH balance or the account addresst. We used to hardcode this values.
What: with this PR we introduce the Ganache methods for getting the accounts and getting the balance of the account 0, so we do not need to hardcode balances/accounts anymore. Benefits:
setAccountNonce
etc.Screenshots/Screencaps
n/a
Before
We look for this specific balance value on the UI:
text: '24.9977 ETH',
After
We get the current balance value and look for that value on the UI:
const balance = await ganacheServer.getBalance();
text: ${balance} ETH,
Manual Testing Steps
Run the affected tests manually on your local:
yarn test:e2e:single test/e2e/tests/send-hex-address.spec.js --browser=chrome --leave-running=true
yarn test:e2e:single test/e2e/tests/metamask-responsive-ui.spec.js --browser=chrome --leave-running=true
Pre-merge author checklist
Pre-merge reviewer checklist
If further QA is required (e.g. new feature, complex testing steps, large refactor), add the
Extension QA Board
label.In this case, a QA Engineer approval will be be required.