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

chore(tests): E2e html reporter #2585

Merged
merged 2 commits into from
Aug 3, 2023
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,8 @@ coverage/
# .vscode
**/extensions.json

apps/test/
apps/test/

#e2e
artifacts/
html-report/
14 changes: 13 additions & 1 deletion apps/wallet-mobile/e2e/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@ module.exports = {
maxWorkers: 1,
globalSetup: 'detox/runners/jest/globalSetup',
globalTeardown: 'detox/runners/jest/globalTeardown',
reporters: ['detox/runners/jest/reporter'],
reporters: [
"default",
[
"jest-html-reporters",
{
"publicPath": "./html-report",
"filename": "report.html",
"includeConsoleLog": true,
"openReport": true,
"pageTitle": "YOMO e2e Test Results"
}
]
],
testEnvironment: 'detox/runners/jest/testEnvironment',
verbose: true,
};
5 changes: 5 additions & 0 deletions apps/wallet-mobile/e2e/screens/shareUserInsights.screen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {by, element} from 'detox'

export const btn_Skip = () => element(by.label('SKIP'))
Copy link
Collaborator

Choose a reason for hiding this comment

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

could we use camelCase here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MichalSzorad this is a practice I follow to indicate the type of the locator (btn for button, lnk for link etc..). But I have been getting review comments all the time for following the camelCase :) . I will make changes in the next PR. Thanks for your review!

export const btn_Accept = () => element(by.label('ACCEPT'))
export const txt_PageTitle = () => element(by.label('Join the journey to improve Yoroi'))
4 changes: 4 additions & 0 deletions apps/wallet-mobile/e2e/tests/_android/create-wallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('Create a wallet', () => {
});

