1 /* tslint:disable:no-unused-expression */
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'
11 checkVideoFilesWereRemoved,
16 flushAndRunMultipleServers,
26 setAccessTokensToServers,
37 addVideoCommentThread,
39 getVideoCommentThreads,
40 getVideoThreadComments
41 } from '../../utils/videos/video-comments'
42 import { waitJobs } from '../../utils/server/jobs'
44 const expect = chai.expect
46 describe('Test multiple servers', function () {
47 let servers: ServerInfo[] = []
50 let videoChannelId: number
52 before(async function () {
55 servers = await flushAndRunMultipleServers(3)
57 // Get the access tokens
58 await setAccessTokensToServers(servers)
61 const videoChannel = {
62 name: 'super_channel_name',
63 displayName: 'my channel',
64 description: 'super channel'
66 await addVideoChannel(servers[ 0 ].url, servers[ 0 ].accessToken, videoChannel)
67 const channelRes = await getVideoChannelsList(servers[ 0 ].url, 0, 1)
68 videoChannelId = channelRes.body.data[ 0 ].id
71 // Server 1 and server 2 follow each other
72 await doubleFollow(servers[0], servers[1])
73 // Server 1 and server 3 follow each other
74 await doubleFollow(servers[0], servers[2])
75 // Server 2 and server 3 follow each other
76 await doubleFollow(servers[1], servers[2])
79 it('Should not have videos for all servers', async function () {
80 for (const server of servers) {
81 const res = await getVideosList(server.url)
82 const videos = res.body.data
83 expect(videos).to.be.an('array')
84 expect(videos.length).to.equal(0)
88 describe('Should upload the video and propagate on each server', function () {
89 it('Should upload the video on server 1 and propagate on each server', async function () {
92 const videoAttributes = {
93 name: 'my super name for server 1',
98 description: 'my super description for server 1',
99 support: 'my super support text for server 1',
100 tags: [ 'tag1p1', 'tag2p1' ],
101 channelId: videoChannelId,
102 fixture: 'video_short1.webm'
104 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
106 await waitJobs(servers)
108 // All servers should have this video
109 let publishedAt: string = null
110 for (const server of servers) {
111 const isLocal = server.url === 'http://localhost:9001'
112 const checkAttributes = {
113 name: 'my super name for server 1',
118 description: 'my super description for server 1',
119 support: 'my super support text for server 1',
122 host: 'localhost:9001'
127 tags: [ 'tag1p1', 'tag2p1' ],
128 privacy: VideoPrivacy.PUBLIC,
129 commentsEnabled: true,
130 downloadEnabled: true,
132 displayName: 'my channel',
133 name: 'super_channel_name',
134 description: 'super channel',
137 fixture: 'video_short1.webm',
146 const res = await getVideosList(server.url)
147 const videos = res.body.data
148 expect(videos).to.be.an('array')
149 expect(videos.length).to.equal(1)
150 const video = videos[0]
152 await completeVideoCheck(server.url, video, checkAttributes)
153 publishedAt = video.publishedAt
157 it('Should upload the video on server 2 and propagate on each server', async function () {
162 password: 'super_password'
164 await createUser(servers[1].url, servers[1].accessToken, user.username, user.password)
165 const userAccessToken = await userLogin(servers[1], user)
167 const videoAttributes = {
168 name: 'my super name for server 2',
173 description: 'my super description for server 2',
174 support: 'my super support text for server 2',
175 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
176 fixture: 'video_short2.webm',
177 thumbnailfile: 'thumbnail.jpg',
178 previewfile: 'preview.jpg'
180 await uploadVideo(servers[1].url, userAccessToken, videoAttributes)
183 await waitJobs(servers)
185 // All servers should have this video
186 for (const server of servers) {
187 const isLocal = server.url === 'http://localhost:9002'
188 const checkAttributes = {
189 name: 'my super name for server 2',
194 description: 'my super description for server 2',
195 support: 'my super support text for server 2',
198 host: 'localhost:9002'
201 commentsEnabled: true,
202 downloadEnabled: true,
204 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
205 privacy: VideoPrivacy.PUBLIC,
207 displayName: 'Main user1 channel',
208 name: 'user1_channel',
209 description: 'super channel',
212 fixture: 'video_short2.webm',
231 thumbnailfile: 'thumbnail',
232 previewfile: 'preview'
235 const res = await getVideosList(server.url)
236 const videos = res.body.data
237 expect(videos).to.be.an('array')
238 expect(videos.length).to.equal(2)
239 const video = videos[1]
241 await completeVideoCheck(server.url, video, checkAttributes)
245 it('Should upload two videos on server 3 and propagate on each server', async function () {
248 const videoAttributes1 = {
249 name: 'my super name for server 3',
254 description: 'my super description for server 3',
255 support: 'my super support text for server 3',
257 fixture: 'video_short3.webm'
259 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes1)
261 const videoAttributes2 = {
262 name: 'my super name for server 3-2',
267 description: 'my super description for server 3-2',
268 support: 'my super support text for server 3-2',
269 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
270 fixture: 'video_short.webm'
272 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes2)
274 await waitJobs(servers)
276 // All servers should have this video
277 for (const server of servers) {
278 const isLocal = server.url === 'http://localhost:9003'
279 const res = await getVideosList(server.url)
281 const videos = res.body.data
282 expect(videos).to.be.an('array')
283 expect(videos.length).to.equal(4)
285 // We not sure about the order of the two last uploads
288 if (videos[2].name === 'my super name for server 3') {
296 const checkAttributesVideo1 = {
297 name: 'my super name for server 3',
302 description: 'my super description for server 3',
303 support: 'my super support text for server 3',
306 host: 'localhost:9003'
310 commentsEnabled: true,
311 downloadEnabled: true,
313 privacy: VideoPrivacy.PUBLIC,
315 displayName: 'Main root channel',
316 name: 'root_channel',
320 fixture: 'video_short3.webm',
328 await completeVideoCheck(server.url, video1, checkAttributesVideo1)
330 const checkAttributesVideo2 = {
331 name: 'my super name for server 3-2',
336 description: 'my super description for server 3-2',
337 support: 'my super support text for server 3-2',
340 host: 'localhost:9003'
342 commentsEnabled: true,
343 downloadEnabled: true,
346 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
347 privacy: VideoPrivacy.PUBLIC,
349 displayName: 'Main root channel',
350 name: 'root_channel',
354 fixture: 'video_short.webm',
362 await completeVideoCheck(server.url, video2, checkAttributesVideo2)
367 describe('It should list local videos', function () {
368 it('Should list only local videos on server 1', async function () {
369 const { body } = await getLocalVideos(servers[0].url)
371 expect(body.total).to.equal(1)
372 expect(body.data).to.be.an('array')
373 expect(body.data.length).to.equal(1)
374 expect(body.data[0].name).to.equal('my super name for server 1')
377 it('Should list only local videos on server 2', async function () {
378 const { body } = await getLocalVideos(servers[1].url)
380 expect(body.total).to.equal(1)
381 expect(body.data).to.be.an('array')
382 expect(body.data.length).to.equal(1)
383 expect(body.data[0].name).to.equal('my super name for server 2')
386 it('Should list only local videos on server 3', async function () {
387 const { body } = await getLocalVideos(servers[2].url)
389 expect(body.total).to.equal(2)
390 expect(body.data).to.be.an('array')
391 expect(body.data.length).to.equal(2)
392 expect(body.data[0].name).to.equal('my super name for server 3')
393 expect(body.data[1].name).to.equal('my super name for server 3-2')
397 describe('Should seed the uploaded video', function () {
398 it('Should add the file 1 by asking server 3', async function () {
401 const res = await getVideosList(servers[2].url)
403 const video = res.body.data[0]
404 toRemove.push(res.body.data[2])
405 toRemove.push(res.body.data[3])
407 const res2 = await getVideo(servers[2].url, video.id)
408 const videoDetails = res2.body
410 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
411 expect(torrent.files).to.be.an('array')
412 expect(torrent.files.length).to.equal(1)
413 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
416 it('Should add the file 2 by asking server 1', async function () {
419 const res = await getVideosList(servers[0].url)
421 const video = res.body.data[1]
422 const res2 = await getVideo(servers[0].url, video.id)
423 const videoDetails = res2.body
425 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
426 expect(torrent.files).to.be.an('array')
427 expect(torrent.files.length).to.equal(1)
428 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
431 it('Should add the file 3 by asking server 2', async function () {
434 const res = await getVideosList(servers[1].url)
436 const video = res.body.data[2]
437 const res2 = await getVideo(servers[1].url, video.id)
438 const videoDetails = res2.body
440 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
441 expect(torrent.files).to.be.an('array')
442 expect(torrent.files.length).to.equal(1)
443 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
446 it('Should add the file 3-2 by asking server 1', async function () {
449 const res = await getVideosList(servers[0].url)
451 const video = res.body.data[3]
452 const res2 = await getVideo(servers[0].url, video.id)
453 const videoDetails = res2.body
455 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
456 expect(torrent.files).to.be.an('array')
457 expect(torrent.files.length).to.equal(1)
458 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
461 it('Should add the file 2 in 360p by asking server 1', async function () {
464 const res = await getVideosList(servers[0].url)
466 const video = res.body.data.find(v => v.name === 'my super name for server 2')
467 const res2 = await getVideo(servers[0].url, video.id)
468 const videoDetails = res2.body
470 const file = videoDetails.files.find(f => f.resolution.id === 360)
471 expect(file).not.to.be.undefined
473 const torrent = await webtorrentAdd(file.magnetUri)
474 expect(torrent.files).to.be.an('array')
475 expect(torrent.files.length).to.equal(1)
476 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
480 describe('Should update video views, likes and dislikes', function () {
481 let localVideosServer3 = []
482 let remoteVideosServer1 = []
483 let remoteVideosServer2 = []
484 let remoteVideosServer3 = []
486 before(async function () {
487 const res1 = await getVideosList(servers[0].url)
488 remoteVideosServer1 = res1.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
490 const res2 = await getVideosList(servers[1].url)
491 remoteVideosServer2 = res2.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
493 const res3 = await getVideosList(servers[2].url)
494 localVideosServer3 = res3.body.data.filter(video => video.isLocal === true).map(video => video.uuid)
495 remoteVideosServer3 = res3.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
498 it('Should view multiple videos on owned servers', async function () {
501 const tasks: Promise<any>[] = []
502 await viewVideo(servers[2].url, localVideosServer3[0])
503 await viewVideo(servers[2].url, localVideosServer3[0])
504 await viewVideo(servers[2].url, localVideosServer3[0])
505 await viewVideo(servers[2].url, localVideosServer3[1])
507 await Promise.all(tasks)
508 await waitJobs(servers)
510 await viewVideo(servers[2].url, localVideosServer3[0])
512 await waitJobs(servers)
514 await viewVideo(servers[2].url, localVideosServer3[0])
516 await waitJobs(servers)
518 // Wait the repeatable job
521 for (const server of servers) {
522 const res = await getVideosList(server.url)
524 const videos = res.body.data
525 const video0 = videos.find(v => v.uuid === localVideosServer3[0])
526 const video1 = videos.find(v => v.uuid === localVideosServer3[1])
528 expect(video0.views).to.equal(3)
529 expect(video1.views).to.equal(1)
533 it('Should view multiple videos on each servers', async function () {
536 const tasks: Promise<any>[] = []
537 tasks.push(viewVideo(servers[0].url, remoteVideosServer1[0]))
538 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
539 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
540 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[0]))
541 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
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, localVideosServer3[1]))
545 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
546 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
548 await Promise.all(tasks)
550 await waitJobs(servers)
552 // Wait the repeatable job
555 let baseVideos = null
557 for (const server of servers) {
558 const res = await getVideosList(server.url)
560 const videos = res.body.data
562 // Initialize base videos for future comparisons
563 if (baseVideos === null) {
568 for (const baseVideo of baseVideos) {
569 const sameVideo = videos.find(video => video.name === baseVideo.name)
570 expect(baseVideo.views).to.equal(sameVideo.views)
575 it('Should like and dislikes videos on different services', async function () {
578 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
580 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'dislike')
582 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
583 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'like')
585 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'dislike')
586 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[1], 'dislike')
588 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like')
590 await waitJobs(servers)
592 let baseVideos = null
593 for (const server of servers) {
594 const res = await getVideosList(server.url)
596 const videos = res.body.data
598 // Initialize base videos for future comparisons
599 if (baseVideos === null) {
604 for (const baseVideo of baseVideos) {
605 const sameVideo = videos.find(video => video.name === baseVideo.name)
606 expect(baseVideo.likes).to.equal(sameVideo.likes)
607 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes)
613 describe('Should manipulate these videos', function () {
614 it('Should update the video 3 by asking server 3', async function () {
618 name: 'my super video updated',
623 description: 'my super description updated',
624 support: 'my super support text updated',
625 tags: [ 'tag_up_1', 'tag_up_2' ],
626 thumbnailfile: 'thumbnail.jpg',
627 previewfile: 'preview.jpg'
630 await updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes)
632 await waitJobs(servers)
635 it('Should have the video 3 updated on each server', async function () {
638 for (const server of servers) {
639 const res = await getVideosList(server.url)
641 const videos = res.body.data
642 const videoUpdated = videos.find(video => video.name === 'my super video updated')
643 expect(!!videoUpdated).to.be.true
645 const isLocal = server.url === 'http://localhost:9003'
646 const checkAttributes = {
647 name: 'my super video updated',
652 description: 'my super description updated',
653 support: 'my super support text updated',
656 host: 'localhost:9003'
660 commentsEnabled: true,
661 downloadEnabled: true,
662 tags: [ 'tag_up_1', 'tag_up_2' ],
663 privacy: VideoPrivacy.PUBLIC,
665 displayName: 'Main root channel',
666 name: 'root_channel',
670 fixture: 'video_short3.webm',
677 thumbnailfile: 'thumbnail',
678 previewfile: 'preview'
680 await completeVideoCheck(server.url, videoUpdated, checkAttributes)
684 it('Should remove the videos 3 and 3-2 by asking server 3', async function () {
687 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].id)
688 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[1].id)
690 await waitJobs(servers)
693 it('Should not have files of videos 3 and 3-2 on each server', async function () {
694 for (const server of servers) {
695 await checkVideoFilesWereRemoved(toRemove[0].uuid, server.serverNumber)
696 await checkVideoFilesWereRemoved(toRemove[1].uuid, server.serverNumber)
700 it('Should have videos 1 and 3 on each server', async function () {
701 for (const server of servers) {
702 const res = await getVideosList(server.url)
704 const videos = res.body.data
705 expect(videos).to.be.an('array')
706 expect(videos.length).to.equal(2)
707 expect(videos[0].name).not.to.equal(videos[1].name)
708 expect(videos[0].name).not.to.equal(toRemove[0].name)
709 expect(videos[1].name).not.to.equal(toRemove[0].name)
710 expect(videos[0].name).not.to.equal(toRemove[1].name)
711 expect(videos[1].name).not.to.equal(toRemove[1].name)
713 videoUUID = videos.find(video => video.name === 'my super name for server 1').uuid
717 it('Should get the same video by UUID on each server', async function () {
719 for (const server of servers) {
720 const res = await getVideo(server.url, videoUUID)
722 const video = res.body
724 if (baseVideo === null) {
729 expect(baseVideo.name).to.equal(video.name)
730 expect(baseVideo.uuid).to.equal(video.uuid)
731 expect(baseVideo.category.id).to.equal(video.category.id)
732 expect(baseVideo.language.id).to.equal(video.language.id)
733 expect(baseVideo.licence.id).to.equal(video.licence.id)
734 expect(baseVideo.nsfw).to.equal(video.nsfw)
735 expect(baseVideo.account.name).to.equal(video.account.name)
736 expect(baseVideo.account.displayName).to.equal(video.account.displayName)
737 expect(baseVideo.account.url).to.equal(video.account.url)
738 expect(baseVideo.account.host).to.equal(video.account.host)
739 expect(baseVideo.tags).to.deep.equal(video.tags)
743 it('Should get the preview from each server', async function () {
744 for (const server of servers) {
745 const res = await getVideo(server.url, videoUUID)
746 const video = res.body
748 await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
753 describe('Should comment these videos', function () {
754 let childOfFirstChild: VideoCommentThreadTree
756 it('Should add comment (threads and replies)', async function () {
760 const text = 'my super first comment'
761 await addVideoCommentThread(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID, text)
765 const text = 'my super second comment'
766 await addVideoCommentThread(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, text)
769 await waitJobs(servers)
772 const res = await getVideoCommentThreads(servers[1].url, videoUUID, 0, 5)
773 const threadId = res.body.data.find(c => c.text === 'my super first comment').id
775 const text = 'my super answer to thread 1'
776 await addVideoCommentReply(servers[ 1 ].url, servers[ 1 ].accessToken, videoUUID, threadId, text)
779 await waitJobs(servers)
782 const res1 = await getVideoCommentThreads(servers[2].url, videoUUID, 0, 5)
783 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
785 const res2 = await getVideoThreadComments(servers[2].url, videoUUID, threadId)
786 const childCommentId = res2.body.children[0].comment.id
788 const text3 = 'my second answer to thread 1'
789 await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, threadId, text3)
791 const text2 = 'my super answer to answer of thread 1'
792 await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, childCommentId, text2)
795 await waitJobs(servers)
798 it('Should have these threads', async function () {
799 for (const server of servers) {
800 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
802 expect(res.body.total).to.equal(2)
803 expect(res.body.data).to.be.an('array')
804 expect(res.body.data).to.have.lengthOf(2)
807 const comment: VideoComment = res.body.data.find(c => c.text === 'my super first comment')
808 expect(comment).to.not.be.undefined
809 expect(comment.inReplyToCommentId).to.be.null
810 expect(comment.account.name).to.equal('root')
811 expect(comment.account.host).to.equal('localhost:9001')
812 expect(comment.totalReplies).to.equal(3)
813 expect(dateIsValid(comment.createdAt as string)).to.be.true
814 expect(dateIsValid(comment.updatedAt as string)).to.be.true
818 const comment: VideoComment = res.body.data.find(c => c.text === 'my super second comment')
819 expect(comment).to.not.be.undefined
820 expect(comment.inReplyToCommentId).to.be.null
821 expect(comment.account.name).to.equal('root')
822 expect(comment.account.host).to.equal('localhost:9003')
823 expect(comment.totalReplies).to.equal(0)
824 expect(dateIsValid(comment.createdAt as string)).to.be.true
825 expect(dateIsValid(comment.updatedAt as string)).to.be.true
830 it('Should have these comments', async function () {
831 for (const server of servers) {
832 const res1 = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
833 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
835 const res2 = await getVideoThreadComments(server.url, videoUUID, threadId)
837 const tree: VideoCommentThreadTree = res2.body
838 expect(tree.comment.text).equal('my super first comment')
839 expect(tree.comment.account.name).equal('root')
840 expect(tree.comment.account.host).equal('localhost:9001')
841 expect(tree.children).to.have.lengthOf(2)
843 const firstChild = tree.children[0]
844 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
845 expect(firstChild.comment.account.name).equal('root')
846 expect(firstChild.comment.account.host).equal('localhost:9002')
847 expect(firstChild.children).to.have.lengthOf(1)
849 childOfFirstChild = firstChild.children[0]
850 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
851 expect(childOfFirstChild.comment.account.name).equal('root')
852 expect(childOfFirstChild.comment.account.host).equal('localhost:9003')
853 expect(childOfFirstChild.children).to.have.lengthOf(0)
855 const secondChild = tree.children[1]
856 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
857 expect(secondChild.comment.account.name).equal('root')
858 expect(secondChild.comment.account.host).equal('localhost:9003')
859 expect(secondChild.children).to.have.lengthOf(0)
863 it('Should delete a reply', async function () {
866 await deleteVideoComment(servers[2].url, servers[2].accessToken, videoUUID, childOfFirstChild.comment.id)
868 await waitJobs(servers)
871 it('Should not have this comment anymore', async function () {
872 for (const server of servers) {
873 const res1 = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
874 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
876 const res2 = await getVideoThreadComments(server.url, videoUUID, threadId)
878 const tree: VideoCommentThreadTree = res2.body
879 expect(tree.comment.text).equal('my super first comment')
881 const firstChild = tree.children[0]
882 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
883 expect(firstChild.children).to.have.lengthOf(0)
885 const secondChild = tree.children[1]
886 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
890 it('Should delete the thread comments', async function () {
893 const res1 = await getVideoCommentThreads(servers[0].url, videoUUID, 0, 5)
894 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
895 await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId)
897 await waitJobs(servers)
900 it('Should have the thread comments deleted on other servers too', async function () {
901 for (const server of servers) {
902 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
904 expect(res.body.total).to.equal(1)
905 expect(res.body.data).to.be.an('array')
906 expect(res.body.data).to.have.lengthOf(1)
909 const comment: VideoComment = res.body.data[0]
910 expect(comment).to.not.be.undefined
911 expect(comment.inReplyToCommentId).to.be.null
912 expect(comment.account.name).to.equal('root')
913 expect(comment.account.host).to.equal('localhost:9003')
914 expect(comment.totalReplies).to.equal(0)
915 expect(dateIsValid(comment.createdAt as string)).to.be.true
916 expect(dateIsValid(comment.updatedAt as string)).to.be.true
921 it('Should disable comments and download', async function () {
925 commentsEnabled: false,
926 downloadEnabled: false
929 await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, attributes)
931 await waitJobs(servers)
933 for (const server of servers) {
934 const res = await getVideo(server.url, videoUUID)
935 expect(res.body.commentsEnabled).to.be.false
936 expect(res.body.downloadEnabled).to.be.false
938 const text = 'my super forbidden comment'
939 await addVideoCommentThread(server.url, server.accessToken, videoUUID, text, 409)
944 describe('With minimum parameters', function () {
945 it('Should upload and propagate the video', async function () {
948 const path = '/api/v1/videos/upload'
950 const req = request(servers[1].url)
952 .set('Accept', 'application/json')
953 .set('Authorization', 'Bearer ' + servers[1].accessToken)
954 .field('name', 'minimum parameters')
955 .field('privacy', '1')
956 .field('channelId', '1')
958 const filePath = join(__dirname, '..', '..', 'fixtures', 'video_short.webm')
960 await req.attach('videofile', filePath)
963 await waitJobs(servers)
965 for (const server of servers) {
966 const res = await getVideosList(server.url)
967 const video = res.body.data.find(v => v.name === 'minimum parameters')
969 const isLocal = server.url === 'http://localhost:9002'
970 const checkAttributes = {
971 name: 'minimum parameters',
980 host: 'localhost:9002'
984 commentsEnabled: false,
985 downloadEnabled: false,
987 privacy: VideoPrivacy.PUBLIC,
989 displayName: 'Main root channel',
990 name: 'root_channel',
994 fixture: 'video_short.webm',
1014 await completeVideoCheck(server.url, video, checkAttributes)
1019 after(async function () {
1020 killallServers(servers)
1022 // Keep the logs if the test failed