aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/moderation/abuses.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-09 14:15:11 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit12edc1495a36b2199f1bf1ba37f50c7b694be382 (patch)
tree3abfe2e5b54076de73fbfa25386d0313fc3b7242 /server/tests/api/moderation/abuses.ts
parenta54618880c394ad7571f3f3222dc96ec2dd10d9a (diff)
downloadPeerTube-12edc1495a36b2199f1bf1ba37f50c7b694be382.tar.gz
PeerTube-12edc1495a36b2199f1bf1ba37f50c7b694be382.tar.zst
PeerTube-12edc1495a36b2199f1bf1ba37f50c7b694be382.zip
Introduce comments command
Diffstat (limited to 'server/tests/api/moderation/abuses.ts')
-rw-r--r--server/tests/api/moderation/abuses.ts29
1 files changed, 13 insertions, 16 deletions
diff --git a/server/tests/api/moderation/abuses.ts b/server/tests/api/moderation/abuses.ts
index a2bd07b12..e428cf1a8 100644
--- a/server/tests/api/moderation/abuses.ts
+++ b/server/tests/api/moderation/abuses.ts
@@ -4,14 +4,11 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { 5import {
6 AbusesCommand, 6 AbusesCommand,
7 addVideoCommentThread,
8 cleanupTests, 7 cleanupTests,
9 createUser, 8 createUser,
10 deleteVideoComment,
11 doubleFollow, 9 doubleFollow,
12 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
13 generateUserAccessToken, 11 generateUserAccessToken,
14 getVideoCommentThreads,
15 getVideoIdFromUUID, 12 getVideoIdFromUUID,
16 getVideosList, 13 getVideosList,
17 removeUser, 14 removeUser,
@@ -23,7 +20,7 @@ import {
23 userLogin, 20 userLogin,
24 waitJobs 21 waitJobs
25} from '@shared/extra-utils' 22} from '@shared/extra-utils'
26import { AbuseMessage, AbusePredefinedReasonsString, AbuseState, AdminAbuse, UserAbuse, VideoComment } from '@shared/models' 23import { AbuseMessage, AbusePredefinedReasonsString, AbuseState, AdminAbuse, UserAbuse } from '@shared/models'
27 24
28const expect = chai.expect 25const expect = chai.expect
29 26
@@ -399,14 +396,14 @@ describe('Test abuses', function () {
399 396
400 describe('Comment abuses', function () { 397 describe('Comment abuses', function () {
401 398
402 async function getComment (url: string, videoIdArg: number | string) { 399 async function getComment (server: ServerInfo, videoIdArg: number | string) {
403 const videoId = typeof videoIdArg === 'string' 400 const videoId = typeof videoIdArg === 'string'
404 ? await getVideoIdFromUUID(url, videoIdArg) 401 ? await getVideoIdFromUUID(server.url, videoIdArg)
405 : videoIdArg 402 : videoIdArg
406 403
407 const res = await getVideoCommentThreads(url, videoId, 0, 5) 404 const { data } = await server.commentsCommand.listThreads({ videoId })
408 405
409 return res.body.data[0] as VideoComment 406 return data[0]
410 } 407 }
411 408
412 before(async function () { 409 before(async function () {
@@ -415,8 +412,8 @@ describe('Test abuses', function () {
415 servers[0].video = await uploadVideoAndGetId({ server: servers[0], videoName: 'server 1' }) 412 servers[0].video = await uploadVideoAndGetId({ server: servers[0], videoName: 'server 1' })
416 servers[1].video = await uploadVideoAndGetId({ server: servers[1], videoName: 'server 2' }) 413 servers[1].video = await uploadVideoAndGetId({ server: servers[1], videoName: 'server 2' })
417 414
418 await addVideoCommentThread(servers[0].url, servers[0].accessToken, servers[0].video.id, 'comment server 1') 415 await servers[0].commentsCommand.createThread({ videoId: servers[0].video.id, text: 'comment server 1' })
419 await addVideoCommentThread(servers[1].url, servers[1].accessToken, servers[1].video.id, 'comment server 2') 416 await servers[1].commentsCommand.createThread({ videoId: servers[1].video.id, text: 'comment server 2' })
420 417
421 await waitJobs(servers) 418 await waitJobs(servers)
422 }) 419 })
@@ -424,7 +421,7 @@ describe('Test abuses', function () {
424 it('Should report abuse on a comment', async function () { 421 it('Should report abuse on a comment', async function () {
425 this.timeout(15000) 422 this.timeout(15000)
426 423
427 const comment = await getComment(servers[0].url, servers[0].video.id) 424 const comment = await getComment(servers[0], servers[0].video.id)
428 425
429 const reason = 'it is a bad comment' 426 const reason = 'it is a bad comment'
430 await commands[0].report({ commentId: comment.id, reason }) 427 await commands[0].report({ commentId: comment.id, reason })
@@ -434,7 +431,7 @@ describe('Test abuses', function () {
434 431
435 it('Should have 1 comment abuse on server 1 and 0 on server 2', async function () { 432 it('Should have 1 comment abuse on server 1 and 0 on server 2', async function () {
436 { 433 {
437 const comment = await getComment(servers[0].url, servers[0].video.id) 434 const comment = await getComment(servers[0], servers[0].video.id)
438 const body = await commands[0].getAdminList({ filter: 'comment' }) 435 const body = await commands[0].getAdminList({ filter: 'comment' })
439 436
440 expect(body.total).to.equal(1) 437 expect(body.total).to.equal(1)
@@ -469,7 +466,7 @@ describe('Test abuses', function () {
469 it('Should report abuse on a remote comment', async function () { 466 it('Should report abuse on a remote comment', async function () {
470 this.timeout(10000) 467 this.timeout(10000)
471 468
472 const comment = await getComment(servers[0].url, servers[1].video.uuid) 469 const comment = await getComment(servers[0], servers[1].video.uuid)
473 470
474 const reason = 'it is a really bad comment' 471 const reason = 'it is a really bad comment'
475 await commands[0].report({ commentId: comment.id, reason }) 472 await commands[0].report({ commentId: comment.id, reason })
@@ -478,7 +475,7 @@ describe('Test abuses', function () {
478 }) 475 })
479 476
480 it('Should have 2 comment abuses on server 1 and 1 on server 2', async function () { 477 it('Should have 2 comment abuses on server 1 and 1 on server 2', async function () {
481 const commentServer2 = await getComment(servers[0].url, servers[1].video.id) 478 const commentServer2 = await getComment(servers[0], servers[1].video.id)
482 479
483 { 480 {
484 const body = await commands[0].getAdminList({ filter: 'comment' }) 481 const body = await commands[0].getAdminList({ filter: 'comment' })
@@ -537,9 +534,9 @@ describe('Test abuses', function () {
537 it('Should keep the comment abuse when deleting the comment', async function () { 534 it('Should keep the comment abuse when deleting the comment', async function () {
538 this.timeout(10000) 535 this.timeout(10000)
539 536
540 const commentServer2 = await getComment(servers[0].url, servers[1].video.id) 537 const commentServer2 = await getComment(servers[0], servers[1].video.id)
541 538
542 await deleteVideoComment(servers[0].url, servers[0].accessToken, servers[1].video.uuid, commentServer2.id) 539 await servers[0].commentsCommand.delete({ videoId: servers[1].video.uuid, commentId: commentServer2.id })
543 540
544 await waitJobs(servers) 541 await waitJobs(servers)
545 542