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'
12 checkVideoFilesWereRemoved,
17 flushAndRunMultipleServers,
27 setAccessTokensToServers,
35 } from '../../../../shared/utils'
38 addVideoCommentThread,
40 getVideoCommentThreads,
41 getVideoThreadComments
42 } from '../../../../shared/utils/videos/video-comments'
43 import { waitJobs } from '../../../../shared/utils/server/jobs'
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 tags: [ 'tag1p1', 'tag2p1' ],
102 channelId: videoChannelId,
103 fixture: 'video_short1.webm'
105 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
107 await waitJobs(servers)
109 // All servers should have this video
110 let publishedAt: string = null
111 for (const server of servers) {
112 const isLocal = server.url === 'http://localhost:9001'
113 const checkAttributes = {
114 name: 'my super name for server 1',
119 description: 'my super description for server 1',
120 support: 'my super support text for server 1',
123 host: 'localhost:9001'
128 tags: [ 'tag1p1', 'tag2p1' ],
129 privacy: VideoPrivacy.PUBLIC,
130 commentsEnabled: 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,
203 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
204 privacy: VideoPrivacy.PUBLIC,
206 displayName: 'Main user1 channel',
207 name: 'user1_channel',
208 description: 'super channel',
211 fixture: 'video_short2.webm',
230 thumbnailfile: 'thumbnail',
231 previewfile: 'preview'
234 const res = await getVideosList(server.url)
235 const videos = res.body.data
236 expect(videos).to.be.an('array')
237 expect(videos.length).to.equal(2)
238 const video = videos[1]
240 await completeVideoCheck(server.url, video, checkAttributes)
244 it('Should upload two videos on server 3 and propagate on each server', async function () {
247 const videoAttributes1 = {
248 name: 'my super name for server 3',
253 description: 'my super description for server 3',
254 support: 'my super support text for server 3',
256 fixture: 'video_short3.webm'
258 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes1)
260 const videoAttributes2 = {
261 name: 'my super name for server 3-2',
266 description: 'my super description for server 3-2',
267 support: 'my super support text for server 3-2',
268 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
269 fixture: 'video_short.webm'
271 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes2)
273 await waitJobs(servers)
275 // All servers should have this video
276 for (const server of servers) {
277 const isLocal = server.url === 'http://localhost:9003'
278 const res = await getVideosList(server.url)
280 const videos = res.body.data
281 expect(videos).to.be.an('array')
282 expect(videos.length).to.equal(4)
284 // We not sure about the order of the two last uploads
287 if (videos[2].name === 'my super name for server 3') {
295 const checkAttributesVideo1 = {
296 name: 'my super name for server 3',
301 description: 'my super description for server 3',
302 support: 'my super support text for server 3',
305 host: 'localhost:9003'
309 commentsEnabled: true,
311 privacy: VideoPrivacy.PUBLIC,
313 displayName: 'Main root channel',
314 name: 'root_channel',
318 fixture: 'video_short3.webm',
326 await completeVideoCheck(server.url, video1, checkAttributesVideo1)
328 const checkAttributesVideo2 = {
329 name: 'my super name for server 3-2',
334 description: 'my super description for server 3-2',
335 support: 'my super support text for server 3-2',
338 host: 'localhost:9003'
340 commentsEnabled: true,
343 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
344 privacy: VideoPrivacy.PUBLIC,
346 displayName: 'Main root channel',
347 name: 'root_channel',
351 fixture: 'video_short.webm',
359 await completeVideoCheck(server.url, video2, checkAttributesVideo2)
364 describe('It should list local videos', function () {
365 it('Should list only local videos on server 1', async function () {
366 const { body } = await getLocalVideos(servers[0].url)
368 expect(body.total).to.equal(1)
369 expect(body.data).to.be.an('array')
370 expect(body.data.length).to.equal(1)
371 expect(body.data[0].name).to.equal('my super name for server 1')
374 it('Should list only local videos on server 2', async function () {
375 const { body } = await getLocalVideos(servers[1].url)
377 expect(body.total).to.equal(1)
378 expect(body.data).to.be.an('array')
379 expect(body.data.length).to.equal(1)
380 expect(body.data[0].name).to.equal('my super name for server 2')
383 it('Should list only local videos on server 3', async function () {
384 const { body } = await getLocalVideos(servers[2].url)
386 expect(body.total).to.equal(2)
387 expect(body.data).to.be.an('array')
388 expect(body.data.length).to.equal(2)
389 expect(body.data[0].name).to.equal('my super name for server 3')
390 expect(body.data[1].name).to.equal('my super name for server 3-2')
394 describe('Should seed the uploaded video', function () {
395 it('Should add the file 1 by asking server 3', async function () {
398 const res = await getVideosList(servers[2].url)
400 const video = res.body.data[0]
401 toRemove.push(res.body.data[2])
402 toRemove.push(res.body.data[3])
404 const res2 = await getVideo(servers[2].url, video.id)
405 const videoDetails = res2.body
407 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
408 expect(torrent.files).to.be.an('array')
409 expect(torrent.files.length).to.equal(1)
410 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
413 it('Should add the file 2 by asking server 1', async function () {
416 const res = await getVideosList(servers[0].url)
418 const video = res.body.data[1]
419 const res2 = await getVideo(servers[0].url, video.id)
420 const videoDetails = res2.body
422 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
423 expect(torrent.files).to.be.an('array')
424 expect(torrent.files.length).to.equal(1)
425 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
428 it('Should add the file 3 by asking server 2', async function () {
431 const res = await getVideosList(servers[1].url)
433 const video = res.body.data[2]
434 const res2 = await getVideo(servers[1].url, video.id)
435 const videoDetails = res2.body
437 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
438 expect(torrent.files).to.be.an('array')
439 expect(torrent.files.length).to.equal(1)
440 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
443 it('Should add the file 3-2 by asking server 1', async function () {
446 const res = await getVideosList(servers[0].url)
448 const video = res.body.data[3]
449 const res2 = await getVideo(servers[0].url, video.id)
450 const videoDetails = res2.body
452 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
453 expect(torrent.files).to.be.an('array')
454 expect(torrent.files.length).to.equal(1)
455 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
458 it('Should add the file 2 in 360p by asking server 1', async function () {
461 const res = await getVideosList(servers[0].url)
463 const video = res.body.data.find(v => v.name === 'my super name for server 2')
464 const res2 = await getVideo(servers[0].url, video.id)
465 const videoDetails = res2.body
467 const file = videoDetails.files.find(f => f.resolution.id === 360)
468 expect(file).not.to.be.undefined
470 const torrent = await webtorrentAdd(file.magnetUri)
471 expect(torrent.files).to.be.an('array')
472 expect(torrent.files.length).to.equal(1)
473 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
477 describe('Should update video views, likes and dislikes', function () {
478 let localVideosServer3 = []
479 let remoteVideosServer1 = []
480 let remoteVideosServer2 = []
481 let remoteVideosServer3 = []
483 before(async function () {
484 const res1 = await getVideosList(servers[0].url)
485 remoteVideosServer1 = res1.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
487 const res2 = await getVideosList(servers[1].url)
488 remoteVideosServer2 = res2.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
490 const res3 = await getVideosList(servers[2].url)
491 localVideosServer3 = res3.body.data.filter(video => video.isLocal === true).map(video => video.uuid)
492 remoteVideosServer3 = res3.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
495 it('Should view multiple videos on owned servers', async function () {
498 const tasks: Promise<any>[] = []
499 await viewVideo(servers[2].url, localVideosServer3[0])
500 await viewVideo(servers[2].url, localVideosServer3[0])
501 await viewVideo(servers[2].url, localVideosServer3[0])
502 await viewVideo(servers[2].url, localVideosServer3[1])
504 await Promise.all(tasks)
505 await waitJobs(servers)
507 await viewVideo(servers[2].url, localVideosServer3[0])
509 await waitJobs(servers)
511 await viewVideo(servers[2].url, localVideosServer3[0])
513 await waitJobs(servers)
515 // Wait the repeatable job
518 for (const server of servers) {
519 const res = await getVideosList(server.url)
521 const videos = res.body.data
522 const video0 = videos.find(v => v.uuid === localVideosServer3[0])
523 const video1 = videos.find(v => v.uuid === localVideosServer3[1])
525 expect(video0.views).to.equal(3)
526 expect(video1.views).to.equal(1)
530 it('Should view multiple videos on each servers', async function () {
533 const tasks: Promise<any>[] = []
534 tasks.push(viewVideo(servers[0].url, remoteVideosServer1[0]))
535 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
536 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
537 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[0]))
538 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
539 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
540 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
541 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
542 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
543 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
545 await Promise.all(tasks)
547 await waitJobs(servers)
549 // Wait the repeatable job
552 let baseVideos = null
554 for (const server of servers) {
555 const res = await getVideosList(server.url)
557 const videos = res.body.data
559 // Initialize base videos for future comparisons
560 if (baseVideos === null) {
565 for (const baseVideo of baseVideos) {
566 const sameVideo = videos.find(video => video.name === baseVideo.name)
567 expect(baseVideo.views).to.equal(sameVideo.views)
572 it('Should like and dislikes videos on different services', async function () {
575 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
577 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'dislike')
579 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
580 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'like')
582 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'dislike')
583 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[1], 'dislike')
585 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like')
587 await waitJobs(servers)
589 let baseVideos = null
590 for (const server of servers) {
591 const res = await getVideosList(server.url)
593 const videos = res.body.data
595 // Initialize base videos for future comparisons
596 if (baseVideos === null) {
601 for (const baseVideo of baseVideos) {
602 const sameVideo = videos.find(video => video.name === baseVideo.name)
603 expect(baseVideo.likes).to.equal(sameVideo.likes)
604 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes)
610 describe('Should manipulate these videos', function () {
611 it('Should update the video 3 by asking server 3', async function () {
615 name: 'my super video updated',
620 description: 'my super description updated',
621 support: 'my super support text updated',
622 tags: [ 'tag_up_1', 'tag_up_2' ],
623 thumbnailfile: 'thumbnail.jpg',
624 previewfile: 'preview.jpg'
627 await updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes)
629 await waitJobs(servers)
632 it('Should have the video 3 updated on each server', async function () {
635 for (const server of servers) {
636 const res = await getVideosList(server.url)
638 const videos = res.body.data
639 const videoUpdated = videos.find(video => video.name === 'my super video updated')
640 expect(!!videoUpdated).to.be.true
642 const isLocal = server.url === 'http://localhost:9003'
643 const checkAttributes = {
644 name: 'my super video updated',
649 description: 'my super description updated',
650 support: 'my super support text updated',
653 host: 'localhost:9003'
657 commentsEnabled: true,
658 tags: [ 'tag_up_1', 'tag_up_2' ],
659 privacy: VideoPrivacy.PUBLIC,
661 displayName: 'Main root channel',
662 name: 'root_channel',
666 fixture: 'video_short3.webm',
673 thumbnailfile: 'thumbnail',
674 previewfile: 'preview'
676 await completeVideoCheck(server.url, videoUpdated, checkAttributes)
680 it('Should remove the videos 3 and 3-2 by asking server 3', async function () {
683 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].id)
684 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[1].id)
686 await waitJobs(servers)
689 it('Should not have files of videos 3 and 3-2 on each server', async function () {
690 for (const server of servers) {
691 await checkVideoFilesWereRemoved(toRemove[0].uuid, server.serverNumber)
692 await checkVideoFilesWereRemoved(toRemove[1].uuid, server.serverNumber)
696 it('Should have videos 1 and 3 on each server', async function () {
697 for (const server of servers) {
698 const res = await getVideosList(server.url)
700 const videos = res.body.data
701 expect(videos).to.be.an('array')
702 expect(videos.length).to.equal(2)
703 expect(videos[0].name).not.to.equal(videos[1].name)
704 expect(videos[0].name).not.to.equal(toRemove[0].name)
705 expect(videos[1].name).not.to.equal(toRemove[0].name)
706 expect(videos[0].name).not.to.equal(toRemove[1].name)
707 expect(videos[1].name).not.to.equal(toRemove[1].name)
709 videoUUID = videos.find(video => video.name === 'my super name for server 1').uuid
713 it('Should get the same video by UUID on each server', async function () {
715 for (const server of servers) {
716 const res = await getVideo(server.url, videoUUID)
718 const video = res.body
720 if (baseVideo === null) {
725 expect(baseVideo.name).to.equal(video.name)
726 expect(baseVideo.uuid).to.equal(video.uuid)
727 expect(baseVideo.category.id).to.equal(video.category.id)
728 expect(baseVideo.language.id).to.equal(video.language.id)
729 expect(baseVideo.licence.id).to.equal(video.licence.id)
730 expect(baseVideo.nsfw).to.equal(video.nsfw)
731 expect(baseVideo.account.name).to.equal(video.account.name)
732 expect(baseVideo.account.displayName).to.equal(video.account.displayName)
733 expect(baseVideo.account.url).to.equal(video.account.url)
734 expect(baseVideo.account.host).to.equal(video.account.host)
735 expect(baseVideo.tags).to.deep.equal(video.tags)
739 it('Should get the preview from each server', async function () {
740 for (const server of servers) {
741 const res = await getVideo(server.url, videoUUID)
742 const video = res.body
744 await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
749 describe('Should comment these videos', function () {
750 let childOfFirstChild: VideoCommentThreadTree
752 it('Should add comment (threads and replies)', async function () {
756 const text = 'my super first comment'
757 await addVideoCommentThread(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID, text)
761 const text = 'my super second comment'
762 await addVideoCommentThread(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, text)
765 await waitJobs(servers)
768 const res = await getVideoCommentThreads(servers[1].url, videoUUID, 0, 5)
769 const threadId = res.body.data.find(c => c.text === 'my super first comment').id
771 const text = 'my super answer to thread 1'
772 await addVideoCommentReply(servers[ 1 ].url, servers[ 1 ].accessToken, videoUUID, threadId, text)
775 await waitJobs(servers)
778 const res1 = await getVideoCommentThreads(servers[2].url, videoUUID, 0, 5)
779 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
781 const res2 = await getVideoThreadComments(servers[2].url, videoUUID, threadId)
782 const childCommentId = res2.body.children[0].comment.id
784 const text3 = 'my second answer to thread 1'
785 await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, threadId, text3)
787 const text2 = 'my super answer to answer of thread 1'
788 await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, childCommentId, text2)
791 await waitJobs(servers)
794 it('Should have these threads', async function () {
795 for (const server of servers) {
796 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
798 expect(res.body.total).to.equal(2)
799 expect(res.body.data).to.be.an('array')
800 expect(res.body.data).to.have.lengthOf(2)
803 const comment: VideoComment = res.body.data.find(c => c.text === 'my super first comment')
804 expect(comment).to.not.be.undefined
805 expect(comment.inReplyToCommentId).to.be.null
806 expect(comment.account.name).to.equal('root')
807 expect(comment.account.host).to.equal('localhost:9001')
808 expect(comment.totalReplies).to.equal(3)
809 expect(dateIsValid(comment.createdAt as string)).to.be.true
810 expect(dateIsValid(comment.updatedAt as string)).to.be.true
814 const comment: VideoComment = res.body.data.find(c => c.text === 'my super second comment')
815 expect(comment).to.not.be.undefined
816 expect(comment.inReplyToCommentId).to.be.null
817 expect(comment.account.name).to.equal('root')
818 expect(comment.account.host).to.equal('localhost:9003')
819 expect(comment.totalReplies).to.equal(0)
820 expect(dateIsValid(comment.createdAt as string)).to.be.true
821 expect(dateIsValid(comment.updatedAt as string)).to.be.true
826 it('Should have these comments', async function () {
827 for (const server of servers) {
828 const res1 = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
829 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
831 const res2 = await getVideoThreadComments(server.url, videoUUID, threadId)
833 const tree: VideoCommentThreadTree = res2.body
834 expect(tree.comment.text).equal('my super first comment')
835 expect(tree.comment.account.name).equal('root')
836 expect(tree.comment.account.host).equal('localhost:9001')
837 expect(tree.children).to.have.lengthOf(2)
839 const firstChild = tree.children[0]
840 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
841 expect(firstChild.comment.account.name).equal('root')
842 expect(firstChild.comment.account.host).equal('localhost:9002')
843 expect(firstChild.children).to.have.lengthOf(1)
845 childOfFirstChild = firstChild.children[0]
846 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
847 expect(childOfFirstChild.comment.account.name).equal('root')
848 expect(childOfFirstChild.comment.account.host).equal('localhost:9003')
849 expect(childOfFirstChild.children).to.have.lengthOf(0)
851 const secondChild = tree.children[1]
852 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
853 expect(secondChild.comment.account.name).equal('root')
854 expect(secondChild.comment.account.host).equal('localhost:9003')
855 expect(secondChild.children).to.have.lengthOf(0)
859 it('Should delete a reply', async function () {
862 await deleteVideoComment(servers[2].url, servers[2].accessToken, videoUUID, childOfFirstChild.comment.id)
864 await waitJobs(servers)
867 it('Should not have this comment anymore', async function () {
868 for (const server of servers) {
869 const res1 = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
870 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
872 const res2 = await getVideoThreadComments(server.url, videoUUID, threadId)
874 const tree: VideoCommentThreadTree = res2.body
875 expect(tree.comment.text).equal('my super first comment')
877 const firstChild = tree.children[0]
878 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
879 expect(firstChild.children).to.have.lengthOf(0)
881 const secondChild = tree.children[1]
882 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
886 it('Should delete the thread comments', async function () {
889 const res1 = await getVideoCommentThreads(servers[0].url, videoUUID, 0, 5)
890 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
891 await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId)
893 await waitJobs(servers)
896 it('Should have the thread comments deleted on other servers too', async function () {
897 for (const server of servers) {
898 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
900 expect(res.body.total).to.equal(1)
901 expect(res.body.data).to.be.an('array')
902 expect(res.body.data).to.have.lengthOf(1)
905 const comment: VideoComment = res.body.data[0]
906 expect(comment).to.not.be.undefined
907 expect(comment.inReplyToCommentId).to.be.null
908 expect(comment.account.name).to.equal('root')
909 expect(comment.account.host).to.equal('localhost:9003')
910 expect(comment.totalReplies).to.equal(0)
911 expect(dateIsValid(comment.createdAt as string)).to.be.true
912 expect(dateIsValid(comment.updatedAt as string)).to.be.true
917 it('Should disable comments', async function () {
921 commentsEnabled: false
924 await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, attributes)
926 await waitJobs(servers)
928 for (const server of servers) {
929 const res = await getVideo(server.url, videoUUID)
930 expect(res.body.commentsEnabled).to.be.false
932 const text = 'my super forbidden comment'
933 await addVideoCommentThread(server.url, server.accessToken, videoUUID, text, 409)
938 describe('With minimum parameters', function () {
939 it('Should upload and propagate the video', async function () {
942 const path = '/api/v1/videos/upload'
944 const req = request(servers[1].url)
946 .set('Accept', 'application/json')
947 .set('Authorization', 'Bearer ' + servers[1].accessToken)
948 .field('name', 'minimum parameters')
949 .field('privacy', '1')
950 .field('channelId', '1')
952 const filePath = join(__dirname, '..', '..', 'fixtures', 'video_short.webm')
954 await req.attach('videofile', filePath)
957 await waitJobs(servers)
959 for (const server of servers) {
960 const res = await getVideosList(server.url)
961 const video = res.body.data.find(v => v.name === 'minimum parameters')
963 const isLocal = server.url === 'http://localhost:9002'
964 const checkAttributes = {
965 name: 'minimum parameters',
974 host: 'localhost:9002'
978 commentsEnabled: false,
980 privacy: VideoPrivacy.PUBLIC,
982 displayName: 'Main root channel',
983 name: 'root_channel',
987 fixture: 'video_short.webm',
1007 await completeVideoCheck(server.url, video, checkAttributes)
1012 describe('TMP directory', function () {
1013 it('Should have an empty tmp directory', async function () {
1014 for (const server of servers) {
1015 await checkTmpIsEmpty(server)
1020 after(async function () {
1021 killallServers(servers)
1023 // Keep the logs if the test failed