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

feat(ci): Setup CI, get e2e tests working #1

Merged
merged 18 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 16 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
5 changes: 4 additions & 1 deletion .github/workflows/e2e-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on:
- nscloud-ubuntu-22.04-amd64-16x64-with-cache
- nscloud-cache-size-20gb
- nscloud-cache-tag-wallet-e2e-android
- nscloud-cache-tag-ms-runtime-e2e-android
# We pay by the minute.
# If it takes longer it usually fails, so no need to pay for more
timeout-minutes: 25
Expand Down Expand Up @@ -50,6 +50,9 @@ jobs:
yes | sdkmanager "platform-tools" "platforms;android-33"
set -o pipefail

# Install Ninja
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I'm not certain why this is required here -- my best guess is that it's something to do with the cache volume, and this dependency somehow already being available in $PATH on the existing volume we use in the wallet. Since we're using a new volume for this repo, if this dep isn't installed during the setup process already, we wouldn't have it available.

Anyway, Detox was failing without it, so I added this here.

sudo apt-get install ninja-build

# Allow the emulator to use /dev/kvm
sudo adduser $USER kvm
sudo chown $USER /dev/kvm
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/e2e-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
with:
android-api-level: 30
secrets: inherit
ios:
name: iOS
uses: ./.github/workflows/e2e-ios.yml
with:
ios-version: '15.0'
secrets: inherit
# ios:
# name: iOS
# uses: ./.github/workflows/e2e-ios.yml
# with:
# ios-version: '15.0'
# secrets: inherit
jophish marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 1 addition & 5 deletions e2e/scripts/check-e2e-wallet-balance.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { E2E_TEST_WALLET, E2E_TEST_WALLET_SECURE_SEND } from './consts'
import { E2E_TEST_WALLET } from './consts'
import { checkBalance, getCeloTokensBalance } from './utils'
;(async () => {
console.log(`E2E_TEST_WALLET: ${E2E_TEST_WALLET}`)
console.table(await getCeloTokensBalance(E2E_TEST_WALLET))
await checkBalance(E2E_TEST_WALLET)

console.log(`E2E_TEST_WALLET_SECURE_SEND: ${E2E_TEST_WALLET_SECURE_SEND}`)
console.table(await getCeloTokensBalance(E2E_TEST_WALLET_SECURE_SEND))
await checkBalance(E2E_TEST_WALLET_SECURE_SEND)
})()
4 changes: 2 additions & 2 deletions e2e/scripts/consts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const E2E_TEST_WALLET = '0x6131a6d616a4be3737b38988847270a64bc10caa'
export const E2E_TEST_WALLET_SECURE_SEND = '0x86b8f44386cb2d457db79c3dab8cf42f9d8a3fc0'
export const E2E_TEST_WALLET = '0x3f4f42aC3a5A3c54454F9d00C27bCAFA78Cc6856'
export const E2E_TEST_WALLET_SECURE_SEND = '0x4971094C1cB186b5589E5709c83D28c264865925'
export const E2E_TEST_FAUCET = '0xe5F5363e31351C38ac82DBAdeaD91Fd5a7B08846'
export const REFILL_TOKENS = ['CELO', 'cUSD', 'cEUR']
12 changes: 2 additions & 10 deletions e2e/scripts/fund-e2e-accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import dotenv from 'dotenv'
// Would be nice to use viem, but mento is using ethers
import { Contract, providers, utils, Wallet } from 'ethers'
import { Address } from 'viem'
import {
E2E_TEST_FAUCET,
E2E_TEST_WALLET,
E2E_TEST_WALLET_SECURE_SEND,
REFILL_TOKENS,
} from './consts'
import { E2E_TEST_FAUCET, E2E_TEST_WALLET, REFILL_TOKENS } from './consts'
import { checkBalance, getCeloTokensBalance } from './utils'

const provider = new providers.JsonRpcProvider('https://alfajores-forno.celo-testnet.org')
Expand Down Expand Up @@ -45,7 +40,7 @@ const TOKENS_BY_SYMBOL: Record<string, Token> = {
}

