Skip to content

Commit

Permalink
fix automation
Browse files Browse the repository at this point in the history
  • Loading branch information
eunjisong committed Dec 23, 2024
1 parent 9d369d9 commit 9c06270
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 28 deletions.
7 changes: 6 additions & 1 deletion packages/core-mobile/e2e/helpers/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ const setInputText = async (xpath: string, text: string) => {
await wb.element(by.web.xpath(xpath)).replaceText(text)
}

const getTextByXpath = async (xpath: string) => {
return await wb.element(by.web.xpath(xpath)).getText()
}

export default {
tap,
tapByText,
Expand All @@ -214,5 +218,6 @@ export default {
isVisibleByRunScript,
verifyUrl,
setInputText,
isVisibleByXpath
isVisibleByXpath,
getTextByXpath
}
11 changes: 10 additions & 1 deletion packages/core-mobile/e2e/pages/browser.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class BrowserPage {
xpath = '//button[@data-id="UnstyledButton"]//div[text()="Login"]'
break
case 'https://ava-labs.github.io/extension-avalanche-playground/': // Core Playground
xpath = '//button[text()="Connect via Wallet Connect - Wagmi"]'
xpath =
'//button[text()="Connect via Wallet Connect - Universal Provider"]'
break
case 'https://app.uniswap.org/': // UniSwap
xpath = '//button[@data-testid="navbar-connect-wallet"]'
Expand Down Expand Up @@ -158,6 +159,7 @@ class BrowserPage {
if (showModal) {
await this.dismissConnectWalletModal()
}
await delay(1000)
await this.tapConnectWallet(dapp)
if (visibleWalletConnectButton) {
await this.tapWalletConnect()
Expand Down Expand Up @@ -291,6 +293,13 @@ class BrowserPage {
"//button[@data-cy='swap-button' and text()='Swap' and not(@disabled)]"
)
}

async getPlaygroundUri() {
await Wbs.waitForEleByXpathToBeVisible(
"//input[contains(@class, 'ant-input')]"
)
return await Wbs.getTextByXpath("//input[contains(@class, 'ant-input')]")
}
}

export default new BrowserPage()
22 changes: 10 additions & 12 deletions packages/core-mobile/e2e/pages/tokenDetail.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,21 +233,19 @@ class TokenDetailsPage {
}

async isPriceValid(expectedPrice: number, currentPrice: string) {
// Remove non-numeric characters (dollar signs, commas, etc.)
const updatedCurrentPrice = currentPrice.replace(/[^0-9]/g, '')
const updatedCurrentPrice = parseFloat(currentPrice.replace(/[$,]/g, ''))

// If the updated price is empty or '0', return false
if (!updatedCurrentPrice || updatedCurrentPrice === '0') {
// return false if the price UI shows 0
if (updatedCurrentPrice === 0) {
return false
} else {
// Get the first two digits from the cleaned currentPrice
const currentPriceFirstTwoDigits = updatedCurrentPrice.slice(0, 2)

// Get the first two digits from expectedPrice
const expectedPriceFirstTwoDigits = String(expectedPrice).slice(0, 2)

// Compare the first two digits
return currentPriceFirstTwoDigits === expectedPriceFirstTwoDigits
const tolerance = 0.1
const diffPercentage =
Math.abs(expectedPrice - updatedCurrentPrice) / expectedPrice
console.log(`Diff Percentage: ${diffPercentage}`)
console.log(`Price on UI: ${updatedCurrentPrice}`)
console.log(`Price on API: ${expectedPrice}`)
return diffPercentage <= tolerance
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/**
* @jest-environment ./environment.ts
*/
// import assertions from '../../../helpers/assertions'
import { warmup } from '../../../helpers/warmup'
import popUpModalPage from '../../../pages/popUpModal.page'
import bottomTabsPage from '../../../pages/bottomTabs.page'
Expand All @@ -16,21 +15,19 @@ import sendPage from '../../../pages/send.page'
import assertions from '../../../helpers/assertions'

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

it('should connect to Core Playground', async () => {
await browserPage.connectTo(
'https://ava-labs.github.io/extension-avalanche-playground/',
false,
false
)
const qrUri = await browserPage.getQrUri()
const qrUri = await browserPage.getPlaygroundUri()
console.log(qrUri)
await plusMenuPage.connectWallet(qrUri)
await connectToSitePage.selectAccountAndconnect()
await bottomTabsPage.tapPortfolioTab()
}, 60000)
})

it('should handle eth_sendTransaction', async () => {
await bottomTabsPage.tapBrowserTab()
Expand Down
14 changes: 7 additions & 7 deletions packages/core-mobile/e2e/tests/plusIcon/send/send.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ describe('Send AVAX', () => {
await cleanup()
})

it('should send AVAX on C-Chain', async () => {
await sendPage.sendTokenTo2ndAccount(
sendLoc.avaxToken,
sendLoc.sendingAmount
)
await sendPage.verifySuccessToast()
})
// it('should send AVAX on C-Chain', async () => {
// await sendPage.sendTokenTo2ndAccount(
// sendLoc.avaxToken,
// sendLoc.sendingAmount
// )
// await sendPage.verifySuccessToast()
// })

it('should send AVAX on P-Chain', async () => {
await bottomTabsPage.tapPortfolioTab()
Expand Down

0 comments on commit 9c06270

Please sign in to comment.