Tests for totalRepliesFromVideoAuthor
[oweals/peertube.git] / server / tests / api / users / blocklist.ts
1 /* tslint:disable:no-unused-expression */
2
3 import * as chai from 'chai'
4 import 'mocha'
5 import { AccountBlock, ServerBlock, UserNotificationType, Video } from '../../../../shared/index'
6 import {
7   cleanupTests,
8   createUser, deleteVideoComment,
9   doubleFollow,
10   flushAndRunMultipleServers,
11   flushTests,
12   killallServers,
13   ServerInfo,
14   uploadVideo,
15   userLogin
16 } from '../../../../shared/extra-utils/index'
17 import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
18 import { getVideosListWithToken, getVideosList } from '../../../../shared/extra-utils/videos/videos'
19 import {
20   addVideoCommentReply,
21   addVideoCommentThread,
22   getVideoCommentThreads,
23   getVideoThreadComments
24 } from '../../../../shared/extra-utils/videos/video-comments'
25 import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
26 import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
27 import {
28   addAccountToAccountBlocklist,
29   addAccountToServerBlocklist,
30   addServerToAccountBlocklist,
31   addServerToServerBlocklist,
32   getAccountBlocklistByAccount,
33   getAccountBlocklistByServer,
34   getServerBlocklistByAccount,
35   getServerBlocklistByServer,
36   removeAccountFromAccountBlocklist,
37   removeAccountFromServerBlocklist,
38   removeServerFromAccountBlocklist,
39   removeServerFromServerBlocklist
40 } from '../../../../shared/extra-utils/users/blocklist'
41 import { getUserNotifications } from '../../../../shared/extra-utils/users/user-notifications'
42
43 const expect = chai.expect
44
45 async function checkAllVideos (url: string, token: string) {
46   {
47     const res = await getVideosListWithToken(url, token)
48
49     expect(res.body.data).to.have.lengthOf(4)
50   }
51
52   {
53     const res = await getVideosList(url)
54
55     expect(res.body.data).to.have.lengthOf(4)
56   }
57 }
58
59 async function checkAllComments (url: string, token: string, videoUUID: string) {
60   const resThreads = await getVideoCommentThreads(url, videoUUID, 0, 25, '-createdAt', token)
61
62   const allThreads: VideoComment[] = resThreads.body.data
63   const threads = allThreads.filter(t => t.isDeleted === false)
64   expect(threads).to.have.lengthOf(2)
65
66   for (const thread of threads) {
67     const res = await getVideoThreadComments(url, videoUUID, thread.id, token)
68
69     const tree: VideoCommentThreadTree = res.body
70     expect(tree.children).to.have.lengthOf(1)
71   }
72 }
73
74 async function checkCommentNotification (
75   mainServer: ServerInfo,
76   comment: { server: ServerInfo, token: string, videoUUID: string, text: string },
77   check: 'presence' | 'absence'
78 ) {
79   const resComment = await addVideoCommentThread(comment.server.url, comment.token, comment.videoUUID, comment.text)
80   const threadId = resComment.body.comment.id
81
82   await waitJobs([ mainServer, comment.server])
83
84   const res = await getUserNotifications(mainServer.url, mainServer.accessToken, 0, 30)
85   const commentNotifications = res.body.data
86                                   .filter(n => n.comment && n.comment.id === threadId)
87
88   if (check === 'presence') expect(commentNotifications).to.have.lengthOf(1)
89   else expect(commentNotifications).to.have.lengthOf(0)
90
91   await deleteVideoComment(comment.server.url, comment.token, comment.videoUUID, threadId)
92
93   await waitJobs([ mainServer, comment.server])
94 }
95
96 describe('Test blocklist', function () {
97   let servers: ServerInfo[]
98   let videoUUID1: string
99   let videoUUID2: string
100   let userToken1: string
101   let userModeratorToken: string
102   let userToken2: string
103
104   before(async function () {
105     this.timeout(60000)
106
107     servers = await flushAndRunMultipleServers(2)
108     await setAccessTokensToServers(servers)
109
110     {
111       const user = { username: 'user1', password: 'password' }
112       await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.password })
113
114       userToken1 = await userLogin(servers[0], user)
115       await uploadVideo(servers[0].url, userToken1, { name: 'video user 1' })
116     }
117
118     {
119       const user = { username: 'moderator', password: 'password' }
120       await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.password })
121
122       userModeratorToken = await userLogin(servers[0], user)
123     }
124
125     {
126       const user = { username: 'user2', password: 'password' }
127       await createUser({ url: servers[ 1 ].url, accessToken: servers[ 1 ].accessToken, username: user.username, password: user.password })
128
129       userToken2 = await userLogin(servers[1], user)
130       await uploadVideo(servers[1].url, userToken2, { name: 'video user 2' })
131     }
132
133     {
134       const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video server 1' })
135       videoUUID1 = res.body.video.uuid
136     }
137
138     {
139       const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video server 2' })
140       videoUUID2 = res.body.video.uuid
141     }
142
143     await doubleFollow(servers[0], servers[1])
144
145     {
146       const resComment = await addVideoCommentThread(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID1, 'comment root 1')
147       const resReply = await addVideoCommentReply(servers[ 0 ].url, userToken1, videoUUID1, resComment.body.comment.id, 'comment user 1')
148       await addVideoCommentReply(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID1, resReply.body.comment.id, 'comment root 1')
149     }
150
151     {
152       const resComment = await addVideoCommentThread(servers[ 0 ].url, userToken1, videoUUID1, 'comment user 1')
153       await addVideoCommentReply(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID1, resComment.body.comment.id, 'comment root 1')
154     }
155
156     await waitJobs(servers)
157   })
158
159   describe('User blocklist', function () {
160
161     describe('When managing account blocklist', function () {
162       it('Should list all videos', function () {
163         return checkAllVideos(servers[ 0 ].url, servers[ 0 ].accessToken)
164       })
165
166       it('Should list the comments', function () {
167         return checkAllComments(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID1)
168       })
169
170       it('Should block a remote account', async function () {
171         await addAccountToAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:' + servers[1].port)
172       })
173
174       it('Should hide its videos', async function () {
175         const res = await getVideosListWithToken(servers[ 0 ].url, servers[ 0 ].accessToken)
176
177         const videos: Video[] = res.body.data
178         expect(videos).to.have.lengthOf(3)
179
180         const v = videos.find(v => v.name === 'video user 2')
181         expect(v).to.be.undefined
182       })
183
184       it('Should block a local account', async function () {
185         await addAccountToAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user1')
186       })
187
188       it('Should hide its videos', async function () {
189         const res = await getVideosListWithToken(servers[ 0 ].url, servers[ 0 ].accessToken)
190
191         const videos: Video[] = res.body.data
192         expect(videos).to.have.lengthOf(2)
193
194         const v = videos.find(v => v.name === 'video user 1')
195         expect(v).to.be.undefined
196       })
197
198       it('Should hide its comments', async function () {
199         const resThreads = await getVideoCommentThreads(servers[ 0 ].url, videoUUID1, 0, 5, '-createdAt', servers[ 0 ].accessToken)
200
201         const threads: VideoComment[] = resThreads.body.data
202         expect(threads).to.have.lengthOf(1)
203         expect(threads[ 0 ].totalReplies).to.equal(0)
204
205         const t = threads.find(t => t.text === 'comment user 1')
206         expect(t).to.be.undefined
207
208         for (const thread of threads) {
209           const res = await getVideoThreadComments(servers[ 0 ].url, videoUUID1, thread.id, servers[ 0 ].accessToken)
210
211           const tree: VideoCommentThreadTree = res.body
212           expect(tree.children).to.have.lengthOf(0)
213         }
214       })
215
216       it('Should not have notifications from blocked accounts', async function () {
217         this.timeout(20000)
218
219         {
220           const comment = { server: servers[ 0 ], token: userToken1, videoUUID: videoUUID1, text: 'hidden comment' }
221           await checkCommentNotification(servers[ 0 ], comment, 'absence')
222         }
223
224         {
225           const comment = {
226             server: servers[ 0 ],
227             token: userToken1,
228             videoUUID: videoUUID2,
229             text: 'hello @root@localhost:' + servers[ 0 ].port
230           }
231           await checkCommentNotification(servers[ 0 ], comment, 'absence')
232         }
233       })
234
235       it('Should list all the videos with another user', async function () {
236         return checkAllVideos(servers[ 0 ].url, userToken1)
237       })
238
239       it('Should list all the comments with another user', async function () {
240         return checkAllComments(servers[ 0 ].url, userToken1, videoUUID1)
241       })
242
243       it('Should list blocked accounts', async function () {
244         {
245           const res = await getAccountBlocklistByAccount(servers[ 0 ].url, servers[ 0 ].accessToken, 0, 1, 'createdAt')
246           const blocks: AccountBlock[] = res.body.data
247
248           expect(res.body.total).to.equal(2)
249
250           const block = blocks[ 0 ]
251           expect(block.byAccount.displayName).to.equal('root')
252           expect(block.byAccount.name).to.equal('root')
253           expect(block.blockedAccount.displayName).to.equal('user2')
254           expect(block.blockedAccount.name).to.equal('user2')
255           expect(block.blockedAccount.host).to.equal('localhost:' + servers[1].port)
256         }
257
258         {
259           const res = await getAccountBlocklistByAccount(servers[ 0 ].url, servers[ 0 ].accessToken, 1, 2, 'createdAt')
260           const blocks: AccountBlock[] = res.body.data
261
262           expect(res.body.total).to.equal(2)
263
264           const block = blocks[ 0 ]
265           expect(block.byAccount.displayName).to.equal('root')
266           expect(block.byAccount.name).to.equal('root')
267           expect(block.blockedAccount.displayName).to.equal('user1')
268           expect(block.blockedAccount.name).to.equal('user1')
269           expect(block.blockedAccount.host).to.equal('localhost:' + servers[0].port)
270         }
271       })
272
273       it('Should unblock the remote account', async function () {
274         await removeAccountFromAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:' + servers[1].port)
275       })
276
277       it('Should display its videos', async function () {
278         const res = await getVideosListWithToken(servers[ 0 ].url, servers[ 0 ].accessToken)
279
280         const videos: Video[] = res.body.data
281         expect(videos).to.have.lengthOf(3)
282
283         const v = videos.find(v => v.name === 'video user 2')
284         expect(v).not.to.be.undefined
285       })
286
287       it('Should unblock the local account', async function () {
288         await removeAccountFromAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user1')
289       })
290
291       it('Should display its comments', function () {
292         return checkAllComments(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID1)
293       })
294
295       it('Should have a notification from a non blocked account', async function () {
296         this.timeout(20000)
297
298         {
299           const comment = { server: servers[ 1 ], token: userToken2, videoUUID: videoUUID1, text: 'displayed comment' }
300           await checkCommentNotification(servers[ 0 ], comment, 'presence')
301         }
302
303         {
304           const comment = {
305             server: servers[ 0 ],
306             token: userToken1,
307             videoUUID: videoUUID2,
308             text: 'hello @root@localhost:' + servers[ 0 ].port
309           }
310           await checkCommentNotification(servers[ 0 ], comment, 'presence')
311         }
312       })
313     })
314
315     describe('When managing server blocklist', function () {
316       it('Should list all videos', function () {
317         return checkAllVideos(servers[ 0 ].url, servers[ 0 ].accessToken)
318       })
319
320       it('Should list the comments', function () {
321         return checkAllComments(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID1)
322       })
323
324       it('Should block a remote server', async function () {
325         await addServerToAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port)
326       })
327
328       it('Should hide its videos', async function () {
329         const res = await getVideosListWithToken(servers[ 0 ].url, servers[ 0 ].accessToken)
330
331         const videos: Video[] = res.body.data
332         expect(videos).to.have.lengthOf(2)
333
334         const v1 = videos.find(v => v.name === 'video user 2')
335         const v2 = videos.find(v => v.name === 'video server 2')
336
337         expect(v1).to.be.undefined
338         expect(v2).to.be.undefined
339       })
340
341       it('Should list all the videos with another user', async function () {
342         return checkAllVideos(servers[ 0 ].url, userToken1)
343       })
344
345       it('Should hide its comments', async function () {
346         this.timeout(10000)
347
348         const resThreads = await addVideoCommentThread(servers[ 1 ].url, userToken2, videoUUID1, 'hidden comment 2')
349         const threadId = resThreads.body.comment.id
350
351         await waitJobs(servers)
352
353         await checkAllComments(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID1)
354
355         await deleteVideoComment(servers[ 1 ].url, userToken2, videoUUID1, threadId)
356       })
357
358       it('Should not have notifications from blocked server', async function () {
359         this.timeout(20000)
360
361         {
362           const comment = { server: servers[ 1 ], token: userToken2, videoUUID: videoUUID1, text: 'hidden comment' }
363           await checkCommentNotification(servers[ 0 ], comment, 'absence')
364         }
365
366         {
367           const comment = {
368             server: servers[ 1 ],
369             token: userToken2,
370             videoUUID: videoUUID1,
371             text: 'hello @root@localhost:' + servers[ 0 ].port
372           }
373           await checkCommentNotification(servers[ 0 ], comment, 'absence')
374         }
375       })
376
377       it('Should list blocked servers', async function () {
378         const res = await getServerBlocklistByAccount(servers[ 0 ].url, servers[ 0 ].accessToken, 0, 1, 'createdAt')
379         const blocks: ServerBlock[] = res.body.data
380
381         expect(res.body.total).to.equal(1)
382
383         const block = blocks[ 0 ]
384         expect(block.byAccount.displayName).to.equal('root')
385         expect(block.byAccount.name).to.equal('root')
386         expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port)
387       })
388
389       it('Should unblock the remote server', async function () {
390         await removeServerFromAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port)
391       })
392
393       it('Should display its videos', function () {
394         return checkAllVideos(servers[ 0 ].url, servers[ 0 ].accessToken)
395       })
396
397       it('Should display its comments', function () {
398         return checkAllComments(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID1)
399       })
400
401       it('Should have notification from unblocked server', async function () {
402         this.timeout(20000)
403
404         {
405           const comment = { server: servers[ 1 ], token: userToken2, videoUUID: videoUUID1, text: 'displayed comment' }
406           await checkCommentNotification(servers[ 0 ], comment, 'presence')
407         }
408
409         {
410           const comment = {
411             server: servers[ 1 ],
412             token: userToken2,
413             videoUUID: videoUUID1,
414             text: 'hello @root@localhost:' + servers[ 0 ].port
415           }
416           await checkCommentNotification(servers[ 0 ], comment, 'presence')
417         }
418       })
419     })
420   })
421
422   describe('Server blocklist', function () {
423
424     describe('When managing account blocklist', function () {
425       it('Should list all videos', async function () {
426         for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
427           await checkAllVideos(servers[ 0 ].url, token)
428         }
429       })
430
431       it('Should list the comments', async function () {
432         for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
433           await checkAllComments(servers[ 0 ].url, token, videoUUID1)
434         }
435       })
436
437       it('Should block a remote account', async function () {
438         await addAccountToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:' + servers[1].port)
439       })
440
441       it('Should hide its videos', async function () {
442         for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
443           const res = await getVideosListWithToken(servers[ 0 ].url, token)
444
445           const videos: Video[] = res.body.data
446           expect(videos).to.have.lengthOf(3)
447
448           const v = videos.find(v => v.name === 'video user 2')
449           expect(v).to.be.undefined
450         }
451       })
452
453       it('Should block a local account', async function () {
454         await addAccountToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user1')
455       })
456
457       it('Should hide its videos', async function () {
458         for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
459           const res = await getVideosListWithToken(servers[ 0 ].url, token)
460
461           const videos: Video[] = res.body.data
462           expect(videos).to.have.lengthOf(2)
463
464           const v = videos.find(v => v.name === 'video user 1')
465           expect(v).to.be.undefined
466         }
467       })
468
469       it('Should hide its comments', async function () {
470         for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
471           const resThreads = await getVideoCommentThreads(servers[ 0 ].url, videoUUID1, 0, 5, '-createdAt', token)
472
473           const threads: VideoComment[] = resThreads.body.data
474           expect(threads).to.have.lengthOf(1)
475           expect(threads[ 0 ].totalReplies).to.equal(0)
476
477           const t = threads.find(t => t.text === 'comment user 1')
478           expect(t).to.be.undefined
479
480           for (const thread of threads) {
481             const res = await getVideoThreadComments(servers[ 0 ].url, videoUUID1, thread.id, token)
482
483             const tree: VideoCommentThreadTree = res.body
484             expect(tree.children).to.have.lengthOf(0)
485           }
486         }
487       })
488
489       it('Should not have notification from blocked accounts by instance', async function () {
490         this.timeout(20000)
491
492         {
493           const comment = { server: servers[ 0 ], token: userToken1, videoUUID: videoUUID1, text: 'hidden comment' }
494           await checkCommentNotification(servers[ 0 ], comment, 'absence')
495         }
496
497         {
498           const comment = {
499             server: servers[ 1 ],
500             token: userToken2,
501             videoUUID: videoUUID1,
502             text: 'hello @root@localhost:' + servers[ 0 ].port
503           }
504           await checkCommentNotification(servers[ 0 ], comment, 'absence')
505         }
506       })
507
508       it('Should list blocked accounts', async function () {
509         {
510           const res = await getAccountBlocklistByServer(servers[ 0 ].url, servers[ 0 ].accessToken, 0, 1, 'createdAt')
511           const blocks: AccountBlock[] = res.body.data
512
513           expect(res.body.total).to.equal(2)
514
515           const block = blocks[ 0 ]
516           expect(block.byAccount.displayName).to.equal('peertube')
517           expect(block.byAccount.name).to.equal('peertube')
518           expect(block.blockedAccount.displayName).to.equal('user2')
519           expect(block.blockedAccount.name).to.equal('user2')
520           expect(block.blockedAccount.host).to.equal('localhost:' + servers[1].port)
521         }
522
523         {
524           const res = await getAccountBlocklistByServer(servers[ 0 ].url, servers[ 0 ].accessToken, 1, 2, 'createdAt')
525           const blocks: AccountBlock[] = res.body.data
526
527           expect(res.body.total).to.equal(2)
528
529           const block = blocks[ 0 ]
530           expect(block.byAccount.displayName).to.equal('peertube')
531           expect(block.byAccount.name).to.equal('peertube')
532           expect(block.blockedAccount.displayName).to.equal('user1')
533           expect(block.blockedAccount.name).to.equal('user1')
534           expect(block.blockedAccount.host).to.equal('localhost:' + servers[0].port)
535         }
536       })
537
538       it('Should unblock the remote account', async function () {
539         await removeAccountFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:' + servers[1].port)
540       })
541
542       it('Should display its videos', async function () {
543         for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
544           const res = await getVideosListWithToken(servers[ 0 ].url, token)
545
546           const videos: Video[] = res.body.data
547           expect(videos).to.have.lengthOf(3)
548
549           const v = videos.find(v => v.name === 'video user 2')
550           expect(v).not.to.be.undefined
551         }
552       })
553
554       it('Should unblock the local account', async function () {
555         await removeAccountFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user1')
556       })
557
558       it('Should display its comments', async function () {
559         for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
560           await checkAllComments(servers[ 0 ].url, token, videoUUID1)
561         }
562       })
563
564       it('Should have notifications from unblocked accounts', async function () {
565         this.timeout(20000)
566
567         {
568           const comment = { server: servers[ 0 ], token: userToken1, videoUUID: videoUUID1, text: 'displayed comment' }
569           await checkCommentNotification(servers[ 0 ], comment, 'presence')
570         }
571
572         {
573           const comment = {
574             server: servers[ 1 ],
575             token: userToken2,
576             videoUUID: videoUUID1,
577             text: 'hello @root@localhost:' + servers[ 0 ].port
578           }
579           await checkCommentNotification(servers[ 0 ], comment, 'presence')
580         }
581       })
582     })
583
584     describe('When managing server blocklist', function () {
585       it('Should list all videos', async function () {
586         for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
587           await checkAllVideos(servers[ 0 ].url, token)
588         }
589       })
590
591       it('Should list the comments', async function () {
592         for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
593           await checkAllComments(servers[ 0 ].url, token, videoUUID1)
594         }
595       })
596
597       it('Should block a remote server', async function () {
598         await addServerToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port)
599       })
600
601       it('Should hide its videos', async function () {
602         for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
603           const res1 = await getVideosList(servers[ 0 ].url)
604           const res2 = await getVideosListWithToken(servers[ 0 ].url, token)
605
606           for (const res of [ res1, res2 ]) {
607             const videos: Video[] = res.body.data
608             expect(videos).to.have.lengthOf(2)
609
610             const v1 = videos.find(v => v.name === 'video user 2')
611             const v2 = videos.find(v => v.name === 'video server 2')
612
613             expect(v1).to.be.undefined
614             expect(v2).to.be.undefined
615           }
616         }
617       })
618
619       it('Should hide its comments', async function () {
620         this.timeout(10000)
621
622         const resThreads = await addVideoCommentThread(servers[ 1 ].url, userToken2, videoUUID1, 'hidden comment 2')
623         const threadId = resThreads.body.comment.id
624
625         await waitJobs(servers)
626
627         await checkAllComments(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID1)
628
629         await deleteVideoComment(servers[ 1 ].url, userToken2, videoUUID1, threadId)
630       })
631
632       it('Should not have notification from blocked instances by instance', async function () {
633         this.timeout(20000)
634
635         {
636           const comment = { server: servers[ 1 ], token: userToken2, videoUUID: videoUUID1, text: 'hidden comment' }
637           await checkCommentNotification(servers[ 0 ], comment, 'absence')
638         }
639
640         {
641           const comment = {
642             server: servers[ 1 ],
643             token: userToken2,
644             videoUUID: videoUUID1,
645             text: 'hello @root@localhost:' + servers[ 0 ].port
646           }
647           await checkCommentNotification(servers[ 0 ], comment, 'absence')
648         }
649       })
650
651       it('Should list blocked servers', async function () {
652         const res = await getServerBlocklistByServer(servers[ 0 ].url, servers[ 0 ].accessToken, 0, 1, 'createdAt')
653         const blocks: ServerBlock[] = res.body.data
654
655         expect(res.body.total).to.equal(1)
656
657         const block = blocks[ 0 ]
658         expect(block.byAccount.displayName).to.equal('peertube')
659         expect(block.byAccount.name).to.equal('peertube')
660         expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port)
661       })
662
663       it('Should unblock the remote server', async function () {
664         await removeServerFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port)
665       })
666
667       it('Should list all videos', async function () {
668         for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
669           await checkAllVideos(servers[ 0 ].url, token)
670         }
671       })
672
673       it('Should list the comments', async function () {
674         for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
675           await checkAllComments(servers[ 0 ].url, token, videoUUID1)
676         }
677       })
678
679       it('Should have notification from unblocked instances', async function () {
680         this.timeout(20000)
681
682         {
683           const comment = { server: servers[ 1 ], token: userToken2, videoUUID: videoUUID1, text: 'displayed comment' }
684           await checkCommentNotification(servers[ 0 ], comment, 'presence')
685         }
686
687         {
688           const comment = {
689             server: servers[ 1 ],
690             token: userToken2,
691             videoUUID: videoUUID1,
692             text: 'hello @root@localhost:' + servers[ 0 ].port
693           }
694           await checkCommentNotification(servers[ 0 ], comment, 'presence')
695         }
696       })
697     })
698   })
699
700   after(async function () {
701     await cleanupTests(servers)
702   })
703 })