aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/users
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/users')
-rw-r--r--server/tests/api/users/user-subscriptions.ts3
-rw-r--r--server/tests/api/users/users-multiple-servers.ts45
-rw-r--r--server/tests/api/users/users-verification.ts48
-rw-r--r--server/tests/api/users/users.ts374
4 files changed, 143 insertions, 327 deletions
diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts
index 1d0fc35f1..c09a85a32 100644
--- a/server/tests/api/users/user-subscriptions.ts
+++ b/server/tests/api/users/user-subscriptions.ts
@@ -4,7 +4,6 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { 5import {
6 cleanupTests, 6 cleanupTests,
7 createUser,
8 doubleFollow, 7 doubleFollow,
9 flushAndRunMultipleServers, 8 flushAndRunMultipleServers,
10 getVideosList, 9 getVideosList,
@@ -39,7 +38,7 @@ describe('Test users subscriptions', function () {
39 { 38 {
40 for (const server of servers) { 39 for (const server of servers) {
41 const user = { username: 'user' + server.serverNumber, password: 'password' } 40 const user = { username: 'user' + server.serverNumber, password: 'password' }
42 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) 41 await server.usersCommand.create({ username: user.username, password: user.password })
43 42
44 const accessToken = await server.loginCommand.getAccessToken(user) 43 const accessToken = await server.loginCommand.getAccessToken(user)
45 users.push({ accessToken }) 44 users.push({ accessToken })
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts
index 99fa08fe2..43e67ee60 100644
--- a/server/tests/api/users/users-multiple-servers.ts
+++ b/server/tests/api/users/users-multiple-servers.ts
@@ -7,17 +7,12 @@ import {
7 checkTmpIsEmpty, 7 checkTmpIsEmpty,
8 checkVideoFilesWereRemoved, 8 checkVideoFilesWereRemoved,
9 cleanupTests, 9 cleanupTests,
10 createUser,
11 doubleFollow, 10 doubleFollow,
12 flushAndRunMultipleServers, 11 flushAndRunMultipleServers,
13 getAccountVideos, 12 getAccountVideos,
14 getMyUserInformation,
15 removeUser,
16 ServerInfo, 13 ServerInfo,
17 setAccessTokensToServers, 14 setAccessTokensToServers,
18 testImage, 15 testImage,
19 updateMyAvatar,
20 updateMyUser,
21 uploadVideo, 16 uploadVideo,
22 waitJobs 17 waitJobs
23} from '@shared/extra-utils' 18} from '@shared/extra-utils'
@@ -56,13 +51,8 @@ describe('Test users with multiple servers', function () {
56 username: 'user1', 51 username: 'user1',
57 password: 'password' 52 password: 'password'
58 } 53 }
59 const res = await createUser({ 54 const created = await servers[0].usersCommand.create(user)
60 url: servers[0].url, 55 userId = created.id
61 accessToken: servers[0].accessToken,
62 username: user.username,
63 password: user.password
64 })
65 userId = res.body.user.id
66 userAccessToken = await servers[0].loginCommand.getAccessToken(user) 56 userAccessToken = await servers[0].loginCommand.getAccessToken(user)
67 } 57 }
68 58
@@ -77,15 +67,9 @@ describe('Test users with multiple servers', function () {
77 it('Should be able to update my display name', async function () { 67 it('Should be able to update my display name', async function () {
78 this.timeout(10000) 68 this.timeout(10000)
79 69
80 await updateMyUser({ 70 await servers[0].usersCommand.updateMe({ displayName: 'my super display name' })
81 url: servers[0].url,
82 accessToken: servers[0].accessToken,
83 displayName: 'my super display name'
84 })
85
86 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
87 user = res.body
88 71
72 user = await servers[0].usersCommand.getMyInfo()
89 expect(user.account.displayName).to.equal('my super display name') 73 expect(user.account.displayName).to.equal('my super display name')
90 74
91 await waitJobs(servers) 75 await waitJobs(servers)
@@ -94,14 +78,9 @@ describe('Test users with multiple servers', function () {
94 it('Should be able to update my description', async function () { 78 it('Should be able to update my description', async function () {
95 this.timeout(10_000) 79 this.timeout(10_000)
96 80
97 await updateMyUser({ 81 await servers[0].usersCommand.updateMe({ description: 'my super description updated' })
98 url: servers[0].url,
99 accessToken: servers[0].accessToken,
100 description: 'my super description updated'
101 })
102 82
103 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) 83 user = await servers[0].usersCommand.getMyInfo()
104 user = res.body
105 expect(user.account.displayName).to.equal('my super display name') 84 expect(user.account.displayName).to.equal('my super display name')
106 expect(user.account.description).to.equal('my super description updated') 85 expect(user.account.description).to.equal('my super description updated')
107 86
@@ -113,15 +92,9 @@ describe('Test users with multiple servers', function () {
113 92
114 const fixture = 'avatar2.png' 93 const fixture = 'avatar2.png'
115 94
116 await updateMyAvatar({ 95 await servers[0].usersCommand.updateMyAvatar({ fixture })
117 url: servers[0].url,
118 accessToken: servers[0].accessToken,
119 fixture
120 })
121
122 const res = await getMyUserInformation(servers[0].url, servers[0].accessToken)
123 user = res.body
124 96
97 user = await servers[0].usersCommand.getMyInfo()
125 userAvatarFilename = user.account.avatar.path 98 userAvatarFilename = user.account.avatar.path
126 99
127 await testImage(servers[0].url, 'avatar2-resized', userAvatarFilename, '.png') 100 await testImage(servers[0].url, 'avatar2-resized', userAvatarFilename, '.png')
@@ -202,7 +175,7 @@ describe('Test users with multiple servers', function () {
202 expect(videoChannelDeleted).not.to.be.undefined 175 expect(videoChannelDeleted).not.to.be.undefined
203 } 176 }
204 177
205 await removeUser(servers[0].url, userId, servers[0].accessToken) 178 await servers[0].usersCommand.remove({ userId })
206 179
207 await waitJobs(servers) 180 await waitJobs(servers)
208 181
diff --git a/server/tests/api/users/users-verification.ts b/server/tests/api/users/users-verification.ts
index ade730323..271aa3c7a 100644
--- a/server/tests/api/users/users-verification.ts
+++ b/server/tests/api/users/users-verification.ts
@@ -3,20 +3,7 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/core-utils'
6import { 6import { cleanupTests, flushAndRunServer, MockSmtpServer, ServerInfo, setAccessTokensToServers, waitJobs } from '@shared/extra-utils'
7 cleanupTests,
8 flushAndRunServer,
9 getMyUserInformation,
10 getUserInformation,
11 MockSmtpServer,
12 registerUser,
13 ServerInfo,
14 setAccessTokensToServers,
15 updateMyUser,
16 verifyEmail,
17 waitJobs
18} from '@shared/extra-utils'
19import { User } from '@shared/models'
20 7
21const expect = chai.expect 8const expect = chai.expect
22 9
@@ -65,7 +52,7 @@ describe('Test users account verification', function () {
65 } 52 }
66 }) 53 })
67 54
68 await registerUser(server.url, user1.username, user1.password) 55 await server.usersCommand.register(user1)
69 56
70 await waitJobs(server) 57 await waitJobs(server)
71 expectedEmailsLength++ 58 expectedEmailsLength++
@@ -84,8 +71,8 @@ describe('Test users account verification', function () {
84 71
85 userId = parseInt(userIdMatches[1], 10) 72 userId = parseInt(userIdMatches[1], 10)
86 73
87 const resUserInfo = await getUserInformation(server.url, server.accessToken, userId) 74 const body = await server.usersCommand.get({ userId })
88 expect(resUserInfo.body.emailVerified).to.be.false 75 expect(body.emailVerified).to.be.false
89 }) 76 })
90 77
91 it('Should not allow login for user with unverified email', async function () { 78 it('Should not allow login for user with unverified email', async function () {
@@ -94,13 +81,13 @@ describe('Test users account verification', function () {
94 }) 81 })
95 82
96 it('Should verify the user via email and allow login', async function () { 83 it('Should verify the user via email and allow login', async function () {
97 await verifyEmail(server.url, userId, verificationString) 84 await server.usersCommand.verifyEmail({ userId, verificationString })
98 85
99 const body = await server.loginCommand.login({ user: user1 }) 86 const body = await server.loginCommand.login({ user: user1 })
100 userAccessToken = body.access_token 87 userAccessToken = body.access_token
101 88
102 const resUserVerified = await getUserInformation(server.url, server.accessToken, userId) 89 const user = await server.usersCommand.get({ userId })
103 expect(resUserVerified.body.emailVerified).to.be.true 90 expect(user.emailVerified).to.be.true
104 }) 91 })
105 92
106 it('Should be able to change the user email', async function () { 93 it('Should be able to change the user email', async function () {
@@ -109,9 +96,8 @@ describe('Test users account verification', function () {
109 let updateVerificationString: string 96 let updateVerificationString: string
110 97
111 { 98 {
112 await updateMyUser({ 99 await server.usersCommand.updateMe({
113 url: server.url, 100 token: userAccessToken,
114 accessToken: userAccessToken,
115 email: 'updated@example.com', 101 email: 'updated@example.com',
116 currentPassword: user1.password 102 currentPassword: user1.password
117 }) 103 })
@@ -127,19 +113,15 @@ describe('Test users account verification', function () {
127 } 113 }
128 114
129 { 115 {
130 const res = await getMyUserInformation(server.url, userAccessToken) 116 const me = await server.usersCommand.getMyInfo({ token: userAccessToken })
131 const me: User = res.body
132
133 expect(me.email).to.equal('user_1@example.com') 117 expect(me.email).to.equal('user_1@example.com')
134 expect(me.pendingEmail).to.equal('updated@example.com') 118 expect(me.pendingEmail).to.equal('updated@example.com')
135 } 119 }
136 120
137 { 121 {
138 await verifyEmail(server.url, userId, updateVerificationString, true) 122 await server.usersCommand.verifyEmail({ userId, verificationString: updateVerificationString, isPendingEmail: true })
139
140 const res = await getMyUserInformation(server.url, userAccessToken)
141 const me: User = res.body
142 123
124 const me = await server.usersCommand.getMyInfo({ token: userAccessToken })
143 expect(me.email).to.equal('updated@example.com') 125 expect(me.email).to.equal('updated@example.com')
144 expect(me.pendingEmail).to.be.null 126 expect(me.pendingEmail).to.be.null
145 } 127 }
@@ -157,15 +139,15 @@ describe('Test users account verification', function () {
157 } 139 }
158 }) 140 })
159 141
160 await registerUser(server.url, user2.username, user2.password) 142 await server.usersCommand.register(user2)
161 143
162 await waitJobs(server) 144 await waitJobs(server)
163 expect(emails).to.have.lengthOf(expectedEmailsLength) 145 expect(emails).to.have.lengthOf(expectedEmailsLength)
164 146
165 const accessToken = await server.loginCommand.getAccessToken(user2) 147 const accessToken = await server.loginCommand.getAccessToken(user2)
166 148
167 const resMyUserInfo = await getMyUserInformation(server.url, accessToken) 149 const user = await server.usersCommand.getMyInfo({ token: accessToken })
168 expect(resMyUserInfo.body.emailVerified).to.be.null 150 expect(user.emailVerified).to.be.null
169 }) 151 })
170 152
171 it('Should allow login for user with unverified email when setting later enabled', async function () { 153 it('Should allow login for user with unverified email when setting later enabled', async function () {
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index 608bedb8b..30d7e850d 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -4,37 +4,22 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/core-utils'
6import { 6import {
7 blockUser,
8 cleanupTests, 7 cleanupTests,
9 createUser,
10 deleteMe,
11 flushAndRunServer, 8 flushAndRunServer,
12 getMyUserInformation,
13 getMyUserVideoQuotaUsed,
14 getMyUserVideoRating,
15 getMyVideos, 9 getMyVideos,
16 getUserInformation,
17 getUsersList,
18 getUsersListPaginationAndSort,
19 getVideosList, 10 getVideosList,
20 killallServers, 11 killallServers,
21 makePutBodyRequest, 12 makePutBodyRequest,
22 rateVideo, 13 rateVideo,
23 registerUserWithChannel,
24 removeUser,
25 removeVideo, 14 removeVideo,
26 reRunServer, 15 reRunServer,
27 ServerInfo, 16 ServerInfo,
28 setAccessTokensToServers, 17 setAccessTokensToServers,
29 testImage, 18 testImage,
30 unblockUser,
31 updateMyAvatar,
32 updateMyUser,
33 updateUser,
34 uploadVideo, 19 uploadVideo,
35 waitJobs 20 waitJobs
36} from '@shared/extra-utils' 21} from '@shared/extra-utils'
37import { AbuseState, MyUser, OAuth2ErrorCode, User, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models' 22import { AbuseState, OAuth2ErrorCode, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models'
38 23
39const expect = chai.expect 24const expect = chai.expect
40 25
@@ -174,8 +159,7 @@ describe('Test users', function () {
174 159
175 it('Should retrieve a video rating', async function () { 160 it('Should retrieve a video rating', async function () {
176 await rateVideo(server.url, accessToken, videoId, 'like') 161 await rateVideo(server.url, accessToken, videoId, 'like')
177 const res = await getMyUserVideoRating(server.url, accessToken, videoId) 162 const rating = await server.usersCommand.getMyRating({ token: accessToken, videoId })
178 const rating = res.body
179 163
180 expect(rating.videoId).to.equal(videoId) 164 expect(rating.videoId).to.equal(videoId)
181 expect(rating.rating).to.equal('like') 165 expect(rating.rating).to.equal('like')
@@ -222,7 +206,7 @@ describe('Test users', function () {
222 }) 206 })
223 207
224 it('Should not be able to get the user information', async function () { 208 it('Should not be able to get the user information', async function () {
225 await getMyUserInformation(server.url, server.accessToken, HttpStatusCode.UNAUTHORIZED_401) 209 await server.usersCommand.getMyInfo({ expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
226 }) 210 })
227 211
228 it('Should not be able to upload a video', async function () { 212 it('Should not be able to upload a video', async function () {
@@ -252,7 +236,7 @@ describe('Test users', function () {
252 }) 236 })
253 237
254 it('Should be able to get my user information again', async function () { 238 it('Should be able to get my user information again', async function () {
255 await getMyUserInformation(server.url, server.accessToken) 239 await server.usersCommand.getMyInfo()
256 }) 240 })
257 241
258 it('Should have an expired access token', async function () { 242 it('Should have an expired access token', async function () {
@@ -264,7 +248,7 @@ describe('Test users', function () {
264 await killallServers([ server ]) 248 await killallServers([ server ])
265 await reRunServer(server) 249 await reRunServer(server)
266 250
267 await getMyUserInformation(server.url, server.accessToken, HttpStatusCode.UNAUTHORIZED_401) 251 await server.usersCommand.getMyInfo({ expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
268 }) 252 })
269 253
270 it('Should not be able to refresh an access token with an expired refresh token', async function () { 254 it('Should not be able to refresh an access token with an expired refresh token', async function () {
@@ -286,21 +270,14 @@ describe('Test users', function () {
286 }) 270 })
287 271
288 it('Should be able to get my user information again', async function () { 272 it('Should be able to get my user information again', async function () {
289 await getMyUserInformation(server.url, server.accessToken) 273 await server.usersCommand.getMyInfo()
290 }) 274 })
291 }) 275 })
292 276
293 describe('Creating a user', function () { 277 describe('Creating a user', function () {
294 278
295 it('Should be able to create a new user', async function () { 279 it('Should be able to create a new user', async function () {
296 await createUser({ 280 await server.usersCommand.create({ ...user, videoQuota: 2 * 1024 * 1024, adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST })
297 url: server.url,
298 accessToken: accessToken,
299 username: user.username,
300 password: user.password,
301 videoQuota: 2 * 1024 * 1024,
302 adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST
303 })
304 }) 281 })
305 282
306 it('Should be able to login with this user', async function () { 283 it('Should be able to login with this user', async function () {
@@ -308,11 +285,9 @@ describe('Test users', function () {
308 }) 285 })
309 286
310 it('Should be able to get user information', async function () { 287 it('Should be able to get user information', async function () {
311 const res1 = await getMyUserInformation(server.url, accessTokenUser) 288 const userMe = await server.usersCommand.getMyInfo({ token: accessTokenUser })
312 const userMe: MyUser = res1.body
313 289
314 const res2 = await getUserInformation(server.url, server.accessToken, userMe.id, true) 290 const userGet = await server.usersCommand.get({ userId: userMe.id, withStats: true })
315 const userGet: User = res2.body
316 291
317 for (const user of [ userMe, userGet ]) { 292 for (const user of [ userMe, userGet ]) {
318 expect(user.username).to.equal('user_1') 293 expect(user.username).to.equal('user_1')
@@ -356,15 +331,11 @@ describe('Test users', function () {
356 }) 331 })
357 332
358 it('Should have video quota updated', async function () { 333 it('Should have video quota updated', async function () {
359 const res = await getMyUserVideoQuotaUsed(server.url, accessTokenUser) 334 const quota = await server.usersCommand.getMyQuotaUsed({ token: accessTokenUser })
360 const data = res.body 335 expect(quota.videoQuotaUsed).to.equal(218910)
361
362 expect(data.videoQuotaUsed).to.equal(218910)
363
364 const resUsers = await getUsersList(server.url, server.accessToken)
365 336
366 const users: User[] = resUsers.body.data 337 const { data } = await server.usersCommand.list()
367 const tmpUser = users.find(u => u.username === user.username) 338 const tmpUser = data.find(u => u.username === user.username)
368 expect(tmpUser.videoQuotaUsed).to.equal(218910) 339 expect(tmpUser.videoQuotaUsed).to.equal(218910)
369 }) 340 })
370 341
@@ -421,9 +392,7 @@ describe('Test users', function () {
421 } 392 }
422 393
423 { 394 {
424 const res = await getMyUserVideoQuotaUsed(server.url, accessTokenUser) 395 const data = await server.usersCommand.getMyQuotaUsed({ token: accessTokenUser })
425 const data = res.body
426
427 expect(data.videoQuotaUsed).to.be.greaterThan(220000) 396 expect(data.videoQuotaUsed).to.be.greaterThan(220000)
428 } 397 }
429 }) 398 })
@@ -432,21 +401,18 @@ describe('Test users', function () {
432 describe('Users listing', function () { 401 describe('Users listing', function () {
433 402
434 it('Should list all the users', async function () { 403 it('Should list all the users', async function () {
435 const res = await getUsersList(server.url, server.accessToken) 404 const { data, total } = await server.usersCommand.list()
436 const result = res.body
437 const total = result.total
438 const users = result.data
439 405
440 expect(total).to.equal(2) 406 expect(total).to.equal(2)
441 expect(users).to.be.an('array') 407 expect(data).to.be.an('array')
442 expect(users.length).to.equal(2) 408 expect(data.length).to.equal(2)
443 409
444 const user = users[0] 410 const user = data[0]
445 expect(user.username).to.equal('user_1') 411 expect(user.username).to.equal('user_1')
446 expect(user.email).to.equal('user_1@example.com') 412 expect(user.email).to.equal('user_1@example.com')
447 expect(user.nsfwPolicy).to.equal('display') 413 expect(user.nsfwPolicy).to.equal('display')
448 414
449 const rootUser = users[1] 415 const rootUser = data[1]
450 expect(rootUser.username).to.equal('root') 416 expect(rootUser.username).to.equal('root')
451 expect(rootUser.email).to.equal('admin' + server.internalServerNumber + '@example.com') 417 expect(rootUser.email).to.equal('admin' + server.internalServerNumber + '@example.com')
452 expect(user.nsfwPolicy).to.equal('display') 418 expect(user.nsfwPolicy).to.equal('display')
@@ -458,16 +424,12 @@ describe('Test users', function () {
458 }) 424 })
459 425
460 it('Should list only the first user by username asc', async function () { 426 it('Should list only the first user by username asc', async function () {
461 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 1, 'username') 427 const { total, data } = await server.usersCommand.list({ start: 0, count: 1, sort: 'username' })
462
463 const result = res.body
464 const total = result.total
465 const users = result.data
466 428
467 expect(total).to.equal(2) 429 expect(total).to.equal(2)
468 expect(users.length).to.equal(1) 430 expect(data.length).to.equal(1)
469 431
470 const user = users[0] 432 const user = data[0]
471 expect(user.username).to.equal('root') 433 expect(user.username).to.equal('root')
472 expect(user.email).to.equal('admin' + server.internalServerNumber + '@example.com') 434 expect(user.email).to.equal('admin' + server.internalServerNumber + '@example.com')
473 expect(user.roleLabel).to.equal('Administrator') 435 expect(user.roleLabel).to.equal('Administrator')
@@ -475,84 +437,66 @@ describe('Test users', function () {
475 }) 437 })
476 438
477 it('Should list only the first user by username desc', async function () { 439 it('Should list only the first user by username desc', async function () {
478 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 1, '-username') 440 const { total, data } = await server.usersCommand.list({ start: 0, count: 1, sort: '-username' })
479 const result = res.body
480 const total = result.total
481 const users = result.data
482 441
483 expect(total).to.equal(2) 442 expect(total).to.equal(2)
484 expect(users.length).to.equal(1) 443 expect(data.length).to.equal(1)
485 444
486 const user = users[0] 445 const user = data[0]
487 expect(user.username).to.equal('user_1') 446 expect(user.username).to.equal('user_1')
488 expect(user.email).to.equal('user_1@example.com') 447 expect(user.email).to.equal('user_1@example.com')
489 expect(user.nsfwPolicy).to.equal('display') 448 expect(user.nsfwPolicy).to.equal('display')
490 }) 449 })
491 450
492 it('Should list only the second user by createdAt desc', async function () { 451 it('Should list only the second user by createdAt desc', async function () {
493 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 1, '-createdAt') 452 const { data, total } = await server.usersCommand.list({ start: 0, count: 1, sort: '-createdAt' })
494 const result = res.body
495 const total = result.total
496 const users = result.data
497
498 expect(total).to.equal(2) 453 expect(total).to.equal(2)
499 expect(users.length).to.equal(1)
500 454
501 const user = users[0] 455 expect(data.length).to.equal(1)
456
457 const user = data[0]
502 expect(user.username).to.equal('user_1') 458 expect(user.username).to.equal('user_1')
503 expect(user.email).to.equal('user_1@example.com') 459 expect(user.email).to.equal('user_1@example.com')
504 expect(user.nsfwPolicy).to.equal('display') 460 expect(user.nsfwPolicy).to.equal('display')
505 }) 461 })
506 462
507 it('Should list all the users by createdAt asc', async function () { 463 it('Should list all the users by createdAt asc', async function () {
508 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 2, 'createdAt') 464 const { data, total } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt' })
509 const result = res.body
510 const total = result.total
511 const users = result.data
512 465
513 expect(total).to.equal(2) 466 expect(total).to.equal(2)
514 expect(users.length).to.equal(2) 467 expect(data.length).to.equal(2)
515 468
516 expect(users[0].username).to.equal('root') 469 expect(data[0].username).to.equal('root')
517 expect(users[0].email).to.equal('admin' + server.internalServerNumber + '@example.com') 470 expect(data[0].email).to.equal('admin' + server.internalServerNumber + '@example.com')
518 expect(users[0].nsfwPolicy).to.equal('display') 471 expect(data[0].nsfwPolicy).to.equal('display')
519 472
520 expect(users[1].username).to.equal('user_1') 473 expect(data[1].username).to.equal('user_1')
521 expect(users[1].email).to.equal('user_1@example.com') 474 expect(data[1].email).to.equal('user_1@example.com')
522 expect(users[1].nsfwPolicy).to.equal('display') 475 expect(data[1].nsfwPolicy).to.equal('display')
523 }) 476 })
524 477
525 it('Should search user by username', async function () { 478 it('Should search user by username', async function () {
526 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 2, 'createdAt', 'oot') 479 const { data, total } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt', search: 'oot' })
527 const users = res.body.data as User[] 480 expect(total).to.equal(1)
528 481 expect(data.length).to.equal(1)
529 expect(res.body.total).to.equal(1) 482 expect(data[0].username).to.equal('root')
530 expect(users.length).to.equal(1)
531
532 expect(users[0].username).to.equal('root')
533 }) 483 })
534 484
535 it('Should search user by email', async function () { 485 it('Should search user by email', async function () {
536 { 486 {
537 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 2, 'createdAt', 'r_1@exam') 487 const { total, data } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt', search: 'r_1@exam' })
538 const users = res.body.data as User[] 488 expect(total).to.equal(1)
539 489 expect(data.length).to.equal(1)
540 expect(res.body.total).to.equal(1) 490 expect(data[0].username).to.equal('user_1')
541 expect(users.length).to.equal(1) 491 expect(data[0].email).to.equal('user_1@example.com')
542
543 expect(users[0].username).to.equal('user_1')
544 expect(users[0].email).to.equal('user_1@example.com')
545 } 492 }
546 493
547 { 494 {
548 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 2, 'createdAt', 'example') 495 const { total, data } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt', search: 'example' })
549 const users = res.body.data as User[] 496 expect(total).to.equal(2)
550 497 expect(data.length).to.equal(2)
551 expect(res.body.total).to.equal(2) 498 expect(data[0].username).to.equal('root')
552 expect(users.length).to.equal(2) 499 expect(data[1].username).to.equal('user_1')
553
554 expect(users[0].username).to.equal('root')
555 expect(users[1].username).to.equal('user_1')
556 } 500 }
557 }) 501 })
558 }) 502 })
@@ -560,9 +504,8 @@ describe('Test users', function () {
560 describe('Update my account', function () { 504 describe('Update my account', function () {
561 505
562 it('Should update my password', async function () { 506 it('Should update my password', async function () {
563 await updateMyUser({ 507 await server.usersCommand.updateMe({
564 url: server.url, 508 token: accessTokenUser,
565 accessToken: accessTokenUser,
566 currentPassword: 'super password', 509 currentPassword: 'super password',
567 password: 'new password' 510 password: 'new password'
568 }) 511 })
@@ -572,15 +515,12 @@ describe('Test users', function () {
572 }) 515 })
573 516
574 it('Should be able to change the NSFW display attribute', async function () { 517 it('Should be able to change the NSFW display attribute', async function () {
575 await updateMyUser({ 518 await server.usersCommand.updateMe({
576 url: server.url, 519 token: accessTokenUser,
577 accessToken: accessTokenUser,
578 nsfwPolicy: 'do_not_list' 520 nsfwPolicy: 'do_not_list'
579 }) 521 })
580 522
581 const res = await getMyUserInformation(server.url, accessTokenUser) 523 const user = await server.usersCommand.getMyInfo({ token: accessTokenUser })
582 const user = res.body
583
584 expect(user.username).to.equal('user_1') 524 expect(user.username).to.equal('user_1')
585 expect(user.email).to.equal('user_1@example.com') 525 expect(user.email).to.equal('user_1@example.com')
586 expect(user.nsfwPolicy).to.equal('do_not_list') 526 expect(user.nsfwPolicy).to.equal('do_not_list')
@@ -591,42 +531,33 @@ describe('Test users', function () {
591 }) 531 })
592 532
593 it('Should be able to change the autoPlayVideo attribute', async function () { 533 it('Should be able to change the autoPlayVideo attribute', async function () {
594 await updateMyUser({ 534 await server.usersCommand.updateMe({
595 url: server.url, 535 token: accessTokenUser,
596 accessToken: accessTokenUser,
597 autoPlayVideo: false 536 autoPlayVideo: false
598 }) 537 })
599 538
600 const res = await getMyUserInformation(server.url, accessTokenUser) 539 const user = await server.usersCommand.getMyInfo({ token: accessTokenUser })
601 const user = res.body
602
603 expect(user.autoPlayVideo).to.be.false 540 expect(user.autoPlayVideo).to.be.false
604 }) 541 })
605 542
606 it('Should be able to change the autoPlayNextVideo attribute', async function () { 543 it('Should be able to change the autoPlayNextVideo attribute', async function () {
607 await updateMyUser({ 544 await server.usersCommand.updateMe({
608 url: server.url, 545 token: accessTokenUser,
609 accessToken: accessTokenUser,
610 autoPlayNextVideo: true 546 autoPlayNextVideo: true
611 }) 547 })
612 548
613 const res = await getMyUserInformation(server.url, accessTokenUser) 549 const user = await server.usersCommand.getMyInfo({ token: accessTokenUser })
614 const user = res.body
615
616 expect(user.autoPlayNextVideo).to.be.true 550 expect(user.autoPlayNextVideo).to.be.true
617 }) 551 })
618 552
619 it('Should be able to change the email attribute', async function () { 553 it('Should be able to change the email attribute', async function () {
620 await updateMyUser({ 554 await server.usersCommand.updateMe({
621 url: server.url, 555 token: accessTokenUser,
622 accessToken: accessTokenUser,
623 currentPassword: 'new password', 556 currentPassword: 'new password',
624 email: 'updated@example.com' 557 email: 'updated@example.com'
625 }) 558 })
626 559
627 const res = await getMyUserInformation(server.url, accessTokenUser) 560 const user = await server.usersCommand.getMyInfo({ token: accessTokenUser })
628 const user = res.body
629
630 expect(user.username).to.equal('user_1') 561 expect(user.username).to.equal('user_1')
631 expect(user.email).to.equal('updated@example.com') 562 expect(user.email).to.equal('updated@example.com')
632 expect(user.nsfwPolicy).to.equal('do_not_list') 563 expect(user.nsfwPolicy).to.equal('do_not_list')
@@ -639,15 +570,9 @@ describe('Test users', function () {
639 it('Should be able to update my avatar with a gif', async function () { 570 it('Should be able to update my avatar with a gif', async function () {
640 const fixture = 'avatar.gif' 571 const fixture = 'avatar.gif'
641 572
642 await updateMyAvatar({ 573 await server.usersCommand.updateMyAvatar({ token: accessTokenUser, fixture })
643 url: server.url,
644 accessToken: accessTokenUser,
645 fixture
646 })
647
648 const res = await getMyUserInformation(server.url, accessTokenUser)
649 const user = res.body
650 574
575 const user = await server.usersCommand.getMyInfo({ token: accessTokenUser })
651 await testImage(server.url, 'avatar-resized', user.account.avatar.path, '.gif') 576 await testImage(server.url, 'avatar-resized', user.account.avatar.path, '.gif')
652 }) 577 })
653 578
@@ -655,29 +580,17 @@ describe('Test users', function () {
655 for (const extension of [ '.png', '.gif' ]) { 580 for (const extension of [ '.png', '.gif' ]) {
656 const fixture = 'avatar' + extension 581 const fixture = 'avatar' + extension
657 582
658 await updateMyAvatar({ 583 await server.usersCommand.updateMyAvatar({ token: accessTokenUser, fixture })
659 url: server.url,
660 accessToken: accessTokenUser,
661 fixture
662 })
663
664 const res = await getMyUserInformation(server.url, accessTokenUser)
665 const user = res.body
666 584
585 const user = await server.usersCommand.getMyInfo({ token: accessTokenUser })
667 await testImage(server.url, 'avatar-resized', user.account.avatar.path, extension) 586 await testImage(server.url, 'avatar-resized', user.account.avatar.path, extension)
668 } 587 }
669 }) 588 })
670 589
671 it('Should be able to update my display name', async function () { 590 it('Should be able to update my display name', async function () {
672 await updateMyUser({ 591 await server.usersCommand.updateMe({ token: accessTokenUser, displayName: 'new display name' })
673 url: server.url,
674 accessToken: accessTokenUser,
675 displayName: 'new display name'
676 })
677
678 const res = await getMyUserInformation(server.url, accessTokenUser)
679 const user = res.body
680 592
593 const user = await server.usersCommand.getMyInfo({ token: accessTokenUser })
681 expect(user.username).to.equal('user_1') 594 expect(user.username).to.equal('user_1')
682 expect(user.email).to.equal('updated@example.com') 595 expect(user.email).to.equal('updated@example.com')
683 expect(user.nsfwPolicy).to.equal('do_not_list') 596 expect(user.nsfwPolicy).to.equal('do_not_list')
@@ -688,15 +601,9 @@ describe('Test users', function () {
688 }) 601 })
689 602
690 it('Should be able to update my description', async function () { 603 it('Should be able to update my description', async function () {
691 await updateMyUser({ 604 await server.usersCommand.updateMe({ token: accessTokenUser, description: 'my super description updated' })
692 url: server.url,
693 accessToken: accessTokenUser,
694 description: 'my super description updated'
695 })
696
697 const res = await getMyUserInformation(server.url, accessTokenUser)
698 const user: User = res.body
699 605
606 const user = await server.usersCommand.getMyInfo({ token: accessTokenUser })
700 expect(user.username).to.equal('user_1') 607 expect(user.username).to.equal('user_1')
701 expect(user.email).to.equal('updated@example.com') 608 expect(user.email).to.equal('updated@example.com')
702 expect(user.nsfwPolicy).to.equal('do_not_list') 609 expect(user.nsfwPolicy).to.equal('do_not_list')
@@ -710,30 +617,21 @@ describe('Test users', function () {
710 617
711 it('Should be able to update my theme', async function () { 618 it('Should be able to update my theme', async function () {
712 for (const theme of [ 'background-red', 'default', 'instance-default' ]) { 619 for (const theme of [ 'background-red', 'default', 'instance-default' ]) {
713 await updateMyUser({ 620 await server.usersCommand.updateMe({ token: accessTokenUser, theme })
714 url: server.url,
715 accessToken: accessTokenUser,
716 theme
717 })
718 621
719 const res = await getMyUserInformation(server.url, accessTokenUser) 622 const user = await server.usersCommand.getMyInfo({ token: accessTokenUser })
720 const body: User = res.body 623 expect(user.theme).to.equal(theme)
721
722 expect(body.theme).to.equal(theme)
723 } 624 }
724 }) 625 })
725 626
726 it('Should be able to update my modal preferences', async function () { 627 it('Should be able to update my modal preferences', async function () {
727 await updateMyUser({ 628 await server.usersCommand.updateMe({
728 url: server.url, 629 token: accessTokenUser,
729 accessToken: accessTokenUser,
730 noInstanceConfigWarningModal: true, 630 noInstanceConfigWarningModal: true,
731 noWelcomeModal: true 631 noWelcomeModal: true
732 }) 632 })
733 633
734 const res = await getMyUserInformation(server.url, accessTokenUser) 634 const user = await server.usersCommand.getMyInfo({ token: accessTokenUser })
735 const user: User = res.body
736
737 expect(user.noWelcomeModal).to.be.true 635 expect(user.noWelcomeModal).to.be.true
738 expect(user.noInstanceConfigWarningModal).to.be.true 636 expect(user.noInstanceConfigWarningModal).to.be.true
739 }) 637 })
@@ -741,10 +639,9 @@ describe('Test users', function () {
741 639
742 describe('Updating another user', function () { 640 describe('Updating another user', function () {
743 it('Should be able to update another user', async function () { 641 it('Should be able to update another user', async function () {
744 await updateUser({ 642 await server.usersCommand.update({
745 url: server.url,
746 userId, 643 userId,
747 accessToken, 644 token: accessToken,
748 email: 'updated2@example.com', 645 email: 'updated2@example.com',
749 emailVerified: true, 646 emailVerified: true,
750 videoQuota: 42, 647 videoQuota: 42,
@@ -753,8 +650,7 @@ describe('Test users', function () {
753 pluginAuth: 'toto' 650 pluginAuth: 'toto'
754 }) 651 })
755 652
756 const res = await getUserInformation(server.url, accessToken, userId) 653 const user = await server.usersCommand.get({ token: accessToken, userId })
757 const user = res.body as User
758 654
759 expect(user.username).to.equal('user_1') 655 expect(user.username).to.equal('user_1')
760 expect(user.email).to.equal('updated2@example.com') 656 expect(user.email).to.equal('updated2@example.com')
@@ -768,28 +664,22 @@ describe('Test users', function () {
768 }) 664 })
769 665
770 it('Should reset the auth plugin', async function () { 666 it('Should reset the auth plugin', async function () {
771 await updateUser({ url: server.url, userId, accessToken, pluginAuth: null }) 667 await server.usersCommand.update({ userId, token: accessToken, pluginAuth: null })
772 668
773 const res = await getUserInformation(server.url, accessToken, userId) 669 const user = await server.usersCommand.get({ token: accessToken, userId })
774 const user = res.body as User
775 expect(user.pluginAuth).to.be.null 670 expect(user.pluginAuth).to.be.null
776 }) 671 })
777 672
778 it('Should have removed the user token', async function () { 673 it('Should have removed the user token', async function () {
779 await getMyUserVideoQuotaUsed(server.url, accessTokenUser, HttpStatusCode.UNAUTHORIZED_401) 674 await server.usersCommand.getMyQuotaUsed({ token: accessTokenUser, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
780 675
781 accessTokenUser = await server.loginCommand.getAccessToken(user) 676 accessTokenUser = await server.loginCommand.getAccessToken(user)
782 }) 677 })
783 678
784 it('Should be able to update another user password', async function () { 679 it('Should be able to update another user password', async function () {
785 await updateUser({ 680 await server.usersCommand.update({ userId, token: accessToken, password: 'password updated' })
786 url: server.url,
787 userId,
788 accessToken,
789 password: 'password updated'
790 })
791 681
792 await getMyUserVideoQuotaUsed(server.url, accessTokenUser, HttpStatusCode.UNAUTHORIZED_401) 682 await server.usersCommand.getMyQuotaUsed({ token: accessTokenUser, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
793 683
794 await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 684 await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
795 685
@@ -806,7 +696,7 @@ describe('Test users', function () {
806 696
807 describe('Remove a user', function () { 697 describe('Remove a user', function () {
808 it('Should be able to remove this user', async function () { 698 it('Should be able to remove this user', async function () {
809 await removeUser(server.url, userId, accessToken) 699 await server.usersCommand.remove({ userId, token: accessToken })
810 }) 700 })
811 701
812 it('Should not be able to login with this user', async function () { 702 it('Should not be able to login with this user', async function () {
@@ -830,7 +720,7 @@ describe('Test users', function () {
830 const user = { displayName: 'super user 15', username: 'user_15', password: 'my super password' } 720 const user = { displayName: 'super user 15', username: 'user_15', password: 'my super password' }
831 const channel = { name: 'my_user_15_channel', displayName: 'my channel rocks' } 721 const channel = { name: 'my_user_15_channel', displayName: 'my channel rocks' }
832 722
833 await registerUserWithChannel({ url: server.url, user, channel }) 723 await server.usersCommand.register({ ...user, channel })
834 }) 724 })
835 725
836 it('Should be able to login with this registered user', async function () { 726 it('Should be able to login with this registered user', async function () {
@@ -843,16 +733,12 @@ describe('Test users', function () {
843 }) 733 })
844 734
845 it('Should have the correct display name', async function () { 735 it('Should have the correct display name', async function () {
846 const res = await getMyUserInformation(server.url, user15AccessToken) 736 const user = await server.usersCommand.getMyInfo({ token: user15AccessToken })
847 const user: User = res.body
848
849 expect(user.account.displayName).to.equal('super user 15') 737 expect(user.account.displayName).to.equal('super user 15')
850 }) 738 })
851 739
852 it('Should have the correct video quota', async function () { 740 it('Should have the correct video quota', async function () {
853 const res = await getMyUserInformation(server.url, user15AccessToken) 741 const user = await server.usersCommand.getMyInfo({ token: user15AccessToken })
854 const user = res.body
855
856 expect(user.videoQuota).to.equal(5 * 1024 * 1024) 742 expect(user.videoQuota).to.equal(5 * 1024 * 1024)
857 }) 743 })
858 744
@@ -864,15 +750,15 @@ describe('Test users', function () {
864 750
865 it('Should remove me', async function () { 751 it('Should remove me', async function () {
866 { 752 {
867 const res = await getUsersList(server.url, server.accessToken) 753 const { data } = await server.usersCommand.list()
868 expect(res.body.data.find(u => u.username === 'user_15')).to.not.be.undefined 754 expect(data.find(u => u.username === 'user_15')).to.not.be.undefined
869 } 755 }
870 756
871 await deleteMe(server.url, user15AccessToken) 757 await server.usersCommand.deleteMe({ token: user15AccessToken })
872 758
873 { 759 {
874 const res = await getUsersList(server.url, server.accessToken) 760 const { data } = await server.usersCommand.list()
875 expect(res.body.data.find(u => u.username === 'user_15')).to.be.undefined 761 expect(data.find(u => u.username === 'user_15')).to.be.undefined
876 } 762 }
877 }) 763 })
878 }) 764 })
@@ -886,49 +772,40 @@ describe('Test users', function () {
886 } 772 }
887 773
888 it('Should block a user', async function () { 774 it('Should block a user', async function () {
889 const resUser = await createUser({ 775 const user = await server.usersCommand.create({ ...user16 })
890 url: server.url, 776 user16Id = user.id
891 accessToken: server.accessToken,
892 username: user16.username,
893 password: user16.password
894 })
895 user16Id = resUser.body.user.id
896 777
897 user16AccessToken = await server.loginCommand.getAccessToken(user16) 778 user16AccessToken = await server.loginCommand.getAccessToken(user16)
898 779
899 await getMyUserInformation(server.url, user16AccessToken, HttpStatusCode.OK_200) 780 await server.usersCommand.getMyInfo({ token: user16AccessToken, expectedStatus: HttpStatusCode.OK_200 })
900 await blockUser(server.url, user16Id, server.accessToken) 781 await server.usersCommand.banUser({ userId: user16Id })
901 782
902 await getMyUserInformation(server.url, user16AccessToken, HttpStatusCode.UNAUTHORIZED_401) 783 await server.usersCommand.getMyInfo({ token: user16AccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
903 await server.loginCommand.login({ user: user16, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 784 await server.loginCommand.login({ user: user16, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
904 }) 785 })
905 786
906 it('Should search user by banned status', async function () { 787 it('Should search user by banned status', async function () {
907 { 788 {
908 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 2, 'createdAt', undefined, true) 789 const { data, total } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt', blocked: true })
909 const users = res.body.data as User[] 790 expect(total).to.equal(1)
791 expect(data.length).to.equal(1)
910 792
911 expect(res.body.total).to.equal(1) 793 expect(data[0].username).to.equal(user16.username)
912 expect(users.length).to.equal(1)
913
914 expect(users[0].username).to.equal(user16.username)
915 } 794 }
916 795
917 { 796 {
918 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 2, 'createdAt', undefined, false) 797 const { data, total } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt', blocked: false })
919 const users = res.body.data as User[] 798 expect(total).to.equal(1)
920 799 expect(data.length).to.equal(1)
921 expect(res.body.total).to.equal(1)
922 expect(users.length).to.equal(1)
923 800
924 expect(users[0].username).to.not.equal(user16.username) 801 expect(data[0].username).to.not.equal(user16.username)
925 } 802 }
926 }) 803 })
927 804
928 it('Should unblock a user', async function () { 805 it('Should unblock a user', async function () {
929 await unblockUser(server.url, user16Id, server.accessToken) 806 await server.usersCommand.unbanUser({ userId: user16Id })
930 user16AccessToken = await server.loginCommand.getAccessToken(user16) 807 user16AccessToken = await server.loginCommand.getAccessToken(user16)
931 await getMyUserInformation(server.url, user16AccessToken, HttpStatusCode.OK_200) 808 await server.usersCommand.getMyInfo({ token: user16AccessToken, expectedStatus: HttpStatusCode.OK_200 })
932 }) 809 })
933 }) 810 })
934 811
@@ -941,19 +818,12 @@ describe('Test users', function () {
941 username: 'user_17', 818 username: 'user_17',
942 password: 'my super password' 819 password: 'my super password'
943 } 820 }
944 const resUser = await createUser({ 821 const created = await server.usersCommand.create({ ...user17 })
945 url: server.url,
946 accessToken: server.accessToken,
947 username: user17.username,
948 password: user17.password
949 })
950 822
951 user17Id = resUser.body.user.id 823 user17Id = created.id
952 user17AccessToken = await server.loginCommand.getAccessToken(user17) 824 user17AccessToken = await server.loginCommand.getAccessToken(user17)
953 825
954 const res = await getUserInformation(server.url, server.accessToken, user17Id, true) 826 const user = await server.usersCommand.get({ userId: user17Id, withStats: true })
955 const user: User = res.body
956
957 expect(user.videosCount).to.equal(0) 827 expect(user.videosCount).to.equal(0)
958 expect(user.videoCommentsCount).to.equal(0) 828 expect(user.videoCommentsCount).to.equal(0)
959 expect(user.abusesCount).to.equal(0) 829 expect(user.abusesCount).to.equal(0)
@@ -969,9 +839,7 @@ describe('Test users', function () {
969 const res1 = await getVideosList(server.url) 839 const res1 = await getVideosList(server.url)
970 videoId = res1.body.data.find(video => video.name === videoAttributes.name).id 840 videoId = res1.body.data.find(video => video.name === videoAttributes.name).id
971 841
972 const res2 = await getUserInformation(server.url, server.accessToken, user17Id, true) 842 const user = await server.usersCommand.get({ userId: user17Id, withStats: true })
973 const user: User = res2.body
974
975 expect(user.videosCount).to.equal(1) 843 expect(user.videosCount).to.equal(1)
976 }) 844 })
977 845
@@ -979,9 +847,7 @@ describe('Test users', function () {
979 const text = 'super comment' 847 const text = 'super comment'
980 await server.commentsCommand.createThread({ token: user17AccessToken, videoId, text }) 848 await server.commentsCommand.createThread({ token: user17AccessToken, videoId, text })
981 849
982 const res = await getUserInformation(server.url, server.accessToken, user17Id, true) 850 const user = await server.usersCommand.get({ userId: user17Id, withStats: true })
983 const user: User = res.body
984
985 expect(user.videoCommentsCount).to.equal(1) 851 expect(user.videoCommentsCount).to.equal(1)
986 }) 852 })
987 853
@@ -992,17 +858,13 @@ describe('Test users', function () {
992 const body1 = await server.abusesCommand.getAdminList() 858 const body1 = await server.abusesCommand.getAdminList()
993 const abuseId = body1.data[0].id 859 const abuseId = body1.data[0].id
994 860
995 const res2 = await getUserInformation(server.url, server.accessToken, user17Id, true) 861 const user2 = await server.usersCommand.get({ userId: user17Id, withStats: true })
996 const user2: User = res2.body
997
998 expect(user2.abusesCount).to.equal(1) // number of incriminations 862 expect(user2.abusesCount).to.equal(1) // number of incriminations
999 expect(user2.abusesCreatedCount).to.equal(1) // number of reports created 863 expect(user2.abusesCreatedCount).to.equal(1) // number of reports created
1000 864
1001 await server.abusesCommand.update({ abuseId, body: { state: AbuseState.ACCEPTED } }) 865 await server.abusesCommand.update({ abuseId, body: { state: AbuseState.ACCEPTED } })
1002 866
1003 const res3 = await getUserInformation(server.url, server.accessToken, user17Id, true) 867 const user3 = await server.usersCommand.get({ userId: user17Id, withStats: true })
1004 const user3: User = res3.body
1005
1006 expect(user3.abusesAcceptedCount).to.equal(1) // number of reports created accepted 868 expect(user3.abusesAcceptedCount).to.equal(1) // number of reports created accepted
1007 }) 869 })
1008 }) 870 })