-
Notifications
You must be signed in to change notification settings - Fork 11
/
profile.test.js
653 lines (557 loc) · 25.7 KB
/
profile.test.js
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
/* global localStorage */
import {
SEED,
USERADDRESS,
assertUserIsLoggedIn,
createUser,
createUserKeystore,
getAnonymousAddress,
resetDb,
createUserAndLogin,
login,
waitForUserIsLoggedIn,
assertUserIsNotLoggedIn,
nukeLocalStorage,
clearUserKeystoreFromLocalStorage,
getEthAccountFromApp,
waitForKeystore
} from './helpers.js'
import { add0x } from '../imports/lib/utils.js'
import { assert } from 'chai'
describe('Profile and accounts workflow:', function () {
beforeEach(function () {
browser.url('http://localhost:3000/')
browser.execute(nukeLocalStorage)
server.execute(resetDb)
})
it('register a new user', function () {
browser.execute(nukeLocalStorage)
browser.url('http://localhost:3000')
// log in as the created user
assertUserIsNotLoggedIn(browser)
browser.url('http://localhost:3000')
browser.waitForClickable('#nav-profile')
browser.click('#nav-profile')
browser.waitForClickable('#at-signUp')
browser.click('#at-signUp')
// fill in the form
browser.waitForClickable('[name="at-field-name"]')
browser.setValue('[name="at-field-name"]', 'Guildenstern')
browser.setValue('[name="at-field-email"]', 'guildenstern@rosencrantz.com')
browser.setValue('[name="at-field-password"]', 'password')
// .setValue('[name="at-field-password_again"]', 'password')
// submit the form
browser.waitForClickable('#at-btn')
browser.click('#at-btn')
// the new user is automaticaly logged in after account creation
waitForUserIsLoggedIn(browser)
// wait for the keystore to be generated
waitForKeystore(browser)
// now a modal should be opened with the seed
browser.waitForClickable('#seed')
const seed = browser.getText('#seed strong', false)
browser.waitForClickable('#btn-check-seed')
browser.click('#btn-check-seed')
browser.waitForClickable('[name="check_seed"]')
browser.setValue('[name="check_seed"]', seed)
browser.waitForClickable('#btn-check-seed-finish')
browser.click('#btn-check-seed-finish')
browser.pause(1000)
// the user is now logged in
assertUserIsLoggedIn(browser)
})
it('login as an existing user on a device with no keystore - use existing anonymous keystore ', function () {
// create a meteor user
server.execute(createUser)
assertUserIsNotLoggedIn(browser)
// go to the home page
browser.url('http://localhost:3000')
// wait until we have an anymous keystore available
browser.waitUntil(function () {
return browser.execute(function () {
return localStorage.getItem(`keystore-anonymous`)
}).value
})
const anonymousAddress = getAnonymousAddress()
browser.waitAndClick('#nav-profile')
browser.waitForClickable('[name="at-field-email"]')
browser.waitAndSetValue('[name="at-field-email"]', 'guildenstern@rosencrantz.com')
browser.waitAndSetValue('[name="at-field-password"]', 'password')
browser.waitAndClick('#at-btn')
// the user is now logged in
waitForUserIsLoggedIn(browser)
// we should now see a modal presenting a choice to restore the wallet or use a new one
browser.waitForClickable('#walletModal')
browser.waitAndClick('#create-wallet')
browser.waitAndSetValue('[name="user_password"]', 'password')
browser.click('#btn-create-wallet')
waitForKeystore(browser)
// the address of the new keystore should be the same as the old 'anonymous' address
const publicAddress = getEthAccountFromApp()
assert.equal(publicAddress, add0x(anonymousAddress))
})
it('change password', async function (done) {
browser.execute(clearUserKeystoreFromLocalStorage)
createUserAndLogin(browser)
waitForUserIsLoggedIn(browser)
browser.url('http://localhost:3000/profile')
const userAccount = getEthAccountFromApp()
browser.sendSomeETH(userAccount, 3.1)
browser.waitAndClick('.button-settings')
browser.waitAndClick('.edit-password')
browser.waitAndSetValue('[name="current-password"]', 'password')
browser.waitAndSetValue('[name="new-password"]', 'new-password')
browser.waitAndClick('#save-password')
browser.waitForVisible('li.profile-wallet-item:last-child .amount')
const amount = await browser.getText('li.profile-wallet-item:last-child .profile-wallet-item-balance', false)
assert.isOk(['3.10 ETH', '3,10 ETH'].indexOf(amount) > -1)
done()
})
it('show an error message if provided wrong password ', function () {
browser.execute(clearUserKeystoreFromLocalStorage)
server.execute(resetDb)
browser.pause(2000)
// create a meteor user
server.execute(createUser)
// log in as the created user
assertUserIsNotLoggedIn(browser)
browser.url('http://localhost:3000')
browser.waitAndClick('#nav-profile')
browser.waitAndSetValue('[name="at-field-email"]', 'guildenstern@rosencrantz.com')
browser.waitAndSetValue('[name="at-field-password"]', 'wrong password')
browser.waitAndClick('#at-btn')
// the user is now still not logged in
assertUserIsNotLoggedIn(browser)
browser.waitForClickable('.main-alert.error')
let errorMsg = browser.getText('.main-alert.error p')
assert.equal(errorMsg, 'That email and password combination is incorrect.')
})
it('login as an existing user on a device with no keystore - restore keystore with a seedPhrase', function () {
browser.execute(nukeLocalStorage)
server.execute(resetDb)
// create a meteor user
server.execute(createUser)
assertUserIsNotLoggedIn(browser)
browser.url('http://localhost:3000')
browser.waitForClickable('#nav-profile')
browser.click('#nav-profile')
browser.waitForClickable('[name="at-field-email"]')
browser.setValue('[name="at-field-email"]', 'guildenstern@rosencrantz.com')
browser.setValue('[name="at-field-password"]', 'password')
browser.waitForClickable('#at-btn')
browser.click('#at-btn')
waitForUserIsLoggedIn(browser)
// // we should now see a modal presenting a choice to restore the wallet or use a new one
browser.waitForExist('#walletModal')
// we choose to restore the keystore
browser.waitForClickable('#restore-keystore')
browser.click('#restore-keystore')
// we now should see a modal in which we are asked for the seed to regenerate the keystore
browser.waitForClickable('[name="field-seed"]')
browser.setValue('[name="field-seed"]', SEED)
browser.setValue('[name="field-password"]', 'password')
browser.click('#btn-restorekeystore-restore')
browser.waitUntil(function () {
let publicAddress = getEthAccountFromApp()
return publicAddress === USERADDRESS
})
})
it('try to register a new account with a used email', function () {
server.execute(createUser)
// browser.url('http://localhost:3000/profile')
browser.url('http://localhost:3000/')
browser.waitForClickable('#nav-profile')
browser.click('#nav-profile')
browser.pause(2000)
// we should see the login form, we click on the register link
browser.waitForClickable('#at-signUp')
browser.click('#at-signUp')
browser.pause(2000)
// fill in the form
browser.waitForExist('[name="at-field-name"]')
browser.setValue('[name="at-field-name"]', 'Guildenstern')
browser.setValue('[name="at-field-email"]', 'guildenstern@rosencrantz.com')
browser.setValue('[name="at-field-password"]', 'password')
// .setValue('[name="at-field-password_again"]', 'password')
// submit the form
browser.click('#at-btn')
browser.waitForClickable('.main-alert.error')
let errorMsg = browser.getText('.main-alert.error p')
assert.equal(errorMsg, 'Email already exists.')
})
it('do not overwrite a user address if failed to register a new user with a used email [TODO]', function () {
// createUserAndLogin(browser)
// browser.waitForVisible('#public_address')
// const address = browser.getText('#public_address')
// browser.pause(5000)
// // logout
// browser.$('#logout').click()
// // browser.url('http://localhost:3000/profile')
// browser.url('http://localhost:3000')
// browser.waitForClickable('#nav-profile')
// browser.click('#nav-profile')
// // we should see the login form, we click on the register link
// browser.waitForClickable('#at-signUp')
// browser.pause(2000)
// browser.click('#at-signUp')
// // fill in the form
// browser.waitForExist('[name="at-field-name"]')
// browser
// .setValue('[name="at-field-name"]', 'Guildenstern')
// .setValue('[name="at-field-email"]', 'guildenstern@rosencrantz.com')
// .setValue('[name="at-field-password"]', 'password')
// .setValue('[name="at-field-password_again"]', 'password')
// // submit the form
// browser.$('#at-btn').click()
//
// // verify if the address doesn't changed
// login(browser)
// browser.waitForVisible('#public_address')
// const address2 = browser.getText('#public_address')
// assert.equal(web3.toChecksumAddress(address), address2, 'The address is not the same')
// browser.pause(5000)
})
it('shows the seed', function () {
browser.execute(clearUserKeystoreFromLocalStorage)
createUserAndLogin(browser)
// browser.url('http://localhost:3000/profile')
browser.execute(function () {
utils = require('/imports/lib/utils.js') // eslint-disable-line no-undef
utils.showModal('showSeed') // eslint-disable-line no-undef
})
// the showSeed modal should now be visible
browser.waitForVisible('#show-seed')
// TODO: why do we not ask for a password anymore here?
// browser.waitForVisible('[name="user_password"]')
// browser.setValue('[name="user_password"]', 'password')
// browser.waitForEnabled('#btn-show-seed')
// browser.pause(1000)
// browser.click('#btn-show-seed')
// browser.waitForClickable('#closeModal')
})
it('send ether dialog works', function () {
browser.execute(clearUserKeystoreFromLocalStorage)
createUserAndLogin(browser)
browser.execute(function () {
utils = require('/imports/lib/utils.js') // eslint-disable-line no-undef
utils.showModal('doTransaction', { type: 'Eth', label: 'Send Ether' }) // eslint-disable-line no-undef
})
// browser.url('http://localhost:3000/profile')
// browser.waitForEnabled('#send-eth')
// browser.pause(1000)
browser.waitForExist('#form-doTransaction')
// browser.pause(1000)
})
it.skip('do not show the seed if wrong password', function () {
createUserAndLogin(browser)
browser.pause(3000)
browser.url('http://localhost:3000/profile')
browser.waitForClickable('#show-seed')
browser.click('#show-seed')
browser.waitForVisible('[name="user_password"]')
browser.setValue('[name="user_password"]', 'wrong')
browser.waitForEnabled('#btn-show-seed')
browser.pause(1000)
browser.click('#btn-show-seed')
// browser.waitForVisible('.main-form-input-password.error', 30000)
browser.waitForVisible('.main-form-input-password.error')
// // TODO: next test checks for error message - temp comment to get the test to pass
// browser.waitForVisible('.control-label')
// assert.equal(browser.getText('.control-label'), 'Wrong password', 'should show "Wrong password" text')
})
it.skip('restore the keystore', function () {
createUserAndLogin(browser)
browser.pause(4000)
browser.url('http://localhost:3000/profile')
browser.waitForClickable('#show-seed')
browser.click('#show-seed')
browser.waitForClickable('[name="user_password"]')
browser.pause(1000)
browser.setValue('[name="user_password"]', 'password')
browser.waitForEnabled('#btn-show-seed')
browser.click('#btn-show-seed')
browser.pause(1000)
browser.waitForClickable('#seed')
const seed = browser.getHTML('#seed strong', false)
const publicAddress = browser.getHTML('#public_address', false)
browser.click('#closeModal')
browser.execute(clearUserKeystoreFromLocalStorage)
browser.refresh()
browser.pause(2000)
// we now have a user account that is known in meteor, but no keystore
// TODO: in this case, the user is logged in, but has removed his keystore after logging in, the bastard
// we need to show a blocking modal here
//
browser.waitForClickable('#walletModal #restore-keystore')
browser.click('#walletModal #restore-keystore')
browser.waitForClickable('[name="field-seed"]')
browser.setValue('[name="field-seed"]', seed)
browser.setValue('[name="field-password"]', 'password')
browser.click('#btn-restorekeystore-restore')
browser.waitForExist('#public_address')
const newPublicAddress = browser.getHTML('#public_address', false)
assert.equal(publicAddress, newPublicAddress)
})
it.skip('do not restore keystore if wrong password', function () {
createUserAndLogin(browser)
browser.url('http://localhost:3000/profile')
browser.waitForClickable('#show-seed')
browser.click('#show-seed')
browser.waitForEnabled('[name="user_password"]')
browser.pause(500)
browser.setValue('[name="user_password"]', 'password')
browser.waitForClickable('#btn-show-seed')
browser.click('#btn-show-seed')
browser.waitForClickable('#seed')
const seed = browser.getHTML('#seed strong', false)
// const publicAddress = browser.getHTML('#public_address', false)
browser.waitForClickable('#closeModal')
browser.click('#closeModal')
browser.execute(clearUserKeystoreFromLocalStorage)
browser.refresh()
browser.waitForClickable('#walletModal #restore-keystore')
browser.click('#walletModal #restore-keystore')
browser.waitForVisible('[name="field-seed"]')
browser.setValue('[name="field-seed"]', seed)
browser.setValue('[name="field-password"]', 'wrong')
browser.click('#btn-restorekeystore-restore')
browser.waitForVisible('.main-form-input-password.error')
// // TODO: next test checks for error message - temp comment to get the test to pass
// browser.waitForVisible('.control-label')
// assert.equal(browser.getText('.control-label'), 'Wrong password', 'should show "Wrong password" text')
})
it('do not create a new wallet if the password is wrong', function () {
// create a meteor user
server.execute(createUser)
assertUserIsNotLoggedIn(browser)
// log in as the created user
browser.url('http://localhost:3000')
browser.waitForClickable('#nav-profile')
browser.click('#nav-profile')
browser.waitForClickable('[name="at-field-email"]')
browser.setValue('[name="at-field-email"]', 'guildenstern@rosencrantz.com')
browser.setValue('[name="at-field-password"]', 'password')
browser.click('#at-btn')
// the user is now logged in
waitForUserIsLoggedIn(browser)
// we should now see a modal presenting a choice to restore the wallet or use a new one
browser.waitForClickable('#walletModal')
browser.waitForClickable('#walletModal #create-wallet')
browser.click('#walletModal #create-wallet')
browser.waitForClickable('[name="user_password"]')
browser.setValue('[name="user_password"]', 'wrong password')
browser.click('#btn-create-wallet')
browser.waitForVisible('.main-form-input-password.error')
// // TODO: next test checks for error message - temp comment to get the test to pass
// browser.waitForVisible('.control-label')
// assert.equal(browser.getText('.control-label'), 'Wrong password', 'should show "Wrong password" text')
})
it('arriving on profile page without being logged should redirect to home', function () {
// TODO: implement the functionality and write this test
browser.url('http://localhost:3000/profile')
const url = browser.url()
browser.pause(1000)
assert.equal(url.value, 'http://localhost:3000/')
})
it('arriving on the app with a keystore, but without being logged in, should ask what to do, then continue anonymously ', function () {
// We show a modal with a short explation :
// 'A wallet was found on this computer. Please sign in to use this wallet; or continue navigating anonymously'
// if the user chooses the second option, a session var should be st so the user is not bothered again in the future
createUserKeystore(browser)
browser.url('http://localhost:3000')
assertUserIsNotLoggedIn(browser)
browser.waitForVisible('#foundKeystore')
// the user can now choose between contiuing anonimously, or to log in
// we choose anonimity
browser.waitAndClick('#btn-foundKeystore-cancel')
// we now see the main-alert-content
browser.waitForEnabled('.main-alert-content')
// and dismiss it
browser.waitAndClick('.main-alert-button-close')
// we remain not logged in
assertUserIsNotLoggedIn(browser)
})
it('arriving on the app with a keystore, but without being logged in, should ask what to do, then proceed to log in ', function () {
// We show a modal with a short explation :
// 'A wallet was found on this computer. Please sign in to use this wallet; or continue navigating anonymously'
// if the user chooses the second option, a session var should be st so the user is not bothered again in the future
createUserKeystore(browser)
browser.url('http://localhost:3000')
assertUserIsNotLoggedIn(browser)
browser.waitForVisible('#foundKeystore')
// the user can now choose between contiuing anonimously, or to log in
// we choose to log in
browser.waitAndClick('#btn-foundKeystore-login')
// we should now see the login modal
browser.waitForVisible('#loginModal')
})
describe('Password reset:', () => {
it('should not allow the user to change their password if they enter the incorrect current password ', function () {
createUserAndLogin(browser)
browser.url('http://localhost:3000/profile')
browser.waitForClickable('.button-settings')
browser.click('.button-settings')
browser.waitForClickable('.edit-password')
browser.click('.edit-password')
browser.waitAndSetValue('#current-password', 'foobar')
browser.waitAndSetValue('#new-password', 'myshinynewpassword')
browser.click('#save-password')
assert.equal(browser.isVisible('.edit-password-modal'), true)
browser.waitForVisible('.main-alert-content')
browser.waitUntil(() => {
// console.log(browser.getText('.main-alert-content'))
return browser.getText('.main-alert-content') === 'Wrong password'
})
})
it('should not allow the user to attempt to change their password if they do not enter their current password ', function () {
createUserAndLogin(browser)
browser.url('http://localhost:3000/profile')
browser.waitForClickable('.button-settings')
browser.click('.button-settings')
browser.waitForClickable('.edit-password')
browser.click('.edit-password')
browser.waitAndSetValue('#current-password', 'myshinynewpassword')
browser.click('#save-password')
assert.equal(browser.isVisible('.edit-password-modal'), true)
assert.equal(browser.getAttribute('#save-password', 'disabled'), 'true')
})
it('should not allow the user to attempt to change their password if they do not enter a new password', function () {
createUserAndLogin(browser)
browser.url('http://localhost:3000/profile')
browser.waitAndClick('.button-settings')
browser.waitAndClick('.edit-password')
browser.waitAndSetValue('#current-password', 'myshinynewpassword')
browser.click('#save-password')
assert.equal(browser.isVisible('.edit-password-modal'), true)
assert.equal(browser.getAttribute('#save-password', 'disabled'), 'true')
})
it('should not allow the user to attempt to change their password if they do not enter their current password or a new password', function () {
createUserAndLogin(browser)
browser.url('http://localhost:3000/profile')
browser.waitForClickable('.button-settings')
browser.click('.button-settings')
browser.waitForClickable('.edit-password')
browser.click('.edit-password')
browser.waitForClickable('#current-password')
assert.equal(browser.getAttribute('#save-password', 'disabled'), 'true')
})
it('should allow the user to attempt to change their password if they enter the correct current password and a new password', function () {
createUserAndLogin(browser)
browser.url('http://localhost:3000/profile')
browser.waitForClickable('.button-settings')
browser.click('.button-settings')
browser.waitForClickable('.edit-password')
browser.click('.edit-password')
browser.waitAndSetValue('#current-password', 'password')
browser.waitAndSetValue('#new-password', 'foobar')
browser.waitForClickable('#save-password')
browser.click('#save-password')
browser.waitUntil(() => {
return !browser.isVisible('.edit-password-modal')
})
browser.pause(500)
browser.waitForClickable('#logout a')
browser.click('#logout a')
browser.waitForVisible('#confirmLogout')
browser.pause(500)
browser.waitForClickable('#logoutBtn')
browser.click('#logoutBtn')
browser.waitForClickable('#nav-profile')
assertUserIsNotLoggedIn(browser)
login(browser, 'foobar')
waitForUserIsLoggedIn(browser)
assertUserIsLoggedIn(browser)
})
})
describe('edit profile', () => {
it('should render the current profile\'s information correctly', () => {
createUserAndLogin(browser)
browser.url('http://localhost:3000/profile')
browser.waitForClickable('.button-settings')
browser.click('.button-settings')
browser.waitForClickable('.edit-profile-info')
browser.click('.edit-profile-info')
browser.waitForVisible('.modal-profile')
assert.equal(browser.getAttribute('#new-username', 'placeholder'), 'foobar baz')
assert.equal(browser.getAttribute('#new-email', 'placeholder'), 'guildenstern@rosencrantz.com')
assert.equal(browser.getAttribute('.current-avatar', 'src'), 'https://google.com/images/stock.jpg')
})
it('should not allow the user to save profile information if no new information is entered', () => {
createUserAndLogin(browser)
browser.url('http://localhost:3000/profile')
browser.waitForClickable('.button-settings')
browser.click('.button-settings')
browser.waitForClickable('.edit-profile-info')
browser.click('.edit-profile-info')
browser.waitForVisible('.modal-profile')
assert.equal(browser.getAttribute('#save-profile-info', 'disabled'), 'true')
})
it('should not allow the user to save profile information if only whitespace is entered into the name or email fields', () => {
createUserAndLogin(browser)
browser.url('http://localhost:3000/profile')
browser.waitForClickable('.button-settings')
browser.click('.button-settings')
browser.waitForClickable('.edit-profile-info')
browser.click('.edit-profile-info')
browser.waitForVisible('.modal-profile')
browser.waitAndSetValue('#new-username', ' \n ')
assert.equal(browser.getAttribute('#save-profile-info', 'disabled'), 'true')
browser.waitForVisible('.modal-profile')
browser.waitAndSetValue('#new-email', ' ')
assert.equal(browser.getAttribute('#save-profile-info', 'disabled'), 'true')
})
it('should allow the user to update their name', () => {
createUserAndLogin(browser)
browser.url('http://localhost:3000/profile')
browser.waitForClickable('.button-settings')
assert.equal(browser.getText('.internals-header-title'), 'foobar baz')
browser.click('.button-settings')
browser.waitForClickable('.edit-profile-info')
browser.click('.edit-profile-info')
browser.waitForVisible('.modal-profile')
browser.waitAndSetValue('#new-username', 'my shiny new name')
browser.waitForClickable('#save-profile-info')
browser.click('#save-profile-info')
browser.waitUntil(() => {
return browser.getText('.internals-header-title') === 'my shiny new name'
})
})
it('should allow the user to update their email', () => {
createUserAndLogin(browser)
browser.url('http://localhost:3000/profile')
browser.waitForClickable('.button-settings')
browser.waitForVisible('.profile-user-email')
assert.equal(browser.getText('.profile-user-email'), 'guildenstern@rosencrantz.com')
browser.click('.button-settings')
browser.waitForClickable('.edit-profile-info')
browser.waitAndClick('.edit-profile-info')
browser.waitForVisible('.modal-profile')
browser.waitAndSetValue('#new-email', 'myGreatEmail@aol.com')
browser.waitForClickable('#save-profile-info')
browser.click('#save-profile-info')
browser.waitUntil(() => {
return browser.getText('.profile-user-email') === 'myGreatEmail@aol.com'
})
})
it('should not allow the user to update their email if they enter an invalid email', () => {
createUserAndLogin(browser)
browser.url('http://localhost:3000/profile')
browser.waitForClickable('.button-settings')
browser.waitForVisible('.profile-user-email')
assert.equal(browser.getText('.profile-user-email'), 'guildenstern@rosencrantz.com')
browser.click('.button-settings')
browser.waitForClickable('.edit-profile-info')
browser.waitAndClick('.edit-profile-info')
browser.waitForVisible('.modal-profile')
browser.waitAndSetValue('#new-email', 'fajwefnnnfnann')
browser.waitForClickable('#save-profile-info')
browser.click('#save-profile-info')
browser.waitUntil(() => {
return browser.getAttribute('#new-email', 'class').indexOf('error') >= 0
})
assert.equal(browser.isVisible('.modal-profile'), true)
browser.waitForVisible('.profile-user-email')
assert.equal(browser.getText('.profile-user-email'), 'guildenstern@rosencrantz.com')
})
})
})