Skip to content

Commit

Permalink
chore(e2e): cleanup (#6503)
Browse files Browse the repository at this point in the history
### Description

- Remove unused util functions
- Remove unused dev dependency
[`pixelmatch`](https://www.npmjs.com/package/pixelmatch)
- Move navigation utils from `e2e/src/utils/utils.js` to
`e2e/src/utils/navigation.js`
- Remove old todo test specs.

### Test plan

- [x] Tested locally on iOS
- [x] Tested locally on Android
- [x] Tested in CI

### Related issues

- N/A

### Backwards compatibility

Yes

### Network scalability

N/A
  • Loading branch information
MuckT authored Feb 25, 2025
1 parent b40d536 commit fcd01e4
Show file tree
Hide file tree
Showing 18 changed files with 106 additions and 269 deletions.
2 changes: 1 addition & 1 deletion e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ yarn e2e:test:android-release sample-suite.spec.js -t "Test Name" -r

```JavaScript
// Sample <TestSuiteName>.spec.js setup
import { quickOnboarding, getDeviceModel } from './utils/utils'
import { quickOnboarding } from './utils/utils'
import { reloadReactNative } from '../utils/retries'

import AddedUsecase from './usecases/AddedUsecase'
Expand Down
4 changes: 0 additions & 4 deletions e2e/src/CeloPage.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import CeloEducation from './usecases/CeloEducation'
import CeloNews from './usecases/CeloNews'
import PriceChart from './usecases/PriceChart'
import { quickOnboarding } from './utils/utils'

describe('Celo page', () => {
Expand All @@ -9,6 +7,4 @@ describe('Celo page', () => {
})

describe('celo education', CeloEducation)
describe('price chart', PriceChart)
describe('celo news', CeloNews)
})
2 changes: 0 additions & 2 deletions e2e/src/QRScanner.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,5 @@ describe('Given QR Scanner', () => {
await element(by.text('Done')).tap() // dismiss the keyboard to reveal the proceed button
await expect(element(by.id('SendEnterAmount/ReviewButton'))).toBeVisible()
})

it.todo('Then should be able to wc QR')
})
})
6 changes: 3 additions & 3 deletions e2e/src/WalletConnect.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import WalletConnectV2 from './usecases/WalletConnectV2'
import WalletConnect from './usecases/WalletConnect'
import { quickOnboarding } from './utils/utils'

describe('Given Wallet Connect', () => {
describe('Given Dapp Connection', () => {
beforeAll(async () => {
await quickOnboarding()
})

describe('When V2', WalletConnectV2)
describe('When WalletConnect', WalletConnect)
})
5 changes: 0 additions & 5 deletions e2e/src/usecases/CeloNews.js

This file was deleted.

17 changes: 10 additions & 7 deletions e2e/src/usecases/NewAccountOnboarding.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { sleep } from '../../../src/utils/sleep'
import { launchApp } from '../utils/retries'
import {
completeProtectWalletScreen,
enterPinUi,
navigateToSecurity,
quickOnboarding,
waitForElementById,
} from '../utils/utils'
import { navigateToSecurity } from '../utils/navigation'
import { enterPinUi, quickOnboarding, waitForElementById } from '../utils/utils'

import jestExpect from 'expect'

Expand All @@ -31,6 +26,14 @@ const arriveAtHomeScreen = async () => {
await waitForElementById('HomeAction-Send')
}

const completeProtectWalletScreen = async () => {
await expect(element(by.id('recoveryPhraseCard'))).toBeVisible()
await element(by.id('recoveryPhraseCard')).tap()
await enterPinUi()
await expect(element(by.id('protectWalletBottomSheetContinue'))).toBeVisible()
await element(by.id('protectWalletBottomSheetContinue')).tap()
}

export default NewAccountOnboarding = () => {
let testRecoveryPhrase, testAccountAddress
beforeAll(async () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/src/usecases/OnRamps.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { sleep } from '../../../src/utils/sleep'
import { launchApp } from '../utils/retries'
import { isElementVisible, waitForElementById, waitForElementByText } from '../utils/utils'
import { isElementVisible, waitForElementById } from '../utils/utils'

async function multiTap(testID, { numberOfTaps = 2 } = {}) {
try {
Expand Down Expand Up @@ -40,7 +40,7 @@ export default onRamps = () => {
await waitForElementById('FiatExchangeInput')
await element(by.id('FiatExchangeInput')).replaceText(`${amount}`)
await waitForElementById('FiatExchangeNextButton', { tap: true })
await waitForElementByText({ text: 'Select Payment Method' })
await waitFor(element(by.text('Select Payment Method'))).toBeVisible()
// Check IF Single Card Provider
if (await isElementVisible('Card/singleProvider')) {
await expect(element(by.id('Card/provider-0'))).toExist()
Expand Down
3 changes: 2 additions & 1 deletion e2e/src/usecases/PINChange.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { sleep } from '../../../src/utils/sleep'
import { ALTERNATIVE_PIN, DEFAULT_PIN } from '../utils/consts'
import { reloadReactNative } from '../utils/retries'
import { enterPinUi, navigateToSecurity, waitForElementById } from '../utils/utils'
import { enterPinUi, waitForElementById } from '../utils/utils'
import { navigateToSecurity } from '../utils/navigation'

export default ChangePIN = () => {
it('Then should be retain changed PIN', async () => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/src/usecases/PINRequire.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { reloadReactNative } from '../utils/retries'
import { navigateToSecurity } from '../utils/utils'
import { navigateToSecurity } from '../utils/navigation'

export default RequirePIN = () => {
it('Then should be require PIN on app open', async () => {
Expand Down
4 changes: 0 additions & 4 deletions e2e/src/usecases/PriceChart.js

This file was deleted.

3 changes: 2 additions & 1 deletion e2e/src/usecases/ResetAccount.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { E2E_WALLET_MNEMONIC } from 'react-native-dotenv'
import { reloadReactNative } from '../utils/retries'
import { enterPinUiIfNecessary, navigateToSecurity, waitForElementById } from '../utils/utils'
import { enterPinUiIfNecessary, waitForElementById } from '../utils/utils'
import { navigateToSecurity } from '../utils/navigation'

export default ResetAccount = () => {
beforeEach(async () => {
Expand Down
45 changes: 44 additions & 1 deletion e2e/src/usecases/SecureSend.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { E2E_WALLET_PRIVATE_KEY, E2E_WALLET_SINGLE_VERIFIED_MNEMONIC } from 'react-native-dotenv'
import { createWalletClient, encodeFunctionData, erc20Abi, http, publicActions } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { celo } from 'viem/chains'
import {
WALLET_MULTIPLE_VERIFIED_ADDRESS,
WALLET_MULTIPLE_VERIFIED_PHONE_NUMBER,
Expand All @@ -7,7 +10,6 @@ import {
import { launchApp } from '../utils/retries'
import {
enterPinUiIfNecessary,
fundWallet,
quickOnboarding,
scrollIntoView,
waitForElementById,
Expand All @@ -16,6 +18,47 @@ import {
const AMOUNT_TO_SEND = '0.01'
const WALLET_FUNDING_MULTIPLIER = 2.2

/**
* Fund a wallet, using some existing wallet.
*
* @param senderPrivateKey: private key for wallet with funds
* @param recipientAddress: wallet to receive funds
* @param stableToken: recognised token symbol (e.g. 'cUSD')
* @param amountEther: amount in "ethers" (as opposed to wei)
*/
const fundWallet = async (senderPrivateKey, recipientAddress, stableToken, amountEther) => {
const stableTokenSymbolToAddress = {
cUSD: '0x765de816845861e75a25fca122bb6898b8b1282a',
}
const tokenAddress = stableTokenSymbolToAddress[stableToken]
if (!tokenAddress) {
throw new Error(`Unsupported token symbol passed to fundWallet: ${stableToken}`)
}

const account = privateKeyToAccount(senderPrivateKey)
const senderAddress = account.address
console.log(`Sending ${amountEther} ${stableToken} from ${senderAddress} to ${recipientAddress}`)
const client = createWalletClient({
account,
chain: celo,
transport: http(),
}).extend(publicActions)

const fundingAmount = BigInt(amountEther * 10 ** 18)
const hash = await client.sendTransaction({
to: tokenAddress,
from: senderAddress,
data: encodeFunctionData({
abi: erc20Abi,
functionName: 'transfer',
args: [recipientAddress, fundingAmount],
}),
})
const receipt = await client.waitForTransactionReceipt({ hash })

console.log('Funding TX receipt', receipt)
}

export default SecureSend = () => {
describe('Secure send flow with phone number lookup', () => {
beforeAll(async () => {
Expand Down
8 changes: 2 additions & 6 deletions e2e/src/usecases/Settings.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { sleep } from '../../../src/utils/sleep'
import { dismissBanners } from '../utils/banners'
import { navigateToPreferences, navigateToProfile } from '../utils/navigation'
import { reloadReactNative } from '../utils/retries'
import {
navigateToPreferences,
navigateToProfile,
scrollIntoView,
waitForElementById,
} from '../utils/utils'
import { scrollIntoView, waitForElementById } from '../utils/utils'

const faker = require('@faker-js/faker')

Expand Down
File renamed without changes.
28 changes: 28 additions & 0 deletions e2e/src/utils/navigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { waitForElementById } from './utils'

export async function navigateToSecurity() {
await waitForElementById('WalletHome/SettingsGearButton', {
tap: true,
})
await waitForElementById('SettingsMenu/Security', {
tap: true,
})
}

export async function navigateToProfile() {
await waitForElementById('WalletHome/SettingsGearButton', {
tap: true,
})
await waitForElementById('SettingsMenu/Profile', {
tap: true,
})
}

export async function navigateToPreferences() {
await waitForElementById('WalletHome/SettingsGearButton', {
tap: true,
})
await waitForElementById('SettingsMenu/Preferences', {
tap: true,
})
}
Loading

0 comments on commit fcd01e4

Please # to comment.