1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
3 import * as chai from 'chai'
5 import { join } from 'path'
6 import * as request from 'supertest'
7 import { VideoPrivacy } from '../../../../shared/models/videos'
8 import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
12 checkVideoFilesWereRemoved,
18 flushAndRunMultipleServers,
26 setAccessTokensToServers,
34 } from '../../../../shared/extra-utils'
37 addVideoCommentThread,
39 getVideoCommentThreads,
40 getVideoThreadComments,
42 } from '../../../../shared/extra-utils/videos/video-comments'
43 import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
44 import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
46 const expect = chai.expect
48 describe('Test multiple servers', function () {
49 let servers: ServerInfo[] = []
52 let videoChannelId: number
54 before(async function () {
57 servers = await flushAndRunMultipleServers(3)
59 // Get the access tokens
60 await setAccessTokensToServers(servers)
63 const videoChannel = {
64 name: 'super_channel_name',
65 displayName: 'my channel',
66 description: 'super channel'
68 await addVideoChannel(servers[0].url, servers[0].accessToken, videoChannel)
69 const channelRes = await getVideoChannelsList(servers[0].url, 0, 1)
70 videoChannelId = channelRes.body.data[0].id
73 // Server 1 and server 2 follow each other
74 await doubleFollow(servers[0], servers[1])
75 // Server 1 and server 3 follow each other
76 await doubleFollow(servers[0], servers[2])
77 // Server 2 and server 3 follow each other
78 await doubleFollow(servers[1], servers[2])
81 it('Should not have videos for all servers', async function () {
82 for (const server of servers) {
83 const res = await getVideosList(server.url)
84 const videos = res.body.data
85 expect(videos).to.be.an('array')
86 expect(videos.length).to.equal(0)
90 describe('Should upload the video and propagate on each server', function () {
91 it('Should upload the video on server 1 and propagate on each server', async function () {
94 const videoAttributes = {
95 name: 'my super name for server 1',
100 description: 'my super description for server 1',
101 support: 'my super support text for server 1',
102 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
103 tags: [ 'tag1p1', 'tag2p1' ],
104 channelId: videoChannelId,
105 fixture: 'video_short1.webm'
107 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
109 await waitJobs(servers)
111 // All servers should have this video
112 let publishedAt: string = null
113 for (const server of servers) {
114 const isLocal = server.port === servers[0].port
115 const checkAttributes = {
116 name: 'my super name for server 1',
121 description: 'my super description for server 1',
122 support: 'my super support text for server 1',
123 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
126 host: 'localhost:' + servers[0].port
131 tags: [ 'tag1p1', 'tag2p1' ],
132 privacy: VideoPrivacy.PUBLIC,
133 commentsEnabled: true,
134 downloadEnabled: true,
136 displayName: 'my channel',
137 name: 'super_channel_name',
138 description: 'super channel',
141 fixture: 'video_short1.webm',
150 const res = await getVideosList(server.url)
151 const videos = res.body.data
152 expect(videos).to.be.an('array')
153 expect(videos.length).to.equal(1)
154 const video = videos[0]
156 await completeVideoCheck(server.url, video, checkAttributes)
157 publishedAt = video.publishedAt
161 it('Should upload the video on server 2 and propagate on each server', async function () {
166 password: 'super_password'
168 await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password })
169 const userAccessToken = await userLogin(servers[1], user)
171 const videoAttributes = {
172 name: 'my super name for server 2',
177 description: 'my super description for server 2',
178 support: 'my super support text for server 2',
179 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
180 fixture: 'video_short2.webm',
181 thumbnailfile: 'thumbnail.jpg',
182 previewfile: 'preview.jpg'
184 await uploadVideo(servers[1].url, userAccessToken, videoAttributes, HttpStatusCode.OK_200, 'resumable')
187 await waitJobs(servers)
189 // All servers should have this video
190 for (const server of servers) {
191 const isLocal = server.url === 'http://localhost:' + servers[1].port
192 const checkAttributes = {
193 name: 'my super name for server 2',
198 description: 'my super description for server 2',
199 support: 'my super support text for server 2',
202 host: 'localhost:' + servers[1].port
205 commentsEnabled: true,
206 downloadEnabled: true,
208 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
209 privacy: VideoPrivacy.PUBLIC,
211 displayName: 'Main user1 channel',
212 name: 'user1_channel',
213 description: 'super channel',
216 fixture: 'video_short2.webm',
235 thumbnailfile: 'thumbnail',
236 previewfile: 'preview'
239 const res = await getVideosList(server.url)
240 const videos = res.body.data
241 expect(videos).to.be.an('array')
242 expect(videos.length).to.equal(2)
243 const video = videos[1]
245 await completeVideoCheck(server.url, video, checkAttributes)
249 it('Should upload two videos on server 3 and propagate on each server', async function () {
252 const videoAttributes1 = {
253 name: 'my super name for server 3',
258 description: 'my super description for server 3',
259 support: 'my super support text for server 3',
261 fixture: 'video_short3.webm'
263 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes1)
265 const videoAttributes2 = {
266 name: 'my super name for server 3-2',
271 description: 'my super description for server 3-2',
272 support: 'my super support text for server 3-2',
273 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
274 fixture: 'video_short.webm'
276 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes2)
278 await waitJobs(servers)
280 // All servers should have this video
281 for (const server of servers) {
282 const isLocal = server.url === 'http://localhost:' + servers[2].port
283 const res = await getVideosList(server.url)
285 const videos = res.body.data
286 expect(videos).to.be.an('array')
287 expect(videos.length).to.equal(4)
289 // We not sure about the order of the two last uploads
292 if (videos[2].name === 'my super name for server 3') {
300 const checkAttributesVideo1 = {
301 name: 'my super name for server 3',
306 description: 'my super description for server 3',
307 support: 'my super support text for server 3',
310 host: 'localhost:' + servers[2].port
314 commentsEnabled: true,
315 downloadEnabled: true,
317 privacy: VideoPrivacy.PUBLIC,
319 displayName: 'Main root channel',
320 name: 'root_channel',
324 fixture: 'video_short3.webm',
332 await completeVideoCheck(server.url, video1, checkAttributesVideo1)
334 const checkAttributesVideo2 = {
335 name: 'my super name for server 3-2',
340 description: 'my super description for server 3-2',
341 support: 'my super support text for server 3-2',
344 host: 'localhost:' + servers[2].port
346 commentsEnabled: true,
347 downloadEnabled: true,
350 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
351 privacy: VideoPrivacy.PUBLIC,
353 displayName: 'Main root channel',
354 name: 'root_channel',
358 fixture: 'video_short.webm',
366 await completeVideoCheck(server.url, video2, checkAttributesVideo2)
371 describe('It should list local videos', function () {
372 it('Should list only local videos on server 1', async function () {
373 const { body } = await getLocalVideos(servers[0].url)
375 expect(body.total).to.equal(1)
376 expect(body.data).to.be.an('array')
377 expect(body.data.length).to.equal(1)
378 expect(body.data[0].name).to.equal('my super name for server 1')
381 it('Should list only local videos on server 2', async function () {
382 const { body } = await getLocalVideos(servers[1].url)
384 expect(body.total).to.equal(1)
385 expect(body.data).to.be.an('array')
386 expect(body.data.length).to.equal(1)
387 expect(body.data[0].name).to.equal('my super name for server 2')
390 it('Should list only local videos on server 3', async function () {
391 const { body } = await getLocalVideos(servers[2].url)
393 expect(body.total).to.equal(2)
394 expect(body.data).to.be.an('array')
395 expect(body.data.length).to.equal(2)
396 expect(body.data[0].name).to.equal('my super name for server 3')
397 expect(body.data[1].name).to.equal('my super name for server 3-2')
401 describe('Should seed the uploaded video', function () {
402 it('Should add the file 1 by asking server 3', async function () {
405 const res = await getVideosList(servers[2].url)
407 const video = res.body.data[0]
408 toRemove.push(res.body.data[2])
409 toRemove.push(res.body.data[3])
411 const res2 = await getVideo(servers[2].url, video.id)
412 const videoDetails = res2.body
414 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
415 expect(torrent.files).to.be.an('array')
416 expect(torrent.files.length).to.equal(1)
417 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
420 it('Should add the file 2 by asking server 1', async function () {
423 const res = await getVideosList(servers[0].url)
425 const video = res.body.data[1]
426 const res2 = await getVideo(servers[0].url, video.id)
427 const videoDetails = res2.body
429 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
430 expect(torrent.files).to.be.an('array')
431 expect(torrent.files.length).to.equal(1)
432 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
435 it('Should add the file 3 by asking server 2', async function () {
438 const res = await getVideosList(servers[1].url)
440 const video = res.body.data[2]
441 const res2 = await getVideo(servers[1].url, video.id)
442 const videoDetails = res2.body
444 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
445 expect(torrent.files).to.be.an('array')
446 expect(torrent.files.length).to.equal(1)
447 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
450 it('Should add the file 3-2 by asking server 1', async function () {
453 const res = await getVideosList(servers[0].url)
455 const video = res.body.data[3]
456 const res2 = await getVideo(servers[0].url, video.id)
457 const videoDetails = res2.body
459 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
460 expect(torrent.files).to.be.an('array')
461 expect(torrent.files.length).to.equal(1)
462 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
465 it('Should add the file 2 in 360p by asking server 1', async function () {
468 const res = await getVideosList(servers[0].url)
470 const video = res.body.data.find(v => v.name === 'my super name for server 2')
471 const res2 = await getVideo(servers[0].url, video.id)
472 const videoDetails = res2.body
474 const file = videoDetails.files.find(f => f.resolution.id === 360)
475 expect(file).not.to.be.undefined
477 const torrent = await webtorrentAdd(file.magnetUri)
478 expect(torrent.files).to.be.an('array')
479 expect(torrent.files.length).to.equal(1)
480 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
484 describe('Should update video views, likes and dislikes', function () {
485 let localVideosServer3 = []
486 let remoteVideosServer1 = []
487 let remoteVideosServer2 = []
488 let remoteVideosServer3 = []
490 before(async function () {
491 const res1 = await getVideosList(servers[0].url)
492 remoteVideosServer1 = res1.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
494 const res2 = await getVideosList(servers[1].url)
495 remoteVideosServer2 = res2.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
497 const res3 = await getVideosList(servers[2].url)
498 localVideosServer3 = res3.body.data.filter(video => video.isLocal === true).map(video => video.uuid)
499 remoteVideosServer3 = res3.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
502 it('Should view multiple videos on owned servers', async function () {
505 await viewVideo(servers[2].url, localVideosServer3[0])
508 await viewVideo(servers[2].url, localVideosServer3[0])
509 await viewVideo(servers[2].url, localVideosServer3[1])
513 await viewVideo(servers[2].url, localVideosServer3[0])
514 await viewVideo(servers[2].url, localVideosServer3[0])
516 await waitJobs(servers)
518 // Wait the repeatable job
521 await waitJobs(servers)
523 for (const server of servers) {
524 const res = await getVideosList(server.url)
526 const videos = res.body.data
527 const video0 = videos.find(v => v.uuid === localVideosServer3[0])
528 const video1 = videos.find(v => v.uuid === localVideosServer3[1])
530 expect(video0.views).to.equal(3)
531 expect(video1.views).to.equal(1)
535 it('Should view multiple videos on each servers', async function () {
538 const tasks: Promise<any>[] = []
539 tasks.push(viewVideo(servers[0].url, remoteVideosServer1[0]))
540 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
541 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
542 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[0]))
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, remoteVideosServer3[1]))
546 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
547 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
548 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
550 await Promise.all(tasks)
552 await waitJobs(servers)
554 // Wait the repeatable job
557 await waitJobs(servers)
559 let baseVideos = null
561 for (const server of servers) {
562 const res = await getVideosList(server.url)
564 const videos = res.body.data
566 // Initialize base videos for future comparisons
567 if (baseVideos === null) {
572 for (const baseVideo of baseVideos) {
573 const sameVideo = videos.find(video => video.name === baseVideo.name)
574 expect(baseVideo.views).to.equal(sameVideo.views)
579 it('Should like and dislikes videos on different services', async function () {
582 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
584 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'dislike')
586 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
587 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'like')
589 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'dislike')
590 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[1], 'dislike')
592 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like')
594 await waitJobs(servers)
597 let baseVideos = null
598 for (const server of servers) {
599 const res = await getVideosList(server.url)
601 const videos = res.body.data
603 // Initialize base videos for future comparisons
604 if (baseVideos === null) {
609 for (const baseVideo of baseVideos) {
610 const sameVideo = videos.find(video => video.name === baseVideo.name)
611 expect(baseVideo.likes).to.equal(sameVideo.likes)
612 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes)
618 describe('Should manipulate these videos', function () {
619 it('Should update the video 3 by asking server 3', async function () {
623 name: 'my super video updated',
628 description: 'my super description updated',
629 support: 'my super support text updated',
630 tags: [ 'tag_up_1', 'tag_up_2' ],
631 thumbnailfile: 'thumbnail.jpg',
632 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
633 previewfile: 'preview.jpg'
636 await updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes)
638 await waitJobs(servers)
641 it('Should have the video 3 updated on each server', async function () {
644 for (const server of servers) {
645 const res = await getVideosList(server.url)
647 const videos = res.body.data
648 const videoUpdated = videos.find(video => video.name === 'my super video updated')
649 expect(!!videoUpdated).to.be.true
651 const isLocal = server.url === 'http://localhost:' + servers[2].port
652 const checkAttributes = {
653 name: 'my super video updated',
658 description: 'my super description updated',
659 support: 'my super support text updated',
660 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
663 host: 'localhost:' + servers[2].port
667 commentsEnabled: true,
668 downloadEnabled: true,
669 tags: [ 'tag_up_1', 'tag_up_2' ],
670 privacy: VideoPrivacy.PUBLIC,
672 displayName: 'Main root channel',
673 name: 'root_channel',
677 fixture: 'video_short3.webm',
684 thumbnailfile: 'thumbnail',
685 previewfile: 'preview'
687 await completeVideoCheck(server.url, videoUpdated, checkAttributes)
691 it('Should remove the videos 3 and 3-2 by asking server 3', async function () {
694 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].id)
695 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[1].id)
697 await waitJobs(servers)
700 it('Should not have files of videos 3 and 3-2 on each server', async function () {
701 for (const server of servers) {
702 await checkVideoFilesWereRemoved(toRemove[0].uuid, server.internalServerNumber)
703 await checkVideoFilesWereRemoved(toRemove[1].uuid, server.internalServerNumber)
707 it('Should have videos 1 and 3 on each server', async function () {
708 for (const server of servers) {
709 const res = await getVideosList(server.url)
711 const videos = res.body.data
712 expect(videos).to.be.an('array')
713 expect(videos.length).to.equal(2)
714 expect(videos[0].name).not.to.equal(videos[1].name)
715 expect(videos[0].name).not.to.equal(toRemove[0].name)
716 expect(videos[1].name).not.to.equal(toRemove[0].name)
717 expect(videos[0].name).not.to.equal(toRemove[1].name)
718 expect(videos[1].name).not.to.equal(toRemove[1].name)
720 videoUUID = videos.find(video => video.name === 'my super name for server 1').uuid
724 it('Should get the same video by UUID on each server', async function () {
726 for (const server of servers) {
727 const res = await getVideo(server.url, videoUUID)
729 const video = res.body
731 if (baseVideo === null) {
736 expect(baseVideo.name).to.equal(video.name)
737 expect(baseVideo.uuid).to.equal(video.uuid)
738 expect(baseVideo.category.id).to.equal(video.category.id)
739 expect(baseVideo.language.id).to.equal(video.language.id)
740 expect(baseVideo.licence.id).to.equal(video.licence.id)
741 expect(baseVideo.nsfw).to.equal(video.nsfw)
742 expect(baseVideo.account.name).to.equal(video.account.name)
743 expect(baseVideo.account.displayName).to.equal(video.account.displayName)
744 expect(baseVideo.account.url).to.equal(video.account.url)
745 expect(baseVideo.account.host).to.equal(video.account.host)
746 expect(baseVideo.tags).to.deep.equal(video.tags)
750 it('Should get the preview from each server', async function () {
751 for (const server of servers) {
752 const res = await getVideo(server.url, videoUUID)
753 const video = res.body
755 await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
760 describe('Should comment these videos', function () {
761 let childOfFirstChild: VideoCommentThreadTree
763 it('Should add comment (threads and replies)', async function () {
767 const text = 'my super first comment'
768 await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, text)
772 const text = 'my super second comment'
773 await addVideoCommentThread(servers[2].url, servers[2].accessToken, videoUUID, text)
776 await waitJobs(servers)
779 const threadId = await findCommentId(servers[1].url, videoUUID, 'my super first comment')
781 const text = 'my super answer to thread 1'
782 await addVideoCommentReply(servers[1].url, servers[1].accessToken, videoUUID, threadId, text)
785 await waitJobs(servers)
788 const threadId = await findCommentId(servers[2].url, videoUUID, 'my super first comment')
790 const res2 = await getVideoThreadComments(servers[2].url, videoUUID, threadId)
791 const childCommentId = res2.body.children[0].comment.id
793 const text3 = 'my second answer to thread 1'
794 await addVideoCommentReply(servers[2].url, servers[2].accessToken, videoUUID, threadId, text3)
796 const text2 = 'my super answer to answer of thread 1'
797 await addVideoCommentReply(servers[2].url, servers[2].accessToken, videoUUID, childCommentId, text2)
800 await waitJobs(servers)
803 it('Should have these threads', async function () {
804 for (const server of servers) {
805 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
807 expect(res.body.total).to.equal(2)
808 expect(res.body.data).to.be.an('array')
809 expect(res.body.data).to.have.lengthOf(2)
812 const comment: VideoComment = res.body.data.find(c => c.text === 'my super first comment')
813 expect(comment).to.not.be.undefined
814 expect(comment.inReplyToCommentId).to.be.null
815 expect(comment.account.name).to.equal('root')
816 expect(comment.account.host).to.equal('localhost:' + servers[0].port)
817 expect(comment.totalReplies).to.equal(3)
818 expect(dateIsValid(comment.createdAt as string)).to.be.true
819 expect(dateIsValid(comment.updatedAt as string)).to.be.true
823 const comment: VideoComment = res.body.data.find(c => c.text === 'my super second comment')
824 expect(comment).to.not.be.undefined
825 expect(comment.inReplyToCommentId).to.be.null
826 expect(comment.account.name).to.equal('root')
827 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
828 expect(comment.totalReplies).to.equal(0)
829 expect(dateIsValid(comment.createdAt as string)).to.be.true
830 expect(dateIsValid(comment.updatedAt as string)).to.be.true
835 it('Should have these comments', async function () {
836 for (const server of servers) {
837 const res1 = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
838 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
840 const res2 = await getVideoThreadComments(server.url, videoUUID, threadId)
842 const tree: VideoCommentThreadTree = res2.body
843 expect(tree.comment.text).equal('my super first comment')
844 expect(tree.comment.account.name).equal('root')
845 expect(tree.comment.account.host).equal('localhost:' + servers[0].port)
846 expect(tree.children).to.have.lengthOf(2)
848 const firstChild = tree.children[0]
849 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
850 expect(firstChild.comment.account.name).equal('root')
851 expect(firstChild.comment.account.host).equal('localhost:' + servers[1].port)
852 expect(firstChild.children).to.have.lengthOf(1)
854 childOfFirstChild = firstChild.children[0]
855 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
856 expect(childOfFirstChild.comment.account.name).equal('root')
857 expect(childOfFirstChild.comment.account.host).equal('localhost:' + servers[2].port)
858 expect(childOfFirstChild.children).to.have.lengthOf(0)
860 const secondChild = tree.children[1]
861 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
862 expect(secondChild.comment.account.name).equal('root')
863 expect(secondChild.comment.account.host).equal('localhost:' + servers[2].port)
864 expect(secondChild.children).to.have.lengthOf(0)
868 it('Should delete a reply', async function () {
871 await deleteVideoComment(servers[2].url, servers[2].accessToken, videoUUID, childOfFirstChild.comment.id)
873 await waitJobs(servers)
876 it('Should have this comment marked as deleted', async function () {
877 for (const server of servers) {
878 const res1 = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
879 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
881 const res2 = await getVideoThreadComments(server.url, videoUUID, threadId)
883 const tree: VideoCommentThreadTree = res2.body
884 expect(tree.comment.text).equal('my super first comment')
886 const firstChild = tree.children[0]
887 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
888 expect(firstChild.children).to.have.lengthOf(1)
890 const deletedComment = firstChild.children[0].comment
891 expect(deletedComment.isDeleted).to.be.true
892 expect(deletedComment.deletedAt).to.not.be.null
893 expect(deletedComment.account).to.be.null
894 expect(deletedComment.text).to.equal('')
896 const secondChild = tree.children[1]
897 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
901 it('Should delete the thread comments', async function () {
904 const res = await getVideoCommentThreads(servers[0].url, videoUUID, 0, 5)
905 const threadId = res.body.data.find(c => c.text === 'my super first comment').id
906 await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId)
908 await waitJobs(servers)
911 it('Should have the threads marked as deleted on other servers too', async function () {
912 for (const server of servers) {
913 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
915 expect(res.body.total).to.equal(2)
916 expect(res.body.data).to.be.an('array')
917 expect(res.body.data).to.have.lengthOf(2)
920 const comment: VideoComment = res.body.data[0]
921 expect(comment).to.not.be.undefined
922 expect(comment.inReplyToCommentId).to.be.null
923 expect(comment.account.name).to.equal('root')
924 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
925 expect(comment.totalReplies).to.equal(0)
926 expect(dateIsValid(comment.createdAt as string)).to.be.true
927 expect(dateIsValid(comment.updatedAt as string)).to.be.true
931 const deletedComment: VideoComment = res.body.data[1]
932 expect(deletedComment).to.not.be.undefined
933 expect(deletedComment.isDeleted).to.be.true
934 expect(deletedComment.deletedAt).to.not.be.null
935 expect(deletedComment.text).to.equal('')
936 expect(deletedComment.inReplyToCommentId).to.be.null
937 expect(deletedComment.account).to.be.null
938 expect(deletedComment.totalReplies).to.equal(3)
939 expect(dateIsValid(deletedComment.createdAt as string)).to.be.true
940 expect(dateIsValid(deletedComment.updatedAt as string)).to.be.true
941 expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true
946 it('Should delete a remote thread by the origin server', async function () {
949 const res = await getVideoCommentThreads(servers[0].url, videoUUID, 0, 5)
950 const threadId = res.body.data.find(c => c.text === 'my super second comment').id
951 await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId)
953 await waitJobs(servers)
956 it('Should have the threads marked as deleted on other servers too', async function () {
957 for (const server of servers) {
958 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
960 expect(res.body.total).to.equal(2)
961 expect(res.body.data).to.have.lengthOf(2)
964 const comment: VideoComment = res.body.data[0]
965 expect(comment.text).to.equal('')
966 expect(comment.isDeleted).to.be.true
967 expect(comment.createdAt).to.not.be.null
968 expect(comment.deletedAt).to.not.be.null
969 expect(comment.account).to.be.null
970 expect(comment.totalReplies).to.equal(0)
974 const comment: VideoComment = res.body.data[1]
975 expect(comment.text).to.equal('')
976 expect(comment.isDeleted).to.be.true
977 expect(comment.createdAt).to.not.be.null
978 expect(comment.deletedAt).to.not.be.null
979 expect(comment.account).to.be.null
980 expect(comment.totalReplies).to.equal(3)
985 it('Should disable comments and download', async function () {
989 commentsEnabled: false,
990 downloadEnabled: false
993 await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, attributes)
995 await waitJobs(servers)
997 for (const server of servers) {
998 const res = await getVideo(server.url, videoUUID)
999 expect(res.body.commentsEnabled).to.be.false
1000 expect(res.body.downloadEnabled).to.be.false
1002 const text = 'my super forbidden comment'
1003 await addVideoCommentThread(server.url, server.accessToken, videoUUID, text, HttpStatusCode.CONFLICT_409)
1008 describe('With minimum parameters', function () {
1009 it('Should upload and propagate the video', async function () {
1012 const path = '/api/v1/videos/upload'
1014 const req = request(servers[1].url)
1016 .set('Accept', 'application/json')
1017 .set('Authorization', 'Bearer ' + servers[1].accessToken)
1018 .field('name', 'minimum parameters')
1019 .field('privacy', '1')
1020 .field('channelId', '1')
1022 const filePath = join(__dirname, '..', '..', 'fixtures', 'video_short.webm')
1024 await req.attach('videofile', filePath)
1025 .expect(HttpStatusCode.OK_200)
1027 await waitJobs(servers)
1029 for (const server of servers) {
1030 const res = await getVideosList(server.url)
1031 const video = res.body.data.find(v => v.name === 'minimum parameters')
1033 const isLocal = server.url === 'http://localhost:' + servers[1].port
1034 const checkAttributes = {
1035 name: 'minimum parameters',
1044 host: 'localhost:' + servers[1].port
1048 commentsEnabled: true,
1049 downloadEnabled: true,
1051 privacy: VideoPrivacy.PUBLIC,
1053 displayName: 'Main root channel',
1054 name: 'root_channel',
1058 fixture: 'video_short.webm',
1078 await completeVideoCheck(server.url, video, checkAttributes)
1083 describe('TMP directory', function () {
1084 it('Should have an empty tmp directory', async function () {
1085 for (const server of servers) {
1086 await checkTmpIsEmpty(server)
1091 after(async function () {
1092 await cleanupTests(servers)