1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import * as chai from 'chai'
6 addAccountToAccountBlocklist,
7 addAccountToServerBlocklist,
8 addServerToAccountBlocklist,
9 addServerToServerBlocklist,
11 addVideoCommentThread,
17 flushAndRunMultipleServers,
18 getAccountBlocklistByAccount,
19 getAccountBlocklistByServer,
20 getServerBlocklistByAccount,
21 getServerBlocklistByServer,
23 getVideoCommentThreads,
25 getVideosListWithToken,
26 getVideoThreadComments,
27 removeAccountFromAccountBlocklist,
28 removeAccountFromServerBlocklist,
29 removeServerFromAccountBlocklist,
30 removeServerFromServerBlocklist,
32 setAccessTokensToServers,
36 } from '@shared/extra-utils'
44 VideoCommentThreadTree
45 } from '@shared/models'
47 const expect = chai.expect
49 async function checkAllVideos (url: string, token: string) {
51 const res = await getVideosListWithToken(url, token)
53 expect(res.body.data).to.have.lengthOf(5)
57 const res = await getVideosList(url)
59 expect(res.body.data).to.have.lengthOf(5)
63 async function checkAllComments (url: string, token: string, videoUUID: string) {
64 const resThreads = await getVideoCommentThreads(url, videoUUID, 0, 25, '-createdAt', token)
66 const allThreads: VideoComment[] = resThreads.body.data
67 const threads = allThreads.filter(t => t.isDeleted === false)
68 expect(threads).to.have.lengthOf(2)
70 for (const thread of threads) {
71 const res = await getVideoThreadComments(url, videoUUID, thread.id, token)
73 const tree: VideoCommentThreadTree = res.body
74 expect(tree.children).to.have.lengthOf(1)
78 async function checkCommentNotification (
79 mainServer: ServerInfo,
80 comment: { server: ServerInfo, token: string, videoUUID: string, text: string },
81 check: 'presence' | 'absence'
83 const resComment = await addVideoCommentThread(comment.server.url, comment.token, comment.videoUUID, comment.text)
84 const created = resComment.body.comment as VideoComment
85 const threadId = created.id
86 const createdAt = created.createdAt
88 await waitJobs([ mainServer, comment.server ])
90 const res = await getUserNotifications(mainServer.url, mainServer.accessToken, 0, 30)
91 const commentNotifications = (res.body.data as UserNotification[])
92 .filter(n => n.comment && n.comment.video.uuid === comment.videoUUID && n.createdAt >= createdAt)
94 if (check === 'presence') expect(commentNotifications).to.have.lengthOf(1)
95 else expect(commentNotifications).to.have.lengthOf(0)
97 await deleteVideoComment(comment.server.url, comment.token, comment.videoUUID, threadId)
99 await waitJobs([ mainServer, comment.server ])
102 describe('Test blocklist', function () {
103 let servers: ServerInfo[]
104 let videoUUID1: string
105 let videoUUID2: string
106 let videoUUID3: string
107 let userToken1: string
108 let userModeratorToken: string
109 let userToken2: string
111 before(async function () {
114 servers = await flushAndRunMultipleServers(3)
115 await setAccessTokensToServers(servers)
118 const user = { username: 'user1', password: 'password' }
119 await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
121 userToken1 = await userLogin(servers[0], user)
122 await uploadVideo(servers[0].url, userToken1, { name: 'video user 1' })
126 const user = { username: 'moderator', password: 'password' }
127 await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
129 userModeratorToken = await userLogin(servers[0], user)
133 const user = { username: 'user2', password: 'password' }
134 await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password })
136 userToken2 = await userLogin(servers[1], user)
137 await uploadVideo(servers[1].url, userToken2, { name: 'video user 2' })
141 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video server 1' })
142 videoUUID1 = res.body.video.uuid
146 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video server 2' })
147 videoUUID2 = res.body.video.uuid
151 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video 2 server 1' })
152 videoUUID3 = res.body.video.uuid
155 await doubleFollow(servers[0], servers[1])
156 await doubleFollow(servers[0], servers[2])
159 const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID1, 'comment root 1')
160 const resReply = await addVideoCommentReply(servers[0].url, userToken1, videoUUID1, resComment.body.comment.id, 'comment user 1')
161 await addVideoCommentReply(servers[0].url, servers[0].accessToken, videoUUID1, resReply.body.comment.id, 'comment root 1')
165 const resComment = await addVideoCommentThread(servers[0].url, userToken1, videoUUID1, 'comment user 1')
166 await addVideoCommentReply(servers[0].url, servers[0].accessToken, videoUUID1, resComment.body.comment.id, 'comment root 1')
169 await waitJobs(servers)
172 describe('User blocklist', function () {
174 describe('When managing account blocklist', function () {
175 it('Should list all videos', function () {
176 return checkAllVideos(servers[0].url, servers[0].accessToken)
179 it('Should list the comments', function () {
180 return checkAllComments(servers[0].url, servers[0].accessToken, videoUUID1)
183 it('Should block a remote account', async function () {
184 await addAccountToAccountBlocklist(servers[0].url, servers[0].accessToken, 'user2@localhost:' + servers[1].port)
187 it('Should hide its videos', async function () {
188 const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken)
190 const videos: Video[] = res.body.data
191 expect(videos).to.have.lengthOf(4)
193 const v = videos.find(v => v.name === 'video user 2')
194 expect(v).to.be.undefined
197 it('Should block a local account', async function () {
198 await addAccountToAccountBlocklist(servers[0].url, servers[0].accessToken, 'user1')
201 it('Should hide its videos', async function () {
202 const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken)
204 const videos: Video[] = res.body.data
205 expect(videos).to.have.lengthOf(3)
207 const v = videos.find(v => v.name === 'video user 1')
208 expect(v).to.be.undefined
211 it('Should hide its comments', async function () {
212 const resThreads = await getVideoCommentThreads(servers[0].url, videoUUID1, 0, 25, '-createdAt', servers[0].accessToken)
214 const threads: VideoComment[] = resThreads.body.data
215 expect(threads).to.have.lengthOf(1)
216 expect(threads[0].totalReplies).to.equal(1)
218 const t = threads.find(t => t.text === 'comment user 1')
219 expect(t).to.be.undefined
221 for (const thread of threads) {
222 const res = await getVideoThreadComments(servers[0].url, videoUUID1, thread.id, servers[0].accessToken)
224 const tree: VideoCommentThreadTree = res.body
225 expect(tree.children).to.have.lengthOf(0)
229 it('Should not have notifications from blocked accounts', async function () {
233 const comment = { server: servers[0], token: userToken1, videoUUID: videoUUID1, text: 'hidden comment' }
234 await checkCommentNotification(servers[0], comment, 'absence')
241 videoUUID: videoUUID2,
242 text: 'hello @root@localhost:' + servers[0].port
244 await checkCommentNotification(servers[0], comment, 'absence')
248 it('Should list all the videos with another user', async function () {
249 return checkAllVideos(servers[0].url, userToken1)
252 it('Should list blocked accounts', async function () {
254 const res = await getAccountBlocklistByAccount(servers[0].url, servers[0].accessToken, 0, 1, 'createdAt')
255 const blocks: AccountBlock[] = res.body.data
257 expect(res.body.total).to.equal(2)
259 const block = blocks[0]
260 expect(block.byAccount.displayName).to.equal('root')
261 expect(block.byAccount.name).to.equal('root')
262 expect(block.blockedAccount.displayName).to.equal('user2')
263 expect(block.blockedAccount.name).to.equal('user2')
264 expect(block.blockedAccount.host).to.equal('localhost:' + servers[1].port)
268 const res = await getAccountBlocklistByAccount(servers[0].url, servers[0].accessToken, 1, 2, 'createdAt')
269 const blocks: AccountBlock[] = res.body.data
271 expect(res.body.total).to.equal(2)
273 const block = blocks[0]
274 expect(block.byAccount.displayName).to.equal('root')
275 expect(block.byAccount.name).to.equal('root')
276 expect(block.blockedAccount.displayName).to.equal('user1')
277 expect(block.blockedAccount.name).to.equal('user1')
278 expect(block.blockedAccount.host).to.equal('localhost:' + servers[0].port)
282 it('Should not allow a remote blocked user to comment my videos', async function () {
286 await addVideoCommentThread(servers[1].url, userToken2, videoUUID3, 'comment user 2')
287 await waitJobs(servers)
289 await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID3, 'uploader')
290 await waitJobs(servers)
292 const commentId = await findCommentId(servers[1].url, videoUUID3, 'uploader')
293 const message = 'reply by user 2'
294 const resReply = await addVideoCommentReply(servers[1].url, userToken2, videoUUID3, commentId, message)
295 await addVideoCommentReply(servers[1].url, servers[1].accessToken, videoUUID3, resReply.body.comment.id, 'another reply')
297 await waitJobs(servers)
300 // Server 2 has all the comments
302 const resThreads = await getVideoCommentThreads(servers[1].url, videoUUID3, 0, 25, '-createdAt')
303 const threads: VideoComment[] = resThreads.body.data
305 expect(threads).to.have.lengthOf(2)
306 expect(threads[0].text).to.equal('uploader')
307 expect(threads[1].text).to.equal('comment user 2')
309 const resReplies = await getVideoThreadComments(servers[1].url, videoUUID3, threads[0].id)
311 const tree: VideoCommentThreadTree = resReplies.body
312 expect(tree.children).to.have.lengthOf(1)
313 expect(tree.children[0].comment.text).to.equal('reply by user 2')
314 expect(tree.children[0].children).to.have.lengthOf(1)
315 expect(tree.children[0].children[0].comment.text).to.equal('another reply')
318 // Server 1 and 3 should only have uploader comments
319 for (const server of [ servers[0], servers[2] ]) {
320 const resThreads = await getVideoCommentThreads(server.url, videoUUID3, 0, 25, '-createdAt')
321 const threads: VideoComment[] = resThreads.body.data
323 expect(threads).to.have.lengthOf(1)
324 expect(threads[0].text).to.equal('uploader')
326 const resReplies = await getVideoThreadComments(server.url, videoUUID3, threads[0].id)
328 const tree: VideoCommentThreadTree = resReplies.body
329 if (server.serverNumber === 1) {
330 expect(tree.children).to.have.lengthOf(0)
332 expect(tree.children).to.have.lengthOf(1)
337 it('Should unblock the remote account', async function () {
338 await removeAccountFromAccountBlocklist(servers[0].url, servers[0].accessToken, 'user2@localhost:' + servers[1].port)
341 it('Should display its videos', async function () {
342 const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken)
344 const videos: Video[] = res.body.data
345 expect(videos).to.have.lengthOf(4)
347 const v = videos.find(v => v.name === 'video user 2')
348 expect(v).not.to.be.undefined
351 it('Should display its comments on my video', async function () {
352 for (const server of servers) {
353 const resThreads = await getVideoCommentThreads(server.url, videoUUID3, 0, 25, '-createdAt')
354 const threads: VideoComment[] = resThreads.body.data
356 // Server 3 should not have 2 comment threads, because server 1 did not forward the server 2 comment
357 if (server.serverNumber === 3) {
358 expect(threads).to.have.lengthOf(1)
362 expect(threads).to.have.lengthOf(2)
363 expect(threads[0].text).to.equal('uploader')
364 expect(threads[1].text).to.equal('comment user 2')
366 const resReplies = await getVideoThreadComments(server.url, videoUUID3, threads[0].id)
368 const tree: VideoCommentThreadTree = resReplies.body
369 expect(tree.children).to.have.lengthOf(1)
370 expect(tree.children[0].comment.text).to.equal('reply by user 2')
371 expect(tree.children[0].children).to.have.lengthOf(1)
372 expect(tree.children[0].children[0].comment.text).to.equal('another reply')
376 it('Should unblock the local account', async function () {
377 await removeAccountFromAccountBlocklist(servers[0].url, servers[0].accessToken, 'user1')
380 it('Should display its comments', function () {
381 return checkAllComments(servers[0].url, servers[0].accessToken, videoUUID1)
384 it('Should have a notification from a non blocked account', async function () {
388 const comment = { server: servers[1], token: userToken2, videoUUID: videoUUID1, text: 'displayed comment' }
389 await checkCommentNotification(servers[0], comment, 'presence')
396 videoUUID: videoUUID2,
397 text: 'hello @root@localhost:' + servers[0].port
399 await checkCommentNotification(servers[0], comment, 'presence')
404 describe('When managing server blocklist', function () {
405 it('Should list all videos', function () {
406 return checkAllVideos(servers[0].url, servers[0].accessToken)
409 it('Should list the comments', function () {
410 return checkAllComments(servers[0].url, servers[0].accessToken, videoUUID1)
413 it('Should block a remote server', async function () {
414 await addServerToAccountBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port)
417 it('Should hide its videos', async function () {
418 const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken)
420 const videos: Video[] = res.body.data
421 expect(videos).to.have.lengthOf(3)
423 const v1 = videos.find(v => v.name === 'video user 2')
424 const v2 = videos.find(v => v.name === 'video server 2')
426 expect(v1).to.be.undefined
427 expect(v2).to.be.undefined
430 it('Should list all the videos with another user', async function () {
431 return checkAllVideos(servers[0].url, userToken1)
434 it('Should hide its comments', async function () {
437 const resThreads = await addVideoCommentThread(servers[1].url, userToken2, videoUUID1, 'hidden comment 2')
438 const threadId = resThreads.body.comment.id
440 await waitJobs(servers)
442 await checkAllComments(servers[0].url, servers[0].accessToken, videoUUID1)
444 await deleteVideoComment(servers[1].url, userToken2, videoUUID1, threadId)
447 it('Should not have notifications from blocked server', async function () {
451 const comment = { server: servers[1], token: userToken2, videoUUID: videoUUID1, text: 'hidden comment' }
452 await checkCommentNotification(servers[0], comment, 'absence')
459 videoUUID: videoUUID1,
460 text: 'hello @root@localhost:' + servers[0].port
462 await checkCommentNotification(servers[0], comment, 'absence')
466 it('Should list blocked servers', async function () {
467 const res = await getServerBlocklistByAccount(servers[0].url, servers[0].accessToken, 0, 1, 'createdAt')
468 const blocks: ServerBlock[] = res.body.data
470 expect(res.body.total).to.equal(1)
472 const block = blocks[0]
473 expect(block.byAccount.displayName).to.equal('root')
474 expect(block.byAccount.name).to.equal('root')
475 expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port)
478 it('Should unblock the remote server', async function () {
479 await removeServerFromAccountBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port)
482 it('Should display its videos', function () {
483 return checkAllVideos(servers[0].url, servers[0].accessToken)
486 it('Should display its comments', function () {
487 return checkAllComments(servers[0].url, servers[0].accessToken, videoUUID1)
490 it('Should have notification from unblocked server', async function () {
494 const comment = { server: servers[1], token: userToken2, videoUUID: videoUUID1, text: 'displayed comment' }
495 await checkCommentNotification(servers[0], comment, 'presence')
502 videoUUID: videoUUID1,
503 text: 'hello @root@localhost:' + servers[0].port
505 await checkCommentNotification(servers[0], comment, 'presence')
511 describe('Server blocklist', function () {
513 describe('When managing account blocklist', function () {
514 it('Should list all videos', async function () {
515 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
516 await checkAllVideos(servers[0].url, token)
520 it('Should list the comments', async function () {
521 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
522 await checkAllComments(servers[0].url, token, videoUUID1)
526 it('Should block a remote account', async function () {
527 await addAccountToServerBlocklist(servers[0].url, servers[0].accessToken, 'user2@localhost:' + servers[1].port)
530 it('Should hide its videos', async function () {
531 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
532 const res = await getVideosListWithToken(servers[0].url, token)
534 const videos: Video[] = res.body.data
535 expect(videos).to.have.lengthOf(4)
537 const v = videos.find(v => v.name === 'video user 2')
538 expect(v).to.be.undefined
542 it('Should block a local account', async function () {
543 await addAccountToServerBlocklist(servers[0].url, servers[0].accessToken, 'user1')
546 it('Should hide its videos', async function () {
547 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
548 const res = await getVideosListWithToken(servers[0].url, token)
550 const videos: Video[] = res.body.data
551 expect(videos).to.have.lengthOf(3)
553 const v = videos.find(v => v.name === 'video user 1')
554 expect(v).to.be.undefined
558 it('Should hide its comments', async function () {
559 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
560 const resThreads = await getVideoCommentThreads(servers[0].url, videoUUID1, 0, 20, '-createdAt', token)
562 let threads: VideoComment[] = resThreads.body.data
563 threads = threads.filter(t => t.isDeleted === false)
565 expect(threads).to.have.lengthOf(1)
566 expect(threads[0].totalReplies).to.equal(1)
568 const t = threads.find(t => t.text === 'comment user 1')
569 expect(t).to.be.undefined
571 for (const thread of threads) {
572 const res = await getVideoThreadComments(servers[0].url, videoUUID1, thread.id, token)
574 const tree: VideoCommentThreadTree = res.body
575 expect(tree.children).to.have.lengthOf(0)
580 it('Should not have notification from blocked accounts by instance', async function () {
584 const comment = { server: servers[0], token: userToken1, videoUUID: videoUUID1, text: 'hidden comment' }
585 await checkCommentNotification(servers[0], comment, 'absence')
592 videoUUID: videoUUID1,
593 text: 'hello @root@localhost:' + servers[0].port
595 await checkCommentNotification(servers[0], comment, 'absence')
599 it('Should list blocked accounts', async function () {
601 const res = await getAccountBlocklistByServer(servers[0].url, servers[0].accessToken, 0, 1, 'createdAt')
602 const blocks: AccountBlock[] = res.body.data
604 expect(res.body.total).to.equal(2)
606 const block = blocks[0]
607 expect(block.byAccount.displayName).to.equal('peertube')
608 expect(block.byAccount.name).to.equal('peertube')
609 expect(block.blockedAccount.displayName).to.equal('user2')
610 expect(block.blockedAccount.name).to.equal('user2')
611 expect(block.blockedAccount.host).to.equal('localhost:' + servers[1].port)
615 const res = await getAccountBlocklistByServer(servers[0].url, servers[0].accessToken, 1, 2, 'createdAt')
616 const blocks: AccountBlock[] = res.body.data
618 expect(res.body.total).to.equal(2)
620 const block = blocks[0]
621 expect(block.byAccount.displayName).to.equal('peertube')
622 expect(block.byAccount.name).to.equal('peertube')
623 expect(block.blockedAccount.displayName).to.equal('user1')
624 expect(block.blockedAccount.name).to.equal('user1')
625 expect(block.blockedAccount.host).to.equal('localhost:' + servers[0].port)
629 it('Should unblock the remote account', async function () {
630 await removeAccountFromServerBlocklist(servers[0].url, servers[0].accessToken, 'user2@localhost:' + servers[1].port)
633 it('Should display its videos', async function () {
634 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
635 const res = await getVideosListWithToken(servers[0].url, token)
637 const videos: Video[] = res.body.data
638 expect(videos).to.have.lengthOf(4)
640 const v = videos.find(v => v.name === 'video user 2')
641 expect(v).not.to.be.undefined
645 it('Should unblock the local account', async function () {
646 await removeAccountFromServerBlocklist(servers[0].url, servers[0].accessToken, 'user1')
649 it('Should display its comments', async function () {
650 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
651 await checkAllComments(servers[0].url, token, videoUUID1)
655 it('Should have notifications from unblocked accounts', async function () {
659 const comment = { server: servers[0], token: userToken1, videoUUID: videoUUID1, text: 'displayed comment' }
660 await checkCommentNotification(servers[0], comment, 'presence')
667 videoUUID: videoUUID1,
668 text: 'hello @root@localhost:' + servers[0].port
670 await checkCommentNotification(servers[0], comment, 'presence')
675 describe('When managing server blocklist', function () {
676 it('Should list all videos', async function () {
677 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
678 await checkAllVideos(servers[0].url, token)
682 it('Should list the comments', async function () {
683 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
684 await checkAllComments(servers[0].url, token, videoUUID1)
688 it('Should block a remote server', async function () {
689 await addServerToServerBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port)
692 it('Should hide its videos', async function () {
693 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
694 const res1 = await getVideosList(servers[0].url)
695 const res2 = await getVideosListWithToken(servers[0].url, token)
697 for (const res of [ res1, res2 ]) {
698 const videos: Video[] = res.body.data
699 expect(videos).to.have.lengthOf(3)
701 const v1 = videos.find(v => v.name === 'video user 2')
702 const v2 = videos.find(v => v.name === 'video server 2')
704 expect(v1).to.be.undefined
705 expect(v2).to.be.undefined
710 it('Should hide its comments', async function () {
713 const resThreads = await addVideoCommentThread(servers[1].url, userToken2, videoUUID1, 'hidden comment 2')
714 const threadId = resThreads.body.comment.id
716 await waitJobs(servers)
718 await checkAllComments(servers[0].url, servers[0].accessToken, videoUUID1)
720 await deleteVideoComment(servers[1].url, userToken2, videoUUID1, threadId)
723 it('Should not have notification from blocked instances by instance', async function () {
727 const comment = { server: servers[1], token: userToken2, videoUUID: videoUUID1, text: 'hidden comment' }
728 await checkCommentNotification(servers[0], comment, 'absence')
735 videoUUID: videoUUID1,
736 text: 'hello @root@localhost:' + servers[0].port
738 await checkCommentNotification(servers[0], comment, 'absence')
742 const now = new Date()
743 await servers[1].followsCommand.unfollow({ target: servers[0] })
744 await waitJobs(servers)
745 await servers[1].followsCommand.follow({ targets: [ servers[0].host ] })
747 await waitJobs(servers)
749 const res = await getUserNotifications(servers[0].url, servers[0].accessToken, 0, 30)
750 const commentNotifications = (res.body.data as UserNotification[])
752 return n.type === UserNotificationType.NEW_INSTANCE_FOLLOWER &&
753 n.createdAt >= now.toISOString()
756 expect(commentNotifications).to.have.lengthOf(0)
760 it('Should list blocked servers', async function () {
761 const res = await getServerBlocklistByServer(servers[0].url, servers[0].accessToken, 0, 1, 'createdAt')
762 const blocks: ServerBlock[] = res.body.data
764 expect(res.body.total).to.equal(1)
766 const block = blocks[0]
767 expect(block.byAccount.displayName).to.equal('peertube')
768 expect(block.byAccount.name).to.equal('peertube')
769 expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port)
772 it('Should unblock the remote server', async function () {
773 await removeServerFromServerBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port)
776 it('Should list all videos', async function () {
777 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
778 await checkAllVideos(servers[0].url, token)
782 it('Should list the comments', async function () {
783 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
784 await checkAllComments(servers[0].url, token, videoUUID1)
788 it('Should have notification from unblocked instances', async function () {
792 const comment = { server: servers[1], token: userToken2, videoUUID: videoUUID1, text: 'displayed comment' }
793 await checkCommentNotification(servers[0], comment, 'presence')
800 videoUUID: videoUUID1,
801 text: 'hello @root@localhost:' + servers[0].port
803 await checkCommentNotification(servers[0], comment, 'presence')
807 const now = new Date()
808 await servers[1].followsCommand.unfollow({ target: servers[0] })
809 await waitJobs(servers)
810 await servers[1].followsCommand.follow({ targets: [ servers[0].host ] })
812 await waitJobs(servers)
814 const res = await getUserNotifications(servers[0].url, servers[0].accessToken, 0, 30)
815 const commentNotifications = (res.body.data as UserNotification[])
817 return n.type === UserNotificationType.NEW_INSTANCE_FOLLOWER &&
818 n.createdAt >= now.toISOString()
821 expect(commentNotifications).to.have.lengthOf(1)
827 after(async function () {
828 await cleanupTests(servers)