-
Notifications
You must be signed in to change notification settings - Fork 3
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
QA New Test Balance after hiding and showing token #2062
Merged
+304
−30
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
212 changes: 212 additions & 0 deletions
212
packages/core-mobile/e2e/tests/balance/manageTokenBalance.e2e.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,212 @@ | ||
import assert from 'assert' | ||
import actions from '../../helpers/actions' | ||
import { warmup } from '../../helpers/warmup' | ||
import portfolioLoc from '../../locators/portfolio.loc' | ||
import commonElsPage from '../../pages/commonEls.page' | ||
import manageTokensPage from '../../pages/manageTokens.page' | ||
import networksManagePage from '../../pages/networksManage.page' | ||
import portfolioPage from '../../pages/portfolio.page' | ||
|
||
describe('Balance After Managing Token', () => { | ||
beforeAll(async () => { | ||
await warmup() | ||
}) | ||
|
||
it('should deduct balance after hiding token on C-Chain', async () => { | ||
// Get balances before hiding token | ||
const fullBal = await portfolioPage.getTotalBalance() | ||
const activeNetworkBal = await portfolioPage.getActiveNetworkBalance() | ||
await portfolioPage.tapActiveNetwork() | ||
const networkTokensBal = await portfolioPage.getNetworkTokensBalance() | ||
const btcBal = await portfolioPage.getTokenBalance('BTC.b') | ||
|
||
// Hide token | ||
await actions.scrollToTop(portfolioPage.portfolioTokenList) | ||
await portfolioPage.tapManageTokens() | ||
await manageTokensPage.hideToken('Bitcoin') | ||
|
||
// Get balances after hiding token | ||
const newNetworkTokensBal = await portfolioPage.getNetworkTokensBalance() | ||
await commonElsPage.goBack() | ||
const newFullBal = await portfolioPage.getTotalBalance() | ||
const newActiveNetworkBal = await portfolioPage.getActiveNetworkBalance() | ||
const tolerance = 1 | ||
|
||
// Log token balances before and after hiding token | ||
console.log( | ||
`Before: \nfullBal: ${fullBal}, \nbtcBal: ${btcBal}, \nactiveNetworkBal: ${activeNetworkBal} \nnetworkTotalBal: ${networkTokensBal}` | ||
) | ||
console.log( | ||
`After: \nnewFullBal: ${newFullBal}, \nnewActiveNetworkBal: ${newActiveNetworkBal} \nnewNetworkTotalBal: ${newNetworkTokensBal}` | ||
) | ||
|
||
// Assert that the tolerance is within the expected range | ||
const fullBalDiff = Math.abs(fullBal - btcBal - newFullBal) | ||
const networkTokensBalDiff = Math.abs( | ||
networkTokensBal - btcBal - newNetworkTokensBal | ||
) | ||
const activeNetworkBalDiff = Math.abs( | ||
activeNetworkBal - btcBal - newActiveNetworkBal | ||
) | ||
assert(fullBalDiff < tolerance, `${fullBalDiff} !< ${tolerance}`) | ||
assert( | ||
networkTokensBalDiff < tolerance, | ||
`${networkTokensBalDiff} !< ${tolerance}` | ||
) | ||
assert( | ||
activeNetworkBalDiff < tolerance, | ||
`${activeNetworkBalDiff} !< ${tolerance}` | ||
) | ||
}) | ||
|
||
it('should deduct balance after hiding token on Ethereum', async () => { | ||
// Get balances before hiding token | ||
await networksManagePage.switchActiveNetwork(portfolioLoc.ethNetwork) | ||
const fullBal = await portfolioPage.getTotalBalance() | ||
const activeNetworkBal = await portfolioPage.getActiveNetworkBalance() | ||
await portfolioPage.tapActiveNetwork(portfolioLoc.ethNetwork) | ||
const networkTokensBal = await portfolioPage.getNetworkTokensBalance( | ||
portfolioLoc.ethNetwork | ||
) | ||
const wethBal = await portfolioPage.getTokenBalance('WETH') | ||
|
||
// Hide token | ||
await actions.scrollToTop(portfolioPage.portfolioTokenList) | ||
await portfolioPage.tapManageTokens() | ||
await manageTokensPage.hideToken('Wrapped Ether') | ||
|
||
// Get balances after hiding token | ||
const newNetworkTokensBal = await portfolioPage.getNetworkTokensBalance( | ||
portfolioLoc.ethNetwork | ||
) | ||
await commonElsPage.goBack() | ||
const newFullBal = await portfolioPage.getTotalBalance() | ||
const newActiveNetworkBal = await portfolioPage.getActiveNetworkBalance() | ||
const tolerance = 1 | ||
|
||
// Log token balances before and after hiding token | ||
console.log( | ||
`Before: \nfullBal: ${fullBal}, \nbtcBal: ${wethBal}, \nactiveNetworkBal: ${activeNetworkBal} \nnetworkTotalBal: ${networkTokensBal}` | ||
) | ||
console.log( | ||
`After: \nnewFullBal: ${newFullBal}, \nnewActiveNetworkBal: ${newActiveNetworkBal} \nnewNetworkTotalBal: ${newNetworkTokensBal}` | ||
) | ||
|
||
// Assert that the tolerance is within the expected range | ||
const fullBalDiff = Math.abs(fullBal - wethBal - newFullBal) | ||
const networkTokensBalDiff = Math.abs( | ||
networkTokensBal - wethBal - newNetworkTokensBal | ||
) | ||
const activeNetworkBalDiff = Math.abs( | ||
activeNetworkBal - wethBal - newActiveNetworkBal | ||
) | ||
assert(fullBalDiff < tolerance, `${fullBalDiff} !< ${tolerance}`) | ||
assert( | ||
networkTokensBalDiff < tolerance, | ||
`${networkTokensBalDiff} !< ${tolerance}` | ||
) | ||
assert( | ||
activeNetworkBalDiff < tolerance, | ||
`${activeNetworkBalDiff} !< ${tolerance}` | ||
) | ||
}) | ||
|
||
it('should update balance after showing token on Ethereum', async () => { | ||
// Get balances before showing token | ||
const fullBal = await portfolioPage.getTotalBalance() | ||
const activeNetworkBal = await portfolioPage.getActiveNetworkBalance() | ||
await portfolioPage.tapActiveNetwork(portfolioLoc.ethNetwork) | ||
const networkTokensBal = await portfolioPage.getNetworkTokensBalance( | ||
portfolioLoc.ethNetwork | ||
) | ||
|
||
// Show token | ||
await actions.scrollToTop(portfolioPage.portfolioTokenList) | ||
await portfolioPage.tapManageTokens() | ||
await manageTokensPage.showToken('Wrapped Ether') | ||
|
||
// Get balances after hiding token | ||
const newNetworkTokensBal = await portfolioPage.getNetworkTokensBalance( | ||
portfolioLoc.ethNetwork | ||
) | ||
const wethBal = await portfolioPage.getTokenBalance('WETH') | ||
await commonElsPage.goBack() | ||
const newFullBal = await portfolioPage.getTotalBalance() | ||
const newActiveNetworkBal = await portfolioPage.getActiveNetworkBalance() | ||
const tolerance = 1 | ||
|
||
// Log token balances before and after hiding token | ||
console.log( | ||
`Before: \nfullBal: ${fullBal}, \nactiveNetworkBal: ${activeNetworkBal} \nnetworkTotalBal: ${networkTokensBal}` | ||
) | ||
console.log( | ||
`After: \nnewFullBal: ${newFullBal}, \nwethBal: ${wethBal}, \nnewActiveNetworkBal: ${newActiveNetworkBal} \nnewNetworkTotalBal: ${newNetworkTokensBal}` | ||
) | ||
|
||
// Assert that the tolerance is within the expected range | ||
const fullBalDiff = Math.abs(fullBal + wethBal - newFullBal) | ||
const networkTokensBalDiff = Math.abs( | ||
networkTokensBal + wethBal - newNetworkTokensBal | ||
) | ||
const activeNetworkBalDiff = Math.abs( | ||
activeNetworkBal + wethBal - newActiveNetworkBal | ||
) | ||
assert(fullBalDiff < tolerance, `${fullBalDiff} !< ${tolerance}`) | ||
assert( | ||
networkTokensBalDiff < tolerance, | ||
`${networkTokensBalDiff} !< ${tolerance}` | ||
) | ||
assert( | ||
activeNetworkBalDiff < tolerance, | ||
`${activeNetworkBalDiff} !< ${tolerance}` | ||
) | ||
}) | ||
|
||
it('should update balance after showing token on C-Chain', async () => { | ||
// Get balances before showing token | ||
await networksManagePage.switchActiveNetwork() | ||
const fullBal = await portfolioPage.getTotalBalance() | ||
const activeNetworkBal = await portfolioPage.getActiveNetworkBalance() | ||
await portfolioPage.tapActiveNetwork() | ||
const networkTokensBal = await portfolioPage.getNetworkTokensBalance() | ||
|
||
// Show token | ||
await actions.scrollToTop(portfolioPage.portfolioTokenList) | ||
await portfolioPage.tapManageTokens() | ||
await manageTokensPage.showToken('Bitcoin') | ||
|
||
// Get balances after hiding token | ||
const newNetworkTokensBal = await portfolioPage.getNetworkTokensBalance() | ||
const btcBal = await portfolioPage.getTokenBalance('BTC.b') | ||
await commonElsPage.goBack() | ||
const newFullBal = await portfolioPage.getTotalBalance() | ||
const newActiveNetworkBal = await portfolioPage.getActiveNetworkBalance() | ||
const tolerance = 1 | ||
|
||
// Log token balances before and after hiding token | ||
console.log( | ||
`Before: \nfullBal: ${fullBal}, \nbtcBal: ${btcBal}, \nactiveNetworkBal: ${activeNetworkBal} \nnetworkTotalBal: ${networkTokensBal}` | ||
) | ||
console.log( | ||
`After: \nnewFullBal: ${newFullBal}, \nnewActiveNetworkBal: ${newActiveNetworkBal} \nnewNetworkTotalBal: ${newNetworkTokensBal}` | ||
) | ||
|
||
// Assert that the tolerance is within the expected range | ||
const fullBalDiff = Math.abs(fullBal + btcBal - newFullBal) | ||
const networkTokensBalDiff = Math.abs( | ||
networkTokensBal + btcBal - newNetworkTokensBal | ||
) | ||
const activeNetworkBalDiff = Math.abs( | ||
activeNetworkBal + btcBal - newActiveNetworkBal | ||
) | ||
assert(fullBalDiff < tolerance, `${fullBalDiff} !< ${tolerance}`) | ||
assert( | ||
networkTokensBalDiff < tolerance, | ||
`${networkTokensBalDiff} !< ${tolerance}` | ||
) | ||
assert( | ||
activeNetworkBalDiff < tolerance, | ||
`${activeNetworkBalDiff} !< ${tolerance}` | ||
) | ||
}) | ||
}) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
These methods are almost the same and should be combined into one. Something like this?
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.
Updated