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

QA New - Testing bridge flow across the networks #2015

Merged
merged 5 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions packages/core-mobile/app/screens/bridge/Bridge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ const Bridge: FC = () => {

const renderBlockchain = (
blockchain: Blockchain,
textVariant: 'buttonLarge' | 'buttonMedium'
textVariant: 'buttonLarge' | 'buttonMedium',
testID?: string
): JSX.Element => {
const blockchainTitle = getBlockchainDisplayName(blockchain)

Expand All @@ -387,6 +388,7 @@ const Bridge: FC = () => {
<Avatar.Custom name={blockchain ?? ''} symbol={symbol} />
<Space x={8} />
<Text
testID={testID}
variant={textVariant}
sx={{
maxWidth: blockchainTitleMaxWidth,
Expand All @@ -410,7 +412,7 @@ const Bridge: FC = () => {
justifyContent: 'flex-end',
flex: 0
}}>
{renderBlockchain(blockchain, 'buttonLarge')}
{renderBlockchain(blockchain, 'buttonLarge', 'to_blockchain')}
</Row>
)
}
Expand All @@ -425,7 +427,7 @@ const Bridge: FC = () => {
alignItems: 'center',
justifyContent: 'flex-end'
}}>
{renderBlockchain(blockchain, 'buttonLarge')}
{renderBlockchain(blockchain, 'buttonLarge', 'from_blockchain')}
</Row>
)
}
Expand All @@ -449,7 +451,11 @@ const Bridge: FC = () => {
alignItems: 'center',
flex: 1
}}>
{renderBlockchain(blockchain, 'buttonMedium')}
{renderBlockchain(
blockchain,
'buttonMedium',
`dropdown_item__${blockchain}`
)}
</Row>
{isSelected && (
<View
Expand Down Expand Up @@ -531,7 +537,10 @@ const Bridge: FC = () => {
<Space x={8} />
</>
)}
<Text variant="buttonMedium" style={styles.tokenSelectorText}>
<Text
testID="selected_token"
variant="buttonMedium"
style={styles.tokenSelectorText}>
{selectedAsset ? selectedAssetSymbol : 'Select Token'}
</Text>
<CarrotSVG direction={'down'} size={12} />
Expand Down Expand Up @@ -593,6 +602,7 @@ const Bridge: FC = () => {
if (isAmountTooLow)
return (
<Text
testID="bridge_error"
variant="caption"
sx={{
color: '$dangerDark'
Expand All @@ -604,6 +614,7 @@ const Bridge: FC = () => {
if (isAmountTooLarge)
return (
<Text
testID="bridge_error"
variant="caption"
sx={{
color: '$dangerDark'
Expand All @@ -615,6 +626,7 @@ const Bridge: FC = () => {
if (bridgeError)
return (
<Text
testID="bridge_error"
variant="caption"
sx={{
color: '$dangerDark'
Expand All @@ -626,6 +638,7 @@ const Bridge: FC = () => {
if (hasInvalidReceiveAmount)
return (
<Text
testID="bridge_error"
variant="caption"
sx={{
color: '$dangerDark'
Expand All @@ -637,6 +650,7 @@ const Bridge: FC = () => {
if (isNativeBalanceNotEnoughForNetworkFee)
return (
<Text
testID="bridge_error"
variant="caption"
sx={{
color: '$dangerDark'
Expand Down Expand Up @@ -693,6 +707,7 @@ const Bridge: FC = () => {
const renderToggleBtn = (): JSX.Element => {
return (
<AvaButton.Base
testID="bridge_toggle_btn"
onPress={handleBlockchainToggle}
style={[styles.toggleButton, { backgroundColor: theme.colors.$white }]}>
<BridgeToggleIcon color={theme.colors.$black} />
Expand Down Expand Up @@ -756,7 +771,7 @@ const Bridge: FC = () => {
const renderTransferBtn = (): JSX.Element => {
return (
<Button
testID="transfer_btn"
testID="bridge_btn"
type="primary"
size="xlarge"
style={{ marginHorizontal: 16, marginBottom: 10, marginTop: 16 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function BridgeTokenSelector({

return (
<AvaListItem.Base
testID={`token_selector__${token.symbol}`}
title={title}
leftComponent={tokenLogo()}
rightComponentVerticalAlignment={'center'}
Expand Down Expand Up @@ -95,7 +96,11 @@ function BridgeTokenSelector({

return (
<View style={{ flex: 1, marginHorizontal: horizontalMargin }}>
<SearchBar onTextChanged={setSearchText} searchText={searchText} />
<SearchBar
onTextChanged={setSearchText}
searchText={searchText}
testID="search_bar__select_token"
/>
<Space y={16} />
{!bridgeTokenList ? (
<Loader />
Expand Down
9 changes: 7 additions & 2 deletions packages/core-mobile/e2e/locators/bridgeTab.loc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export default {
completedStatusBtcAvaxMainnet: '6/6',
completedStatusBtcAvaxTestnet: '4/4',
bridgeTitle: 'Bridge',
bridgeBtn: 'transfer_btn',
receive: 'Receive'
bridgeBtn: 'bridge_btn',
receive: 'Receive',
bridgeToggleBtn: 'bridge_toggle_btn',
selectedToken: 'selected_token',
toNetwork: 'to_blockchain',
fromNetwork: 'from_blockchain',
error: 'bridge_error'
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default {
saveButton: 'Save',
securityAndPrivacy: 'Security & Privacy',
showRecoveryPhrase: 'Show recovery phrase',
carrotSvg: 'carrot_svg',
notifications: 'Notifications',
deleteWalletBtn: 'Delete Wallet',
iUnderstand: 'I understand, continue'
Expand Down
3 changes: 2 additions & 1 deletion packages/core-mobile/e2e/locators/commonEls.loc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export default {
searchBar: 'search_bar__search',
bitcoinSVG: 'bitcoin_svg',
avaSVG: 'ava_logo',
reloadSVG: 'reload_svg'
reloadSVG: 'reload_svg',
carrotSVG: 'carrot_svg'
}
3 changes: 2 additions & 1 deletion packages/core-mobile/e2e/locators/send.loc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ export default {
addressField: 'end_token__send_field',
searchBarOnSelectToken: 'search_bar__select_token',
selectTokenTitle: 'Select Token',
sendTo: 'Send To'
sendTo: 'Send To',
max: 'Max'
}
68 changes: 63 additions & 5 deletions packages/core-mobile/e2e/pages/bridgeTab.page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Actions from '../helpers/actions'
import Assert from '../helpers/assertions'
import { Platform } from '../helpers/constants'
import delay from '../helpers/waits'
import bridgeTab from '../locators/bridgeTab.loc'
import BottomTabsPage from '../pages/bottomTabs.page'
import PlusMenuPage from './plusMenu.page'
Expand Down Expand Up @@ -122,6 +123,35 @@ class BridgeTabPage {
return by.text(bridgeTab.receive)
}

get bridgeToggleBtn() {
return by.id(bridgeTab.bridgeToggleBtn)
}

get selectedToken() {
return by.id(bridgeTab.selectedToken)
}

get toNetwork() {
return by.id(bridgeTab.toNetwork)
}

get fromNetwork() {
return by.id(bridgeTab.fromNetwork)
}

get error() {
return by.id(bridgeTab.error)
}

async tapBridgeBtn() {
await delay(1000)
return Actions.tap(this.bridgeBtn)
}

async tapBridgeToggleBtn() {
return Actions.tap(this.bridgeToggleBtn)
}

async tapAvalancheNetwork() {
return Actions.tapElementAtIndex(this.avalancheNetwork, platformIndex2)
}
Expand Down Expand Up @@ -238,19 +268,42 @@ class BridgeTabPage {

async verifyBridgeScreen() {
await Actions.waitForElement(this.bridgeTitle)
await Actions.waitForElement(this.bridgeBtn)
await Actions.waitForElement(this.fromText)
await Actions.waitForElement(this.receive)
await Assert.isVisible(this.bridgeBtn)
await Assert.isVisible(this.fromText)
await Assert.isVisible(this.receive)
await Assert.isVisible(this.bridgeToggleBtn)
}

async tapFromNetwork() {
await Actions.tap(this.fromNetwork)
}

async tapSelectToken() {
await delay(1000)
await Actions.tap(this.selectedToken)
}

async verifyFromNetwork(network: string) {
await Assert.hasText(this.fromNetwork, network, 0)
}

async verifyNetworks(from: string, to: string) {
await this.verifyFromNetwork(from)
await this.verifyToNetwork(to)
}

async verifyToNetwork(network = '') {
await Assert.isVisible(this.toNetwork)
await Assert.hasText(this.toNetwork, network, 0)
}
// eslint-disable-next-line max-params
async verifyBridgeTransaction(
delay: number,
timeout: number,
completedStatusIncomingNetwork: Detox.NativeMatcher,
completedStatusOutgoingNetwork: Detox.NativeMatcher,
successfullBridgeTransaction: Detox.NativeMatcher
) {
await Actions.waitForElementNoSync(this.closebutton, delay)
await Actions.waitForElementNoSync(this.closebutton, timeout)
await Assert.isVisible(completedStatusIncomingNetwork)
await Assert.isVisible(completedStatusOutgoingNetwork)

Expand All @@ -259,6 +312,11 @@ class BridgeTabPage {
await PortfolioPage.tapActivityTab()
await Assert.isVisible(successfullBridgeTransaction)
}

async goToBridge() {
await BottomTabsPage.tapPlusIcon()
await PlusMenuPage.tapBridgeButton()
}
}

export default new BridgeTabPage()
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class BurgerMenuPage {

async swipeLeft() {
await Actions.swipeLeft(
by.id(burgerMenu.carrotSvg),
by.id(commonElsLoc.carrotSVG),
'slow',
0.5,
platformIndex2
Expand Down
13 changes: 13 additions & 0 deletions packages/core-mobile/e2e/pages/commonEls.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ class CommonElsPage {
return by.id(commonEls.reloadSVG)
}

get carrotSVG() {
return by.id(commonEls.carrotSVG)
}

async tapCarrotSVG(index = 0) {
await Actions.tapElementAtIndex(this.carrotSVG, index)
}

async typeSearchBar(text: string) {
await Actions.waitForElement(this.searchBar)
await Actions.setInputText(this.searchBar, text)
Expand Down Expand Up @@ -136,6 +144,11 @@ class CommonElsPage {
}
}

async tapDropdownItem(item: string, index = 0) {
await Actions.waitForElement(by.id(`dropdown_item__${item}`))
await Actions.tapElementAtIndex(by.id(`dropdown_item__${item}`), index)
}

async tapNotNow() {
try {
await Actions.tapElementAtIndex(this.notNow, 0)
Expand Down
2 changes: 1 addition & 1 deletion packages/core-mobile/e2e/pages/popUpModal.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class PopUpModalPage {
}

async verifyFeeIsLegit(isPXChain = false, estimatedGasFee = 0.009) {
await actions.waitForElement(this.approveTransactionTitle, 10000)
await actions.waitForElement(this.popUpModalScrollView, 10000)
await actions.scrollToBottom(this.popUpModalScrollView)
let tokenGasFee
if (isPXChain) {
Expand Down
8 changes: 8 additions & 0 deletions packages/core-mobile/e2e/pages/send.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ class SendPage {
return by.text(Send.sendTo)
}

get max() {
return by.text(Send.max)
}

async tapAddressBook() {
await Actions.tap(this.addressBook)
}
Expand Down Expand Up @@ -107,6 +111,10 @@ class SendPage {
await Actions.tapElementAtIndex(by.id(`token_selector__${tokenName}`), 0)
}

async tapMax() {
await Actions.tap(this.max)
}

async enterAmount(amount: string) {
await Actions.setInputText(this.amountToSendInput, amount, 0)
}
Expand Down
Loading
Loading