From f82d0bd744c290d3f42b7cb858768746f4572109 Mon Sep 17 00:00:00 2001 From: Rahul Date: Thu, 3 Aug 2023 18:01:29 +0530 Subject: [PATCH 1/2] add reporter --- .gitignore | 6 ++++- apps/wallet-mobile/e2e/jest.config.js | 14 ++++++++++- .../e2e/tests/_android/create-wallet.test.ts | 4 ++++ .../e2e/tests/_android/restore-wallet.test.ts | 3 +++ .../e2e/tests/_ios/create-wallet.test.ts | 14 +++++++---- .../e2e/tests/_ios/restore-wallet.test.ts | 3 +++ apps/wallet-mobile/e2e/utils.ts | 24 +++++++++++++++++++ apps/wallet-mobile/package.json | 1 + yarn.lock | 10 +++++++- 9 files changed, 71 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 07ddb82ff7..bf703f91c5 100644 --- a/.gitignore +++ b/.gitignore @@ -81,4 +81,8 @@ coverage/ # .vscode **/extensions.json -apps/test/ \ No newline at end of file +apps/test/ + +#e2e +artifacts/ +html-report/ \ No newline at end of file diff --git a/apps/wallet-mobile/e2e/jest.config.js b/apps/wallet-mobile/e2e/jest.config.js index b0ae98a441..7778244d0f 100644 --- a/apps/wallet-mobile/e2e/jest.config.js +++ b/apps/wallet-mobile/e2e/jest.config.js @@ -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, }; diff --git a/apps/wallet-mobile/e2e/tests/_android/create-wallet.test.ts b/apps/wallet-mobile/e2e/tests/_android/create-wallet.test.ts index fce5f10b5f..81bca245a1 100644 --- a/apps/wallet-mobile/e2e/tests/_android/create-wallet.test.ts +++ b/apps/wallet-mobile/e2e/tests/_android/create-wallet.test.ts @@ -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() }) @@ -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() @@ -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() @@ -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.`) }); }); \ No newline at end of file diff --git a/apps/wallet-mobile/e2e/tests/_android/restore-wallet.test.ts b/apps/wallet-mobile/e2e/tests/_android/restore-wallet.test.ts index e5e56fb6ce..80b1fb9d05 100644 --- a/apps/wallet-mobile/e2e/tests/_android/restore-wallet.test.ts +++ b/apps/wallet-mobile/e2e/tests/_android/restore-wallet.test.ts @@ -17,6 +17,7 @@ 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() @@ -24,6 +25,7 @@ describe('Restore a wallet', () => { 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() @@ -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.`) }) }) \ No newline at end of file diff --git a/apps/wallet-mobile/e2e/tests/_ios/create-wallet.test.ts b/apps/wallet-mobile/e2e/tests/_ios/create-wallet.test.ts index ca8b1997e6..4235c4644e 100644 --- a/apps/wallet-mobile/e2e/tests/_ios/create-wallet.test.ts +++ b/apps/wallet-mobile/e2e/tests/_ios/create-wallet.test.ts @@ -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() }) @@ -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() @@ -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.`) }); }); \ No newline at end of file diff --git a/apps/wallet-mobile/e2e/tests/_ios/restore-wallet.test.ts b/apps/wallet-mobile/e2e/tests/_ios/restore-wallet.test.ts index b9dae6a1a5..72fc9b7d9d 100644 --- a/apps/wallet-mobile/e2e/tests/_ios/restore-wallet.test.ts +++ b/apps/wallet-mobile/e2e/tests/_ios/restore-wallet.test.ts @@ -16,6 +16,7 @@ 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() @@ -23,6 +24,7 @@ describe('Restore a wallet', () => { 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() @@ -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.`) }) }) \ No newline at end of file diff --git a/apps/wallet-mobile/e2e/utils.ts b/apps/wallet-mobile/e2e/utils.ts index 1d3e8d9ee0..0009361025 100644 --- a/apps/wallet-mobile/e2e/utils.ts +++ b/apps/wallet-mobile/e2e/utils.ts @@ -1,4 +1,6 @@ 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' @@ -82,4 +84,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 } \ No newline at end of file diff --git a/apps/wallet-mobile/package.json b/apps/wallet-mobile/package.json index e026e911ed..3bcf44bcb5 100644 --- a/apps/wallet-mobile/package.json +++ b/apps/wallet-mobile/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index 8613396d62..fff3368822 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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== From d7f0b6dff1ea88ff0b550943c55bc4eaf2fd4c13 Mon Sep 17 00:00:00 2001 From: Rahul Date: Thu, 3 Aug 2023 19:01:43 +0530 Subject: [PATCH 2/2] handle insights screen --- apps/wallet-mobile/e2e/screens/shareUserInsights.screen.ts | 5 +++++ apps/wallet-mobile/e2e/utils.ts | 4 ++++ 2 files changed, 9 insertions(+) create mode 100644 apps/wallet-mobile/e2e/screens/shareUserInsights.screen.ts diff --git a/apps/wallet-mobile/e2e/screens/shareUserInsights.screen.ts b/apps/wallet-mobile/e2e/screens/shareUserInsights.screen.ts new file mode 100644 index 0000000000..9c7507c3c0 --- /dev/null +++ b/apps/wallet-mobile/e2e/screens/shareUserInsights.screen.ts @@ -0,0 +1,5 @@ +import {by, element} from 'detox' + +export const btn_Skip = () => element(by.label('SKIP')) +export const btn_Accept = () => element(by.label('ACCEPT')) +export const txt_PageTitle = () => element(by.label('Join the journey to improve Yoroi')) \ No newline at end of file diff --git a/apps/wallet-mobile/e2e/utils.ts b/apps/wallet-mobile/e2e/utils.ts index 0009361025..721a229f61 100644 --- a/apps/wallet-mobile/e2e/utils.ts +++ b/apps/wallet-mobile/e2e/utils.ts @@ -8,6 +8,7 @@ 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 => { for (const pinNumber of pin) { @@ -55,6 +56,9 @@ export const prepareApp = async (pin:string): Promise => { 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() }