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,
18 flushAndRunMultipleServers,
26 setAccessTokensToServers,
34 } from '../../../../shared/extra-utils'
37 addVideoCommentThread,
39 getVideoCommentThreads,
40 getVideoThreadComments
41 } from '../../../../shared/extra-utils/videos/video-comments'
42 import { waitJobs } from '../../../../shared/extra-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 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
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.port === servers[0].port
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',
121 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
124 host: 'localhost:' + servers[0].port
129 tags: [ 'tag1p1', 'tag2p1' ],
130 privacy: VideoPrivacy.PUBLIC,
131 commentsEnabled: true,
132 downloadEnabled: true,
134 displayName: 'my channel',
135 name: 'super_channel_name',
136 description: 'super channel',
139 fixture: 'video_short1.webm',
148 const res = await getVideosList(server.url)
149 const videos = res.body.data
150 expect(videos).to.be.an('array')
151 expect(videos.length).to.equal(1)
152 const video = videos[0]
154 await completeVideoCheck(server.url, video, checkAttributes)
155 publishedAt = video.publishedAt
159 it('Should upload the video on server 2 and propagate on each server', async function () {
164 password: 'super_password'
166 await createUser({ url: servers[ 1 ].url, accessToken: servers[ 1 ].accessToken, username: user.username, password: user.password })
167 const userAccessToken = await userLogin(servers[1], user)
169 const videoAttributes = {
170 name: 'my super name for server 2',
175 description: 'my super description for server 2',
176 support: 'my super support text for server 2',
177 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
178 fixture: 'video_short2.webm',
179 thumbnailfile: 'thumbnail.jpg',
180 previewfile: 'preview.jpg'
182 await uploadVideo(servers[1].url, userAccessToken, videoAttributes)
185 await waitJobs(servers)
187 // All servers should have this video
188 for (const server of servers) {
189 const isLocal = server.url === 'http://localhost:' + servers[1].port
190 const checkAttributes = {
191 name: 'my super name for server 2',
196 description: 'my super description for server 2',
197 support: 'my super support text for server 2',
200 host: 'localhost:' + servers[1].port
203 commentsEnabled: true,
204 downloadEnabled: true,
206 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
207 privacy: VideoPrivacy.PUBLIC,
209 displayName: 'Main user1 channel',
210 name: 'user1_channel',
211 description: 'super channel',
214 fixture: 'video_short2.webm',
233 thumbnailfile: 'thumbnail',
234 previewfile: 'preview'
237 const res = await getVideosList(server.url)
238 const videos = res.body.data
239 expect(videos).to.be.an('array')
240 expect(videos.length).to.equal(2)
241 const video = videos[1]
243 await completeVideoCheck(server.url, video, checkAttributes)
247 it('Should upload two videos on server 3 and propagate on each server', async function () {
250 const videoAttributes1 = {
251 name: 'my super name for server 3',
256 description: 'my super description for server 3',
257 support: 'my super support text for server 3',
259 fixture: 'video_short3.webm'
261 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes1)
263 const videoAttributes2 = {
264 name: 'my super name for server 3-2',
269 description: 'my super description for server 3-2',
270 support: 'my super support text for server 3-2',
271 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
272 fixture: 'video_short.webm'
274 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes2)
276 await waitJobs(servers)
278 // All servers should have this video
279 for (const server of servers) {
280 const isLocal = server.url === 'http://localhost:' + servers[2].port
281 const res = await getVideosList(server.url)
283 const videos = res.body.data
284 expect(videos).to.be.an('array')
285 expect(videos.length).to.equal(4)
287 // We not sure about the order of the two last uploads
290 if (videos[2].name === 'my super name for server 3') {
298 const checkAttributesVideo1 = {
299 name: 'my super name for server 3',
304 description: 'my super description for server 3',
305 support: 'my super support text for server 3',
308 host: 'localhost:' + servers[2].port
312 commentsEnabled: true,
313 downloadEnabled: true,
315 privacy: VideoPrivacy.PUBLIC,
317 displayName: 'Main root channel',
318 name: 'root_channel',
322 fixture: 'video_short3.webm',
330 await completeVideoCheck(server.url, video1, checkAttributesVideo1)
332 const checkAttributesVideo2 = {
333 name: 'my super name for server 3-2',
338 description: 'my super description for server 3-2',
339 support: 'my super support text for server 3-2',
342 host: 'localhost:' + servers[2].port
344 commentsEnabled: true,
345 downloadEnabled: true,
348 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
349 privacy: VideoPrivacy.PUBLIC,
351 displayName: 'Main root channel',
352 name: 'root_channel',
356 fixture: 'video_short.webm',
364 await completeVideoCheck(server.url, video2, checkAttributesVideo2)
369 describe('It should list local videos', function () {
370 it('Should list only local videos on server 1', async function () {
371 const { body } = await getLocalVideos(servers[0].url)
373 expect(body.total).to.equal(1)
374 expect(body.data).to.be.an('array')
375 expect(body.data.length).to.equal(1)
376 expect(body.data[0].name).to.equal('my super name for server 1')
379 it('Should list only local videos on server 2', async function () {
380 const { body } = await getLocalVideos(servers[1].url)
382 expect(body.total).to.equal(1)
383 expect(body.data).to.be.an('array')
384 expect(body.data.length).to.equal(1)
385 expect(body.data[0].name).to.equal('my super name for server 2')
388 it('Should list only local videos on server 3', async function () {
389 const { body } = await getLocalVideos(servers[2].url)
391 expect(body.total).to.equal(2)
392 expect(body.data).to.be.an('array')
393 expect(body.data.length).to.equal(2)
394 expect(body.data[0].name).to.equal('my super name for server 3')
395 expect(body.data[1].name).to.equal('my super name for server 3-2')
399 describe('Should seed the uploaded video', function () {
400 it('Should add the file 1 by asking server 3', async function () {
403 const res = await getVideosList(servers[2].url)
405 const video = res.body.data[0]
406 toRemove.push(res.body.data[2])
407 toRemove.push(res.body.data[3])
409 const res2 = await getVideo(servers[2].url, video.id)
410 const videoDetails = res2.body
412 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
413 expect(torrent.files).to.be.an('array')
414 expect(torrent.files.length).to.equal(1)
415 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
418 it('Should add the file 2 by asking server 1', async function () {
421 const res = await getVideosList(servers[0].url)
423 const video = res.body.data[1]
424 const res2 = await getVideo(servers[0].url, video.id)
425 const videoDetails = res2.body
427 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
428 expect(torrent.files).to.be.an('array')
429 expect(torrent.files.length).to.equal(1)
430 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
433 it('Should add the file 3 by asking server 2', async function () {
436 const res = await getVideosList(servers[1].url)
438 const video = res.body.data[2]
439 const res2 = await getVideo(servers[1].url, video.id)
440 const videoDetails = res2.body
442 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
443 expect(torrent.files).to.be.an('array')
444 expect(torrent.files.length).to.equal(1)
445 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
448 it('Should add the file 3-2 by asking server 1', async function () {
451 const res = await getVideosList(servers[0].url)
453 const video = res.body.data[3]
454 const res2 = await getVideo(servers[0].url, video.id)
455 const videoDetails = res2.body
457 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
458 expect(torrent.files).to.be.an('array')
459 expect(torrent.files.length).to.equal(1)
460 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
463 it('Should add the file 2 in 360p by asking server 1', async function () {
466 const res = await getVideosList(servers[0].url)
468 const video = res.body.data.find(v => v.name === 'my super name for server 2')
469 const res2 = await getVideo(servers[0].url, video.id)
470 const videoDetails = res2.body
472 const file = videoDetails.files.find(f => f.resolution.id === 360)
473 expect(file).not.to.be.undefined
475 const torrent = await webtorrentAdd(file.magnetUri)
476 expect(torrent.files).to.be.an('array')
477 expect(torrent.files.length).to.equal(1)
478 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
482 describe('Should update video views, likes and dislikes', function () {
483 let localVideosServer3 = []
484 let remoteVideosServer1 = []
485 let remoteVideosServer2 = []
486 let remoteVideosServer3 = []
488 before(async function () {
489 const res1 = await getVideosList(servers[0].url)
490 remoteVideosServer1 = res1.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
492 const res2 = await getVideosList(servers[1].url)
493 remoteVideosServer2 = res2.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
495 const res3 = await getVideosList(servers[2].url)
496 localVideosServer3 = res3.body.data.filter(video => video.isLocal === true).map(video => video.uuid)
497 remoteVideosServer3 = res3.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
500 it('Should view multiple videos on owned servers', async function () {
503 await viewVideo(servers[2].url, localVideosServer3[0])
506 await viewVideo(servers[2].url, localVideosServer3[0])
507 await viewVideo(servers[2].url, localVideosServer3[1])
511 await viewVideo(servers[2].url, localVideosServer3[0])
512 await viewVideo(servers[2].url, localVideosServer3[0])
514 await waitJobs(servers)
516 // Wait the repeatable job
519 for (const server of servers) {
520 const res = await getVideosList(server.url)
522 const videos = res.body.data
523 const video0 = videos.find(v => v.uuid === localVideosServer3[0])
524 const video1 = videos.find(v => v.uuid === localVideosServer3[1])
526 expect(video0.views).to.equal(3)
527 expect(video1.views).to.equal(1)
531 it('Should view multiple videos on each servers', async function () {
534 const tasks: Promise<any>[] = []
535 tasks.push(viewVideo(servers[0].url, remoteVideosServer1[0]))
536 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
537 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
538 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[0]))
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, remoteVideosServer3[1]))
542 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
543 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
544 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
546 await Promise.all(tasks)
548 await waitJobs(servers)
550 // Wait the repeatable job
553 let baseVideos = null
555 for (const server of servers) {
556 const res = await getVideosList(server.url)
558 const videos = res.body.data
560 // Initialize base videos for future comparisons
561 if (baseVideos === null) {
566 for (const baseVideo of baseVideos) {
567 const sameVideo = videos.find(video => video.name === baseVideo.name)
568 expect(baseVideo.views).to.equal(sameVideo.views)
573 it('Should like and dislikes videos on different services', async function () {
576 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
578 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'dislike')
580 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
581 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'like')
583 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'dislike')
584 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[1], 'dislike')
586 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like')
588 await waitJobs(servers)
590 let baseVideos = null
591 for (const server of servers) {
592 const res = await getVideosList(server.url)
594 const videos = res.body.data
596 // Initialize base videos for future comparisons
597 if (baseVideos === null) {
602 for (const baseVideo of baseVideos) {
603 const sameVideo = videos.find(video => video.name === baseVideo.name)
604 expect(baseVideo.likes).to.equal(sameVideo.likes)
605 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes)
611 describe('Should manipulate these videos', function () {
612 it('Should update the video 3 by asking server 3', async function () {
616 name: 'my super video updated',
621 description: 'my super description updated',
622 support: 'my super support text updated',
623 tags: [ 'tag_up_1', 'tag_up_2' ],
624 thumbnailfile: 'thumbnail.jpg',
625 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
626 previewfile: 'preview.jpg'
629 await updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes)
631 await waitJobs(servers)
634 it('Should have the video 3 updated on each server', async function () {
637 for (const server of servers) {
638 const res = await getVideosList(server.url)
640 const videos = res.body.data
641 const videoUpdated = videos.find(video => video.name === 'my super video updated')
642 expect(!!videoUpdated).to.be.true
644 const isLocal = server.url === 'http://localhost:' + servers[2].port
645 const checkAttributes = {
646 name: 'my super video updated',
651 description: 'my super description updated',
652 support: 'my super support text updated',
653 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
656 host: 'localhost:' + servers[2].port
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:' + servers[0].port)
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:' + servers[2].port)
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:' + servers[0].port)
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:' + servers[1].port)
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:' + servers[2].port)
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:' + servers[2].port)
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 have this comment marked as deleted', 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(1)
885 const deletedComment = firstChild.children[0].comment
886 expect(deletedComment.isDeleted).to.be.true
887 expect(deletedComment.deletedAt).to.not.be.null
888 expect(deletedComment.account).to.be.null
889 expect(deletedComment.text).to.equal('')
891 const secondChild = tree.children[1]
892 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
896 it('Should delete the thread comments', async function () {
899 const res = await getVideoCommentThreads(servers[ 0 ].url, videoUUID, 0, 5)
900 const threadId = res.body.data.find(c => c.text === 'my super first comment').id
901 await deleteVideoComment(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID, threadId)
903 await waitJobs(servers)
906 it('Should have the threads marked as deleted on other servers too', async function () {
907 for (const server of servers) {
908 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
910 expect(res.body.total).to.equal(2)
911 expect(res.body.data).to.be.an('array')
912 expect(res.body.data).to.have.lengthOf(2)
915 const comment: VideoComment = res.body.data[0]
916 expect(comment).to.not.be.undefined
917 expect(comment.inReplyToCommentId).to.be.null
918 expect(comment.account.name).to.equal('root')
919 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
920 expect(comment.totalReplies).to.equal(0)
921 expect(dateIsValid(comment.createdAt as string)).to.be.true
922 expect(dateIsValid(comment.updatedAt as string)).to.be.true
926 const deletedComment: VideoComment = res.body.data[1]
927 expect(deletedComment).to.not.be.undefined
928 expect(deletedComment.isDeleted).to.be.true
929 expect(deletedComment.deletedAt).to.not.be.null
930 expect(deletedComment.text).to.equal('')
931 expect(deletedComment.inReplyToCommentId).to.be.null
932 expect(deletedComment.account).to.be.null
933 expect(deletedComment.totalReplies).to.equal(3)
934 expect(dateIsValid(deletedComment.createdAt as string)).to.be.true
935 expect(dateIsValid(deletedComment.updatedAt as string)).to.be.true
936 expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true
941 it('Should delete a remote thread by the origin server', async function () {
942 const res = await getVideoCommentThreads(servers[ 0 ].url, videoUUID, 0, 5)
943 const threadId = res.body.data.find(c => c.text === 'my super second comment').id
944 await deleteVideoComment(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID, threadId)
946 await waitJobs(servers)
949 it('Should have the threads marked as deleted on other servers too', async function () {
950 for (const server of servers) {
951 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
953 expect(res.body.total).to.equal(2)
954 expect(res.body.data).to.have.lengthOf(2)
957 const comment: VideoComment = res.body.data[0]
958 expect(comment.text).to.equal('')
959 expect(comment.isDeleted).to.be.true
960 expect(comment.createdAt).to.not.be.null
961 expect(comment.deletedAt).to.not.be.null
962 expect(comment.account).to.be.null
963 expect(comment.totalReplies).to.equal(0)
967 const comment: VideoComment = res.body.data[1]
968 expect(comment.text).to.equal('')
969 expect(comment.isDeleted).to.be.true
970 expect(comment.createdAt).to.not.be.null
971 expect(comment.deletedAt).to.not.be.null
972 expect(comment.account).to.be.null
973 expect(comment.totalReplies).to.equal(3)
978 it('Should disable comments and download', async function () {
982 commentsEnabled: false,
983 downloadEnabled: false
986 await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, attributes)
988 await waitJobs(servers)
990 for (const server of servers) {
991 const res = await getVideo(server.url, videoUUID)
992 expect(res.body.commentsEnabled).to.be.false
993 expect(res.body.downloadEnabled).to.be.false
995 const text = 'my super forbidden comment'
996 await addVideoCommentThread(server.url, server.accessToken, videoUUID, text, 409)
1001 describe('With minimum parameters', function () {
1002 it('Should upload and propagate the video', async function () {
1005 const path = '/api/v1/videos/upload'
1007 const req = request(servers[1].url)
1009 .set('Accept', 'application/json')
1010 .set('Authorization', 'Bearer ' + servers[1].accessToken)
1011 .field('name', 'minimum parameters')
1012 .field('privacy', '1')
1013 .field('channelId', '1')
1015 const filePath = join(__dirname, '..', '..', 'fixtures', 'video_short.webm')
1017 await req.attach('videofile', filePath)
1020 await waitJobs(servers)
1022 for (const server of servers) {
1023 const res = await getVideosList(server.url)
1024 const video = res.body.data.find(v => v.name === 'minimum parameters')
1026 const isLocal = server.url === 'http://localhost:' + servers[1].port
1027 const checkAttributes = {
1028 name: 'minimum parameters',
1037 host: 'localhost:' + servers[1].port
1041 commentsEnabled: true,
1042 downloadEnabled: true,
1044 privacy: VideoPrivacy.PUBLIC,
1046 displayName: 'Main root channel',
1047 name: 'root_channel',
1051 fixture: 'video_short.webm',
1071 await completeVideoCheck(server.url, video, checkAttributes)
1076 describe('TMP directory', function () {
1077 it('Should have an empty tmp directory', async function () {
1078 for (const server of servers) {
1079 await checkTmpIsEmpty(server)
1084 after(async function () {
1085 await cleanupTests(servers)