From ccbc22d35aed43ca107e0966333a5d001c6457a1 Mon Sep 17 00:00:00 2001 From: Arnaud97234 Date: Fri, 3 Aug 2018 10:14:33 +0200 Subject: [PATCH] Update test-e2e --- .circleci/config.yml | 4 +- .../DashboardPage/AccountCard/index.js | 2 +- .../DashboardPage/AccountCardList.js | 1 + .../DashboardPage/AccountCardListHeader.js | 2 +- .../DashboardPage/AccountCardPlaceholder.js | 2 +- .../DashboardPage/CurrentGreetings.js | 2 +- src/components/DashboardPage/SummaryDesc.js | 7 +- .../MainSideBar/AddAccountButton.js | 2 +- src/components/Onboarding/steps/Analytics.js | 14 ++- src/components/OperationsList/index.js | 2 +- src/components/SelectCurrency/index.js | 1 + .../SettingsPage/DisablePasswordModal.js | 4 +- src/components/SettingsPage/PasswordButton.js | 6 +- src/components/SettingsPage/PasswordForm.js | 2 + src/components/SettingsPage/PasswordModal.js | 20 ++- .../SettingsPage/SentryLogsButton.js | 2 +- .../SettingsPage/SettingsSection.js | 2 +- .../SettingsPage/ShareAnalyticsButton.js | 6 +- src/components/TopBar/ActivityIndicator.js | 1 + src/components/base/InputCurrency/index.js | 1 + src/components/base/Modal/ModalTitle.js | 2 +- src/components/modals/Disclaimer.js | 2 +- src/components/modals/ShareAnalytics.js | 6 +- src/components/modals/TechnicalData.js | 4 +- test-e2e/helpers/test_helpers.js | 40 ++++++ test-e2e/nav_to_settings.spec.js | 64 ---------- ...kipOnboarding_GeneralSettingsCheck.spec.js | 119 ++++++++++++++++++ 27 files changed, 230 insertions(+), 90 deletions(-) create mode 100644 test-e2e/helpers/test_helpers.js delete mode 100644 test-e2e/nav_to_settings.spec.js create mode 100644 test-e2e/skipOnboarding_GeneralSettingsCheck.spec.js diff --git a/.circleci/config.yml b/.circleci/config.yml index 97af1a3b..1390a86a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,10 +13,10 @@ jobs: - checkout - restore_cache: keys: - - v8-yarn-packages-{{ checksum "yarn.lock" }} + - v10-yarn-packages-{{ checksum "yarn.lock" }} - run: yarn install - save_cache: - key: v8-yarn-packages-{{ checksum "yarn.lock" }} + key: v10-yarn-packages-{{ checksum "yarn.lock" }} paths: - node_modules - run: yarn lint diff --git a/src/components/DashboardPage/AccountCard/index.js b/src/components/DashboardPage/AccountCard/index.js index 25dc16d4..d60be8de 100644 --- a/src/components/DashboardPage/AccountCard/index.js +++ b/src/components/DashboardPage/AccountCard/index.js @@ -69,7 +69,7 @@ class AccountCard extends PureComponent<{ render() { const { counterValue, account, onClick, daysCount, ...props } = this.props return ( - + diff --git a/src/components/DashboardPage/AccountCardList.js b/src/components/DashboardPage/AccountCardList.js index eee7321e..aff66fd4 100644 --- a/src/components/DashboardPage/AccountCardList.js +++ b/src/components/DashboardPage/AccountCardList.js @@ -28,6 +28,7 @@ class AccountCardList extends Component { justifyContent="flex-start" alignItems="center" style={{ margin: '0 -16px' }} + data-e2e="dashboard_AccountList" > {accounts .map(account => ({ diff --git a/src/components/DashboardPage/AccountCardListHeader.js b/src/components/DashboardPage/AccountCardListHeader.js index 9da0fde5..336193dd 100644 --- a/src/components/DashboardPage/AccountCardListHeader.js +++ b/src/components/DashboardPage/AccountCardListHeader.js @@ -19,7 +19,7 @@ class AccountCardListHeader extends PureComponent { return ( - + {t('app:dashboard.accounts.title', { count: accountsLength })} diff --git a/src/components/DashboardPage/AccountCardPlaceholder.js b/src/components/DashboardPage/AccountCardPlaceholder.js index 1936fe4d..ee3619e0 100644 --- a/src/components/DashboardPage/AccountCardPlaceholder.js +++ b/src/components/DashboardPage/AccountCardPlaceholder.js @@ -31,7 +31,7 @@ class AccountCardPlaceholder extends PureComponent<{ render() { const { t } = this.props return ( - + diff --git a/src/components/DashboardPage/CurrentGreetings.js b/src/components/DashboardPage/CurrentGreetings.js index da4896b8..d45fb579 100644 --- a/src/components/DashboardPage/CurrentGreetings.js +++ b/src/components/DashboardPage/CurrentGreetings.js @@ -21,7 +21,7 @@ class CurrentGettings extends PureComponent<{ t: T }> { render() { const { t } = this.props return ( - + {t(getCurrentGreetings())} ) diff --git a/src/components/DashboardPage/SummaryDesc.js b/src/components/DashboardPage/SummaryDesc.js index ff8c5f3e..85e46f6b 100644 --- a/src/components/DashboardPage/SummaryDesc.js +++ b/src/components/DashboardPage/SummaryDesc.js @@ -12,7 +12,12 @@ class SummaryDesc extends PureComponent<{ render() { const { totalAccounts, t } = this.props return ( - + {t('app:dashboard.summary', { count: totalAccounts })} ) diff --git a/src/components/MainSideBar/AddAccountButton.js b/src/components/MainSideBar/AddAccountButton.js index 32a61434..fbb908d2 100644 --- a/src/components/MainSideBar/AddAccountButton.js +++ b/src/components/MainSideBar/AddAccountButton.js @@ -33,7 +33,7 @@ export default class AddAccountButton extends PureComponent<{ return ( tooltipText}> - + ) diff --git a/src/components/Onboarding/steps/Analytics.js b/src/components/Onboarding/steps/Analytics.js index 90f09ea1..360ce4ba 100644 --- a/src/components/Onboarding/steps/Analytics.js +++ b/src/components/Onboarding/steps/Analytics.js @@ -76,7 +76,9 @@ class Analytics extends PureComponent { - {t('onboarding:analytics.technicalData.title')} + + {t('onboarding:analytics.technicalData.title')} + { color="smoke" ml={2} onClick={this.handleTechnicalDataModal} + data-e2e="analytics_techData_Link" > {t('app:common.learnMore')} @@ -102,7 +105,9 @@ class Analytics extends PureComponent { - {t('onboarding:analytics.shareAnalytics.title')} + + {t('onboarding:analytics.shareAnalytics.title')} + { color="smoke" ml={2} onClick={this.handleShareAnalyticsModal} + data-e2e="analytics_shareAnalytics_Link" > {t('app:common.learnMore')} @@ -133,7 +139,9 @@ class Analytics extends PureComponent { - {t('onboarding:analytics.sentryLogs.title')} + + {t('onboarding:analytics.sentryLogs.title')} + {t('onboarding:analytics.sentryLogs.desc')} diff --git a/src/components/OperationsList/index.js b/src/components/OperationsList/index.js index 264094ec..bbd250ae 100644 --- a/src/components/OperationsList/index.js +++ b/src/components/OperationsList/index.js @@ -102,7 +102,7 @@ export class OperationsList extends PureComponent { return ( {title && ( - + {title} )} diff --git a/src/components/SelectCurrency/index.js b/src/components/SelectCurrency/index.js index 6c7d9a54..9519144c 100644 --- a/src/components/SelectCurrency/index.js +++ b/src/components/SelectCurrency/index.js @@ -40,6 +40,7 @@ const SelectCurrency = ({ onChange, value, t, placeholder, currencies, ...props renderValue={renderOption} options={options} placeholder={placeholder || t('app:common.selectCurrency')} + data-e2e="test" noOptionsMessage={({ inputValue }: { inputValue: string }) => t('app:common.selectCurrencyNoOption', { currencyName: inputValue }) } diff --git a/src/components/SettingsPage/DisablePasswordModal.js b/src/components/SettingsPage/DisablePasswordModal.js index 17b9a0fa..d44a3584 100644 --- a/src/components/SettingsPage/DisablePasswordModal.js +++ b/src/components/SettingsPage/DisablePasswordModal.js @@ -68,7 +68,9 @@ class DisablePasswordModal extends PureComponent { render={({ onClose }) => (
- {t('app:password.disablePassword.title')} + + {t('app:password.disablePassword.title')} + {t('app:password.disablePassword.desc')} diff --git a/src/components/SettingsPage/PasswordButton.js b/src/components/SettingsPage/PasswordButton.js index 9c6b6b32..fa7fb827 100644 --- a/src/components/SettingsPage/PasswordButton.js +++ b/src/components/SettingsPage/PasswordButton.js @@ -88,7 +88,11 @@ class PasswordButton extends PureComponent { {t('app:settings.profile.changePassword')} )} - + { id="newPassword" onChange={onChange('newPassword')} value={newPassword} + data-e2e="setPassword_NewPassword" /> @@ -73,6 +74,7 @@ class PasswordForm extends PureComponent { onChange={onChange('confirmPassword')} value={confirmPassword} error={!isValid() && confirmPassword.length > 0 && new PasswordsDontMatchError()} + data-e2e="setPassword_ConfirmPassword" /> diff --git a/src/components/modals/TechnicalData.js b/src/components/modals/TechnicalData.js index 7a8eb164..2d55b202 100644 --- a/src/components/modals/TechnicalData.js +++ b/src/components/modals/TechnicalData.js @@ -45,7 +45,7 @@ class TechnicalData extends PureComponent { name={MODAL_TECHNICAL_DATA} render={({ onClose }) => ( - + {t('onboarding:analytics.technicalData.mandatoryContextual.title')} {t('onboarding:analytics.technicalData.desc')} @@ -53,7 +53,7 @@ class TechnicalData extends PureComponent {
    {items.map(item =>
  • {item.desc}
  • )}
- diff --git a/test-e2e/helpers/test_helpers.js b/test-e2e/helpers/test_helpers.js new file mode 100644 index 00000000..defcab86 --- /dev/null +++ b/test-e2e/helpers/test_helpers.js @@ -0,0 +1,40 @@ +import { delay } from 'helpers/promise' + +// Wait for an element to be present then continue +export function waitForExpectedText(app, selector, expected, maxRetry = 5) { + async function check() { + if (!maxRetry) { + throw new Error(`Cant find the element ${selector} in the page`) + } + try { + const str = await app.client.getText(selector) + if (str === expected) { + return true + } + } catch (err) {} // eslint-disable-line + await delay(500) + --maxRetry + return check() + } + return check() +} + +// Wait for an element to disappear then continue +export function waitForDisappear(app, selector, maxRetry = 5) { + async function check() { + if (!maxRetry) { + throw new Error('Too many retries for waiting element to disappear') + } + try { + await app.client.getText(selector) + } catch (err) { + if (err.message.startsWith('An element could not be located')) { + return true + } + } + await delay(500) + --maxRetry + return check() + } + return check() +} diff --git a/test-e2e/nav_to_settings.spec.js b/test-e2e/nav_to_settings.spec.js deleted file mode 100644 index d2516b91..00000000 --- a/test-e2e/nav_to_settings.spec.js +++ /dev/null @@ -1,64 +0,0 @@ -const Application = require('spectron').Application - -let app - -const TIMEOUT = 50 * 1000 - -describe('Application launch', () => { - beforeEach(async () => { - app = new Application({ - path: './dist/ledger-live-desktop-1.1.0-linux-x86_64.AppImage', - env: { - SKIP_ONBOARDING: '1', - }, - }) - await app.start() - }, TIMEOUT) - - afterEach(async () => { - if (app && app.isRunning()) { - await app.stop() - } - }, TIMEOUT) - - test( - 'Start app and set developper mode ', - async () => { - const title = await app.client.getTitle() - expect(title).toEqual('Ledger Live') - await app.client.waitUntilWindowLoaded() - await app.client.pause(2000) - - // Post Onboarding - const title_onboarding = await app.client.getText('[data-e2e=onboarding_title]') - expect(title_onboarding).toEqual('Analytics and bug reports') - await app.client.click('[data-e2e=continue_button]') - await app.client.pause(1000) - - const title_finish = await app.client.getText('[data-e2e=finish_title]') - expect(title_finish).toEqual('Your device is ready!') - await app.client.click('[data-e2e=continue_button]') - await app.client.pause(1000) - - const title_disclaimer = await app.client.getText('[data-e2e=disclaimer_title]') - expect(title_disclaimer).toEqual('Trade safely') - await app.client.click('[data-e2e=continue_button]') - await app.client.pause(1000) - - // Dashboard EmptyState - const title_dashboard_empty = await app.client.getText('[data-e2e=dashboard_empty_title]') - expect(title_dashboard_empty).toEqual('Add accounts to your portfolio') - - // Open Settings - await app.client.click('[data-e2e=setting_button]') - await app.client.pause(1000) - const title_settings = await app.client.getText('[data-e2e=settings_title]') - expect(title_settings).toEqual('Settings') - - // DevMode ON - await app.client.click('[data-e2e=devMode_button]') - await app.client.pause(500) - }, - TIMEOUT, - ) -}) diff --git a/test-e2e/skipOnboarding_GeneralSettingsCheck.spec.js b/test-e2e/skipOnboarding_GeneralSettingsCheck.spec.js new file mode 100644 index 00000000..b55b1657 --- /dev/null +++ b/test-e2e/skipOnboarding_GeneralSettingsCheck.spec.js @@ -0,0 +1,119 @@ +import { Application } from 'spectron' + +import { waitForDisappear, waitForExpectedText } from '../test-e2e/helpers/test_helpers' + +const os = require('os') +const appVersion = require('../package.json') + +let app + +const TIMEOUT = 50 * 1000 + +let app_path +const platform = os.platform() +if (platform === 'darwin') { + app_path = `./dist/mac/Ledger Live.app/Contents/MacOS/Ledger Live` +} else if (platform === 'win32') { + app_path = `./dist\\win-unpacked\\Ledger Live.exe` +} else { + app_path = `./dist/ledger-live-desktop-${appVersion.version}-linux-x86_64.AppImage` +} + +describe('Application launch', () => { + beforeEach(async () => { + app = new Application({ + path: app_path, + env: { + SKIP_ONBOARDING: '1', + }, + }) + await app.start() + }, TIMEOUT) + + afterEach(async () => { + if (app && app.isRunning()) { + await app.stop() + } + }, TIMEOUT) + + test( + 'Start app, skip onboarding, check Empty State, check General Settings and verify Developer mode', + async () => { + const title = await app.client.getTitle() + expect(title).toEqual('Ledger Live') + await app.client.waitUntilWindowLoaded() + await waitForDisappear(app, '#preload') + + // Post Onboarding (Analytics) + const analytics_title = await waitForExpectedText( + app, + '[data-e2e=onboarding_title]', + 'Analytics and bug reports', + ) + // Verify "Technical Data" + Link "Learn more" + const analytics_techData_title = await app.client.getText('[data-e2e=analytics_techData]') + expect(analytics_techData_title).toEqual('Technical data *') + await app.client.click('[data-e2e=analytics_techData_Link]') + await waitForExpectedText(app, '[data-e2e=modal_title]', 'Technical data') + await app.client.click('[data-e2e=modal_buttonClose_techData]') + analytics_title + + // Verify "Share analytics" + Link "Learn more" + const analytics_shareAnalytics_title = await app.client.getText( + '[data-e2e=analytics_shareAnalytics]', + ) + expect(analytics_shareAnalytics_title).toEqual('Share analytics') + await app.client.click('[data-e2e=analytics_shareAnalytics_Link]') + await waitForExpectedText(app, '[data-e2e=modal_title]', 'Share analytics') + await app.client.click('[data-e2e=modal_buttonClose_shareAnalytics]') + analytics_title + + // Verify "Report bugs" + const analytics_reportBugs_title = await app.client.getText('[data-e2e=analytics_reportBugs]') + expect(analytics_reportBugs_title).toEqual('Report bugs') + + await app.client.click('[data-e2e=continue_button]') + + // Finish Onboarding + await waitForExpectedText(app, '[data-e2e=finish_title]', 'Your device is ready!') + await app.client.click('[data-e2e=continue_button]') + + await waitForExpectedText(app, '[data-e2e=modal_title]', 'Trade safely') + await app.client.click('[data-e2e=continue_button]') + + // Dashboard EmptyState + await waitForExpectedText( + app, + '[data-e2e=dashboard_empty_title]', + 'Add accounts to your portfolio', + ) + const openManager_button = await app.client.getText('[data-e2e=dashboard_empty_OpenManager]') + expect(openManager_button).toEqual('Open Manager') + const addAccount_button = await app.client.getText('[data-e2e=dashboard_empty_AddAccounts]') + expect(addAccount_button).toEqual('Add accounts') + + // Open Settings + await app.client.click('[data-e2e=setting_button]') + await waitForExpectedText(app, '[data-e2e=settings_title]', 'Settings') + // Verify settings General section + const settingsGeneral_title = await app.client.getText('[data-e2e=settingsGeneral_title]') + expect(settingsGeneral_title).toEqual('General') + + // TO ADD : VERIFY PASSWORD LOCK VALUE = DISABLE ??? + // Report bugs = OFF + await app.client.click('[data-e2e=reportBugs_button]') + + // Analytics = ON + await app.client.click('[data-e2e=shareAnalytics_button]') + + // DevMode = ON + await app.client.click('[data-e2e=devMode_button]') + + // Verify Dev mode + // Add New Account + await app.client.click('[data-e2e=menuAddAccount_button]') + await waitForExpectedText(app, '[data-e2e=modal_title]', 'Add accounts') + }, + TIMEOUT, + ) +})