+ describe('Update my account', function () {
+ it('Should update my password', async function () {
+ await updateMyUser({
+ url: server.url,
+ accessToken: accessTokenUser,
+ currentPassword: 'super password',
+ password: 'new password'
+ })
+ user.password = 'new password'
+
+ await userLogin(server, user, 200)
+ })
+
+ it('Should be able to change the NSFW display attribute', async function () {
+ await updateMyUser({
+ url: server.url,
+ accessToken: accessTokenUser,
+ nsfwPolicy: 'do_not_list'
+ })
+
+ const res = await getMyUserInformation(server.url, accessTokenUser)
+ const user = res.body
+
+ expect(user.username).to.equal('user_1')
+ expect(user.email).to.equal('user_1@example.com')
+ expect(user.nsfwPolicy).to.equal('do_not_list')
+ expect(user.videoQuota).to.equal(2 * 1024 * 1024)
+ expect(user.id).to.be.a('number')
+ expect(user.account.displayName).to.equal('user_1')
+ expect(user.account.description).to.be.null
+ })
+
+ it('Should be able to change the autoPlayVideo attribute', async function () {
+ await updateMyUser({
+ url: server.url,
+ accessToken: accessTokenUser,
+ autoPlayVideo: false
+ })
+
+ const res = await getMyUserInformation(server.url, accessTokenUser)
+ const user = res.body
+
+ expect(user.autoPlayVideo).to.be.false
+ })
+
+ it('Should be able to change the autoPlayNextVideo attribute', async function () {
+ await updateMyUser({
+ url: server.url,
+ accessToken: accessTokenUser,
+ autoPlayNextVideo: true
+ })
+
+ const res = await getMyUserInformation(server.url, accessTokenUser)
+ const user = res.body
+
+ expect(user.autoPlayNextVideo).to.be.true
+ })
+
+ it('Should be able to change the email attribute', async function () {
+ await updateMyUser({
+ url: server.url,
+ accessToken: accessTokenUser,
+ currentPassword: 'new password',
+ email: 'updated@example.com'
+ })
+
+ const res = await getMyUserInformation(server.url, accessTokenUser)
+ const user = res.body
+
+ expect(user.username).to.equal('user_1')
+ expect(user.email).to.equal('updated@example.com')
+ expect(user.nsfwPolicy).to.equal('do_not_list')
+ expect(user.videoQuota).to.equal(2 * 1024 * 1024)
+ expect(user.id).to.be.a('number')
+ expect(user.account.displayName).to.equal('user_1')
+ expect(user.account.description).to.be.null
+ })
+
+ it('Should be able to update my avatar', async function () {
+ const fixture = 'avatar.png'
+
+ await updateMyAvatar({
+ url: server.url,
+ accessToken: accessTokenUser,
+ fixture
+ })
+
+ const res = await getMyUserInformation(server.url, accessTokenUser)
+ const user = res.body
+
+ await testImage(server.url, 'avatar-resized', user.account.avatar.path, '.png')
+ })
+
+ it('Should be able to update my display name', async function () {
+ await updateMyUser({
+ url: server.url,
+ accessToken: accessTokenUser,
+ displayName: 'new display name'
+ })
+
+ const res = await getMyUserInformation(server.url, accessTokenUser)
+ const user = res.body
+
+ expect(user.username).to.equal('user_1')
+ expect(user.email).to.equal('updated@example.com')
+ expect(user.nsfwPolicy).to.equal('do_not_list')
+ expect(user.videoQuota).to.equal(2 * 1024 * 1024)
+ expect(user.id).to.be.a('number')
+ expect(user.account.displayName).to.equal('new display name')
+ expect(user.account.description).to.be.null
+ })
+
+ it('Should be able to update my description', async function () {
+ await updateMyUser({
+ url: server.url,
+ accessToken: accessTokenUser,
+ description: 'my super description updated'
+ })
+
+ const res = await getMyUserInformation(server.url, accessTokenUser)
+ const user: User = res.body
+
+ expect(user.username).to.equal('user_1')
+ expect(user.email).to.equal('updated@example.com')
+ expect(user.nsfwPolicy).to.equal('do_not_list')
+ expect(user.videoQuota).to.equal(2 * 1024 * 1024)
+ expect(user.id).to.be.a('number')
+ expect(user.account.displayName).to.equal('new display name')
+ expect(user.account.description).to.equal('my super description updated')
+ expect(user.noWelcomeModal).to.be.false
+ expect(user.noInstanceConfigWarningModal).to.be.false
+ })
+
+ it('Should be able to update my theme', async function () {
+ for (const theme of [ 'background-red', 'default', 'instance-default' ]) {
+ await updateMyUser({
+ url: server.url,
+ accessToken: accessTokenUser,
+ theme
+ })
+
+ const res = await getMyUserInformation(server.url, accessTokenUser)
+ const body: User = res.body
+
+ expect(body.theme).to.equal(theme)
+ }
+ })
+
+ it('Should be able to update my modal preferences', async function () {
+ await updateMyUser({
+ url: server.url,
+ accessToken: accessTokenUser,
+ noInstanceConfigWarningModal: true,
+ noWelcomeModal: true
+ })
+
+ const res = await getMyUserInformation(server.url, accessTokenUser)
+ const user: User = res.body
+
+ expect(user.noWelcomeModal).to.be.true
+ expect(user.noInstanceConfigWarningModal).to.be.true
+ })