diff options
author | Chocobozzz <me@florianbigard.com> | 2018-04-26 10:03:40 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-04-26 10:03:40 +0200 |
commit | ed56ad1193bb5bb0a81fb843a11eb90d3fed9861 (patch) | |
tree | 64842447b4721978c69e1d2b3a964951c789c408 /server/tests | |
parent | d62cf3234ccfca0223a9639782635f0fb6594f8c (diff) | |
download | PeerTube-ed56ad1193bb5bb0a81fb843a11eb90d3fed9861.tar.gz PeerTube-ed56ad1193bb5bb0a81fb843a11eb90d3fed9861.tar.zst PeerTube-ed56ad1193bb5bb0a81fb843a11eb90d3fed9861.zip |
Add ability to update the user display name/description
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/users/users-multiple-servers.ts | 20 | ||||
-rw-r--r-- | server/tests/api/users/users.ts | 23 | ||||
-rw-r--r-- | server/tests/utils/users/users.ts | 2 |
3 files changed, 44 insertions, 1 deletions
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts index a7f3aa8d3..8b9b63348 100644 --- a/server/tests/api/users/users-multiple-servers.ts +++ b/server/tests/api/users/users-multiple-servers.ts | |||
@@ -76,6 +76,22 @@ describe('Test users with multiple servers', function () { | |||
76 | await wait(5000) | 76 | await wait(5000) |
77 | }) | 77 | }) |
78 | 78 | ||
79 | it('Should be able to update my display name', async function () { | ||
80 | this.timeout(10000) | ||
81 | |||
82 | await updateMyUser({ | ||
83 | url: servers[0].url, | ||
84 | accessToken: servers[0].accessToken, | ||
85 | displayName: 'my super display name' | ||
86 | }) | ||
87 | |||
88 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) | ||
89 | user = res.body | ||
90 | expect(user.account.displayName).to.equal('my super display name') | ||
91 | |||
92 | await wait(5000) | ||
93 | }) | ||
94 | |||
79 | it('Should be able to update my description', async function () { | 95 | it('Should be able to update my description', async function () { |
80 | this.timeout(10000) | 96 | this.timeout(10000) |
81 | 97 | ||
@@ -87,6 +103,7 @@ describe('Test users with multiple servers', function () { | |||
87 | 103 | ||
88 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) | 104 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) |
89 | user = res.body | 105 | user = res.body |
106 | expect(user.account.displayName).to.equal('my super display name') | ||
90 | expect(user.account.description).to.equal('my super description updated') | 107 | expect(user.account.description).to.equal('my super description updated') |
91 | 108 | ||
92 | await wait(5000) | 109 | await wait(5000) |
@@ -111,7 +128,7 @@ describe('Test users with multiple servers', function () { | |||
111 | await wait(5000) | 128 | await wait(5000) |
112 | }) | 129 | }) |
113 | 130 | ||
114 | it('Should have updated my avatar and my description on other servers too', async function () { | 131 | it('Should have updated my profile on other servers too', async function () { |
115 | for (const server of servers) { | 132 | for (const server of servers) { |
116 | const resAccounts = await getAccountsList(server.url, '-createdAt') | 133 | const resAccounts = await getAccountsList(server.url, '-createdAt') |
117 | 134 | ||
@@ -122,6 +139,7 @@ describe('Test users with multiple servers', function () { | |||
122 | const rootServer1Get = resAccount.body as Account | 139 | const rootServer1Get = resAccount.body as Account |
123 | expect(rootServer1Get.name).to.equal('root') | 140 | expect(rootServer1Get.name).to.equal('root') |
124 | expect(rootServer1Get.host).to.equal('localhost:9001') | 141 | expect(rootServer1Get.host).to.equal('localhost:9001') |
142 | expect(rootServer1Get.displayName).to.equal('my super display name') | ||
125 | expect(rootServer1Get.description).to.equal('my super description updated') | 143 | expect(rootServer1Get.description).to.equal('my super description updated') |
126 | 144 | ||
127 | await testImage(server.url, 'avatar2-resized', rootServer1Get.avatar.path, '.png') | 145 | await testImage(server.url, 'avatar2-resized', rootServer1Get.avatar.path, '.png') |
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index 1192ef9e4..1ea599859 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts | |||
@@ -172,6 +172,7 @@ describe('Test users', function () { | |||
172 | expect(user.videoQuota).to.equal(2 * 1024 * 1024) | 172 | expect(user.videoQuota).to.equal(2 * 1024 * 1024) |
173 | expect(user.roleLabel).to.equal('User') | 173 | expect(user.roleLabel).to.equal('User') |
174 | expect(user.id).to.be.a('number') | 174 | expect(user.id).to.be.a('number') |
175 | expect(user.account.displayName).to.equal('user_1') | ||
175 | expect(user.account.description).to.be.null | 176 | expect(user.account.description).to.be.null |
176 | }) | 177 | }) |
177 | 178 | ||
@@ -316,6 +317,7 @@ describe('Test users', function () { | |||
316 | expect(user.nsfwPolicy).to.equal('do_not_list') | 317 | expect(user.nsfwPolicy).to.equal('do_not_list') |
317 | expect(user.videoQuota).to.equal(2 * 1024 * 1024) | 318 | expect(user.videoQuota).to.equal(2 * 1024 * 1024) |
318 | expect(user.id).to.be.a('number') | 319 | expect(user.id).to.be.a('number') |
320 | expect(user.account.displayName).to.equal('user_1') | ||
319 | expect(user.account.description).to.be.null | 321 | expect(user.account.description).to.be.null |
320 | }) | 322 | }) |
321 | 323 | ||
@@ -347,6 +349,7 @@ describe('Test users', function () { | |||
347 | expect(user.nsfwPolicy).to.equal('do_not_list') | 349 | expect(user.nsfwPolicy).to.equal('do_not_list') |
348 | expect(user.videoQuota).to.equal(2 * 1024 * 1024) | 350 | expect(user.videoQuota).to.equal(2 * 1024 * 1024) |
349 | expect(user.id).to.be.a('number') | 351 | expect(user.id).to.be.a('number') |
352 | expect(user.account.displayName).to.equal('user_1') | ||
350 | expect(user.account.description).to.be.null | 353 | expect(user.account.description).to.be.null |
351 | }) | 354 | }) |
352 | 355 | ||
@@ -365,6 +368,25 @@ describe('Test users', function () { | |||
365 | await testImage(server.url, 'avatar-resized', user.account.avatar.path, '.png') | 368 | await testImage(server.url, 'avatar-resized', user.account.avatar.path, '.png') |
366 | }) | 369 | }) |
367 | 370 | ||
371 | it('Should be able to update my display name', async function () { | ||
372 | await updateMyUser({ | ||
373 | url: server.url, | ||
374 | accessToken: accessTokenUser, | ||
375 | displayName: 'new display name' | ||
376 | }) | ||
377 | |||
378 | const res = await getMyUserInformation(server.url, accessTokenUser) | ||
379 | const user = res.body | ||
380 | |||
381 | expect(user.username).to.equal('user_1') | ||
382 | expect(user.email).to.equal('updated@example.com') | ||
383 | expect(user.nsfwPolicy).to.equal('do_not_list') | ||
384 | expect(user.videoQuota).to.equal(2 * 1024 * 1024) | ||
385 | expect(user.id).to.be.a('number') | ||
386 | expect(user.account.displayName).to.equal('new display name') | ||
387 | expect(user.account.description).to.be.null | ||
388 | }) | ||
389 | |||
368 | it('Should be able to update my description', async function () { | 390 | it('Should be able to update my description', async function () { |
369 | await updateMyUser({ | 391 | await updateMyUser({ |
370 | url: server.url, | 392 | url: server.url, |
@@ -380,6 +402,7 @@ describe('Test users', function () { | |||
380 | expect(user.nsfwPolicy).to.equal('do_not_list') | 402 | expect(user.nsfwPolicy).to.equal('do_not_list') |
381 | expect(user.videoQuota).to.equal(2 * 1024 * 1024) | 403 | expect(user.videoQuota).to.equal(2 * 1024 * 1024) |
382 | expect(user.id).to.be.a('number') | 404 | expect(user.id).to.be.a('number') |
405 | expect(user.account.displayName).to.equal('new display name') | ||
383 | expect(user.account.description).to.equal('my super description updated') | 406 | expect(user.account.description).to.equal('my super description updated') |
384 | }) | 407 | }) |
385 | 408 | ||
diff --git a/server/tests/utils/users/users.ts b/server/tests/utils/users/users.ts index fc6b26c50..d31e57a25 100644 --- a/server/tests/utils/users/users.ts +++ b/server/tests/utils/users/users.ts | |||
@@ -132,6 +132,7 @@ function updateMyUser (options: { | |||
132 | nsfwPolicy?: NSFWPolicyType, | 132 | nsfwPolicy?: NSFWPolicyType, |
133 | email?: string, | 133 | email?: string, |
134 | autoPlayVideo?: boolean | 134 | autoPlayVideo?: boolean |
135 | displayName?: string, | ||
135 | description?: string | 136 | description?: string |
136 | }) { | 137 | }) { |
137 | const path = '/api/v1/users/me' | 138 | const path = '/api/v1/users/me' |
@@ -142,6 +143,7 @@ function updateMyUser (options: { | |||
142 | if (options.autoPlayVideo !== undefined && options.autoPlayVideo !== null) toSend['autoPlayVideo'] = options.autoPlayVideo | 143 | if (options.autoPlayVideo !== undefined && options.autoPlayVideo !== null) toSend['autoPlayVideo'] = options.autoPlayVideo |
143 | if (options.email !== undefined && options.email !== null) toSend['email'] = options.email | 144 | if (options.email !== undefined && options.email !== null) toSend['email'] = options.email |
144 | if (options.description !== undefined && options.description !== null) toSend['description'] = options.description | 145 | if (options.description !== undefined && options.description !== null) toSend['description'] = options.description |
146 | if (options.displayName !== undefined && options.displayName !== null) toSend['displayName'] = options.displayName | ||
145 | 147 | ||
146 | return makePutBodyRequest({ | 148 | return makePutBodyRequest({ |
147 | url: options.url, | 149 | url: options.url, |