it('should be able to initiate the "create wallet" process form the home screen', async () => {
await utils.takeScreenshot('Home Screen')
await myWalletsScreen.addWalletTestnetButton().tap()
await myWalletsScreen.createWalletButton().tap()
})
Expand All @@ -28,6 +29,7 @@ describe('Create a wallet', () => {
await waitFor(createWalletFlow.repeatSpendingPasswordInput()).toBeVisible().withTimeout(10000)
await createWalletFlow.repeatSpendingPasswordInput().typeText(`${constants.spending_Password}\n`)
await device.enableSynchronization()
await utils.takeScreenshot('Set the spending password')

await createWalletFlow.credentialsFormContinueButton().tap()
await expect(createWalletFlow.mnemonicExplanationModal()).toBeVisible()
Expand All @@ -36,6 +38,7 @@ describe('Create a wallet', () => {

it('should be able to capture the menmoic displayed and proceed', async() => {
seedPhraseText = await utils.getSeedPhrase()
await utils.takeScreenshot('Seed Phrase')
await createWalletFlow.mnemonicShowScreenConfirmButton().tap()
await expect(createWalletFlow.mnemonicWarningModalCheckbox1()).toBeVisible()
await createWalletFlow.mnemonicWarningModalCheckbox1().tap()
Expand All @@ -47,5 +50,6 @@ describe('Create a wallet', () => {
await utils.repeatSeedPhrase(seedPhraseText)
await createWalletFlow.mnemonicCheckScreenConfirmButton().tap()
await expect(myWalletsScreen.walletByNameButton(constants.wallet_Name)).toBeVisible()
await utils.takeScreenshot(`Wallet "${constants.wallet_Name} is added.`)
});
});
3 changes: 3 additions & 0 deletions apps/wallet-mobile/e2e/tests/_android/restore-wallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ describe('Restore a wallet', () => {
})

it('should be able to initiate the "restore wallet" process from home screen', async () => {
await utils.takeScreenshot('Home Screen')
await myWalletsScreen.addWalletTestnetButton().tap()
await myWalletsScreen.restoreWalletButton().tap()
await restoreWalletFlow.restoreNormalWalletButton().tap()
})

it('should be able to enter the 15-word recovery phrase', async() => {
await utils.enterRecoveryPhrase(constants.normal_15_Word_Wallet.phrase, platform)
await utils.takeScreenshot('Recovery Phrase entered')
await restoreWalletFlow.mnemonicRestoreWalletButton().tap()

await expect(restoreWalletFlow.walletChecksumText()).toBeVisible()
Expand All @@ -41,5 +43,6 @@ describe('Restore a wallet', () => {
await restoreWalletFlow.credentialsContinueButton().tap()
await expect(myWalletsScreen.pageTitle()).toBeVisible()
await expect(myWalletsScreen.walletByNameButton(constants.normal_15_Word_Wallet.name)).toBeVisible()
await utils.takeScreenshot(`Wallet "${constants.wallet_Name} is added.`)
})
})
14 changes: 9 additions & 5 deletions apps/wallet-mobile/e2e/tests/_ios/create-wallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ import { device, expect } from 'detox'
import * as constants from '../../constants'
import * as createWalletFlow from '../../screens/createWalletFlow.screen'
import * as myWalletsScreen from '../../screens/myWallets.screen'
import {getSeedPhrase, prepareApp,repeatSeedPhrase } from '../../utils'
import * as utils from '../../utils'

describe('Create a wallet', () => {
let seedPhraseText: string[]
beforeAll(async () => {
await device.launchApp({ newInstance: true })
await prepareApp(constants.valid_Pin)
await utils.prepareApp(constants.valid_Pin)
});

it('should be able to initiate the "create wallet" process form the home screen', async () => {
await utils.takeScreenshot('Home Screen')
await myWalletsScreen.addWalletTestnetButton().tap()
await myWalletsScreen.createWalletButton().tap()
})
Expand All @@ -25,14 +26,16 @@ describe('Create a wallet', () => {
await waitFor(createWalletFlow.repeatSpendingPasswordInput()).toBeVisible().withTimeout(10000)
await createWalletFlow.repeatSpendingPasswordInput().tap()
await createWalletFlow.repeatSpendingPasswordInput().typeText(constants.spending_Password)
await utils.takeScreenshot('Set the spending password')

await createWalletFlow.credentialsFormContinueButton().tap()
await expect(createWalletFlow.mnemonicExplanationModal()).toBeVisible()
await createWalletFlow.mnemonicExplanationModal().tap()
})

it('should be able to set the spending password', async() => {
seedPhraseText = await getSeedPhrase()
it('should be able to capture the menmoic displayed and proceed', async() => {
seedPhraseText = await utils.getSeedPhrase()
await utils.takeScreenshot('Seed Phrase')
await createWalletFlow.mnemonicShowScreenConfirmButton().tap()
await expect(createWalletFlow.mnemonicWarningModalCheckbox1()).toBeVisible()
await createWalletFlow.mnemonicWarningModalCheckbox1().tap()
Expand All @@ -41,8 +44,9 @@ describe('Create a wallet', () => {
})

it('should be able to enter and verify the stored mnemonic', async() => {
await repeatSeedPhrase(seedPhraseText)
await utils.repeatSeedPhrase(seedPhraseText)
await createWalletFlow.mnemonicCheckScreenConfirmButton().tap()
await expect(myWalletsScreen.walletByNameButton(constants.wallet_Name)).toBeVisible()
await utils.takeScreenshot(`Wallet "${constants.wallet_Name} is added.`)
});
});
3 changes: 3 additions & 0 deletions apps/wallet-mobile/e2e/tests/_ios/restore-wallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ describe('Restore a wallet', () => {
})

it('should be able to initiate the "restore wallet" process from home screen', async () => {
await utils.takeScreenshot('Home Screen')
await myWalletsScreen.addWalletTestnetButton().tap()
await myWalletsScreen.restoreWalletButton().tap()
await restoreWalletFlow.restoreNormalWalletButton().tap()
})

it('should be able to enter the 15-word recovery phrase', async() => {
await utils.enterRecoveryPhrase(constants.normal_15_Word_Wallet.phrase, platform)
await utils.takeScreenshot('Recovery Phrase entered')
await restoreWalletFlow.mnemonicRestoreWalletButton().tap()

await expect(restoreWalletFlow.walletChecksumText()).toBeVisible()
Expand All @@ -42,5 +44,6 @@ describe('Restore a wallet', () => {

await expect(myWalletsScreen.pageTitle()).toBeVisible()
await expect(myWalletsScreen.walletByNameButton(constants.normal_15_Word_Wallet.name)).toBeVisible()
await utils.takeScreenshot(`Wallet "${constants.wallet_Name} is added.`)
})
})
28 changes: 28 additions & 0 deletions apps/wallet-mobile/e2e/utils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { expect } from 'detox'
import fs from 'fs/promises'
import {addAttach, addMsg} from 'jest-html-reporters/helper'
import yargs from 'yargs/yargs'

import { mnemonicBadgeByWord,mnemonicByIndexText } from './screens/createWalletFlow.screen'
import * as myWalletsScreen from './screens/myWallets.screen'
import { pinKeyButton } from './screens/pinCode.screen'
import * as prepareScreens from './screens/prepareApp.screen'
import { mnemonicByIndexInput } from './screens/restoreWalletFlow.screen'
import * as userInsightScreen from './screens/shareUserInsights.screen'

export const enterPIN = async (pin: string): Promise<void> => {
for (const pinNumber of pin) {
Expand Down Expand Up @@ -53,6 +56,9 @@ export const prepareApp = async (pin:string): Promise<void> => {
await expect(pinKeyButton('1')).toBeVisible()
await enterPIN(pin)
await enterPIN(pin)
await expect(userInsightScreen.txt_PageTitle()).toBeVisible()
await takeScreenshot('User consent screen for sharing insights')
await userInsightScreen.btn_Skip().tap()

await expect(myWalletsScreen.pageTitle()).toBeVisible()
}
Expand Down Expand Up @@ -82,4 +88,26 @@ export const disableDeviceSync = async (platform: string) => {
// wrap device.enableSynchronization for android only
export const enableDeviceSync = async (platform: string) => {
platform === 'android' && await device.enableSynchronization()
}

export const takeScreenshot = async (description:string) => {
const tmpPath = await device.takeScreenshot(description)
await addAttach({
attach: await fs.readFile(tmpPath),
description: description,
context: '',
bufferFormat: 'png',
})
}

export const addMsgToReport = async (msg: string) =>{
await addMsg({message: msg, context: null});
}

export const toBase64 = async(fileType: string, filePath: string) =>{
const base64String = await fs.readFile(filePath, {
encoding: 'base64',
})
const withPrefix = `data:image/${fileType};base64,` + base64String;
return withPrefix
}
1 change: 1 addition & 0 deletions apps/wallet-mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@
"i18n-unused": "^0.8.0",
"jest": "^29",
"jest-circus": "^29.5.0",
"jest-html-reporters": "^3.1.4",
"lint-staged": "^13.2.2",
"metro-react-native-babel-preset": "0.73.9",
"node-fetch": "<3",
Expand Down
10 changes: 9 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13626,6 +13626,14 @@ jest-haste-map@^29.6.1:
optionalDependencies:
fsevents "^2.3.2"

jest-html-reporters@^3.1.4:
version "3.1.4"
resolved "https://registry.yarnpkg.com/jest-html-reporters/-/jest-html-reporters-3.1.4.tgz#2ac0cd38540f571032c1d0c6bc100baa85a747cc"
integrity sha512-7lLrKDKDNBNDprd5lP241HRx2mRXb/XQOuYFxX/MxydgHtYRE/lEtK2+J5XLiNTs9JL/rUjWsWhIBOBs9j3wcg==
dependencies:
fs-extra "^10.0.0"
open "^8.0.3"

jest-leak-detector@^28.1.3:
version "28.1.3"
resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-28.1.3.tgz#a6685d9b074be99e3adee816ce84fd30795e654d"
Expand Down Expand Up @@ -16521,7 +16529,7 @@ open@^7.3.1:
is-docker "^2.0.0"
is-wsl "^2.1.1"

open@^8.0.4, open@^8.3.0:
open@^8.0.3, open@^8.0.4, open@^8.3.0:
version "8.4.2"
resolved "https://registry.yarnpkg.com/open/-/open-8.4.2.tgz#5b5ffe2a8f793dcd2aad73e550cb87b59cb084f9"
integrity sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==
Expand Down