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,
19 getAccountBlocklistByAccount,
20 getAccountBlocklistByServer,
21 getServerBlocklistByAccount,
22 getServerBlocklistByServer,
24 getVideoCommentThreads,
26 getVideosListWithToken,
27 getVideoThreadComments,
28 removeAccountFromAccountBlocklist,
29 removeAccountFromServerBlocklist,
30 removeServerFromAccountBlocklist,
31 removeServerFromServerBlocklist,
33 setAccessTokensToServers,
38 } from '@shared/extra-utils'
46 VideoCommentThreadTree
47 } from '@shared/models'
49 const expect = chai.expect
51 async function checkAllVideos (url: string, token: string) {
53 const res = await getVideosListWithToken(url, token)
55 expect(res.body.data).to.have.lengthOf(5)
59 const res = await getVideosList(url)
61 expect(res.body.data).to.have.lengthOf(5)
65 async function checkAllComments (url: string, token: string, videoUUID: string) {
66 const resThreads = await getVideoCommentThreads(url, videoUUID, 0, 25, '-createdAt', token)
68 const allThreads: VideoComment[] = resThreads.body.data
69 const threads = allThreads.filter(t => t.isDeleted === false)
70 expect(threads).to.have.lengthOf(2)
72 for (const thread of threads) {
73 const res = await getVideoThreadComments(url, videoUUID, thread.id, token)
75 const tree: VideoCommentThreadTree = res.body
76 expect(tree.children).to.have.lengthOf(1)
80 async function checkCommentNotification (
81 mainServer: ServerInfo,
82 comment: { server: ServerInfo, token: string, videoUUID: string, text: string },
83 check: 'presence' | 'absence'
85 const resComment = await addVideoCommentThread(comment.server.url, comment.token, comment.videoUUID, comment.text)
86 const created = resComment.body.comment as VideoComment
87 const threadId = created.id
88 const createdAt = created.createdAt
90 await waitJobs([ mainServer, comment.server ])
92 const res = await getUserNotifications(mainServer.url, mainServer.accessToken, 0, 30)
93 const commentNotifications = (res.body.data as UserNotification[])
94 .filter(n => n.comment && n.comment.video.uuid === comment.videoUUID && n.createdAt >= createdAt)
96 if (check === 'presence') expect(commentNotifications).to.have.lengthOf(1)
97 else expect(commentNotifications).to.have.lengthOf(0)
99 await deleteVideoComment(comment.server.url, comment.token, comment.videoUUID, threadId)
101 await waitJobs([ mainServer, comment.server ])
104 describe('Test blocklist', function () {
105 let servers: ServerInfo[]
106 let videoUUID1: string
107 let videoUUID2: string
108 let videoUUID3: string
109 let userToken1: string
110 let userModeratorToken: string
111 let userToken2: string
113 before(async function () {
116 servers = await flushAndRunMultipleServers(3)
117 await setAccessTokensToServers(servers)
120 const user = { username: 'user1', password: 'password' }
121 await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
123 userToken1 = await userLogin(servers[0], user)
124 await uploadVideo(servers[0].url, userToken1, { name: 'video user 1' })
128 const user = { username: 'moderator', password: 'password' }
129 await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
131 userModeratorToken = await userLogin(servers[0], user)
135 const user = { username: 'user2', password: 'password' }
136 await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password })
138 userToken2 = await userLogin(servers[1], user)
139 await uploadVideo(servers[1].url, userToken2, { name: 'video user 2' })
143 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video server 1' })
144 videoUUID1 = res.body.video.uuid
148 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video server 2' })
149 videoUUID2 = res.body.video.uuid
153 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video 2 server 1' })
154 videoUUID3 = res.body.video.uuid
157 await doubleFollow(servers[0], servers[1])
158 await doubleFollow(servers[0], servers[2])
161 const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID1, 'comment root 1')
162 const resReply = await addVideoCommentReply(servers[0].url, userToken1, videoUUID1, resComment.body.comment.id, 'comment user 1')
163 await addVideoCommentReply(servers[0].url, servers[0].accessToken, videoUUID1, resReply.body.comment.id, 'comment root 1')
167 const resComment = await addVideoCommentThread(servers[0].url, userToken1, videoUUID1, 'comment user 1')
168 await addVideoCommentReply(servers[0].url, servers[0].accessToken, videoUUID1, resComment.body.comment.id, 'comment root 1')
171 await waitJobs(servers)
174 describe('User blocklist', function () {
176 describe('When managing account blocklist', function () {
177 it('Should list all videos', function () {
178 return checkAllVideos(servers[0].url, servers[0].accessToken)
181 it('Should list the comments', function () {
182 return checkAllComments(servers[0].url, servers[0].accessToken, videoUUID1)
185 it('Should block a remote account', async function () {
186 await addAccountToAccountBlocklist(servers[0].url, servers[0].accessToken, 'user2@localhost:' + servers[1].port)
189 it('Should hide its videos', async function () {
190 const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken)
192 const videos: Video[] = res.body.data
193 expect(videos).to.have.lengthOf(4)
195 const v = videos.find(v => v.name === 'video user 2')
196 expect(v).to.be.undefined
199 it('Should block a local account', async function () {
200 await addAccountToAccountBlocklist(servers[0].url, servers[0].accessToken, 'user1')
203 it('Should hide its videos', async function () {
204 const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken)
206 const videos: Video[] = res.body.data
207 expect(videos).to.have.lengthOf(3)
209 const v = videos.find(v => v.name === 'video user 1')
210 expect(v).to.be.undefined
213 it('Should hide its comments', async function () {
214 const resThreads = await getVideoCommentThreads(servers[0].url, videoUUID1, 0, 25, '-createdAt', servers[0].accessToken)
216 const threads: VideoComment[] = resThreads.body.data
217 expect(threads).to.have.lengthOf(1)
218 expect(threads[0].totalReplies).to.equal(1)
220 const t = threads.find(t => t.text === 'comment user 1')
221 expect(t).to.be.undefined
223 for (const thread of threads) {
224 const res = await getVideoThreadComments(servers[0].url, videoUUID1, thread.id, servers[0].accessToken)
226 const tree: VideoCommentThreadTree = res.body
227 expect(tree.children).to.have.lengthOf(0)
231 it('Should not have notifications from blocked accounts', async function () {
235 const comment = { server: servers[0], token: userToken1, videoUUID: videoUUID1, text: 'hidden comment' }
236 await checkCommentNotification(servers[0], comment, 'absence')
243 videoUUID: videoUUID2,
244 text: 'hello @root@localhost:' + servers[0].port
246 await checkCommentNotification(servers[0], comment, 'absence')
250 it('Should list all the videos with another user', async function () {
251 return checkAllVideos(servers[0].url, userToken1)
254 it('Should list blocked accounts', async function () {
256 const res = await getAccountBlocklistByAccount(servers[0].url, servers[0].accessToken, 0, 1, 'createdAt')
257 const blocks: AccountBlock[] = res.body.data
259 expect(res.body.total).to.equal(2)
261 const block = blocks[0]
262 expect(block.byAccount.displayName).to.equal('root')
263 expect(block.byAccount.name).to.equal('root')
264 expect(block.blockedAccount.displayName).to.equal('user2')
265 expect(block.blockedAccount.name).to.equal('user2')
266 expect(block.blockedAccount.host).to.equal('localhost:' + servers[1].port)
270 const res = await getAccountBlocklistByAccount(servers[0].url, servers[0].accessToken, 1, 2, 'createdAt')
271 const blocks: AccountBlock[] = res.body.data
273 expect(res.body.total).to.equal(2)
275 const block = blocks[0]
276 expect(block.byAccount.displayName).to.equal('root')
277 expect(block.byAccount.name).to.equal('root')
278 expect(block.blockedAccount.displayName).to.equal('user1')
279 expect(block.blockedAccount.name).to.equal('user1')
280 expect(block.blockedAccount.host).to.equal('localhost:' + servers[0].port)
284 it('Should not allow a remote blocked user to comment my videos', async function () {
288 await addVideoCommentThread(servers[1].url, userToken2, videoUUID3, 'comment user 2')
289 await waitJobs(servers)
291 await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID3, 'uploader')
292 await waitJobs(servers)
294 const commentId = await findCommentId(servers[1].url, videoUUID3, 'uploader')
295 const message = 'reply by user 2'
296 const resReply = await addVideoCommentReply(servers[1].url, userToken2, videoUUID3, commentId, message)
297 await addVideoCommentReply(servers[1].url, servers[1].accessToken, videoUUID3, resReply.body.comment.id, 'another reply')
299 await waitJobs(servers)
302 // Server 2 has all the comments
304 const resThreads = await getVideoCommentThreads(servers[1].url, videoUUID3, 0, 25, '-createdAt')
305 const threads: VideoComment[] = resThreads.body.data
307 expect(threads).to.have.lengthOf(2)
308 expect(threads[0].text).to.equal('uploader')
309 expect(threads[1].text).to.equal('comment user 2')
311 const resReplies = await getVideoThreadComments(servers[1].url, videoUUID3, threads[0].id)
313 const tree: VideoCommentThreadTree = resReplies.body
314 expect(tree.children).to.have.lengthOf(1)
315 expect(tree.children[0].comment.text).to.equal('reply by user 2')
316 expect(tree.children[0].children).to.have.lengthOf(1)
317 expect(tree.children[0].children[0].comment.text).to.equal('another reply')
320 // Server 1 and 3 should only have uploader comments
321 for (const server of [ servers[0], servers[2] ]) {
322 const resThreads = await getVideoCommentThreads(server.url, videoUUID3, 0, 25, '-createdAt')
323 const threads: VideoComment[] = resThreads.body.data
325 expect(threads).to.have.lengthOf(1)
326 expect(threads[0].text).to.equal('uploader')
328 const resReplies = await getVideoThreadComments(server.url, videoUUID3, threads[0].id)
330 const tree: VideoCommentThreadTree = resReplies.body
331 if (server.serverNumber === 1) {
332 expect(tree.children).to.have.lengthOf(0)
334 expect(tree.children).to.have.lengthOf(1)
339 it('Should unblock the remote account', async function () {
340 await removeAccountFromAccountBlocklist(servers[0].url, servers[0].accessToken, 'user2@localhost:' + servers[1].port)
343 it('Should display its videos', async function () {
344 const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken)
346 const videos: Video[] = res.body.data
347 expect(videos).to.have.lengthOf(4)
349 const v = videos.find(v => v.name === 'video user 2')
350 expect(v).not.to.be.undefined
353 it('Should display its comments on my video', async function () {
354 for (const server of servers) {
355 const resThreads = await getVideoCommentThreads(server.url, videoUUID3, 0, 25, '-createdAt')
356 const threads: VideoComment[] = resThreads.body.data
358 // Server 3 should not have 2 comment threads, because server 1 did not forward the server 2 comment
359 if (server.serverNumber === 3) {
360 expect(threads).to.have.lengthOf(1)
364 expect(threads).to.have.lengthOf(2)
365 expect(threads[0].text).to.equal('uploader')
366 expect(threads[1].text).to.equal('comment user 2')
368 const resReplies = await getVideoThreadComments(server.url, videoUUID3, threads[0].id)
370 const tree: VideoCommentThreadTree = resReplies.body
371 expect(tree.children).to.have.lengthOf(1)
372 expect(tree.children[0].comment.text).to.equal('reply by user 2')
373 expect(tree.children[0].children).to.have.lengthOf(1)
374 expect(tree.children[0].children[0].comment.text).to.equal('another reply')
378 it('Should unblock the local account', async function () {
379 await removeAccountFromAccountBlocklist(servers[0].url, servers[0].accessToken, 'user1')
382 it('Should display its comments', function () {
383 return checkAllComments(servers[0].url, servers[0].accessToken, videoUUID1)
386 it('Should have a notification from a non blocked account', async function () {
390 const comment = { server: servers[1], token: userToken2, videoUUID: videoUUID1, text: 'displayed comment' }
391 await checkCommentNotification(servers[0], comment, 'presence')
398 videoUUID: videoUUID2,
399 text: 'hello @root@localhost:' + servers[0].port
401 await checkCommentNotification(servers[0], comment, 'presence')
406 describe('When managing server blocklist', function () {
407 it('Should list all videos', function () {
408 return checkAllVideos(servers[0].url, servers[0].accessToken)
411 it('Should list the comments', function () {
412 return checkAllComments(servers[0].url, servers[0].accessToken, videoUUID1)
415 it('Should block a remote server', async function () {
416 await addServerToAccountBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port)
419 it('Should hide its videos', async function () {
420 const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken)
422 const videos: Video[] = res.body.data
423 expect(videos).to.have.lengthOf(3)
425 const v1 = videos.find(v => v.name === 'video user 2')
426 const v2 = videos.find(v => v.name === 'video server 2')
428 expect(v1).to.be.undefined
429 expect(v2).to.be.undefined
432 it('Should list all the videos with another user', async function () {
433 return checkAllVideos(servers[0].url, userToken1)
436 it('Should hide its comments', async function () {
439 const resThreads = await addVideoCommentThread(servers[1].url, userToken2, videoUUID1, 'hidden comment 2')
440 const threadId = resThreads.body.comment.id
442 await waitJobs(servers)
444 await checkAllComments(servers[0].url, servers[0].accessToken, videoUUID1)
446 await deleteVideoComment(servers[1].url, userToken2, videoUUID1, threadId)
449 it('Should not have notifications from blocked server', async function () {
453 const comment = { server: servers[1], token: userToken2, videoUUID: videoUUID1, text: 'hidden comment' }
454 await checkCommentNotification(servers[0], comment, 'absence')
461 videoUUID: videoUUID1,
462 text: 'hello @root@localhost:' + servers[0].port
464 await checkCommentNotification(servers[0], comment, 'absence')
468 it('Should list blocked servers', async function () {
469 const res = await getServerBlocklistByAccount(servers[0].url, servers[0].accessToken, 0, 1, 'createdAt')
470 const blocks: ServerBlock[] = res.body.data
472 expect(res.body.total).to.equal(1)
474 const block = blocks[0]
475 expect(block.byAccount.displayName).to.equal('root')
476 expect(block.byAccount.name).to.equal('root')
477 expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port)
480 it('Should unblock the remote server', async function () {
481 await removeServerFromAccountBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port)
484 it('Should display its videos', function () {
485 return checkAllVideos(servers[0].url, servers[0].accessToken)
488 it('Should display its comments', function () {
489 return checkAllComments(servers[0].url, servers[0].accessToken, videoUUID1)
492 it('Should have notification from unblocked server', async function () {
496 const comment = { server: servers[1], token: userToken2, videoUUID: videoUUID1, text: 'displayed comment' }
497 await checkCommentNotification(servers[0], comment, 'presence')
504 videoUUID: videoUUID1,
505 text: 'hello @root@localhost:' + servers[0].port
507 await checkCommentNotification(servers[0], comment, 'presence')
513 describe('Server blocklist', function () {
515 describe('When managing account blocklist', function () {
516 it('Should list all videos', async function () {
517 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
518 await checkAllVideos(servers[0].url, token)
522 it('Should list the comments', async function () {
523 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
524 await checkAllComments(servers[0].url, token, videoUUID1)
528 it('Should block a remote account', async function () {
529 await addAccountToServerBlocklist(servers[0].url, servers[0].accessToken, 'user2@localhost:' + servers[1].port)
532 it('Should hide its videos', async function () {
533 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
534 const res = await getVideosListWithToken(servers[0].url, token)
536 const videos: Video[] = res.body.data
537 expect(videos).to.have.lengthOf(4)
539 const v = videos.find(v => v.name === 'video user 2')
540 expect(v).to.be.undefined
544 it('Should block a local account', async function () {
545 await addAccountToServerBlocklist(servers[0].url, servers[0].accessToken, 'user1')
548 it('Should hide its videos', async function () {
549 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
550 const res = await getVideosListWithToken(servers[0].url, token)
552 const videos: Video[] = res.body.data
553 expect(videos).to.have.lengthOf(3)
555 const v = videos.find(v => v.name === 'video user 1')
556 expect(v).to.be.undefined
560 it('Should hide its comments', async function () {
561 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
562 const resThreads = await getVideoCommentThreads(servers[0].url, videoUUID1, 0, 20, '-createdAt', token)
564 let threads: VideoComment[] = resThreads.body.data
565 threads = threads.filter(t => t.isDeleted === false)
567 expect(threads).to.have.lengthOf(1)
568 expect(threads[0].totalReplies).to.equal(1)
570 const t = threads.find(t => t.text === 'comment user 1')
571 expect(t).to.be.undefined
573 for (const thread of threads) {
574 const res = await getVideoThreadComments(servers[0].url, videoUUID1, thread.id, token)
576 const tree: VideoCommentThreadTree = res.body
577 expect(tree.children).to.have.lengthOf(0)
582 it('Should not have notification from blocked accounts by instance', async function () {
586 const comment = { server: servers[0], token: userToken1, videoUUID: videoUUID1, text: 'hidden comment' }
587 await checkCommentNotification(servers[0], comment, 'absence')
594 videoUUID: videoUUID1,
595 text: 'hello @root@localhost:' + servers[0].port
597 await checkCommentNotification(servers[0], comment, 'absence')
601 it('Should list blocked accounts', async function () {
603 const res = await getAccountBlocklistByServer(servers[0].url, servers[0].accessToken, 0, 1, 'createdAt')
604 const blocks: AccountBlock[] = res.body.data
606 expect(res.body.total).to.equal(2)
608 const block = blocks[0]
609 expect(block.byAccount.displayName).to.equal('peertube')
610 expect(block.byAccount.name).to.equal('peertube')
611 expect(block.blockedAccount.displayName).to.equal('user2')
612 expect(block.blockedAccount.name).to.equal('user2')
613 expect(block.blockedAccount.host).to.equal('localhost:' + servers[1].port)
617 const res = await getAccountBlocklistByServer(servers[0].url, servers[0].accessToken, 1, 2, 'createdAt')
618 const blocks: AccountBlock[] = res.body.data
620 expect(res.body.total).to.equal(2)
622 const block = blocks[0]
623 expect(block.byAccount.displayName).to.equal('peertube')
624 expect(block.byAccount.name).to.equal('peertube')
625 expect(block.blockedAccount.displayName).to.equal('user1')
626 expect(block.blockedAccount.name).to.equal('user1')
627 expect(block.blockedAccount.host).to.equal('localhost:' + servers[0].port)
631 it('Should unblock the remote account', async function () {
632 await removeAccountFromServerBlocklist(servers[0].url, servers[0].accessToken, 'user2@localhost:' + servers[1].port)
635 it('Should display its videos', async function () {
636 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
637 const res = await getVideosListWithToken(servers[0].url, token)
639 const videos: Video[] = res.body.data
640 expect(videos).to.have.lengthOf(4)
642 const v = videos.find(v => v.name === 'video user 2')
643 expect(v).not.to.be.undefined
647 it('Should unblock the local account', async function () {
648 await removeAccountFromServerBlocklist(servers[0].url, servers[0].accessToken, 'user1')
651 it('Should display its comments', async function () {
652 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
653 await checkAllComments(servers[0].url, token, videoUUID1)
657 it('Should have notifications from unblocked accounts', async function () {
661 const comment = { server: servers[0], token: userToken1, videoUUID: videoUUID1, text: 'displayed comment' }
662 await checkCommentNotification(servers[0], comment, 'presence')
669 videoUUID: videoUUID1,
670 text: 'hello @root@localhost:' + servers[0].port
672 await checkCommentNotification(servers[0], comment, 'presence')
677 describe('When managing server blocklist', function () {
678 it('Should list all videos', async function () {
679 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
680 await checkAllVideos(servers[0].url, token)
684 it('Should list the comments', async function () {
685 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
686 await checkAllComments(servers[0].url, token, videoUUID1)
690 it('Should block a remote server', async function () {
691 await addServerToServerBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port)
694 it('Should hide its videos', async function () {
695 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
696 const res1 = await getVideosList(servers[0].url)
697 const res2 = await getVideosListWithToken(servers[0].url, token)
699 for (const res of [ res1, res2 ]) {
700 const videos: Video[] = res.body.data
701 expect(videos).to.have.lengthOf(3)
703 const v1 = videos.find(v => v.name === 'video user 2')
704 const v2 = videos.find(v => v.name === 'video server 2')
706 expect(v1).to.be.undefined
707 expect(v2).to.be.undefined
712 it('Should hide its comments', async function () {
715 const resThreads = await addVideoCommentThread(servers[1].url, userToken2, videoUUID1, 'hidden comment 2')
716 const threadId = resThreads.body.comment.id
718 await waitJobs(servers)
720 await checkAllComments(servers[0].url, servers[0].accessToken, videoUUID1)
722 await deleteVideoComment(servers[1].url, userToken2, videoUUID1, threadId)
725 it('Should not have notification from blocked instances by instance', async function () {
729 const comment = { server: servers[1], token: userToken2, videoUUID: videoUUID1, text: 'hidden comment' }
730 await checkCommentNotification(servers[0], comment, 'absence')
737 videoUUID: videoUUID1,
738 text: 'hello @root@localhost:' + servers[0].port
740 await checkCommentNotification(servers[0], comment, 'absence')
744 const now = new Date()
745 await unfollow(servers[1].url, servers[1].accessToken, servers[0])
746 await waitJobs(servers)
747 await follow(servers[1].url, [ servers[0].host ], servers[1].accessToken)
749 await waitJobs(servers)
751 const res = await getUserNotifications(servers[0].url, servers[0].accessToken, 0, 30)
752 const commentNotifications = (res.body.data as UserNotification[])
754 return n.type === UserNotificationType.NEW_INSTANCE_FOLLOWER &&
755 n.createdAt >= now.toISOString()
758 expect(commentNotifications).to.have.lengthOf(0)
762 it('Should list blocked servers', async function () {
763 const res = await getServerBlocklistByServer(servers[0].url, servers[0].accessToken, 0, 1, 'createdAt')
764 const blocks: ServerBlock[] = res.body.data
766 expect(res.body.total).to.equal(1)
768 const block = blocks[0]
769 expect(block.byAccount.displayName).to.equal('peertube')
770 expect(block.byAccount.name).to.equal('peertube')
771 expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port)
774 it('Should unblock the remote server', async function () {
775 await removeServerFromServerBlocklist(servers[0].url, servers[0].accessToken, 'localhost:' + servers[1].port)
778 it('Should list all videos', async function () {
779 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
780 await checkAllVideos(servers[0].url, token)
784 it('Should list the comments', async function () {
785 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
786 await checkAllComments(servers[0].url, token, videoUUID1)
790 it('Should have notification from unblocked instances', async function () {
794 const comment = { server: servers[1], token: userToken2, videoUUID: videoUUID1, text: 'displayed comment' }
795 await checkCommentNotification(servers[0], comment, 'presence')
802 videoUUID: videoUUID1,
803 text: 'hello @root@localhost:' + servers[0].port
805 await checkCommentNotification(servers[0], comment, 'presence')
809 const now = new Date()
810 await unfollow(servers[1].url, servers[1].accessToken, servers[0])
811 await waitJobs(servers)
812 await follow(servers[1].url, [ servers[0].host ], servers[1].accessToken)
814 await waitJobs(servers)
816 const res = await getUserNotifications(servers[0].url, servers[0].accessToken, 0, 30)
817 const commentNotifications = (res.body.data as UserNotification[])
819 return n.type === UserNotificationType.NEW_INSTANCE_FOLLOWER &&
820 n.createdAt >= now.toISOString()
823 expect(commentNotifications).to.have.lengthOf(1)
829 after(async function () {
830 await cleanupTests(servers)