aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/moderation/abuses.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/moderation/abuses.ts')
-rw-r--r--server/tests/api/moderation/abuses.ts57
1 files changed, 27 insertions, 30 deletions
diff --git a/server/tests/api/moderation/abuses.ts b/server/tests/api/moderation/abuses.ts
index a7119263c..7574b8f4a 100644
--- a/server/tests/api/moderation/abuses.ts
+++ b/server/tests/api/moderation/abuses.ts
@@ -7,13 +7,8 @@ import {
7 cleanupTests, 7 cleanupTests,
8 doubleFollow, 8 doubleFollow,
9 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
10 getVideoIdFromUUID,
11 getVideosList,
12 removeVideo,
13 ServerInfo, 10 ServerInfo,
14 setAccessTokensToServers, 11 setAccessTokensToServers,
15 uploadVideo,
16 uploadVideoAndGetId,
17 waitJobs 12 waitJobs
18} from '@shared/extra-utils' 13} from '@shared/extra-utils'
19import { AbuseMessage, AbusePredefinedReasonsString, AbuseState, AdminAbuse, UserAbuse } from '@shared/models' 14import { AbuseMessage, AbusePredefinedReasonsString, AbuseState, AdminAbuse, UserAbuse } from '@shared/models'
@@ -47,28 +42,30 @@ describe('Test abuses', function () {
47 this.timeout(50000) 42 this.timeout(50000)
48 43
49 // Upload some videos on each servers 44 // Upload some videos on each servers
50 const video1Attributes = { 45 {
51 name: 'my super name for server 1', 46 const attributes = {
52 description: 'my super description for server 1' 47 name: 'my super name for server 1',
48 description: 'my super description for server 1'
49 }
50 await servers[0].videosCommand.upload({ attributes })
53 } 51 }
54 await uploadVideo(servers[0].url, servers[0].accessToken, video1Attributes)
55 52
56 const video2Attributes = { 53 {
57 name: 'my super name for server 2', 54 const attributes = {
58 description: 'my super description for server 2' 55 name: 'my super name for server 2',
56 description: 'my super description for server 2'
57 }
58 await servers[1].videosCommand.upload({ attributes })
59 } 59 }
60 await uploadVideo(servers[1].url, servers[1].accessToken, video2Attributes)
61 60
62 // Wait videos propagation, server 2 has transcoding enabled 61 // Wait videos propagation, server 2 has transcoding enabled
63 await waitJobs(servers) 62 await waitJobs(servers)
64 63
65 const res = await getVideosList(servers[0].url) 64 const { data } = await servers[0].videosCommand.list()
66 const videos = res.body.data 65 expect(data.length).to.equal(2)
67
68 expect(videos.length).to.equal(2)
69 66
70 servers[0].video = videos.find(video => video.name === 'my super name for server 1') 67 servers[0].video = data.find(video => video.name === 'my super name for server 1')
71 servers[1].video = videos.find(video => video.name === 'my super name for server 2') 68 servers[1].video = data.find(video => video.name === 'my super name for server 2')
72 }) 69 })
73 70
74 it('Should not have abuses', async function () { 71 it('Should not have abuses', async function () {
@@ -130,7 +127,7 @@ describe('Test abuses', function () {
130 this.timeout(10000) 127 this.timeout(10000)
131 128
132 const reason = 'my super bad reason 2' 129 const reason = 'my super bad reason 2'
133 const videoId = await getVideoIdFromUUID(servers[0].url, servers[1].video.uuid) 130 const videoId = await servers[0].videosCommand.getId({ uuid: servers[1].video.uuid })
134 await commands[0].report({ videoId, reason }) 131 await commands[0].report({ videoId, reason })
135 132
136 // We wait requests propagation 133 // We wait requests propagation
@@ -203,7 +200,7 @@ describe('Test abuses', function () {
203 this.timeout(10000) 200 this.timeout(10000)
204 201
205 { 202 {
206 const videoId = await getVideoIdFromUUID(servers[1].url, servers[0].video.uuid) 203 const videoId = await servers[1].videosCommand.getId({ uuid: servers[0].video.uuid })
207 await commands[1].report({ videoId, reason: 'will mute this' }) 204 await commands[1].report({ videoId, reason: 'will mute this' })
208 await waitJobs(servers) 205 await waitJobs(servers)
209 206
@@ -255,7 +252,7 @@ describe('Test abuses', function () {
255 it('Should keep the video abuse when deleting the video', async function () { 252 it('Should keep the video abuse when deleting the video', async function () {
256 this.timeout(10000) 253 this.timeout(10000)
257 254
258 await removeVideo(servers[1].url, servers[1].accessToken, abuseServer2.video.uuid) 255 await servers[1].videosCommand.remove({ id: abuseServer2.video.uuid })
259 256
260 await waitJobs(servers) 257 await waitJobs(servers)
261 258
@@ -279,12 +276,12 @@ describe('Test abuses', function () {
279 const userAccessToken = await servers[0].loginCommand.getAccessToken(user) 276 const userAccessToken = await servers[0].loginCommand.getAccessToken(user)
280 277
281 // upload a third video via this user 278 // upload a third video via this user
282 const video3Attributes = { 279 const attributes = {
283 name: 'my second super name for server 1', 280 name: 'my second super name for server 1',
284 description: 'my second super description for server 1' 281 description: 'my second super description for server 1'
285 } 282 }
286 const resUpload = await uploadVideo(servers[0].url, userAccessToken, video3Attributes) 283 const { id } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes })
287 const video3Id = resUpload.body.video.id 284 const video3Id = id
288 285
289 // resume with the test 286 // resume with the test
290 const reason3 = 'my super bad reason 3' 287 const reason3 = 'my super bad reason 3'
@@ -394,7 +391,7 @@ describe('Test abuses', function () {
394 391
395 async function getComment (server: ServerInfo, videoIdArg: number | string) { 392 async function getComment (server: ServerInfo, videoIdArg: number | string) {
396 const videoId = typeof videoIdArg === 'string' 393 const videoId = typeof videoIdArg === 'string'
397 ? await getVideoIdFromUUID(server.url, videoIdArg) 394 ? await server.videosCommand.getId({ uuid: videoIdArg })
398 : videoIdArg 395 : videoIdArg
399 396
400 const { data } = await server.commentsCommand.listThreads({ videoId }) 397 const { data } = await server.commentsCommand.listThreads({ videoId })
@@ -405,8 +402,8 @@ describe('Test abuses', function () {
405 before(async function () { 402 before(async function () {
406 this.timeout(50000) 403 this.timeout(50000)
407 404
408 servers[0].video = await uploadVideoAndGetId({ server: servers[0], videoName: 'server 1' }) 405 servers[0].video = await await servers[0].videosCommand.quickUpload({ name: 'server 1' })
409 servers[1].video = await uploadVideoAndGetId({ server: servers[1], videoName: 'server 2' }) 406 servers[1].video = await await servers[1].videosCommand.quickUpload({ name: 'server 2' })
410 407
411 await servers[0].commentsCommand.createThread({ videoId: servers[0].video.id, text: 'comment server 1' }) 408 await servers[0].commentsCommand.createThread({ videoId: servers[0].video.id, text: 'comment server 1' })
412 await servers[1].commentsCommand.createThread({ videoId: servers[1].video.id, text: 'comment server 2' }) 409 await servers[1].commentsCommand.createThread({ videoId: servers[1].video.id, text: 'comment server 2' })
@@ -604,7 +601,7 @@ describe('Test abuses', function () {
604 await servers[0].usersCommand.create({ username: 'user_1', password: 'donald' }) 601 await servers[0].usersCommand.create({ username: 'user_1', password: 'donald' })
605 602
606 const token = await servers[1].usersCommand.generateUserAndToken('user_2') 603 const token = await servers[1].usersCommand.generateUserAndToken('user_2')
607 await uploadVideo(servers[1].url, token, { name: 'super video' }) 604 await servers[1].videosCommand.upload({ token, attributes: { name: 'super video' } })
608 605
609 await waitJobs(servers) 606 await waitJobs(servers)
610 }) 607 })
@@ -766,7 +763,7 @@ describe('Test abuses', function () {
766 763
767 await commands[0].report({ token: userAccessToken, videoId: servers[0].video.id, reason: 'user reason 1' }) 764 await commands[0].report({ token: userAccessToken, videoId: servers[0].video.id, reason: 'user reason 1' })
768 765
769 const videoId = await getVideoIdFromUUID(servers[0].url, servers[1].video.uuid) 766 const videoId = await servers[0].videosCommand.getId({ uuid: servers[1].video.uuid })
770 await commands[0].report({ token: userAccessToken, videoId, reason: 'user reason 2' }) 767 await commands[0].report({ token: userAccessToken, videoId, reason: 'user reason 2' })
771 }) 768 })
772 769