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 - Handle new swap default tokens and small fixes #1996

Merged
merged 3 commits into from
Oct 23, 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
2 changes: 2 additions & 0 deletions packages/core-mobile/app/screens/swap/SwapView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export default function SwapView(): JSX.Element {
<Space y={20} />

<UniversalTokenSelector
testID="from_token_selector"
label={'From'}
hideZeroBalanceTokens
onTokenChange={token => {
Expand Down Expand Up @@ -226,6 +227,7 @@ export default function SwapView(): JSX.Element {
</AvaButton.Base>
<Space y={20} />
<UniversalTokenSelector
testID="to_token_selector"
label={'To'}
onTokenChange={token => {
const tkWithBalance = token as TokenWithBalance
Expand Down
5 changes: 3 additions & 2 deletions packages/core-mobile/e2e/locators/swapTab.loc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export default {
avaxSymbol: 'AVAX',
usdcToken: 'USD Coin',
tokenValueAvax: '0.01',
selectTokenDropdown: 'Select',
amountField: 'universal_token_selector__amount_field',
from: 'From',
reviewOrderBtn: 'review_order_button',
Expand All @@ -13,5 +12,7 @@ export default {
approveBtn: 'approve_button',
rejectBtn: 'reject_button',
tokenSpendApproval: 'Token Spend Approval',
swapTitle: 'Swap'
swapTitle: 'Swap',
fromTokenSelector: 'from_token_selector',
toTokenSelector: 'to_token_selector'
}
8 changes: 4 additions & 4 deletions packages/core-mobile/e2e/pages/createPin.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ class CreatePinPage {
}

async enterNewCurrentPin() {
while (await Action.isVisible(this.numpadOne, 0)) {
while (await Action.isVisible(this.setNewPinHeader, 0)) {
await element(this.numpadOne).multiTap(6)
}
}

async enterCurrentPin() {
while (await Action.isVisible(this.numpadZero, 0)) {
await element(this.numpadZero).multiTap(6)
async enterCurrentPin(pin = '0') {
while (await Action.isVisible(this.enterYourPinHeader, 0)) {
await element(by.id(pin)).multiTap(6)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core-mobile/e2e/pages/send.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class SendPage {
}

async waitForNextBtnEnabled() {
await Actions.waitForElement(this.nextButton, 5000)
await Actions.waitForElementNoSync(this.nextButton, 8000)
}

async tapMyAccounts() {
Expand Down
36 changes: 23 additions & 13 deletions packages/core-mobile/e2e/pages/swapTab.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import sendPage from './send.page'
const platformIndex = Actions.platform() === Platform.Android ? 1 : 0

class SwapTabPage {
get selectTokenDropdown() {
return by.text(swapTab.selectTokenDropdown)
}

get avaxToken() {
return by.text(swapTab.avaxToken)
}
Expand Down Expand Up @@ -63,20 +59,31 @@ class SwapTabPage {
return by.text(swapTab.swapTitle)
}

get fromTokenSelector() {
return by.id(swapTab.fromTokenSelector)
}

get toTokenSelector() {
return by.id(swapTab.toTokenSelector)
}

async tapAvaxToken() {
return Actions.tapElementAtIndex(this.avaxToken, 0)
}

async tapUsdcToken() {
return Actions.tapElementAtIndex(this.usdcToken, 0)
}
async tapFromTokenSelector() {
await Actions.tapElementAtIndex(this.fromTokenSelector, 0)
}

async tapSelectTokenDropdown() {
await Actions.tapElementAtIndex(this.selectTokenDropdown, 0)
async tapToTokenSelector() {
await Actions.tapElementAtIndex(this.toTokenSelector, 0)
}

async tapReviewOrderButton(index = 0) {
await Actions.waitForElementNoSync(this.reviewOrderBtn, 8000)
await Actions.waitForElementNoSync(this.reviewOrderBtn, 15000)
await Actions.tapElementAtIndex(this.reviewOrderBtn, index)
}

Expand Down Expand Up @@ -116,14 +123,18 @@ class SwapTabPage {
async swap(from: string, to: string, amount = '0.00001') {
await bottomTabsPage.tapPlusIcon()
await plusMenuPage.tapSwapButton()
await this.tapSelectTokenDropdown()
await sendPage.selectToken(from)
if (from !== 'AVAX') {
await this.tapFromTokenSelector()
await sendPage.selectToken(from)
}
if (to !== 'USDC') {
await this.tapToTokenSelector()
await sendPage.selectToken(to)
}
await this.inputTokenAmount(amount)
await this.tapSelectTokenDropdown()
await sendPage.selectToken(to)
await this.tapReviewOrderButton()
try {
await Actions.waitForElement(this.tokenSpendApproval, 5000)
await Actions.waitForElementNoSync(this.tokenSpendApproval, 8000)
await this.tapApproveButton()
} catch (e) {
console.error('Token spend approval not found')
Expand All @@ -134,7 +145,6 @@ class SwapTabPage {

async verifySwapScreen() {
await Actions.waitForElement(this.swapTitle)
await Actions.waitForElement(this.selectTokenDropdown)
await Actions.waitForElement(this.disabledReviewOrderBtn)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Change Pin', () => {
it('Should set previous Pin', async () => {
await Actions.waitForElement(SecurityAndPrivacyPage.changePin)
await SecurityAndPrivacyPage.tapChangePin()
await CreatePinPage.enterNewCurrentPin()
await CreatePinPage.enterCurrentPin('1')
await CreatePinPage.createPin()
})
})
Loading