2015-12-13 06:11:22 +08:00
|
|
|
import fs from 'fs';
|
|
|
|
import path from 'path';
|
|
|
|
import N1Launcher from './helpers/n1-launcher';
|
|
|
|
import {currentConfig, FAKE_DATA_PATH} from './helpers/config-helper';
|
|
|
|
import {assertBasicWindow, assertNoErrorsInLogs} from './helpers/shared-assertions';
|
|
|
|
import {clickRepeat, wait} from './helpers/client-actions';
|
2015-12-10 23:52:20 +08:00
|
|
|
|
2015-12-13 06:11:22 +08:00
|
|
|
describe('Clean app boot', ()=> {
|
2015-12-10 23:52:20 +08:00
|
|
|
beforeAll((done)=>{
|
|
|
|
// Boot in dev mode with no arguments
|
2015-12-13 06:11:22 +08:00
|
|
|
this.app = new N1Launcher(['--dev'], N1Launcher.CLEAR_CONFIG);
|
2015-12-10 23:52:20 +08:00
|
|
|
this.app.onboardingWindowReady().finally(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll((done)=> {
|
|
|
|
if (this.app && this.app.isRunning()) {
|
|
|
|
this.app.stop().finally(done);
|
|
|
|
} else {
|
2015-12-13 06:11:22 +08:00
|
|
|
done();
|
2015-12-10 23:52:20 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
it("has the autoupdater pointing to the correct url when there's no config loaded", () => {
|
|
|
|
this.app.client.execute(()=>{
|
2016-04-14 06:35:01 +08:00
|
|
|
const app = require('electron').remote.getGlobal('application');
|
2015-12-10 23:52:20 +08:00
|
|
|
return {
|
|
|
|
platform: process.platform,
|
|
|
|
arch: process.arch,
|
2015-12-13 06:11:22 +08:00
|
|
|
feedUrl: app.autoUpdateManager.feedURL,
|
|
|
|
};
|
2015-12-10 23:52:20 +08:00
|
|
|
}).then(({value})=>{
|
2015-12-13 06:11:22 +08:00
|
|
|
const base = 'https://edgehill.nylas.com/update-check';
|
|
|
|
const config = currentConfig();
|
2015-12-10 23:52:20 +08:00
|
|
|
// NOTE: Since there's no loaded config yet (we haven't logged in),
|
|
|
|
// a random id will be sent with no emails
|
2015-12-13 06:11:22 +08:00
|
|
|
const url = `${base}?platform=${value.platform}&arch=${value.arch}&version=${config.version}`;
|
|
|
|
expect(value.feedUrl.indexOf(url)).toBe(0);
|
|
|
|
});
|
2015-12-10 23:52:20 +08:00
|
|
|
});
|
|
|
|
|
2015-12-13 06:11:22 +08:00
|
|
|
assertBasicWindow.call(this);
|
2015-12-10 23:52:20 +08:00
|
|
|
|
2015-12-13 06:11:22 +08:00
|
|
|
it('has width', (done)=> {
|
2015-12-10 23:52:20 +08:00
|
|
|
this.app.client.getWindowWidth()
|
2015-12-13 06:11:22 +08:00
|
|
|
.then((result)=> expect(result).toBeGreaterThan(0) )
|
|
|
|
.finally(done);
|
2015-12-10 23:52:20 +08:00
|
|
|
});
|
|
|
|
|
2015-12-13 06:11:22 +08:00
|
|
|
it('has height', (done)=> {
|
2015-12-10 23:52:20 +08:00
|
|
|
this.app.client.getWindowHeight()
|
2015-12-13 06:11:22 +08:00
|
|
|
.then((result)=> expect(result).toBeGreaterThan(0) )
|
|
|
|
.finally(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('can sign up using Gmail', ()=> {
|
|
|
|
// TODO
|
|
|
|
});
|
|
|
|
|
|
|
|
it('can sign up using Exchange', (done)=> {
|
|
|
|
const client = this.app.client;
|
|
|
|
const fakeAccountJson = fs.readFileSync(
|
|
|
|
path.join(FAKE_DATA_PATH, 'account_exchange.json'),
|
|
|
|
'utf8'
|
|
|
|
);
|
|
|
|
|
|
|
|
client.execute((jsonStr)=> {
|
|
|
|
// Monkeypatch NylasAPI and EdgehillAPI
|
|
|
|
const json = JSON.parse(jsonStr);
|
|
|
|
$n._nylasApiMakeRequest = $n.NylasAPI.makeRequest;
|
|
|
|
$n._edgehillRequest = $n.EdgehillAPI.request;
|
|
|
|
$n.NylasAPI.makeRequest = ()=> {
|
|
|
|
return Promise.resolve(json);
|
|
|
|
};
|
|
|
|
$n.EdgehillAPI.request = ({success})=> {
|
|
|
|
success(json);
|
|
|
|
};
|
|
|
|
}, fakeAccountJson)
|
|
|
|
.then(()=> clickRepeat(client, '.btn-continue', {times: 3, interval: 500}))
|
|
|
|
.then(()=> client.click('.provider.exchange'))
|
|
|
|
.then(()=> wait(500))
|
|
|
|
.then(()=> client.click('input[data-field="name"]'))
|
|
|
|
.then(()=> client.keys('name'))
|
|
|
|
.then(()=> client.click('input[data-field="email"]'))
|
|
|
|
.then(()=> client.keys('email@nylas.com'))
|
|
|
|
.then(()=> client.click('input[data-field="password"]'))
|
|
|
|
.then(()=> client.keys('password'))
|
|
|
|
.then(()=> client.click('.btn-add-account'))
|
|
|
|
.then(()=> wait(500))
|
|
|
|
.then(()=> {
|
|
|
|
// Expect the onboarding window to have no errors at this point
|
|
|
|
return assertNoErrorsInLogs(client);
|
|
|
|
})
|
|
|
|
.then(()=> client.click('button.btn-large'))
|
|
|
|
.then(()=> wait(500))
|
|
|
|
.then(()=> client.click('.btn-get-started'))
|
|
|
|
.then(()=> wait(500))
|
|
|
|
.then(()=> N1Launcher.waitUntilMatchingWindowLoaded(client, N1Launcher.mainWindowLoadedMatcher))
|
|
|
|
.then(()=> {
|
|
|
|
// Expect the main window logs to contain no errors
|
|
|
|
// This will run on the main window because waitUntilMatchingWindowLoaded
|
|
|
|
// focuses the window after its loaded
|
|
|
|
return assertNoErrorsInLogs(client);
|
|
|
|
})
|
|
|
|
.finally(done);
|
2015-12-10 23:52:20 +08:00
|
|
|
});
|
|
|
|
});
|