2019-05-29 05:21:06 -04:00
|
|
|
/* eslint-disable
|
2022-05-16 10:25:49 -04:00
|
|
|
n/handle-callback-err,
|
2019-05-29 05:21:06 -04:00
|
|
|
*/
|
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Fix any style issues and re-enable lint.
|
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
2024-10-14 06:41:11 -04:00
|
|
|
import { expect } from 'chai'
|
|
|
|
|
|
|
|
import async from 'async'
|
|
|
|
import User from './helpers/User.js'
|
|
|
|
import Features from '../../../app/src/infrastructure/Features.js'
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('SettingsPage', function () {
|
|
|
|
beforeEach(function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
this.user = new User()
|
|
|
|
return async.series(
|
|
|
|
[
|
|
|
|
this.user.ensureUserExists.bind(this.user),
|
|
|
|
this.user.login.bind(this.user),
|
|
|
|
],
|
|
|
|
done
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('load settings page', function (done) {
|
2019-08-07 10:04:04 -04:00
|
|
|
return this.user.getUserSettingsPage((err, statusCode) => {
|
2019-05-29 05:21:06 -04:00
|
|
|
statusCode.should.equal(200)
|
|
|
|
return done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('update main email address', function (done) {
|
2024-02-02 05:23:33 -05:00
|
|
|
if (Features.externalAuthenticationSystemUsed()) {
|
|
|
|
this.skip()
|
|
|
|
return
|
|
|
|
}
|
2019-05-29 05:21:06 -04:00
|
|
|
const newEmail = 'foo@bar.com'
|
|
|
|
return this.user.updateSettings({ email: newEmail }, error => {
|
2021-03-31 08:20:55 -04:00
|
|
|
expect(error).not.to.exist
|
2019-08-07 10:04:04 -04:00
|
|
|
return this.user.get((error, user) => {
|
2019-05-29 05:21:06 -04:00
|
|
|
user.email.should.equal(newEmail)
|
|
|
|
user.emails.length.should.equal(1)
|
|
|
|
user.emails[0].email.should.equal(newEmail)
|
|
|
|
return done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2024-10-01 09:38:04 -04:00
|
|
|
|
|
|
|
it('prevents first name from being updated to a string longer than 255 characters', function (done) {
|
|
|
|
const newFirstName = 'a'.repeat(256)
|
|
|
|
return this.user.updateSettings({ first_name: newFirstName }, error => {
|
|
|
|
expect(error).to.exist
|
|
|
|
expect(error.message).to.contain('update settings failed: status=400')
|
|
|
|
return done()
|
|
|
|
})
|
|
|
|
})
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|