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,
131 downloadEnabled: true,
133 displayName: 'my channel',
134 name: 'super_channel_name',
135 description: 'super channel',
138 fixture: 'video_short1.webm',
147 const res = await getVideosList(server.url)
148 const videos = res.body.data
149 expect(videos).to.be.an('array')
150 expect(videos.length).to.equal(1)
151 const video = videos[0]
153 await completeVideoCheck(server.url, video, checkAttributes)
154 publishedAt = video.publishedAt
158 it('Should upload the video on server 2 and propagate on each server', async function () {
163 password: 'super_password'
165 await createUser(servers[1].url, servers[1].accessToken, user.username, user.password)
166 const userAccessToken = await userLogin(servers[1], user)
168 const videoAttributes = {
169 name: 'my super name for server 2',
174 description: 'my super description for server 2',
175 support: 'my super support text for server 2',
176 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
177 fixture: 'video_short2.webm',
178 thumbnailfile: 'thumbnail.jpg',
179 previewfile: 'preview.jpg'
181 await uploadVideo(servers[1].url, userAccessToken, videoAttributes)
184 await waitJobs(servers)
186 // All servers should have this video
187 for (const server of servers) {
188 const isLocal = server.url === 'http://localhost:9002'
189 const checkAttributes = {
190 name: 'my super name for server 2',
195 description: 'my super description for server 2',
196 support: 'my super support text for server 2',
199 host: 'localhost:9002'
202 commentsEnabled: true,
203 downloadEnabled: true,
205 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
206 privacy: VideoPrivacy.PUBLIC,
208 displayName: 'Main user1 channel',
209 name: 'user1_channel',
210 description: 'super channel',
213 fixture: 'video_short2.webm',
232 thumbnailfile: 'thumbnail',
233 previewfile: 'preview'
236 const res = await getVideosList(server.url)
237 const videos = res.body.data
238 expect(videos).to.be.an('array')
239 expect(videos.length).to.equal(2)
240 const video = videos[1]
242 await completeVideoCheck(server.url, video, checkAttributes)
246 it('Should upload two videos on server 3 and propagate on each server', async function () {
249 const videoAttributes1 = {
250 name: 'my super name for server 3',
255 description: 'my super description for server 3',
256 support: 'my super support text for server 3',
258 fixture: 'video_short3.webm'
260 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes1)
262 const videoAttributes2 = {
263 name: 'my super name for server 3-2',
268 description: 'my super description for server 3-2',
269 support: 'my super support text for server 3-2',
270 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
271 fixture: 'video_short.webm'
273 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes2)
275 await waitJobs(servers)
277 // All servers should have this video
278 for (const server of servers) {
279 const isLocal = server.url === 'http://localhost:9003'
280 const res = await getVideosList(server.url)
282 const videos = res.body.data
283 expect(videos).to.be.an('array')
284 expect(videos.length).to.equal(4)
286 // We not sure about the order of the two last uploads
289 if (videos[2].name === 'my super name for server 3') {
297 const checkAttributesVideo1 = {
298 name: 'my super name for server 3',
303 description: 'my super description for server 3',
304 support: 'my super support text for server 3',
307 host: 'localhost:9003'
311 commentsEnabled: true,
312 downloadEnabled: true,
314 privacy: VideoPrivacy.PUBLIC,
316 displayName: 'Main root channel',
317 name: 'root_channel',
321 fixture: 'video_short3.webm',
329 await completeVideoCheck(server.url, video1, checkAttributesVideo1)
331 const checkAttributesVideo2 = {
332 name: 'my super name for server 3-2',
337 description: 'my super description for server 3-2',
338 support: 'my super support text for server 3-2',
341 host: 'localhost:9003'
343 commentsEnabled: true,
344 downloadEnabled: true,
347 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
348 privacy: VideoPrivacy.PUBLIC,
350 displayName: 'Main root channel',
351 name: 'root_channel',
355 fixture: 'video_short.webm',
363 await completeVideoCheck(server.url, video2, checkAttributesVideo2)
368 describe('It should list local videos', function () {
369 it('Should list only local videos on server 1', async function () {
370 const { body } = await getLocalVideos(servers[0].url)
372 expect(body.total).to.equal(1)
373 expect(body.data).to.be.an('array')
374 expect(body.data.length).to.equal(1)
375 expect(body.data[0].name).to.equal('my super name for server 1')
378 it('Should list only local videos on server 2', async function () {
379 const { body } = await getLocalVideos(servers[1].url)
381 expect(body.total).to.equal(1)
382 expect(body.data).to.be.an('array')
383 expect(body.data.length).to.equal(1)
384 expect(body.data[0].name).to.equal('my super name for server 2')
387 it('Should list only local videos on server 3', async function () {
388 const { body } = await getLocalVideos(servers[2].url)
390 expect(body.total).to.equal(2)
391 expect(body.data).to.be.an('array')
392 expect(body.data.length).to.equal(2)
393 expect(body.data[0].name).to.equal('my super name for server 3')
394 expect(body.data[1].name).to.equal('my super name for server 3-2')
398 describe('Should seed the uploaded video', function () {
399 it('Should add the file 1 by asking server 3', async function () {
402 const res = await getVideosList(servers[2].url)
404 const video = res.body.data[0]
405 toRemove.push(res.body.data[2])
406 toRemove.push(res.body.data[3])
408 const res2 = await getVideo(servers[2].url, video.id)
409 const videoDetails = res2.body
411 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
412 expect(torrent.files).to.be.an('array')
413 expect(torrent.files.length).to.equal(1)
414 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
417 it('Should add the file 2 by asking server 1', async function () {
420 const res = await getVideosList(servers[0].url)
422 const video = res.body.data[1]
423 const res2 = await getVideo(servers[0].url, video.id)
424 const videoDetails = res2.body
426 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
427 expect(torrent.files).to.be.an('array')
428 expect(torrent.files.length).to.equal(1)
429 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
432 it('Should add the file 3 by asking server 2', async function () {
435 const res = await getVideosList(servers[1].url)
437 const video = res.body.data[2]
438 const res2 = await getVideo(servers[1].url, video.id)
439 const videoDetails = res2.body
441 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
442 expect(torrent.files).to.be.an('array')
443 expect(torrent.files.length).to.equal(1)
444 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
447 it('Should add the file 3-2 by asking server 1', async function () {
450 const res = await getVideosList(servers[0].url)
452 const video = res.body.data[3]
453 const res2 = await getVideo(servers[0].url, video.id)
454 const videoDetails = res2.body
456 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
457 expect(torrent.files).to.be.an('array')
458 expect(torrent.files.length).to.equal(1)
459 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
462 it('Should add the file 2 in 360p by asking server 1', async function () {
465 const res = await getVideosList(servers[0].url)
467 const video = res.body.data.find(v => v.name === 'my super name for server 2')
468 const res2 = await getVideo(servers[0].url, video.id)
469 const videoDetails = res2.body
471 const file = videoDetails.files.find(f => f.resolution.id === 360)
472 expect(file).not.to.be.undefined
474 const torrent = await webtorrentAdd(file.magnetUri)
475 expect(torrent.files).to.be.an('array')
476 expect(torrent.files.length).to.equal(1)
477 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
481 describe('Should update video views, likes and dislikes', function () {
482 let localVideosServer3 = []
483 let remoteVideosServer1 = []
484 let remoteVideosServer2 = []
485 let remoteVideosServer3 = []
487 before(async function () {
488 const res1 = await getVideosList(servers[0].url)
489 remoteVideosServer1 = res1.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
491 const res2 = await getVideosList(servers[1].url)
492 remoteVideosServer2 = res2.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
494 const res3 = await getVideosList(servers[2].url)
495 localVideosServer3 = res3.body.data.filter(video => video.isLocal === true).map(video => video.uuid)
496 remoteVideosServer3 = res3.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
499 it('Should view multiple videos on owned servers', async function () {
502 const tasks: Promise<any>[] = []
503 await viewVideo(servers[2].url, localVideosServer3[0])
504 await viewVideo(servers[2].url, localVideosServer3[0])
505 await viewVideo(servers[2].url, localVideosServer3[0])
506 await viewVideo(servers[2].url, localVideosServer3[1])
508 await Promise.all(tasks)
509 await waitJobs(servers)
511 await viewVideo(servers[2].url, localVideosServer3[0])
513 await waitJobs(servers)
515 await viewVideo(servers[2].url, localVideosServer3[0])
517 await waitJobs(servers)
519 // Wait the repeatable job
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 let baseVideos = null
558 for (const server of servers) {
559 const res = await getVideosList(server.url)
561 const videos = res.body.data
563 // Initialize base videos for future comparisons
564 if (baseVideos === null) {
569 for (const baseVideo of baseVideos) {
570 const sameVideo = videos.find(video => video.name === baseVideo.name)
571 expect(baseVideo.views).to.equal(sameVideo.views)
576 it('Should like and dislikes videos on different services', async function () {
579 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
581 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'dislike')
583 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
584 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'like')
586 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'dislike')
587 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[1], 'dislike')
589 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like')
591 await waitJobs(servers)
593 let baseVideos = null
594 for (const server of servers) {
595 const res = await getVideosList(server.url)
597 const videos = res.body.data
599 // Initialize base videos for future comparisons
600 if (baseVideos === null) {
605 for (const baseVideo of baseVideos) {
606 const sameVideo = videos.find(video => video.name === baseVideo.name)
607 expect(baseVideo.likes).to.equal(sameVideo.likes)
608 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes)
614 describe('Should manipulate these videos', function () {
615 it('Should update the video 3 by asking server 3', async function () {
619 name: 'my super video updated',
624 description: 'my super description updated',
625 support: 'my super support text updated',
626 tags: [ 'tag_up_1', 'tag_up_2' ],
627 thumbnailfile: 'thumbnail.jpg',
628 previewfile: 'preview.jpg'
631 await updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes)
633 await waitJobs(servers)
636 it('Should have the video 3 updated on each server', async function () {
639 for (const server of servers) {
640 const res = await getVideosList(server.url)
642 const videos = res.body.data
643 const videoUpdated = videos.find(video => video.name === 'my super video updated')
644 expect(!!videoUpdated).to.be.true
646 const isLocal = server.url === 'http://localhost:9003'
647 const checkAttributes = {
648 name: 'my super video updated',
653 description: 'my super description updated',
654 support: 'my super support text updated',
657 host: 'localhost:9003'
661 commentsEnabled: true,
662 downloadEnabled: true,
663 tags: [ 'tag_up_1', 'tag_up_2' ],
664 privacy: VideoPrivacy.PUBLIC,
666 displayName: 'Main root channel',
667 name: 'root_channel',
671 fixture: 'video_short3.webm',
678 thumbnailfile: 'thumbnail',
679 previewfile: 'preview'
681 await completeVideoCheck(server.url, videoUpdated, checkAttributes)
685 it('Should remove the videos 3 and 3-2 by asking server 3', async function () {
688 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].id)
689 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[1].id)
691 await waitJobs(servers)
694 it('Should not have files of videos 3 and 3-2 on each server', async function () {
695 for (const server of servers) {
696 await checkVideoFilesWereRemoved(toRemove[0].uuid, server.serverNumber)
697 await checkVideoFilesWereRemoved(toRemove[1].uuid, server.serverNumber)
701 it('Should have videos 1 and 3 on each server', async function () {
702 for (const server of servers) {
703 const res = await getVideosList(server.url)
705 const videos = res.body.data
706 expect(videos).to.be.an('array')
707 expect(videos.length).to.equal(2)
708 expect(videos[0].name).not.to.equal(videos[1].name)
709 expect(videos[0].name).not.to.equal(toRemove[0].name)
710 expect(videos[1].name).not.to.equal(toRemove[0].name)
711 expect(videos[0].name).not.to.equal(toRemove[1].name)
712 expect(videos[1].name).not.to.equal(toRemove[1].name)
714 videoUUID = videos.find(video => video.name === 'my super name for server 1').uuid
718 it('Should get the same video by UUID on each server', async function () {
720 for (const server of servers) {
721 const res = await getVideo(server.url, videoUUID)
723 const video = res.body
725 if (baseVideo === null) {
730 expect(baseVideo.name).to.equal(video.name)
731 expect(baseVideo.uuid).to.equal(video.uuid)
732 expect(baseVideo.category.id).to.equal(video.category.id)
733 expect(baseVideo.language.id).to.equal(video.language.id)
734 expect(baseVideo.licence.id).to.equal(video.licence.id)
735 expect(baseVideo.nsfw).to.equal(video.nsfw)
736 expect(baseVideo.account.name).to.equal(video.account.name)
737 expect(baseVideo.account.displayName).to.equal(video.account.displayName)
738 expect(baseVideo.account.url).to.equal(video.account.url)
739 expect(baseVideo.account.host).to.equal(video.account.host)
740 expect(baseVideo.tags).to.deep.equal(video.tags)
744 it('Should get the preview from each server', async function () {
745 for (const server of servers) {
746 const res = await getVideo(server.url, videoUUID)
747 const video = res.body
749 await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
754 describe('Should comment these videos', function () {
755 let childOfFirstChild: VideoCommentThreadTree
757 it('Should add comment (threads and replies)', async function () {
761 const text = 'my super first comment'
762 await addVideoCommentThread(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID, text)
766 const text = 'my super second comment'
767 await addVideoCommentThread(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, text)
770 await waitJobs(servers)
773 const res = await getVideoCommentThreads(servers[1].url, videoUUID, 0, 5)
774 const threadId = res.body.data.find(c => c.text === 'my super first comment').id
776 const text = 'my super answer to thread 1'
777 await addVideoCommentReply(servers[ 1 ].url, servers[ 1 ].accessToken, videoUUID, threadId, text)
780 await waitJobs(servers)
783 const res1 = await getVideoCommentThreads(servers[2].url, videoUUID, 0, 5)
784 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
786 const res2 = await getVideoThreadComments(servers[2].url, videoUUID, threadId)
787 const childCommentId = res2.body.children[0].comment.id
789 const text3 = 'my second answer to thread 1'
790 await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, threadId, text3)
792 const text2 = 'my super answer to answer of thread 1'
793 await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, childCommentId, text2)
796 await waitJobs(servers)
799 it('Should have these threads', async function () {
800 for (const server of servers) {
801 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
803 expect(res.body.total).to.equal(2)
804 expect(res.body.data).to.be.an('array')
805 expect(res.body.data).to.have.lengthOf(2)
808 const comment: VideoComment = res.body.data.find(c => c.text === 'my super first comment')
809 expect(comment).to.not.be.undefined
810 expect(comment.inReplyToCommentId).to.be.null
811 expect(comment.account.name).to.equal('root')
812 expect(comment.account.host).to.equal('localhost:9001')
813 expect(comment.totalReplies).to.equal(3)
814 expect(dateIsValid(comment.createdAt as string)).to.be.true
815 expect(dateIsValid(comment.updatedAt as string)).to.be.true
819 const comment: VideoComment = res.body.data.find(c => c.text === 'my super second comment')
820 expect(comment).to.not.be.undefined
821 expect(comment.inReplyToCommentId).to.be.null
822 expect(comment.account.name).to.equal('root')
823 expect(comment.account.host).to.equal('localhost:9003')
824 expect(comment.totalReplies).to.equal(0)
825 expect(dateIsValid(comment.createdAt as string)).to.be.true
826 expect(dateIsValid(comment.updatedAt as string)).to.be.true
831 it('Should have these comments', async function () {
832 for (const server of servers) {
833 const res1 = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
834 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
836 const res2 = await getVideoThreadComments(server.url, videoUUID, threadId)
838 const tree: VideoCommentThreadTree = res2.body
839 expect(tree.comment.text).equal('my super first comment')
840 expect(tree.comment.account.name).equal('root')
841 expect(tree.comment.account.host).equal('localhost:9001')
842 expect(tree.children).to.have.lengthOf(2)
844 const firstChild = tree.children[0]
845 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
846 expect(firstChild.comment.account.name).equal('root')
847 expect(firstChild.comment.account.host).equal('localhost:9002')
848 expect(firstChild.children).to.have.lengthOf(1)
850 childOfFirstChild = firstChild.children[0]
851 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
852 expect(childOfFirstChild.comment.account.name).equal('root')
853 expect(childOfFirstChild.comment.account.host).equal('localhost:9003')
854 expect(childOfFirstChild.children).to.have.lengthOf(0)
856 const secondChild = tree.children[1]
857 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
858 expect(secondChild.comment.account.name).equal('root')
859 expect(secondChild.comment.account.host).equal('localhost:9003')
860 expect(secondChild.children).to.have.lengthOf(0)
864 it('Should delete a reply', async function () {
867 await deleteVideoComment(servers[2].url, servers[2].accessToken, videoUUID, childOfFirstChild.comment.id)
869 await waitJobs(servers)
872 it('Should not have this comment anymore', async function () {
873 for (const server of servers) {
874 const res1 = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
875 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
877 const res2 = await getVideoThreadComments(server.url, videoUUID, threadId)
879 const tree: VideoCommentThreadTree = res2.body
880 expect(tree.comment.text).equal('my super first comment')
882 const firstChild = tree.children[0]
883 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
884 expect(firstChild.children).to.have.lengthOf(0)
886 const secondChild = tree.children[1]
887 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
891 it('Should delete the thread comments', async function () {
894 const res1 = await getVideoCommentThreads(servers[0].url, videoUUID, 0, 5)
895 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
896 await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId)
898 await waitJobs(servers)
901 it('Should have the thread comments deleted on other servers too', async function () {
902 for (const server of servers) {
903 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
905 expect(res.body.total).to.equal(1)
906 expect(res.body.data).to.be.an('array')
907 expect(res.body.data).to.have.lengthOf(1)
910 const comment: VideoComment = res.body.data[0]
911 expect(comment).to.not.be.undefined
912 expect(comment.inReplyToCommentId).to.be.null
913 expect(comment.account.name).to.equal('root')
914 expect(comment.account.host).to.equal('localhost:9003')
915 expect(comment.totalReplies).to.equal(0)
916 expect(dateIsValid(comment.createdAt as string)).to.be.true
917 expect(dateIsValid(comment.updatedAt as string)).to.be.true
922 it('Should disable comments and download', async function () {
926 commentsEnabled: false,
927 downloadEnabled: false
930 await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, attributes)
932 await waitJobs(servers)
934 for (const server of servers) {
935 const res = await getVideo(server.url, videoUUID)
936 expect(res.body.commentsEnabled).to.be.false
937 expect(res.body.downloadEnabled).to.be.false
939 const text = 'my super forbidden comment'
940 await addVideoCommentThread(server.url, server.accessToken, videoUUID, text, 409)
945 describe('With minimum parameters', function () {
946 it('Should upload and propagate the video', async function () {
949 const path = '/api/v1/videos/upload'
951 const req = request(servers[1].url)
953 .set('Accept', 'application/json')
954 .set('Authorization', 'Bearer ' + servers[1].accessToken)
955 .field('name', 'minimum parameters')
956 .field('privacy', '1')
957 .field('channelId', '1')
959 const filePath = join(__dirname, '..', '..', 'fixtures', 'video_short.webm')
961 await req.attach('videofile', filePath)
964 await waitJobs(servers)
966 for (const server of servers) {
967 const res = await getVideosList(server.url)
968 const video = res.body.data.find(v => v.name === 'minimum parameters')
970 const isLocal = server.url === 'http://localhost:9002'
971 const checkAttributes = {
972 name: 'minimum parameters',
981 host: 'localhost:9002'
985 commentsEnabled: false,
986 downloadEnabled: false,
988 privacy: VideoPrivacy.PUBLIC,
990 displayName: 'Main root channel',
991 name: 'root_channel',
995 fixture: 'video_short.webm',
1015 await completeVideoCheck(server.url, video, checkAttributes)
1020 describe('TMP directory', function () {
1021 it('Should have an empty tmp directory', async function () {
1022 for (const server of servers) {
1023 await checkTmpIsEmpty(server)
1028 after(async function () {
1029 killallServers(servers)
1031 // Keep the logs if the test failed