Skip to content

Commit

Permalink
QA handle slide button to logout and other fixes (#2053)
Browse files Browse the repository at this point in the history
  • Loading branch information
eunjisong authored Nov 5, 2024
1 parent 30604e4 commit f5528e1
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ const UniversalTokenSelector: FC<Props> = ({
<Space y={8} />
<Row>
{hasError && (
<Text variant="body2" sx={{ color: '$dangerMain' }}>
<Text
testID="error_msg"
variant="body2"
sx={{ color: '$dangerMain' }}>
{error}
</Text>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const SlideToConfirm = ({
<Animated.View
{...panResponder.panHandlers}
style={[styles.slider, { width: sliderWidth }]}>
<Animated.View style={{ opacity: iconOpacityAnim }}>
<Animated.View testID="slide" style={{ opacity: iconOpacityAnim }}>
<Icons.Navigation.ArrowForwardIOS color={colors.$neutral900} />
</Animated.View>
</Animated.View>
Expand Down
1 change: 1 addition & 0 deletions packages/core-mobile/app/screens/mainView/SignOutModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const SignOutModal = ({
<FlexSpacer />
<SlideToConfirm onConfirm={onConfirm} text={'Slide to confirm'} />
<Button
testID="cancel_btn"
type="tertiary"
size="xlarge"
style={{ marginTop: 16 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ const NetworkTokens = (): JSX.Element => {

const renderTokens = (): JSX.Element => (
<FlatList
testID="portfolio_token_list"
contentContainerStyle={{
paddingHorizontal: 16,
paddingBottom: 100,
Expand Down
37 changes: 35 additions & 2 deletions packages/core-mobile/e2e/helpers/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,19 @@ const isVisible = async (
.catch(() => false)
}

const hasText = async (
item: Detox.NativeMatcher,
text: string,
index = 1,
timeout = 2000
): Promise<boolean> => {
return await waitFor(element(item).atIndex(index))
.toHaveText(text)
.withTimeout(timeout)
.then(() => true)
.catch(() => false)
}

const swipeUp = async (
item: Detox.NativeMatcher,
speed: Detox.Speed,
Expand Down Expand Up @@ -348,10 +361,28 @@ async function waitForCondition(func: any, condition: any, timeout = 5000) {
const drag = async (
item: Detox.NativeMatcher,
direction: Detox.Direction = 'down',
percentage = 0.2,
index = 0
) => {
await element(item).atIndex(index).longPress()
await element(item).atIndex(index).swipe(direction, 'fast', 0.2)
await element(item).atIndex(index).swipe(direction, 'fast', percentage)
}

const dragTo = async (
fromEle: Detox.NativeMatcher,
targetEle: Detox.NativeMatcher,
targetOffset: [number, number] // [targetOffsetX, targetOffsetY]
) => {
await element(fromEle).longPressAndDrag(
500,
NaN,
NaN,
element(targetEle),
targetOffset[0],
targetOffset[1],
'fast',
0
)
}

const shuffleArray = <T>(array: T[]): T[] =>
Expand Down Expand Up @@ -390,7 +421,9 @@ export default {
clearTextInput,
getElementTextNoSync,
drag,
dragTo,
shuffleArray,
scrollToBottom,
scrollToTop
scrollToTop,
hasText
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export default {
showRecoveryPhrase: 'Show recovery phrase',
notifications: 'Notifications',
deleteWalletBtn: 'Delete Wallet',
iUnderstand: 'I understand, continue'
slideBtn: 'slide',
cancel: 'cancel_btn'
}
3 changes: 2 additions & 1 deletion packages/core-mobile/e2e/locators/portfolio.loc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ export default {
tokensTab: 'Tokens',
benqi: 'BENQI',
activeNetworkBalance: 'active_network_balance',
tokensTabListView: 'tokens_tab_list_view'
tokensTabListView: 'tokens_tab_list_view',
portfolioTokenList: 'portfolio_token_list'
}
6 changes: 0 additions & 6 deletions packages/core-mobile/e2e/pages/browser.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,6 @@ class BrowserPage {
}

async sendRpcCall(rpcCall: string) {
await bottomTabsPage.tapBrowserTab()
try {
await this.reconnectRpc()
} catch (e) {
console.log('No need to reconnect RPC Playground')
}
await this.goToRpcCallPage()
await this.enterRpcCall(rpcCall)
await this.tapSend()
Expand Down
17 changes: 14 additions & 3 deletions packages/core-mobile/e2e/pages/burgerMenu/burgerMenu.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ class BurgerMenuPage {
return by.text(burgerMenu.deleteWalletBtn)
}

get iUnderstand() {
return by.text(burgerMenu.iUnderstand)
get slideBtn() {
return by.id(burgerMenu.slideBtn)
}

get cancel() {
return by.id(burgerMenu.cancel)
}

async swipeLeft() {
Expand Down Expand Up @@ -90,7 +94,14 @@ class BurgerMenuPage {

async deleteWallet() {
await Actions.tapElementAtIndex(this.deleteWalletBtn, 0)
await Actions.tapElementAtIndex(this.iUnderstand, 0)
await this.swipeToLogout()
}
async swipeToLogout() {
if (Actions.platform() === Platform.iOS) {
await Actions.dragTo(this.slideBtn, this.cancel, [1, 0])
} else {
await Actions.drag(this.slideBtn, 'right', 1)
}
}
}

Expand Down
11 changes: 10 additions & 1 deletion packages/core-mobile/e2e/pages/portfolio.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ class PortfolioPage {
return by.id(portfolio.tokensTabListView)
}

get portfolioTokenList() {
return by.id(portfolio.portfolioTokenList)
}

async verifyPorfolioScreen() {
await Assert.isVisible(this.viewAllBtn)
await Assert.isVisible(this.favoritesHeader)
Expand Down Expand Up @@ -309,7 +313,12 @@ class PortfolioPage {
}

async tapToken(token: string) {
await Action.waitForElement(by.id(`${token}_portfolio_list_item`))
await Action.waitForElement(this.portfolioTokenList)
await Action.scrollListUntil(
by.id(`${token}_portfolio_list_item`),
this.portfolioTokenList,
100
)
await Action.tap(by.id(`${token}_portfolio_list_item`))
}

Expand Down
34 changes: 18 additions & 16 deletions packages/core-mobile/e2e/pages/swapTab.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ class SwapTabPage {

async tapReviewOrderButton(index = 0) {
await Actions.waitForElementNoSync(this.reviewOrderBtn, 15000)
await Actions.tapElementAtIndex(this.reviewOrderBtn, index)
while (await Actions.isVisible(this.reviewOrderBtn, index)) {
await Actions.tapElementAtIndex(this.reviewOrderBtn, index)
await delay(3000)
}
}

async tapApproveButton() {
Expand Down Expand Up @@ -126,34 +129,30 @@ class SwapTabPage {
}

async swap(from: string, to: string, amount = '0.000001') {
// Go to swap form
await bottomTabsPage.tapPlusIcon()
await plusMenuPage.tapSwapButton()

// Select From Token
if (from !== 'AVAX') {
await this.tapFromTokenSelector()
await sendPage.selectToken(from)
}

// Select To Token
if (to !== 'USDC') {
await this.tapToTokenSelector()
await sendPage.selectToken(to)
}

// Enter input
await this.inputTokenAmount(amount)
let newAmount = amount

// Update input if error message is displayed
while (
(await Actions.isVisible(
by.text('No routes found with enough liquidity'),
0,
500
)) ||
(await Actions.isVisible(
by.text('ESTIMATED_LOSS_GREATER_THAN_MAX_IMPACT'),
0,
500
)) ||
(await Actions.isVisible(
by.text('Amount 1 is too small to proceed'),
0,
500
))
(await Actions.isVisible(by.id('error_msg'), 0, 500)) ||
(await Actions.hasText(this.amountField, ''))
) {
newAmount = await this.adjustAmount(newAmount)
console.log(newAmount)
Expand All @@ -162,13 +161,16 @@ class SwapTabPage {
break
}
}
// Tap Review Order
await this.tapReviewOrderButton()
try {
await Actions.waitForElementNoSync(this.tokenSpendApproval, 8000)
await this.tapApproveButton()
} catch (e) {
console.error('Token spend approval not found')
}

// Verify fee and approve
await popUpModalPage.verifyFeeIsLegit(false, 0.2)
await this.tapApproveButton()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
/**
* @jest-environment ./environment.ts
*/
import actions from '../../../helpers/actions'
import assertions from '../../../helpers/assertions'
// import assertions from '../../../helpers/assertions'
import { warmup } from '../../../helpers/warmup'
import popUpModalPage from '../../../pages/popUpModal.page'
import bottomTabsPage from '../../../pages/bottomTabs.page'
Expand All @@ -14,10 +13,14 @@ import connectToSitePage from '../../../pages/connectToSite.page'
import plusMenuPage from '../../../pages/plusMenu.page'
import portfolioPage from '../../../pages/portfolio.page'
import sendPage from '../../../pages/send.page'
import assertions from '../../../helpers/assertions'

describe('Dapp - Core Playground', () => {
beforeAll(async () => {
await warmup()
})

it('should connect to Core Playground', async () => {
await browserPage.connectTo(
'https://ava-labs.github.io/extension-avalanche-playground/',
false,
Expand All @@ -29,12 +32,8 @@ describe('Dapp - Core Playground', () => {
await bottomTabsPage.tapPortfolioTab()
})

beforeEach(async () => {
const newInstance = actions.platform() === 'android' ? true : false
await warmup(newInstance)
})

it('should handle eth_sendTransaction', async () => {
await bottomTabsPage.tapBrowserTab()
await browserPage.sendRpcCall('eth_sendTransaction')
await popUpModalPage.verifyApproveTransactionItems()
await popUpModalPage.tapApproveBtn()
Expand Down Expand Up @@ -89,6 +88,7 @@ describe('Dapp - Core Playground', () => {
})

it('should handle wallet_switchEthereumChain', async () => {
await bottomTabsPage.tapBrowserTab()
await browserPage.sendRpcCall('wallet_switchEthereumChain')
await popUpModalPage.verifySwitchToFujiNetworkModal()
await popUpModalPage.tapApproveBtn()
Expand Down

0 comments on commit f5528e1

Please sign in to comment.