1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import * as chai from 'chai'
5 import * as request from 'supertest'
6 import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
9 buildAbsoluteFixturePath,
11 checkVideoFilesWereRemoved,
17 flushAndRunMultipleServers,
25 setAccessTokensToServers,
33 } from '../../../../shared/extra-utils'
34 import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
37 addVideoCommentThread,
40 getVideoCommentThreads,
41 getVideoThreadComments
42 } from '../../../../shared/extra-utils/videos/video-comments'
43 import { VideoComment, VideoCommentThreadTree, VideoPrivacy } from '../../../../shared/models/videos'
45 const expect = chai.expect
47 describe('Test multiple servers', function () {
48 let servers: ServerInfo[] = []
51 let videoChannelId: number
53 before(async function () {
56 servers = await flushAndRunMultipleServers(3)
58 // Get the access tokens
59 await setAccessTokensToServers(servers)
62 const videoChannel = {
63 name: 'super_channel_name',
64 displayName: 'my channel',
65 description: 'super channel'
67 await addVideoChannel(servers[0].url, servers[0].accessToken, videoChannel)
68 const channelRes = await getVideoChannelsList(servers[0].url, 0, 1)
69 videoChannelId = channelRes.body.data[0].id
72 // Server 1 and server 2 follow each other
73 await doubleFollow(servers[0], servers[1])
74 // Server 1 and server 3 follow each other
75 await doubleFollow(servers[0], servers[2])
76 // Server 2 and server 3 follow each other
77 await doubleFollow(servers[1], servers[2])
80 it('Should not have videos for all servers', async function () {
81 for (const server of servers) {
82 const res = await getVideosList(server.url)
83 const videos = res.body.data
84 expect(videos).to.be.an('array')
85 expect(videos.length).to.equal(0)
89 describe('Should upload the video and propagate on each server', function () {
90 it('Should upload the video on server 1 and propagate on each server', async function () {
93 const videoAttributes = {
94 name: 'my super name for server 1',
99 description: 'my super description for server 1',
100 support: 'my super support text for server 1',
101 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
102 tags: [ 'tag1p1', 'tag2p1' ],
103 channelId: videoChannelId,
104 fixture: 'video_short1.webm'
106 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
108 await waitJobs(servers)
110 // All servers should have this video
111 let publishedAt: string = null
112 for (const server of servers) {
113 const isLocal = server.port === servers[0].port
114 const checkAttributes = {
115 name: 'my super name for server 1',
120 description: 'my super description for server 1',
121 support: 'my super support text for server 1',
122 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
125 host: 'localhost:' + servers[0].port
130 tags: [ 'tag1p1', 'tag2p1' ],
131 privacy: VideoPrivacy.PUBLIC,
132 commentsEnabled: true,
133 downloadEnabled: true,
135 displayName: 'my channel',
136 name: 'super_channel_name',
137 description: 'super channel',
140 fixture: 'video_short1.webm',
149 const res = await getVideosList(server.url)
150 const videos = res.body.data
151 expect(videos).to.be.an('array')
152 expect(videos.length).to.equal(1)
153 const video = videos[0]
155 await completeVideoCheck(server.url, video, checkAttributes)
156 publishedAt = video.publishedAt
160 it('Should upload the video on server 2 and propagate on each server', async function () {
165 password: 'super_password'
167 await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password })
168 const userAccessToken = await userLogin(servers[1], user)
170 const videoAttributes = {
171 name: 'my super name for server 2',
176 description: 'my super description for server 2',
177 support: 'my super support text for server 2',
178 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
179 fixture: 'video_short2.webm',
180 thumbnailfile: 'thumbnail.jpg',
181 previewfile: 'preview.jpg'
183 await uploadVideo(servers[1].url, userAccessToken, videoAttributes, HttpStatusCode.OK_200, 'resumable')
186 await waitJobs(servers)
188 // All servers should have this video
189 for (const server of servers) {
190 const isLocal = server.url === 'http://localhost:' + servers[1].port
191 const checkAttributes = {
192 name: 'my super name for server 2',
197 description: 'my super description for server 2',
198 support: 'my super support text for server 2',
201 host: 'localhost:' + servers[1].port
204 commentsEnabled: true,
205 downloadEnabled: true,
207 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
208 privacy: VideoPrivacy.PUBLIC,
210 displayName: 'Main user1 channel',
211 name: 'user1_channel',
212 description: 'super channel',
215 fixture: 'video_short2.webm',
234 thumbnailfile: 'thumbnail',
235 previewfile: 'preview'
238 const res = await getVideosList(server.url)
239 const videos = res.body.data
240 expect(videos).to.be.an('array')
241 expect(videos.length).to.equal(2)
242 const video = videos[1]
244 await completeVideoCheck(server.url, video, checkAttributes)
248 it('Should upload two videos on server 3 and propagate on each server', async function () {
251 const videoAttributes1 = {
252 name: 'my super name for server 3',
257 description: 'my super description for server 3',
258 support: 'my super support text for server 3',
260 fixture: 'video_short3.webm'
262 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes1)
264 const videoAttributes2 = {
265 name: 'my super name for server 3-2',
270 description: 'my super description for server 3-2',
271 support: 'my super support text for server 3-2',
272 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
273 fixture: 'video_short.webm'
275 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes2)
277 await waitJobs(servers)
279 // All servers should have this video
280 for (const server of servers) {
281 const isLocal = server.url === 'http://localhost:' + servers[2].port
282 const res = await getVideosList(server.url)
284 const videos = res.body.data
285 expect(videos).to.be.an('array')
286 expect(videos.length).to.equal(4)
288 // We not sure about the order of the two last uploads
291 if (videos[2].name === 'my super name for server 3') {
299 const checkAttributesVideo1 = {
300 name: 'my super name for server 3',
305 description: 'my super description for server 3',
306 support: 'my super support text for server 3',
309 host: 'localhost:' + servers[2].port
313 commentsEnabled: true,
314 downloadEnabled: true,
316 privacy: VideoPrivacy.PUBLIC,
318 displayName: 'Main root channel',
319 name: 'root_channel',
323 fixture: 'video_short3.webm',
331 await completeVideoCheck(server.url, video1, checkAttributesVideo1)
333 const checkAttributesVideo2 = {
334 name: 'my super name for server 3-2',
339 description: 'my super description for server 3-2',
340 support: 'my super support text for server 3-2',
343 host: 'localhost:' + servers[2].port
345 commentsEnabled: true,
346 downloadEnabled: true,
349 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
350 privacy: VideoPrivacy.PUBLIC,
352 displayName: 'Main root channel',
353 name: 'root_channel',
357 fixture: 'video_short.webm',
365 await completeVideoCheck(server.url, video2, checkAttributesVideo2)
370 describe('It should list local videos', function () {
371 it('Should list only local videos on server 1', async function () {
372 const { body } = await getLocalVideos(servers[0].url)
374 expect(body.total).to.equal(1)
375 expect(body.data).to.be.an('array')
376 expect(body.data.length).to.equal(1)
377 expect(body.data[0].name).to.equal('my super name for server 1')
380 it('Should list only local videos on server 2', async function () {
381 const { body } = await getLocalVideos(servers[1].url)
383 expect(body.total).to.equal(1)
384 expect(body.data).to.be.an('array')
385 expect(body.data.length).to.equal(1)
386 expect(body.data[0].name).to.equal('my super name for server 2')
389 it('Should list only local videos on server 3', async function () {
390 const { body } = await getLocalVideos(servers[2].url)
392 expect(body.total).to.equal(2)
393 expect(body.data).to.be.an('array')
394 expect(body.data.length).to.equal(2)
395 expect(body.data[0].name).to.equal('my super name for server 3')
396 expect(body.data[1].name).to.equal('my super name for server 3-2')
400 describe('Should seed the uploaded video', function () {
401 it('Should add the file 1 by asking server 3', async function () {
404 const res = await getVideosList(servers[2].url)
406 const video = res.body.data[0]
407 toRemove.push(res.body.data[2])
408 toRemove.push(res.body.data[3])
410 const res2 = await getVideo(servers[2].url, video.id)
411 const videoDetails = res2.body
413 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
414 expect(torrent.files).to.be.an('array')
415 expect(torrent.files.length).to.equal(1)
416 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
419 it('Should add the file 2 by asking server 1', async function () {
422 const res = await getVideosList(servers[0].url)
424 const video = res.body.data[1]
425 const res2 = await getVideo(servers[0].url, video.id)
426 const videoDetails = res2.body
428 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
429 expect(torrent.files).to.be.an('array')
430 expect(torrent.files.length).to.equal(1)
431 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
434 it('Should add the file 3 by asking server 2', async function () {
437 const res = await getVideosList(servers[1].url)
439 const video = res.body.data[2]
440 const res2 = await getVideo(servers[1].url, video.id)
441 const videoDetails = res2.body
443 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
444 expect(torrent.files).to.be.an('array')
445 expect(torrent.files.length).to.equal(1)
446 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
449 it('Should add the file 3-2 by asking server 1', async function () {
452 const res = await getVideosList(servers[0].url)
454 const video = res.body.data[3]
455 const res2 = await getVideo(servers[0].url, video.id)
456 const videoDetails = res2.body
458 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
459 expect(torrent.files).to.be.an('array')
460 expect(torrent.files.length).to.equal(1)
461 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
464 it('Should add the file 2 in 360p by asking server 1', async function () {
467 const res = await getVideosList(servers[0].url)
469 const video = res.body.data.find(v => v.name === 'my super name for server 2')
470 const res2 = await getVideo(servers[0].url, video.id)
471 const videoDetails = res2.body
473 const file = videoDetails.files.find(f => f.resolution.id === 360)
474 expect(file).not.to.be.undefined
476 const torrent = await webtorrentAdd(file.magnetUri)
477 expect(torrent.files).to.be.an('array')
478 expect(torrent.files.length).to.equal(1)
479 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
483 describe('Should update video views, likes and dislikes', function () {
484 let localVideosServer3 = []
485 let remoteVideosServer1 = []
486 let remoteVideosServer2 = []
487 let remoteVideosServer3 = []
489 before(async function () {
490 const res1 = await getVideosList(servers[0].url)
491 remoteVideosServer1 = res1.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
493 const res2 = await getVideosList(servers[1].url)
494 remoteVideosServer2 = res2.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
496 const res3 = await getVideosList(servers[2].url)
497 localVideosServer3 = res3.body.data.filter(video => video.isLocal === true).map(video => video.uuid)
498 remoteVideosServer3 = res3.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
501 it('Should view multiple videos on owned servers', async function () {
504 await viewVideo(servers[2].url, localVideosServer3[0])
507 await viewVideo(servers[2].url, localVideosServer3[0])
508 await viewVideo(servers[2].url, localVideosServer3[1])
512 await viewVideo(servers[2].url, localVideosServer3[0])
513 await viewVideo(servers[2].url, localVideosServer3[0])
515 await waitJobs(servers)
517 // Wait the repeatable job
520 await waitJobs(servers)
522 for (const server of servers) {
523 const res = await getVideosList(server.url)
525 const videos = res.body.data
526 const video0 = videos.find(v => v.uuid === localVideosServer3[0])
527 const video1 = videos.find(v => v.uuid === localVideosServer3[1])
529 expect(video0.views).to.equal(3)
530 expect(video1.views).to.equal(1)
534 it('Should view multiple videos on each servers', async function () {
537 const tasks: Promise<any>[] = []
538 tasks.push(viewVideo(servers[0].url, remoteVideosServer1[0]))
539 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
540 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
541 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[0]))
542 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
543 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
544 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
545 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
546 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
547 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
549 await Promise.all(tasks)
551 await waitJobs(servers)
553 // Wait the repeatable job
556 await waitJobs(servers)
558 let baseVideos = null
560 for (const server of servers) {
561 const res = await getVideosList(server.url)
563 const videos = res.body.data
565 // Initialize base videos for future comparisons
566 if (baseVideos === null) {
571 for (const baseVideo of baseVideos) {
572 const sameVideo = videos.find(video => video.name === baseVideo.name)
573 expect(baseVideo.views).to.equal(sameVideo.views)
578 it('Should like and dislikes videos on different services', async function () {
581 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
583 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'dislike')
585 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
586 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'like')
588 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'dislike')
589 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[1], 'dislike')
591 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like')
593 await waitJobs(servers)
596 let baseVideos = null
597 for (const server of servers) {
598 const res = await getVideosList(server.url)
600 const videos = res.body.data
602 // Initialize base videos for future comparisons
603 if (baseVideos === null) {
608 for (const baseVideo of baseVideos) {
609 const sameVideo = videos.find(video => video.name === baseVideo.name)
610 expect(baseVideo.likes).to.equal(sameVideo.likes)
611 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes)
617 describe('Should manipulate these videos', function () {
618 it('Should update the video 3 by asking server 3', async function () {
622 name: 'my super video updated',
627 description: 'my super description updated',
628 support: 'my super support text updated',
629 tags: [ 'tag_up_1', 'tag_up_2' ],
630 thumbnailfile: 'thumbnail.jpg',
631 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
632 previewfile: 'preview.jpg'
635 await updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes)
637 await waitJobs(servers)
640 it('Should have the video 3 updated on each server', async function () {
643 for (const server of servers) {
644 const res = await getVideosList(server.url)
646 const videos = res.body.data
647 const videoUpdated = videos.find(video => video.name === 'my super video updated')
648 expect(!!videoUpdated).to.be.true
650 const isLocal = server.url === 'http://localhost:' + servers[2].port
651 const checkAttributes = {
652 name: 'my super video updated',
657 description: 'my super description updated',
658 support: 'my super support text updated',
659 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
662 host: 'localhost:' + servers[2].port
666 commentsEnabled: true,
667 downloadEnabled: true,
668 tags: [ 'tag_up_1', 'tag_up_2' ],
669 privacy: VideoPrivacy.PUBLIC,
671 displayName: 'Main root channel',
672 name: 'root_channel',
676 fixture: 'video_short3.webm',
683 thumbnailfile: 'thumbnail',
684 previewfile: 'preview'
686 await completeVideoCheck(server.url, videoUpdated, checkAttributes)
690 it('Should remove the videos 3 and 3-2 by asking server 3', async function () {
693 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].id)
694 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[1].id)
696 await waitJobs(servers)
699 it('Should not have files of videos 3 and 3-2 on each server', async function () {
700 for (const server of servers) {
701 await checkVideoFilesWereRemoved(toRemove[0].uuid, server.internalServerNumber)
702 await checkVideoFilesWereRemoved(toRemove[1].uuid, server.internalServerNumber)
706 it('Should have videos 1 and 3 on each server', async function () {
707 for (const server of servers) {
708 const res = await getVideosList(server.url)
710 const videos = res.body.data
711 expect(videos).to.be.an('array')
712 expect(videos.length).to.equal(2)
713 expect(videos[0].name).not.to.equal(videos[1].name)
714 expect(videos[0].name).not.to.equal(toRemove[0].name)
715 expect(videos[1].name).not.to.equal(toRemove[0].name)
716 expect(videos[0].name).not.to.equal(toRemove[1].name)
717 expect(videos[1].name).not.to.equal(toRemove[1].name)
719 videoUUID = videos.find(video => video.name === 'my super name for server 1').uuid
723 it('Should get the same video by UUID on each server', async function () {
725 for (const server of servers) {
726 const res = await getVideo(server.url, videoUUID)
728 const video = res.body
730 if (baseVideo === null) {
735 expect(baseVideo.name).to.equal(video.name)
736 expect(baseVideo.uuid).to.equal(video.uuid)
737 expect(baseVideo.category.id).to.equal(video.category.id)
738 expect(baseVideo.language.id).to.equal(video.language.id)
739 expect(baseVideo.licence.id).to.equal(video.licence.id)
740 expect(baseVideo.nsfw).to.equal(video.nsfw)
741 expect(baseVideo.account.name).to.equal(video.account.name)
742 expect(baseVideo.account.displayName).to.equal(video.account.displayName)
743 expect(baseVideo.account.url).to.equal(video.account.url)
744 expect(baseVideo.account.host).to.equal(video.account.host)
745 expect(baseVideo.tags).to.deep.equal(video.tags)
749 it('Should get the preview from each server', async function () {
750 for (const server of servers) {
751 const res = await getVideo(server.url, videoUUID)
752 const video = res.body
754 await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
759 describe('Should comment these videos', function () {
760 let childOfFirstChild: VideoCommentThreadTree
762 it('Should add comment (threads and replies)', async function () {
766 const text = 'my super first comment'
767 await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, text)
771 const text = 'my super second comment'
772 await addVideoCommentThread(servers[2].url, servers[2].accessToken, videoUUID, text)
775 await waitJobs(servers)
778 const threadId = await findCommentId(servers[1].url, videoUUID, 'my super first comment')
780 const text = 'my super answer to thread 1'
781 await addVideoCommentReply(servers[1].url, servers[1].accessToken, videoUUID, threadId, text)
784 await waitJobs(servers)
787 const threadId = await findCommentId(servers[2].url, videoUUID, 'my super first comment')
789 const res2 = await getVideoThreadComments(servers[2].url, videoUUID, threadId)
790 const childCommentId = res2.body.children[0].comment.id
792 const text3 = 'my second answer to thread 1'
793 await addVideoCommentReply(servers[2].url, servers[2].accessToken, videoUUID, threadId, text3)
795 const text2 = 'my super answer to answer of thread 1'
796 await addVideoCommentReply(servers[2].url, servers[2].accessToken, videoUUID, childCommentId, text2)
799 await waitJobs(servers)
802 it('Should have these threads', async function () {
803 for (const server of servers) {
804 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
806 expect(res.body.total).to.equal(2)
807 expect(res.body.data).to.be.an('array')
808 expect(res.body.data).to.have.lengthOf(2)
811 const comment: VideoComment = res.body.data.find(c => c.text === 'my super first comment')
812 expect(comment).to.not.be.undefined
813 expect(comment.inReplyToCommentId).to.be.null
814 expect(comment.account.name).to.equal('root')
815 expect(comment.account.host).to.equal('localhost:' + servers[0].port)
816 expect(comment.totalReplies).to.equal(3)
817 expect(dateIsValid(comment.createdAt as string)).to.be.true
818 expect(dateIsValid(comment.updatedAt as string)).to.be.true
822 const comment: VideoComment = res.body.data.find(c => c.text === 'my super second comment')
823 expect(comment).to.not.be.undefined
824 expect(comment.inReplyToCommentId).to.be.null
825 expect(comment.account.name).to.equal('root')
826 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
827 expect(comment.totalReplies).to.equal(0)
828 expect(dateIsValid(comment.createdAt as string)).to.be.true
829 expect(dateIsValid(comment.updatedAt as string)).to.be.true
834 it('Should have these comments', async function () {
835 for (const server of servers) {
836 const res1 = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
837 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
839 const res2 = await getVideoThreadComments(server.url, videoUUID, threadId)
841 const tree: VideoCommentThreadTree = res2.body
842 expect(tree.comment.text).equal('my super first comment')
843 expect(tree.comment.account.name).equal('root')
844 expect(tree.comment.account.host).equal('localhost:' + servers[0].port)
845 expect(tree.children).to.have.lengthOf(2)
847 const firstChild = tree.children[0]
848 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
849 expect(firstChild.comment.account.name).equal('root')
850 expect(firstChild.comment.account.host).equal('localhost:' + servers[1].port)
851 expect(firstChild.children).to.have.lengthOf(1)
853 childOfFirstChild = firstChild.children[0]
854 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
855 expect(childOfFirstChild.comment.account.name).equal('root')
856 expect(childOfFirstChild.comment.account.host).equal('localhost:' + servers[2].port)
857 expect(childOfFirstChild.children).to.have.lengthOf(0)
859 const secondChild = tree.children[1]
860 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
861 expect(secondChild.comment.account.name).equal('root')
862 expect(secondChild.comment.account.host).equal('localhost:' + servers[2].port)
863 expect(secondChild.children).to.have.lengthOf(0)
867 it('Should delete a reply', async function () {
870 await deleteVideoComment(servers[2].url, servers[2].accessToken, videoUUID, childOfFirstChild.comment.id)
872 await waitJobs(servers)
875 it('Should have this comment marked as deleted', async function () {
876 for (const server of servers) {
877 const res1 = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
878 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
880 const res2 = await getVideoThreadComments(server.url, videoUUID, threadId)
882 const tree: VideoCommentThreadTree = res2.body
883 expect(tree.comment.text).equal('my super first comment')
885 const firstChild = tree.children[0]
886 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
887 expect(firstChild.children).to.have.lengthOf(1)
889 const deletedComment = firstChild.children[0].comment
890 expect(deletedComment.isDeleted).to.be.true
891 expect(deletedComment.deletedAt).to.not.be.null
892 expect(deletedComment.account).to.be.null
893 expect(deletedComment.text).to.equal('')
895 const secondChild = tree.children[1]
896 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
900 it('Should delete the thread comments', async function () {
903 const res = await getVideoCommentThreads(servers[0].url, videoUUID, 0, 5)
904 const threadId = res.body.data.find(c => c.text === 'my super first comment').id
905 await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId)
907 await waitJobs(servers)
910 it('Should have the threads marked as deleted on other servers too', async function () {
911 for (const server of servers) {
912 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
914 expect(res.body.total).to.equal(2)
915 expect(res.body.data).to.be.an('array')
916 expect(res.body.data).to.have.lengthOf(2)
919 const comment: VideoComment = res.body.data[0]
920 expect(comment).to.not.be.undefined
921 expect(comment.inReplyToCommentId).to.be.null
922 expect(comment.account.name).to.equal('root')
923 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
924 expect(comment.totalReplies).to.equal(0)
925 expect(dateIsValid(comment.createdAt as string)).to.be.true
926 expect(dateIsValid(comment.updatedAt as string)).to.be.true
930 const deletedComment: VideoComment = res.body.data[1]
931 expect(deletedComment).to.not.be.undefined
932 expect(deletedComment.isDeleted).to.be.true
933 expect(deletedComment.deletedAt).to.not.be.null
934 expect(deletedComment.text).to.equal('')
935 expect(deletedComment.inReplyToCommentId).to.be.null
936 expect(deletedComment.account).to.be.null
937 expect(deletedComment.totalReplies).to.equal(2)
938 expect(dateIsValid(deletedComment.createdAt as string)).to.be.true
939 expect(dateIsValid(deletedComment.updatedAt as string)).to.be.true
940 expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true
945 it('Should delete a remote thread by the origin server', async function () {
948 const res = await getVideoCommentThreads(servers[0].url, videoUUID, 0, 5)
949 const threadId = res.body.data.find(c => c.text === 'my super second comment').id
950 await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId)
952 await waitJobs(servers)
955 it('Should have the threads marked as deleted on other servers too', async function () {
956 for (const server of servers) {
957 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
959 expect(res.body.total).to.equal(2)
960 expect(res.body.data).to.have.lengthOf(2)
963 const comment: VideoComment = res.body.data[0]
964 expect(comment.text).to.equal('')
965 expect(comment.isDeleted).to.be.true
966 expect(comment.createdAt).to.not.be.null
967 expect(comment.deletedAt).to.not.be.null
968 expect(comment.account).to.be.null
969 expect(comment.totalReplies).to.equal(0)
973 const comment: VideoComment = res.body.data[1]
974 expect(comment.text).to.equal('')
975 expect(comment.isDeleted).to.be.true
976 expect(comment.createdAt).to.not.be.null
977 expect(comment.deletedAt).to.not.be.null
978 expect(comment.account).to.be.null
979 expect(comment.totalReplies).to.equal(2)
984 it('Should disable comments and download', async function () {
988 commentsEnabled: false,
989 downloadEnabled: false
992 await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, attributes)
994 await waitJobs(servers)
996 for (const server of servers) {
997 const res = await getVideo(server.url, videoUUID)
998 expect(res.body.commentsEnabled).to.be.false
999 expect(res.body.downloadEnabled).to.be.false
1001 const text = 'my super forbidden comment'
1002 await addVideoCommentThread(server.url, server.accessToken, videoUUID, text, HttpStatusCode.CONFLICT_409)
1007 describe('With minimum parameters', function () {
1008 it('Should upload and propagate the video', async function () {
1011 const path = '/api/v1/videos/upload'
1013 const req = request(servers[1].url)
1015 .set('Accept', 'application/json')
1016 .set('Authorization', 'Bearer ' + servers[1].accessToken)
1017 .field('name', 'minimum parameters')
1018 .field('privacy', '1')
1019 .field('channelId', '1')
1021 await req.attach('videofile', buildAbsoluteFixturePath('video_short.webm'))
1022 .expect(HttpStatusCode.OK_200)
1024 await waitJobs(servers)
1026 for (const server of servers) {
1027 const res = await getVideosList(server.url)
1028 const video = res.body.data.find(v => v.name === 'minimum parameters')
1030 const isLocal = server.url === 'http://localhost:' + servers[1].port
1031 const checkAttributes = {
1032 name: 'minimum parameters',
1041 host: 'localhost:' + servers[1].port
1045 commentsEnabled: true,
1046 downloadEnabled: true,
1048 privacy: VideoPrivacy.PUBLIC,
1050 displayName: 'Main root channel',
1051 name: 'root_channel',
1055 fixture: 'video_short.webm',
1075 await completeVideoCheck(server.url, video, checkAttributes)
1080 describe('TMP directory', function () {
1081 it('Should have an empty tmp directory', async function () {
1082 for (const server of servers) {
1083 await checkTmpIsEmpty(server)
1088 after(async function () {
1089 await cleanupTests(servers)