diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-15 10:02:54 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:18 +0200 |
commit | d23dd9fbfc4d26026352c10f81d2795ceaf2908a (patch) | |
tree | da82286d423c5e834a1ee2dcd5970076b8263cf1 /server/tests/api/notifications/moderation-notifications.ts | |
parent | 7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 (diff) | |
download | PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.gz PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.zst PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.zip |
Introduce videos command
Diffstat (limited to 'server/tests/api/notifications/moderation-notifications.ts')
-rw-r--r-- | server/tests/api/notifications/moderation-notifications.ts | 51 |
1 files changed, 19 insertions, 32 deletions
diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index 0269124c5..91a2b4fa5 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts | |||
@@ -17,12 +17,10 @@ import { | |||
17 | checkVideoAutoBlacklistForModerators, | 17 | checkVideoAutoBlacklistForModerators, |
18 | checkVideoIsPublished, | 18 | checkVideoIsPublished, |
19 | cleanupTests, | 19 | cleanupTests, |
20 | getVideoIdFromUUID, | ||
21 | MockInstancesIndex, | 20 | MockInstancesIndex, |
22 | MockSmtpServer, | 21 | MockSmtpServer, |
23 | prepareNotificationsTest, | 22 | prepareNotificationsTest, |
24 | ServerInfo, | 23 | ServerInfo, |
25 | uploadVideo, | ||
26 | wait, | 24 | wait, |
27 | waitJobs | 25 | waitJobs |
28 | } from '@shared/extra-utils' | 26 | } from '@shared/extra-utils' |
@@ -64,8 +62,7 @@ describe('Test moderation notifications', function () { | |||
64 | this.timeout(20000) | 62 | this.timeout(20000) |
65 | 63 | ||
66 | const name = 'video for abuse ' + buildUUID() | 64 | const name = 'video for abuse ' + buildUUID() |
67 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) | 65 | const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) |
68 | const video = resVideo.body.video | ||
69 | 66 | ||
70 | await servers[0].abusesCommand.report({ videoId: video.id, reason: 'super reason' }) | 67 | await servers[0].abusesCommand.report({ videoId: video.id, reason: 'super reason' }) |
71 | 68 | ||
@@ -77,12 +74,11 @@ describe('Test moderation notifications', function () { | |||
77 | this.timeout(20000) | 74 | this.timeout(20000) |
78 | 75 | ||
79 | const name = 'video for abuse ' + buildUUID() | 76 | const name = 'video for abuse ' + buildUUID() |
80 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) | 77 | const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) |
81 | const video = resVideo.body.video | ||
82 | 78 | ||
83 | await waitJobs(servers) | 79 | await waitJobs(servers) |
84 | 80 | ||
85 | const videoId = await getVideoIdFromUUID(servers[1].url, video.uuid) | 81 | const videoId = await servers[1].videosCommand.getId({ uuid: video.uuid }) |
86 | await servers[1].abusesCommand.report({ videoId, reason: 'super reason' }) | 82 | await servers[1].abusesCommand.report({ videoId, reason: 'super reason' }) |
87 | 83 | ||
88 | await waitJobs(servers) | 84 | await waitJobs(servers) |
@@ -93,8 +89,7 @@ describe('Test moderation notifications', function () { | |||
93 | this.timeout(20000) | 89 | this.timeout(20000) |
94 | 90 | ||
95 | const name = 'video for abuse ' + buildUUID() | 91 | const name = 'video for abuse ' + buildUUID() |
96 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) | 92 | const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) |
97 | const video = resVideo.body.video | ||
98 | const comment = await servers[0].commentsCommand.createThread({ | 93 | const comment = await servers[0].commentsCommand.createThread({ |
99 | token: userAccessToken, | 94 | token: userAccessToken, |
100 | videoId: video.id, | 95 | videoId: video.id, |
@@ -113,8 +108,7 @@ describe('Test moderation notifications', function () { | |||
113 | this.timeout(20000) | 108 | this.timeout(20000) |
114 | 109 | ||
115 | const name = 'video for abuse ' + buildUUID() | 110 | const name = 'video for abuse ' + buildUUID() |
116 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) | 111 | const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) |
117 | const video = resVideo.body.video | ||
118 | 112 | ||
119 | await servers[0].commentsCommand.createThread({ | 113 | await servers[0].commentsCommand.createThread({ |
120 | token: userAccessToken, | 114 | token: userAccessToken, |
@@ -150,7 +144,7 @@ describe('Test moderation notifications', function () { | |||
150 | 144 | ||
151 | const username = 'user' + new Date().getTime() | 145 | const username = 'user' + new Date().getTime() |
152 | const tmpToken = await servers[0].usersCommand.generateUserAndToken(username) | 146 | const tmpToken = await servers[0].usersCommand.generateUserAndToken(username) |
153 | await uploadVideo(servers[0].url, tmpToken, { name: 'super video' }) | 147 | await servers[0].videosCommand.upload({ token: tmpToken, attributes: { name: 'super video' } }) |
154 | 148 | ||
155 | await waitJobs(servers) | 149 | await waitJobs(servers) |
156 | 150 | ||
@@ -175,8 +169,7 @@ describe('Test moderation notifications', function () { | |||
175 | } | 169 | } |
176 | 170 | ||
177 | const name = 'abuse ' + buildUUID() | 171 | const name = 'abuse ' + buildUUID() |
178 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) | 172 | const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) |
179 | const video = resVideo.body.video | ||
180 | 173 | ||
181 | const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) | 174 | const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) |
182 | abuseId = body.abuse.id | 175 | abuseId = body.abuse.id |
@@ -223,8 +216,7 @@ describe('Test moderation notifications', function () { | |||
223 | } | 216 | } |
224 | 217 | ||
225 | const name = 'abuse ' + buildUUID() | 218 | const name = 'abuse ' + buildUUID() |
226 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) | 219 | const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) |
227 | const video = resVideo.body.video | ||
228 | 220 | ||
229 | { | 221 | { |
230 | const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) | 222 | const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) |
@@ -294,8 +286,7 @@ describe('Test moderation notifications', function () { | |||
294 | this.timeout(10000) | 286 | this.timeout(10000) |
295 | 287 | ||
296 | const name = 'video for abuse ' + buildUUID() | 288 | const name = 'video for abuse ' + buildUUID() |
297 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) | 289 | const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) |
298 | const uuid = resVideo.body.video.uuid | ||
299 | 290 | ||
300 | await servers[0].blacklistCommand.add({ videoId: uuid }) | 291 | await servers[0].blacklistCommand.add({ videoId: uuid }) |
301 | 292 | ||
@@ -307,8 +298,7 @@ describe('Test moderation notifications', function () { | |||
307 | this.timeout(10000) | 298 | this.timeout(10000) |
308 | 299 | ||
309 | const name = 'video for abuse ' + buildUUID() | 300 | const name = 'video for abuse ' + buildUUID() |
310 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) | 301 | const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) |
311 | const uuid = resVideo.body.video.uuid | ||
312 | 302 | ||
313 | await servers[0].blacklistCommand.add({ videoId: uuid }) | 303 | await servers[0].blacklistCommand.add({ videoId: uuid }) |
314 | 304 | ||
@@ -497,8 +487,8 @@ describe('Test moderation notifications', function () { | |||
497 | this.timeout(40000) | 487 | this.timeout(40000) |
498 | 488 | ||
499 | videoName = 'video with auto-blacklist ' + buildUUID() | 489 | videoName = 'video with auto-blacklist ' + buildUUID() |
500 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: videoName }) | 490 | const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name: videoName } }) |
501 | videoUUID = resVideo.body.video.uuid | 491 | videoUUID = uuid |
502 | 492 | ||
503 | await waitJobs(servers) | 493 | await waitJobs(servers) |
504 | await checkVideoAutoBlacklistForModerators(adminBaseParamsServer1, videoUUID, videoName, 'presence') | 494 | await checkVideoAutoBlacklistForModerators(adminBaseParamsServer1, videoUUID, videoName, 'presence') |
@@ -544,17 +534,16 @@ describe('Test moderation notifications', function () { | |||
544 | 534 | ||
545 | const name = 'video with auto-blacklist and future schedule ' + buildUUID() | 535 | const name = 'video with auto-blacklist and future schedule ' + buildUUID() |
546 | 536 | ||
547 | const data = { | 537 | const attributes = { |
548 | name, | 538 | name, |
549 | privacy: VideoPrivacy.PRIVATE, | 539 | privacy: VideoPrivacy.PRIVATE, |
550 | scheduleUpdate: { | 540 | scheduleUpdate: { |
551 | updateAt: updateAt.toISOString(), | 541 | updateAt: updateAt.toISOString(), |
552 | privacy: VideoPrivacy.PUBLIC | 542 | privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC |
553 | } | 543 | } |
554 | } | 544 | } |
555 | 545 | ||
556 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, data) | 546 | const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes }) |
557 | const uuid = resVideo.body.video.uuid | ||
558 | 547 | ||
559 | await servers[0].blacklistCommand.remove({ videoId: uuid }) | 548 | await servers[0].blacklistCommand.remove({ videoId: uuid }) |
560 | 549 | ||
@@ -577,17 +566,16 @@ describe('Test moderation notifications', function () { | |||
577 | 566 | ||
578 | const name = 'video with schedule done and still auto-blacklisted ' + buildUUID() | 567 | const name = 'video with schedule done and still auto-blacklisted ' + buildUUID() |
579 | 568 | ||
580 | const data = { | 569 | const attributes = { |
581 | name, | 570 | name, |
582 | privacy: VideoPrivacy.PRIVATE, | 571 | privacy: VideoPrivacy.PRIVATE, |
583 | scheduleUpdate: { | 572 | scheduleUpdate: { |
584 | updateAt: updateAt.toISOString(), | 573 | updateAt: updateAt.toISOString(), |
585 | privacy: VideoPrivacy.PUBLIC | 574 | privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC |
586 | } | 575 | } |
587 | } | 576 | } |
588 | 577 | ||
589 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, data) | 578 | const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes }) |
590 | const uuid = resVideo.body.video.uuid | ||
591 | 579 | ||
592 | await wait(6000) | 580 | await wait(6000) |
593 | await checkVideoIsPublished(userBaseParams, name, uuid, 'absence') | 581 | await checkVideoIsPublished(userBaseParams, name, uuid, 'absence') |
@@ -601,8 +589,7 @@ describe('Test moderation notifications', function () { | |||
601 | const name = 'video without auto-blacklist ' + buildUUID() | 589 | const name = 'video without auto-blacklist ' + buildUUID() |
602 | 590 | ||
603 | // admin with blacklist right will not be auto-blacklisted | 591 | // admin with blacklist right will not be auto-blacklisted |
604 | const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name }) | 592 | const { uuid } = await servers[0].videosCommand.upload({ attributes: { name } }) |
605 | const uuid = resVideo.body.video.uuid | ||
606 | 593 | ||
607 | await waitJobs(servers) | 594 | await waitJobs(servers) |
608 | await checkVideoAutoBlacklistForModerators(adminBaseParamsServer1, uuid, name, 'absence') | 595 | await checkVideoAutoBlacklistForModerators(adminBaseParamsServer1, uuid, name, 'absence') |