forked from nylas/nylas-mail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclean-app-boot-spec.es6
106 lines (97 loc) · 3.56 KB
/
clean-app-boot-spec.es6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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';
describe('Clean app boot', ()=> {
beforeAll((done)=>{
// Boot in dev mode with no arguments
this.app = new N1Launcher(['--dev'], N1Launcher.CLEAR_CONFIG);
this.app.onboardingWindowReady().finally(done);
});
afterAll((done)=> {
if (this.app && this.app.isRunning()) {
this.app.stop().finally(done);
} else {
done();
}
});
it("has the autoupdater pointing to the correct url when there's no config loaded", () => {
this.app.client.execute(()=>{
const app = require('electron').remote.getGlobal('application');
return {
platform: process.platform,
arch: process.arch,
feedUrl: app.autoUpdateManager.feedURL,
};
}).then(({value})=>{
const base = 'https://edgehill.nylas.com/update-check';
const config = currentConfig();
// NOTE: Since there's no loaded config yet (we haven't logged in),
// a random id will be sent with no emails
const url = `${base}?platform=${value.platform}&arch=${value.arch}&version=${config.version}`;
expect(value.feedUrl.indexOf(url)).toBe(0);
});
});
assertBasicWindow.call(this);
it('has width', (done)=> {
this.app.client.getWindowWidth()
.then((result)=> expect(result).toBeGreaterThan(0) )
.finally(done);
});
it('has height', (done)=> {
this.app.client.getWindowHeight()
.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.makeRequest;
$n.NylasAPI.makeRequest = ()=> {
return Promise.resolve(json);
};
$n.EdgehillAPI.makeRequest = ({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);
});
});