Arnaud97234
6 years ago
27 changed files with 230 additions and 90 deletions
@ -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() |
|||
} |
@ -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, |
|||
) |
|||
}) |
@ -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, |
|||
) |
|||
}) |
Loading…
Reference in new issue