diff --git a/packages/core-mobile/e2e/helpers/actions.ts b/packages/core-mobile/e2e/helpers/actions.ts index 4f70301f22..b697780cd0 100644 --- a/packages/core-mobile/e2e/helpers/actions.ts +++ b/packages/core-mobile/e2e/helpers/actions.ts @@ -138,6 +138,14 @@ const waitForElementNoSync = async ( throw new Error('Element not visible within timeout') } +const getRandomEle = (items: any[]): any => { + return items[Math.floor(Math.random() * items.length)] +} + +const getRandomIndex = (itemsLength: number): number => { + return Math.floor(Math.random() * itemsLength) +} + const getElementTextNoSync = async ( item: Detox.NativeMatcher, timeout = 2000, @@ -436,5 +444,7 @@ export default { scrollToBottom, scrollToTop, hasText, - getAmount + getAmount, + getRandomEle, + getRandomIndex } diff --git a/packages/core-mobile/e2e/pages/Stake/stake.page.ts b/packages/core-mobile/e2e/pages/Stake/stake.page.ts index 3bb9c7d366..e516b1c606 100644 --- a/packages/core-mobile/e2e/pages/Stake/stake.page.ts +++ b/packages/core-mobile/e2e/pages/Stake/stake.page.ts @@ -517,6 +517,13 @@ class StakePage { await Actions.tap(this.customRadio) await Actions.tap(commonElsPage.calendarSVG) const datePicker = element(commonElsPage.datePicker) + duration = new Date( + new Date().setFullYear(new Date().getFullYear() + 2) + ).toLocaleDateString('en-US', { + year: 'numeric', + month: 'long', + day: 'numeric' + }) await datePicker.setDatePickerDate(duration, 'MMMM dd, yyyy') if (Actions.platform() === Platform.Android) { await Actions.tap(commonElsPage.okBtn) @@ -539,7 +546,7 @@ class StakePage { this.instantBaseFee, this.customBaseFee ] - const randomIndex = Math.floor(Math.random() * feeOptions.length) + const randomIndex = Actions.getRandomIndex(feeOptions.length) const selectedFeeOption = feeOptions[randomIndex] as Detox.NativeMatcher await Actions.tap(selectedFeeOption) diff --git a/packages/core-mobile/e2e/pages/popUpModal.page.ts b/packages/core-mobile/e2e/pages/popUpModal.page.ts index a7792a7194..4ea73d6085 100644 --- a/packages/core-mobile/e2e/pages/popUpModal.page.ts +++ b/packages/core-mobile/e2e/pages/popUpModal.page.ts @@ -107,6 +107,7 @@ class PopUpModalPage { } async tapApproveBtn() { + await actions.waitForElement(this.popUpModalScrollView, 10000) await actions.tapElementAtIndex(this.approveBtn, 0) } diff --git a/packages/core-mobile/e2e/tests/plusIcon/walletConnect/dappIntegrationsRPCPlayground.e2e.ts b/packages/core-mobile/e2e/tests/plusIcon/walletConnect/dappIntegrationsRPCPlayground.e2e.ts index 6c1320438d..443cebb7e2 100644 --- a/packages/core-mobile/e2e/tests/plusIcon/walletConnect/dappIntegrationsRPCPlayground.e2e.ts +++ b/packages/core-mobile/e2e/tests/plusIcon/walletConnect/dappIntegrationsRPCPlayground.e2e.ts @@ -35,7 +35,6 @@ describe('Dapp - Core Playground', () => { it('should handle eth_sendTransaction', async () => { await bottomTabsPage.tapBrowserTab() await browserPage.sendRpcCall('eth_sendTransaction') - await popUpModalPage.verifyApproveTransactionItems() await popUpModalPage.tapApproveBtn() await sendPage.verifySuccessToast() }) diff --git a/packages/core-mobile/e2e/tests/portfolioTab/subTabs.e2e.ts b/packages/core-mobile/e2e/tests/portfolioTab/subTabs.e2e.ts index 7924c4b532..e7beb6336f 100644 --- a/packages/core-mobile/e2e/tests/portfolioTab/subTabs.e2e.ts +++ b/packages/core-mobile/e2e/tests/portfolioTab/subTabs.e2e.ts @@ -34,7 +34,7 @@ describe('Sub tabs on Portfolio', () => { it('should navigate sub tabs fine', async () => { for (let i = 0; i < 5; i++) { - const randomIndex = Math.floor(Math.random() * subTabs.length) + const randomIndex = Actions.getRandomIndex(subTabs.length) if (subTabs[randomIndex]) { await Actions.tapElementAtIndex(by.text(subTabs[randomIndex]), 0) await portfolioPage.verifySubTab(subTabs[randomIndex]) diff --git a/packages/core-mobile/e2e/tests/stake/stakingTestnet.e2e.ts b/packages/core-mobile/e2e/tests/stake/stakingTestnet.e2e.ts index 0ee8ac6f1d..b1cd767d13 100644 --- a/packages/core-mobile/e2e/tests/stake/stakingTestnet.e2e.ts +++ b/packages/core-mobile/e2e/tests/stake/stakingTestnet.e2e.ts @@ -1,7 +1,4 @@ -import { expect as jestExpect } from 'expect' import Actions from '../../helpers/actions' -import Assert from '../../helpers/assertions' -import AccountManagePage from '../../pages/accountManage.page' import AdvancedPage from '../../pages/burgerMenu/advanced.page' import BottomTabsPage from '../../pages/bottomTabs.page' import { warmup } from '../../helpers/warmup' @@ -18,47 +15,20 @@ describe('Stake on Testnet', () => { afterAll(async () => { await cleanup() }) + const duration = Actions.getRandomEle([ + '1 Day', + '1 Month', + '3 Months', + '6 Months', + '1 Year', + 'Custom' + ]) - it('should stake one day', async () => { + it(`should stake with random ${duration} duration`, async () => { + const isCustom = duration === 'Custom' ? true : false + console.log('duration: ', duration) await BottomTabsPage.tapStakeTab() - await StakePage.stake('1', '1 Day') - await StakePage.verifyStakeSuccessToast() - }) - - it('should stake one month', async () => { - await BottomTabsPage.tapStakeTab() - await StakePage.stake('1', '1 Month') - await StakePage.verifyStakeSuccessToast() - }) - - it('should stake three months', async () => { - await BottomTabsPage.tapStakeTab() - await StakePage.stake('1', '3 Months') - await StakePage.verifyStakeSuccessToast() - }) - - it('should stake six months', async () => { - await BottomTabsPage.tapStakeTab() - await StakePage.stake('1', '6 Months') - await StakePage.verifyStakeSuccessToast() - }) - - it('should stake one year', async () => { - await BottomTabsPage.tapStakeTab() - await StakePage.stake('1', '1 Year') - await StakePage.verifyStakeSuccessToast() - }) - - it('should stake custom duration', async () => { - await BottomTabsPage.tapStakeTab() - const maximumDuration = new Date( - new Date().setFullYear(new Date().getFullYear() + 2) - ).toLocaleDateString('en-US', { - year: 'numeric', - month: 'long', - day: 'numeric' - }) - await StakePage.stake('1', maximumDuration, true) + await StakePage.stake('1', duration, isCustom) await StakePage.verifyStakeSuccessToast() }) @@ -70,19 +40,7 @@ describe('Stake on Testnet', () => { await Actions.tap(StakePage.stakeClaimButton) await ClaimPage.verifyClaimRewardsScreenItems(claimableBalance) await ClaimPage.tapClaimNowButton() - await Actions.waitForElement(StakePage.stakePrimaryButton, 25000, 0) - await Assert.isVisible(StakePage.stakePrimaryButton) - if (Actions.platform() === 'android') { - const newClaimableBalance = await StakePage.getTopBalance('claimable') - jestExpect(newClaimableBalance).toBe(0) - } + await Actions.waitForElementNotVisible(ClaimPage.claimButton, 10000) } }) - - it('should test a staking flow for a new account on testnet', async () => { - await BottomTabsPage.tapPortfolioTab() - await AccountManagePage.createNthAccountAndSwitchToNth(3) - await BottomTabsPage.tapStakeTab() - await StakePage.verifyNoActiveStakesScreenItems() - }) })