;(async () => {
const walletsToBeFunded: Address[] = [E2E_TEST_WALLET, E2E_TEST_WALLET_SECURE_SEND]
const walletsToBeFunded: Address[] = [E2E_TEST_WALLET]
jophish marked this conversation as resolved.
Show resolved Hide resolved
const walletBalances = await Promise.all(walletsToBeFunded.map(getCeloTokensBalance))
for (let i = 0; i < walletsToBeFunded.length; i++) {
console.log(`Initial balance for ${walletsToBeFunded[i]}:`)
Expand Down Expand Up @@ -234,11 +229,8 @@ const TOKENS_BY_SYMBOL: Record<string, Token> = {
// Log Balances
console.log('E2E Test Account:', E2E_TEST_WALLET)
console.table(await getCeloTokensBalance(E2E_TEST_WALLET))
console.log('E2E Test Account Secure Send:', E2E_TEST_WALLET_SECURE_SEND)
console.table(await getCeloTokensBalance(E2E_TEST_WALLET_SECURE_SEND))
jophish marked this conversation as resolved.
Show resolved Hide resolved
console.log('Valora Test Faucet:', E2E_TEST_FAUCET)
console.table(await getCeloTokensBalance(E2E_TEST_FAUCET))

await checkBalance(E2E_TEST_WALLET)
await checkBalance(E2E_TEST_WALLET_SECURE_SEND)
})()
4 changes: 3 additions & 1 deletion e2e/src/HomeFeed.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ describe('Home Feed', () => {
await expect(element(by.text(`$${amount}`)).atIndex(0)).toBeVisible()
})

it('should load more items on scroll', async () => {
// TODO(mobilestack): Un-skip once more items are in the feed. Currently
// there's not really a backlog so this will fail.
it.skip('should load more items on scroll', async () => {
// Tap back button if present form previous test
try {
await element(by.id('BackChevron')).tap()
Expand Down
3 changes: 2 additions & 1 deletion e2e/src/usecases/NewAccountPhoneVerification.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ export default NewAccountPhoneVerification = () => {
}

// Assert correct content is visible on the phone verification screen
it('Then should have correct phone verification screen', async () => {
// TODO(mobilestack): Un-skip if CPV is enabled
it.skip('Then should have correct phone verification screen', async () => {
await expect(element(by.id('PhoneVerificationHeader'))).toBeVisible()
let skipAttributes = await element(by.text('Skip')).getAttributes()
jestExpect(skipAttributes.enabled).toBe(true)
Expand Down
3 changes: 2 additions & 1 deletion e2e/src/usecases/SecureSend.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const AMOUNT_TO_SEND = '0.01'
const WALLET_FUNDING_MULTIPLIER = 2.2

export default SecureSend = () => {
describe('Secure send flow with phone number lookup', () => {
// TODO(mobilestack): Un-skip this if we ever support CPV
describe.skip('Secure send flow with phone number lookup', () => {
beforeAll(async () => {
// uninstall the app to remove secure send mapping
await device.uninstallApp()
Expand Down
20 changes: 12 additions & 8 deletions e2e/src/usecases/Send.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ export default Send = () => {
})
})

// TODO(mobilestack): Un-skip these if we ever support CPV.
// This is the ONLY place in tests where the centrally verified e2e account
// is used, so enabling these also means we'll need to add this account (SAMPLE_BACKUP_KEY_VERIFIED)
// back into the funding scripts.
describe('When multi-token send flow to phone number with one address', () => {
beforeAll(async () => {
await device.uninstallApp()
Expand All @@ -141,12 +145,12 @@ export default Send = () => {
await quickOnboarding({ mnemonic: SAMPLE_BACKUP_KEY_VERIFIED })
})

it('Then should navigate to send search input from home action', async () => {
it.skip('Then should navigate to send search input from home action', async () => {
await waitForElementByIdAndTap('HomeAction-Send', 30_000)
await waitForElementId('SendSelectRecipientSearchInput', 10_000)
})

it('Then should be able to enter a phone number', async () => {
it.skip('Then should be able to enter a phone number', async () => {
await waitForElementByIdAndTap('SendSelectRecipientSearchInput', 30_000)
await element(by.id('SendSelectRecipientSearchInput')).typeText(
SINGLE_ADDRESS_VERIFIED_PHONE_NUMBER
Expand All @@ -155,35 +159,35 @@ export default Send = () => {
await isElementVisible('RecipientItem', 0)
})

it('Then tapping a recipient should show send button', async () => {
it.skip('Then tapping a recipient should show send button', async () => {
await element(by.id('RecipientItem')).atIndex(0).tap()
await waitForElementId('SendOrInviteButton', 30_000)
})

it('Then tapping send button should navigate to Send Enter Amount screen', async () => {
it.skip('Then tapping send button should navigate to Send Enter Amount screen', async () => {
await element(by.id('SendOrInviteButton')).tap()
await waitForElementId('SendEnterAmount/TokenAmountInput', 30_000)
})

it('Then should be able to select token', async () => {
it.skip('Then should be able to select token', async () => {
await element(by.id('SendEnterAmount/TokenSelect')).tap()
await element(by.id('cUSDSymbol')).tap()
await expect(element(by.text('cUSD')).atIndex(0)).toBeVisible()
})

it('Then should be able to enter amount and navigate to review screen', async () => {
it.skip('Then should be able to enter amount and navigate to review screen', async () => {
await waitForElementByIdAndTap('SendEnterAmount/TokenAmountInput', 30_000)
await element(by.id('SendEnterAmount/TokenAmountInput')).replaceText('0.01')
await element(by.id('SendEnterAmount/TokenAmountInput')).tapReturnKey()
await waitForElementByIdAndTap('SendEnterAmount/ReviewButton', 30_000)
await isElementVisible('ConfirmButton')
})

it('Then should display correct recipient', async () => {
it.skip('Then should display correct recipient', async () => {
await expect(element(by.text(SINGLE_ADDRESS_VERIFIED_PHONE_NUMBER_DISPLAY))).toBeVisible()
})

it('Then should be able to send', async () => {
it.skip('Then should be able to send', async () => {
await element(by.id('ConfirmButton')).tap()
await enterPinUiIfNecessary()
await expect(element(by.text('Transaction failed, please retry'))).not.toBeVisible()
Expand Down
3 changes: 2 additions & 1 deletion e2e/src/usecases/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export default Settings = () => {
await sleep(3000)
})

it('Edit Profile Name', async () => {
// mobilestack: no profile support
it.skip('Edit Profile Name', async () => {
let randomName = faker.lorem.words()
await navigateToProfile()
await element(by.id('ProfileSubmenu/EditProfile')).tap()
Expand Down
2 changes: 1 addition & 1 deletion e2e/src/usecases/WalletConnectV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import jestExpect from 'expect'

const dappName = 'WalletConnectV2 E2E'
const walletAddress = (
process.env.E2E_WALLET_ADDRESS || '0x6131a6d616a4be3737b38988847270a64bc10caa'
process.env.E2E_WALLET_ADDRESS || '0x3f4f42aC3a5A3c54454F9d00C27bCAFA78Cc6856'
).toLowerCase()

const client = createPublicClient({
Expand Down
10 changes: 5 additions & 5 deletions e2e/src/utils/consts.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export const DEFAULT_RECIPIENT_ADDRESS = '0xe5F5363e31351C38ac82DBAdeaD91Fd5a7B08846'
export const SAMPLE_BACKUP_KEY =
'general debate dial flock want basket local machine effort monitor stomach purity attend brand extend salon obscure soul open floor useful like cause exhaust'
'industry almost clinic kitchen garage vibrant episode credit solution blanket repair whisper height autumn elevator abstract viable gate girl sadness price process hard ready'
export const SAMPLE_PRIVATE_KEY = // corresponds to backup key above
'0x34c78f42ec153668070bd55c0d237adcdfee0359f1ea473b8e16c8d5f99be14a'
export const SAMPLE_WALLET_ADDRESS = '0x6131a6d616a4be3737b38988847270a64bc10caa' // corresponds to the backup key above
'0x81f25dc705a953868e172e155ef02ecdf4e0b950af91918d0dd13fb5f586945c'
export const SAMPLE_WALLET_ADDRESS = '0x3f4f42ac3a5a3c54454f9d00c27bcafa78cc6856' // corresponds to the backup key above
export const SAMPLE_BACKUP_KEY_VERIFIED =
'embody siege middle glory soda solar nasty report swap now never any'
export const SAMPLE_WALLET_ADDRESS_VERIFIED = '0x86b8f44386cb2d457db79c3dab8cf42f9d8a3fc0' // corresponds to the backup key above
'call broccoli practice engage private amused seek sure barely horn oyster try farm nest victory cloth pilot sense return glad wrist toilet device upset'
export const SAMPLE_WALLET_ADDRESS_VERIFIED = '0x4971094C1cB186b5589E5709c83D28c264865925' // corresponds to the backup key above
export const SAMPLE_BACKUP_KEY_VERIFIED_2 =
'bench album relax truth pond orchard diet unaware cloud tackle twin tongue'
export const SAMPLE_WALLET_ADDRESS_VERIFIED_2 = '0x5fe1407f47b1310ff232a8d368b36099eff61604' // corresponds to the backup key above
Expand Down
2 changes: 1 addition & 1 deletion renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Deps updates will be handled from the wallet repo and synced here
// to avoid conflicts and duplicated PRs
enabled: false,

extends: ['github>valora-inc/renovate-config:default.json5', ':disableDigestUpdates'],

// Restrict semantic commit type to "chore"
Expand Down
Loading